; LLVM IR from tangjz/acm-icpc :: poj (1384)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@v = external dso_local global i32, align 4
@f = external dso_local global [10001 x i64], align 16
@INF = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [54 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %8

8:                                                ; preds = %81, %0
  %9 = load i32, ptr @t, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  store i32 %10, ptr @t, align 4, !tbaa !5
  %11 = icmp ne i32 %9, 0
  br i1 %11, label %12, label %82

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %2, ptr noundef %3, ptr noundef @n)
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sub nsw i32 %14, %15
  store i32 %16, ptr @v, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @f, i8 63, i64 80008, i1 false)
  store i64 0, ptr @f, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %63, %12
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  store i32 4, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %66

22:                                               ; preds = %17
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %3, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %24 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %24, ptr %6, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %59, %22
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = load i32, ptr @v, align 4, !tbaa !5
  %28 = icmp sle i32 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  store i32 7, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %62

30:                                               ; preds = %25
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [10001 x i64], ptr @f, i64 0, i64 %32
  %34 = load i64, ptr %33, align 8, !tbaa !9
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = sub nsw i32 %35, %36
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [10001 x i64], ptr @f, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = add nsw i64 %40, %42
  %44 = icmp sgt i64 %34, %43
  br i1 %44, label %45, label %58

45:                                               ; preds = %30
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sub nsw i32 %46, %47
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [10001 x i64], ptr @f, i64 0, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !9
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = add nsw i64 %51, %53
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [10001 x i64], ptr @f, i64 0, i64 %56
  store i64 %54, ptr %57, align 8, !tbaa !9
  br label %58

58:                                               ; preds = %45, %30
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %6, align 4, !tbaa !5
  br label %25, !llvm.loop !11

62:                                               ; preds = %29
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %4, align 4, !tbaa !5
  br label %17, !llvm.loop !13

66:                                               ; preds = %21
  %67 = load i32, ptr @v, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [10001 x i64], ptr @f, i64 0, i64 %68
  %70 = load i64, ptr %69, align 8, !tbaa !9
  %71 = load i64, ptr @INF, align 8, !tbaa !9
  %72 = icmp eq i64 %70, %71
  br i1 %72, label %73, label %75

73:                                               ; preds = %66
  %74 = call i32 @puts(ptr noundef @.str.3)
  br label %81

75:                                               ; preds = %66
  %76 = load i32, ptr @v, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [10001 x i64], ptr @f, i64 0, i64 %77
  %79 = load i64, ptr %78, align 8, !tbaa !9
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i64 noundef %79)
  br label %81

81:                                               ; preds = %75, %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %8, !llvm.loop !14

82:                                               ; preds = %8
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

declare i32 @puts(ptr noundef) #1

declare i32 @printf(ptr noundef, ...) #1

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@v = external dso_local local_unnamed_addr global i32, align 4
@f = external dso_local local_unnamed_addr global [10001 x i64], align 16
@INF = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [54 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %4 = load i32, ptr @t, align 4, !tbaa !5
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @t, align 4, !tbaa !5
  %.not18 = icmp eq i32 %4, 0
  br i1 %.not18, label %._crit_edge21, label %.lr.ph20

.lr.ph20:                                         ; preds = %0, %58
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull @n)
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %9 = sub nsw i32 %7, %8
  store i32 %9, ptr @v, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(80008) @f, i8 63, i64 80008, i1 false)
  store i64 0, ptr @f, align 16, !tbaa !9
  %10 = load i32, ptr @n, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph16, label %._crit_edge17

._crit_edge17:                                    ; preds = %._crit_edge, %.lr.ph20
  %12 = phi i32 [ %9, %.lr.ph20 ], [ %20, %._crit_edge ]
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [10001 x i64], ptr @f, i64 0, i64 %13
  %15 = load i64, ptr %14, align 8, !tbaa !9
  %16 = load i64, ptr @INF, align 8, !tbaa !9
  %17 = icmp eq i64 %15, %16
  br i1 %17, label %54, label %56

.lr.ph16:                                         ; preds = %.lr.ph20, %._crit_edge
  %.0814 = phi i32 [ %33, %._crit_edge ], [ 0, %.lr.ph20 ]
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %2, ptr noundef nonnull %1)
  %19 = load i32, ptr %1, align 4, !tbaa !5
  %20 = load i32, ptr @v, align 4, !tbaa !5
  %.not1112 = icmp sgt i32 %19, %20
  br i1 %.not1112, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph16
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = sext i32 %19 to i64
  %24 = add i32 %20, 1
  %25 = sub i32 %24, %19
  %xtraiter = and i32 %25, 1
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.prol.loopexit, label %.prol.preheader

.prol.preheader:                                  ; preds = %.lr.ph
  %26 = getelementptr inbounds [10001 x i64], ptr @f, i64 0, i64 %23
  %27 = load i64, ptr %26, align 8, !tbaa !9
  %28 = load i64, ptr @f, align 16, !tbaa !9
  %29 = add nsw i64 %28, %22
  %30 = icmp sgt i64 %27, %29
  br i1 %30, label %31, label %.prol.loopexit.unr-lcssa

31:                                               ; preds = %.prol.preheader
  store i64 %29, ptr %26, align 8, !tbaa !9
  br label %.prol.loopexit.unr-lcssa

.prol.loopexit.unr-lcssa:                         ; preds = %31, %.prol.preheader
  %indvars.iv.next.prol = add nsw i64 %23, 1
  br label %.prol.loopexit

.prol.loopexit:                                   ; preds = %.prol.loopexit.unr-lcssa, %.lr.ph
  %indvars.iv.unr = phi i64 [ %23, %.lr.ph ], [ %indvars.iv.next.prol, %.prol.loopexit.unr-lcssa ]
  %32 = icmp eq i32 %20, %19
  br i1 %32, label %._crit_edge, label %.lr.ph.new

._crit_edge:                                      ; preds = %.prol.loopexit, %53, %.lr.ph16
  %33 = add nuw nsw i32 %.0814, 1
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %.lr.ph16, label %._crit_edge17, !llvm.loop !11

.lr.ph.new:                                       ; preds = %.prol.loopexit, %53
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %53 ], [ %indvars.iv.unr, %.prol.loopexit ]
  %36 = getelementptr inbounds [10001 x i64], ptr @f, i64 0, i64 %indvars.iv
  %37 = load i64, ptr %36, align 8, !tbaa !9
  %38 = sub nsw i64 %indvars.iv, %23
  %39 = getelementptr inbounds [10001 x i64], ptr @f, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = add nsw i64 %40, %22
  %42 = icmp sgt i64 %37, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %.lr.ph.new
  store i64 %41, ptr %36, align 8, !tbaa !9
  br label %44

44:                                               ; preds = %.lr.ph.new, %43
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %45 = getelementptr inbounds [10001 x i64], ptr @f, i64 0, i64 %indvars.iv.next
  %46 = load i64, ptr %45, align 8, !tbaa !9
  %47 = sub nsw i64 %indvars.iv.next, %23
  %48 = getelementptr inbounds [10001 x i64], ptr @f, i64 0, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !9
  %50 = add nsw i64 %49, %22
  %51 = icmp sgt i64 %46, %50
  br i1 %51, label %52, label %53

52:                                               ; preds = %44
  store i64 %50, ptr %45, align 8, !tbaa !9
  br label %53

53:                                               ; preds = %52, %44
  %indvars.iv.next.1 = add nsw i64 %indvars.iv, 2
  %lftr.wideiv.1 = trunc i64 %indvars.iv.next.1 to i32
  %exitcond.not.1 = icmp eq i32 %24, %lftr.wideiv.1
  br i1 %exitcond.not.1, label %._crit_edge, label %.lr.ph.new, !llvm.loop !13

54:                                               ; preds = %._crit_edge17
  %55 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %58

56:                                               ; preds = %._crit_edge17
  %57 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i64 noundef %15)
  br label %58

58:                                               ; preds = %56, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %59 = load i32, ptr @t, align 4, !tbaa !5
  %60 = add nsw i32 %59, -1
  store i32 %60, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %59, 0
  br i1 %.not, label %._crit_edge21, label %.lr.ph20, !llvm.loop !14

._crit_edge21:                                    ; preds = %58, %0
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { mustprogress nofree norecurse nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind }

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass