program AGC40
  character(500000)::S
  integer(8),allocatable::A(:)
  read(*,*)S
  N=len_trim(S)+1
  allocate(A(N))
  A=500000
  if(S(1:1)=='<') A(1)=0
  if(S(N-1:N-1)=='>') A(N)=0
  do i=1,N-1
     if(S(i:i)=='>' .and. S(i+1:i+1)=='<') A(i+1)=0
  end do
  do i=1,N-1
     if(S(i:i)=='<') A(i+1)=A(i)+1
  end do
  do i=N,2,-1
     if(S(i-1:i-1)=='>' .and. (A(i-1)==500000 .or. A(i-1)<=A(i))) A(i-1)=A(i)+1        
  end do
  write(*,*)sum(A)
end program AGC40
; ModuleID = 'FIRModule'
source_filename = "FIRModule"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@_QFEa.0 = internal unnamed_addr global ptr null
@_QFEa.7 = internal unnamed_addr global i64 1
@_QFEa.8 = internal unnamed_addr global i64 0
@_QFEs = internal global [500000 x i8] undef
@_QQcl.81e49c09a282bfa5818d95a8aa9f4a78 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3026/source.f\00"
@_QQcl.16373402fa3425c6e46827601abb88fa = linkonce constant [76 x i8] c"array left hand side must be allocated when the right hand side is a scalar\00"
@_QQcl.3C = linkonce constant [1 x i8] c"<"
@_QQcl.3E = linkonce constant [1 x i8] c">"
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

define void @_QQmain() local_unnamed_addr {
  %1 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.81e49c09a282bfa5818d95a8aa9f4a78, i32 4)
  %2 = tail call i1 @_FortranAioInputAscii(ptr %1, ptr nonnull @_QFEs, i64 500000)
  %3 = tail call i32 @_FortranAioEndIoStatement(ptr %1)
  br label %4

4:                                                ; preds = %0, %4
  %5 = phi i64 [ 499999, %0 ], [ %9, %4 ]
  %6 = getelementptr [500000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %5
  %7 = load i8, ptr %6, align 1, !tbaa !3
  %8 = icmp eq i8 %7, 32
  %9 = add nsw i64 %5, -1
  %10 = icmp ne i64 %5, 0
  %11 = and i1 %8, %10
  br i1 %11, label %4, label %12

12:                                               ; preds = %4
  %13 = trunc i64 %5 to i32
  %14 = add i32 %13, 1
  %15 = select i1 %8, i32 0, i32 %14
  %16 = add i32 %15, 1
  %17 = sext i32 %16 to i64
  %18 = tail call i64 @llvm.smax.i64(i64 %17, i64 0)
  %19 = shl nuw nsw i64 %18, 3
  %20 = tail call ptr @malloc(i64 %19)
  store ptr %20, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 1, ptr @_QFEa.7, align 8, !tbaa !7
  store i64 %18, ptr @_QFEa.8, align 8, !tbaa !7
  %.not = icmp eq ptr %20, null
  br i1 %.not, label %30, label %.preheader440

.preheader440:                                    ; preds = %12
  %.not446 = icmp ugt i32 %15, 2147483646
  br i1 %.not446, label %.loopexit, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader440
  %min.iters.check = icmp ult i64 %18, 4
  br i1 %min.iters.check, label %.lr.ph.preheader477, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %18, 9223372036854775804
  %ind.end = and i64 %18, 3
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %21 = getelementptr i64, ptr %20, i64 %index
  store <2 x i64> <i64 500000, i64 500000>, ptr %21, align 8, !tbaa !3
  %22 = getelementptr i64, ptr %21, i64 2
  store <2 x i64> <i64 500000, i64 500000>, ptr %22, align 8, !tbaa !3
  %index.next = add nuw i64 %index, 4
  %23 = icmp eq i64 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %18, %n.vec
  br i1 %cmp.n, label %.loopexit, label %.lr.ph.preheader477

.lr.ph.preheader477:                              ; preds = %.lr.ph.preheader, %middle.block
  %.ph478 = phi i64 [ %18, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.ph479 = phi i64 [ 0, %.lr.ph.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader477, %.lr.ph
  %24 = phi i64 [ %28, %.lr.ph ], [ %.ph478, %.lr.ph.preheader477 ]
  %25 = phi i64 [ %26, %.lr.ph ], [ %.ph479, %.lr.ph.preheader477 ]
  %26 = add nuw nsw i64 %25, 1
  %27 = getelementptr i64, ptr %20, i64 %25
  store i64 500000, ptr %27, align 8, !tbaa !3
  %28 = add nsw i64 %24, -1
  %29 = icmp ugt i64 %24, 1
  br i1 %29, label %.lr.ph, label %.loopexit, !llvm.loop !12

30:                                               ; preds = %12
  %31 = tail call {} @_FortranAReportFatalUserError(ptr nonnull @_QQcl.16373402fa3425c6e46827601abb88fa, ptr nonnull @_QQcl.81e49c09a282bfa5818d95a8aa9f4a78, i32 7)
  %.unpack425.unpack.unpack = load i64, ptr @_QFEa.7, align 8, !tbaa !7
  %32 = icmp ugt i32 %15, 2147483646
  %33 = select i1 %32, i64 1, i64 %.unpack425.unpack.unpack
  store ptr null, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %33, ptr @_QFEa.7, align 8, !tbaa !7
  store i64 %18, ptr @_QFEa.8, align 8, !tbaa !7
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %middle.block, %.preheader440, %30
  %34 = tail call i32 @_FortranACharacterCompareScalar1(ptr nonnull @_QFEs, ptr nonnull @_QQcl.3C, i64 1, i64 1)
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %39

36:                                               ; preds = %.loopexit
  %.unpack406 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack413.unpack.unpack = load i64, ptr @_QFEa.7, align 8, !tbaa !7
  %37 = sub i64 1, %.unpack413.unpack.unpack
  %38 = getelementptr i64, ptr %.unpack406, i64 %37
  store i64 0, ptr %38, align 8, !tbaa !3
  br label %39

39:                                               ; preds = %36, %.loopexit
  %40 = sext i32 %15 to i64
  %41 = add nsw i64 %40, -1
  %42 = getelementptr [500000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %41
  %43 = tail call i32 @_FortranACharacterCompareScalar1(ptr %42, ptr nonnull @_QQcl.3E, i64 1, i64 1)
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %48

45:                                               ; preds = %39
  %.unpack394 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack401.unpack.unpack = load i64, ptr @_QFEa.7, align 8, !tbaa !7
  %46 = sub i64 %17, %.unpack401.unpack.unpack
  %47 = getelementptr i64, ptr %.unpack394, i64 %46
  store i64 0, ptr %47, align 8, !tbaa !3
  br label %48

48:                                               ; preds = %45, %39
  %49 = icmp sgt i32 %15, 0
  br i1 %49, label %.lr.ph443, label %._crit_edge

.preheader439:                                    ; preds = %63
  br i1 %49, label %.lr.ph444.preheader, label %._crit_edge

.lr.ph444.preheader:                              ; preds = %.preheader439
  %50 = add nsw i64 %40, 1
  br label %.lr.ph444

.lr.ph443:                                        ; preds = %48, %63
  %indvars.iv = phi i64 [ %indvars.iv.next, %63 ], [ 1, %48 ]
  %51 = add nsw i64 %indvars.iv, -1
  %52 = getelementptr [500000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %51
  %53 = tail call i32 @_FortranACharacterCompareScalar1(ptr %52, ptr nonnull @_QQcl.3E, i64 1, i64 1)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %sext454 = shl i64 %indvars.iv.next, 32
  %54 = ashr exact i64 %sext454, 32
  %55 = add nsw i64 %54, -1
  %56 = getelementptr [500000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %55
  %57 = tail call i32 @_FortranACharacterCompareScalar1(ptr %56, ptr nonnull @_QQcl.3C, i64 1, i64 1)
  %58 = or i32 %57, %53
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %63

60:                                               ; preds = %.lr.ph443
  %.unpack382 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack389.unpack.unpack = load i64, ptr @_QFEa.7, align 8, !tbaa !7
  %61 = sub i64 %54, %.unpack389.unpack.unpack
  %62 = getelementptr i64, ptr %.unpack382, i64 %61
  store i64 0, ptr %62, align 8, !tbaa !3
  br label %63

63:                                               ; preds = %60, %.lr.ph443
  %exitcond.not = icmp eq i64 %indvars.iv, %40
  br i1 %exitcond.not, label %.preheader439, label %.lr.ph443

.preheader:                                       ; preds = %78
  %64 = icmp sgt i32 %16, 1
  br i1 %64, label %.lr.ph445, label %._crit_edge

.lr.ph444:                                        ; preds = %.lr.ph444.preheader, %78
  %indvars.iv450 = phi i64 [ 1, %.lr.ph444.preheader ], [ %indvars.iv.next451.pre-phi, %78 ]
  %65 = add nsw i64 %indvars.iv450, -1
  %66 = getelementptr [500000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %65
  %67 = tail call i32 @_FortranACharacterCompareScalar1(ptr %66, ptr nonnull @_QQcl.3C, i64 1, i64 1)
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %.lr.ph444._crit_edge

.lr.ph444._crit_edge:                             ; preds = %.lr.ph444
  %.pre = add nuw nsw i64 %indvars.iv450, 1
  br label %78

69:                                               ; preds = %.lr.ph444
  %.unpack370 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack377.unpack.unpack = load i64, ptr @_QFEa.7, align 8, !tbaa !7
  %70 = sub i64 %indvars.iv450, %.unpack377.unpack.unpack
  %71 = getelementptr i64, ptr %.unpack370, i64 %70
  %72 = load i64, ptr %71, align 8, !tbaa !3
  %73 = add i64 %72, 1
  %74 = add nuw nsw i64 %indvars.iv450, 1
  %sext = shl i64 %74, 32
  %75 = ashr exact i64 %sext, 32
  %76 = sub i64 %75, %.unpack377.unpack.unpack
  %77 = getelementptr i64, ptr %.unpack370, i64 %76
  store i64 %73, ptr %77, align 8, !tbaa !3
  br label %78

78:                                               ; preds = %.lr.ph444._crit_edge, %69
  %indvars.iv.next451.pre-phi = phi i64 [ %.pre, %.lr.ph444._crit_edge ], [ %74, %69 ]
  %exitcond453.not = icmp eq i64 %indvars.iv.next451.pre-phi, %50
  br i1 %exitcond453.not, label %.preheader, label %.lr.ph444

.lr.ph445:                                        ; preds = %.preheader, %100
  %.in = phi i64 [ %80, %100 ], [ %17, %.preheader ]
  %79 = phi i32 [ %81, %100 ], [ %16, %.preheader ]
  %80 = add nsw i64 %.in, -1
  %81 = add i32 %79, -1
  %82 = sext i32 %81 to i64
  %83 = add nsw i64 %82, -1
  %84 = getelementptr [500000 x [1 x i8]], ptr @_QFEs, i64 0, i64 %83
  %85 = tail call i32 @_FortranACharacterCompareScalar1(ptr %84, ptr nonnull @_QQcl.3E, i64 1, i64 1)
  %86 = icmp eq i32 %85, 0
  %.unpack358 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack365.unpack.unpack = load i64, ptr @_QFEa.7, align 8, !tbaa !7
  %87 = sub i64 %82, %.unpack365.unpack.unpack
  %88 = getelementptr i64, ptr %.unpack358, i64 %87
  %89 = load i64, ptr %88, align 8, !tbaa !3
  %90 = icmp eq i64 %89, 500000
  %91 = sext i32 %79 to i64
  %92 = sub i64 %91, %.unpack365.unpack.unpack
  %93 = getelementptr i64, ptr %.unpack358, i64 %92
  %94 = load i64, ptr %93, align 8, !tbaa !3
  %95 = icmp sle i64 %89, %94
  %96 = or i1 %90, %95
  %97 = and i1 %86, %96
  br i1 %97, label %98, label %100

98:                                               ; preds = %.lr.ph445
  %99 = add i64 %94, 1
  store i64 %99, ptr %88, align 8, !tbaa !3
  br label %100

100:                                              ; preds = %98, %.lr.ph445
  %101 = icmp sgt i64 %.in, 2
  br i1 %101, label %.lr.ph445, label %._crit_edge

._crit_edge:                                      ; preds = %100, %48, %.preheader439, %.preheader
  %102 = tail call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull @_QQcl.81e49c09a282bfa5818d95a8aa9f4a78, i32 19)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack353.unpack.unpack355 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  %103 = icmp sgt i64 %.unpack353.unpack.unpack355, 0
  br i1 %103, label %.lr.ph.i.preheader, label %_FortranASumInteger8x1_contract_simplified.exit

.lr.ph.i.preheader:                               ; preds = %._crit_edge
  %min.iters.check462 = icmp ult i64 %.unpack353.unpack.unpack355, 4
  br i1 %min.iters.check462, label %.lr.ph.i.preheader473, label %vector.ph463

vector.ph463:                                     ; preds = %.lr.ph.i.preheader
  %n.vec465 = and i64 %.unpack353.unpack.unpack355, -4
  br label %vector.body468

vector.body468:                                   ; preds = %vector.body468, %vector.ph463
  %index469 = phi i64 [ 0, %vector.ph463 ], [ %index.next472, %vector.body468 ]
  %vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph463 ], [ %107, %vector.body468 ]
  %vec.phi470 = phi <2 x i64> [ zeroinitializer, %vector.ph463 ], [ %108, %vector.body468 ]
  %104 = shl i64 %index469, 3
  %105 = getelementptr i8, ptr %.unpack, i64 %104
  %wide.load = load <2 x i64>, ptr %105, align 8, !tbaa !3
  %106 = getelementptr i64, ptr %105, i64 2
  %wide.load471 = load <2 x i64>, ptr %106, align 8, !tbaa !3
  %107 = add <2 x i64> %wide.load, %vec.phi
  %108 = add <2 x i64> %wide.load471, %vec.phi470
  %index.next472 = add nuw i64 %index469, 4
  %109 = icmp eq i64 %index.next472, %n.vec465
  br i1 %109, label %middle.block460, label %vector.body468, !llvm.loop !13

middle.block460:                                  ; preds = %vector.body468
  %bin.rdx = add <2 x i64> %108, %107
  %110 = tail call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %cmp.n467 = icmp eq i64 %.unpack353.unpack.unpack355, %n.vec465
  br i1 %cmp.n467, label %_FortranASumInteger8x1_contract_simplified.exit, label %.lr.ph.i.preheader473

.lr.ph.i.preheader473:                            ; preds = %.lr.ph.i.preheader, %middle.block460
  %.ph = phi i64 [ 0, %.lr.ph.i.preheader ], [ %110, %middle.block460 ]
  %.ph474 = phi i64 [ 0, %.lr.ph.i.preheader ], [ %n.vec465, %middle.block460 ]
  br label %.lr.ph.i

.lr.ph.i:                                         ; preds = %.lr.ph.i.preheader473, %.lr.ph.i
  %111 = phi i64 [ %116, %.lr.ph.i ], [ %.ph, %.lr.ph.i.preheader473 ]
  %112 = phi i64 [ %117, %.lr.ph.i ], [ %.ph474, %.lr.ph.i.preheader473 ]
  %113 = shl i64 %112, 3
  %114 = getelementptr i8, ptr %.unpack, i64 %113
  %115 = load i64, ptr %114, align 8, !tbaa !3
  %116 = add i64 %115, %111
  %117 = add nuw nsw i64 %112, 1
  %exitcond.not.i = icmp eq i64 %117, %.unpack353.unpack.unpack355
  br i1 %exitcond.not.i, label %_FortranASumInteger8x1_contract_simplified.exit, label %.lr.ph.i, !llvm.loop !14

_FortranASumInteger8x1_contract_simplified.exit:  ; preds = %.lr.ph.i, %middle.block460, %._crit_edge
  %.lcssa.i = phi i64 [ 0, %._crit_edge ], [ %110, %middle.block460 ], [ %116, %.lr.ph.i ]
  %118 = tail call i1 @_FortranAioOutputInteger64(ptr %102, i64 %.lcssa.i)
  %119 = tail call i32 @_FortranAioEndIoStatement(ptr %102)
  ret void
}

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputAscii(ptr, ptr, i64) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare {} @_FortranAReportFatalUserError(ptr, ptr, i32) local_unnamed_addr

declare i32 @_FortranACharacterCompareScalar1(ptr, ptr, i64, i64) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListOutput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputInteger64(ptr, i64) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #2

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
!9 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !11, !10}
!13 = distinct !{!13, !10, !11}
!14 = distinct !{!14, !11, !10}
