; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/LONG/AUG15/WOUT (A)

; 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"

@dp = external dso_local global [1001000 x i64], align 16
@n = external dso_local global i64, align 8
@h = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@cur = external dso_local global i64, align 8
@t = external dso_local global i32, align 4
@ll = external dso_local global i32, align 4
@hh = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 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
  %7 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %9

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

13:                                               ; preds = %9
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @h)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %25, %13
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = load i64, ptr @n, align 8, !tbaa !9
  %19 = icmp slt i64 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %28

21:                                               ; preds = %15
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %23
  store i64 0, ptr %24, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %21
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !11

28:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %48, %28
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = load i64, ptr @n, align 8, !tbaa !9
  %33 = icmp slt i64 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %51

35:                                               ; preds = %29
  %36 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @ll, ptr noundef @hh)
  %37 = load i32, ptr @ll, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = add nsw i64 %40, 1
  store i64 %41, ptr %39, align 8, !tbaa !9
  %42 = load i32, ptr @hh, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !9
  %47 = add nsw i64 %46, -1
  store i64 %47, ptr %45, align 8, !tbaa !9
  br label %48

48:                                               ; preds = %35
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %3, align 4, !tbaa !5
  br label %29, !llvm.loop !13

51:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %69, %51
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = load i64, ptr @n, align 8, !tbaa !9
  %56 = icmp slt i64 %54, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %72

58:                                               ; preds = %52
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sub nsw i32 %59, 1
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !9
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !9
  %68 = add nsw i64 %67, %63
  store i64 %68, ptr %66, align 8, !tbaa !9
  br label %69

69:                                               ; preds = %58
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %4, align 4, !tbaa !5
  br label %52, !llvm.loop !14

72:                                               ; preds = %57
  store i64 0, ptr @cur, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %73

73:                                               ; preds = %86, %72
  %74 = load i32, ptr %5, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = load i64, ptr @h, align 8, !tbaa !9
  %77 = icmp slt i64 %75, %76
  br i1 %77, label %79, label %78

78:                                               ; preds = %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %89

79:                                               ; preds = %73
  %80 = load i32, ptr %5, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %81
  %83 = load i64, ptr %82, align 8, !tbaa !9
  %84 = load i64, ptr @cur, align 8, !tbaa !9
  %85 = add nsw i64 %84, %83
  store i64 %85, ptr @cur, align 8, !tbaa !9
  br label %86

86:                                               ; preds = %79
  %87 = load i32, ptr %5, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %5, align 4, !tbaa !5
  br label %73, !llvm.loop !15

89:                                               ; preds = %78
  %90 = load i64, ptr @n, align 8, !tbaa !9
  %91 = load i64, ptr @h, align 8, !tbaa !9
  %92 = mul nsw i64 %90, %91
  %93 = load i64, ptr @cur, align 8, !tbaa !9
  %94 = sub nsw i64 %92, %93
  store i64 %94, ptr @ans, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %95 = load i64, ptr @h, align 8, !tbaa !9
  %96 = trunc i64 %95 to i32
  store i32 %96, ptr %6, align 4, !tbaa !5
  br label %97

97:                                               ; preds = %125, %89
  %98 = load i32, ptr %6, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = load i64, ptr @n, align 8, !tbaa !9
  %101 = icmp slt i64 %99, %100
  br i1 %101, label %103, label %102

102:                                              ; preds = %97
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %128

103:                                              ; preds = %97
  %104 = load i32, ptr %6, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %105
  %107 = load i64, ptr %106, align 8, !tbaa !9
  %108 = load i64, ptr @cur, align 8, !tbaa !9
  %109 = add nsw i64 %108, %107
  store i64 %109, ptr @cur, align 8, !tbaa !9
  %110 = load i32, ptr %6, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = load i64, ptr @h, align 8, !tbaa !9
  %113 = sub nsw i64 %111, %112
  %114 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %113
  %115 = load i64, ptr %114, align 8, !tbaa !9
  %116 = load i64, ptr @cur, align 8, !tbaa !9
  %117 = sub nsw i64 %116, %115
  store i64 %117, ptr @cur, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %118 = load i64, ptr @n, align 8, !tbaa !9
  %119 = load i64, ptr @h, align 8, !tbaa !9
  %120 = mul nsw i64 %118, %119
  %121 = load i64, ptr @cur, align 8, !tbaa !9
  %122 = sub nsw i64 %120, %121
  store i64 %122, ptr %7, align 8, !tbaa !9
  %123 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @ans, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %124 = load i64, ptr %123, align 8, !tbaa !9
  store i64 %124, ptr @ans, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %125

125:                                              ; preds = %103
  %126 = load i32, ptr %6, align 4, !tbaa !5
  %127 = add nsw i32 %126, 1
  store i32 %127, ptr %6, align 4, !tbaa !5
  br label %97, !llvm.loop !16

128:                                              ; preds = %102
  %129 = load i64, ptr @ans, align 8, !tbaa !9
  %130 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %129)
  br label %9, !llvm.loop !17

131:                                              ; preds = %9
  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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

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 = { inlinehint mustprogress 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 #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}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !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"

@dp = external dso_local local_unnamed_addr global [1001000 x i64], align 16
@n = external dso_local global i64, align 8
@h = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@cur = external dso_local local_unnamed_addr global i64, align 8
@t = external dso_local global i32, align 4
@ll = external dso_local global i32, align 4
@hh = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

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

.lr.ph44:                                         ; preds = %0, %._crit_edge41
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @h)
  %6 = load i64, ptr @n, align 8, !tbaa !9
  %7 = icmp sgt i64 %6, 0
  br i1 %7, label %.lr.ph29.preheader, label %._crit_edge

.lr.ph29.preheader:                               ; preds = %.lr.ph44
  %8 = shl nuw i64 %6, 3
  call void @llvm.memset.p0.i64(ptr nonnull align 16 @dp, i8 0, i64 %8, i1 false), !tbaa !9
  br label %.lr.ph29

.preheader:                                       ; preds = %.lr.ph29
  %9 = icmp sgt i64 %25, 1
  br i1 %9, label %.lr.ph31.preheader, label %._crit_edge

.lr.ph31.preheader:                               ; preds = %.preheader
  %.pre = load i64, ptr @dp, align 16, !tbaa !9
  %10 = add nsw i64 %25, -1
  %11 = add nsw i64 %25, -2
  %xtraiter = and i64 %10, 3
  %12 = icmp ult i64 %11, 3
  br i1 %12, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph31.preheader.new

.lr.ph31.preheader.new:                           ; preds = %.lr.ph31.preheader
  %unroll_iter = and i64 %10, -4
  br label %.lr.ph31

.lr.ph29:                                         ; preds = %.lr.ph29.preheader, %.lr.ph29
  %indvars.iv = phi i64 [ 0, %.lr.ph29.preheader ], [ %indvars.iv.next, %.lr.ph29 ]
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @ll, ptr noundef nonnull @hh)
  %14 = load i32, ptr @ll, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %15
  %17 = load i64, ptr %16, align 8, !tbaa !9
  %18 = add nsw i64 %17, 1
  store i64 %18, ptr %16, align 8, !tbaa !9
  %19 = load i32, ptr @hh, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %21
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = add nsw i64 %23, -1
  store i64 %24, ptr %22, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = load i64, ptr @n, align 8, !tbaa !9
  %26 = icmp sgt i64 %25, %indvars.iv.next
  br i1 %26, label %.lr.ph29, label %.preheader, !llvm.loop !11

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph31, %.lr.ph31.preheader
  %.unr = phi i64 [ %.pre, %.lr.ph31.preheader ], [ %52, %.lr.ph31 ]
  %indvars.iv50.unr = phi i64 [ 1, %.lr.ph31.preheader ], [ %indvars.iv.next51.3, %.lr.ph31 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph31.epil

.lr.ph31.epil:                                    ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph31.epil
  %27 = phi i64 [ %30, %.lr.ph31.epil ], [ %.unr, %._crit_edge.loopexit.unr-lcssa ]
  %indvars.iv50.epil = phi i64 [ %indvars.iv.next51.epil, %.lr.ph31.epil ], [ %indvars.iv50.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph31.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %28 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %indvars.iv50.epil
  %29 = load i64, ptr %28, align 8, !tbaa !9
  %30 = add nsw i64 %29, %27
  store i64 %30, ptr %28, align 8, !tbaa !9
  %indvars.iv.next51.epil = add nuw nsw i64 %indvars.iv50.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph31.epil, !llvm.loop !13

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph31.epil, %.lr.ph44, %.preheader
  %31 = phi i64 [ %25, %.preheader ], [ %6, %.lr.ph44 ], [ %25, %.lr.ph31.epil ], [ %25, %._crit_edge.loopexit.unr-lcssa ]
  store i64 0, ptr @cur, align 8, !tbaa !9
  %32 = load i64, ptr @h, align 8, !tbaa !9
  %33 = icmp sgt i64 %32, 0
  br i1 %33, label %.lr.ph34.preheader, label %53

.lr.ph34.preheader:                               ; preds = %._crit_edge
  %min.iters.check = icmp ult i64 %32, 4
  br i1 %min.iters.check, label %.lr.ph34.preheader66, label %vector.ph

.lr.ph34.preheader66:                             ; preds = %middle.block, %.lr.ph34.preheader
  %indvars.iv53.ph = phi i64 [ 0, %.lr.ph34.preheader ], [ %n.vec, %middle.block ]
  %.ph = phi i64 [ 0, %.lr.ph34.preheader ], [ %39, %middle.block ]
  br label %.lr.ph34

vector.ph:                                        ; preds = %.lr.ph34.preheader
  %n.vec = and i64 %32, 9223372036854775804
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %36, %vector.body ]
  %vec.phi64 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %37, %vector.body ]
  %34 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %index
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  %wide.load = load <2 x i64>, ptr %34, align 16, !tbaa !9
  %wide.load65 = load <2 x i64>, ptr %35, align 16, !tbaa !9
  %36 = add <2 x i64> %vec.phi, %wide.load
  %37 = add <2 x i64> %vec.phi64, %wide.load65
  %index.next = add nuw i64 %index, 4
  %38 = icmp eq i64 %index.next, %n.vec
  br i1 %38, label %middle.block, label %vector.body, !llvm.loop !15

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %37, %36
  %39 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %cmp.n = icmp eq i64 %32, %n.vec
  br i1 %cmp.n, label %._crit_edge35, label %.lr.ph34.preheader66

.lr.ph31:                                         ; preds = %.lr.ph31, %.lr.ph31.preheader.new
  %40 = phi i64 [ %.pre, %.lr.ph31.preheader.new ], [ %52, %.lr.ph31 ]
  %indvars.iv50 = phi i64 [ 1, %.lr.ph31.preheader.new ], [ %indvars.iv.next51.3, %.lr.ph31 ]
  %niter = phi i64 [ 0, %.lr.ph31.preheader.new ], [ %niter.next.3, %.lr.ph31 ]
  %41 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %indvars.iv50
  %42 = load i64, ptr %41, align 8, !tbaa !9
  %43 = add nsw i64 %42, %40
  store i64 %43, ptr %41, align 8, !tbaa !9
  %indvars.iv.next51 = add nuw nsw i64 %indvars.iv50, 1
  %44 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %indvars.iv.next51
  %45 = load i64, ptr %44, align 8, !tbaa !9
  %46 = add nsw i64 %45, %43
  store i64 %46, ptr %44, align 8, !tbaa !9
  %indvars.iv.next51.1 = add nuw nsw i64 %indvars.iv50, 2
  %47 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %indvars.iv.next51.1
  %48 = load i64, ptr %47, align 8, !tbaa !9
  %49 = add nsw i64 %48, %46
  store i64 %49, ptr %47, align 8, !tbaa !9
  %indvars.iv.next51.2 = add nuw nsw i64 %indvars.iv50, 3
  %50 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %indvars.iv.next51.2
  %51 = load i64, ptr %50, align 8, !tbaa !9
  %52 = add nsw i64 %51, %49
  store i64 %52, ptr %50, align 8, !tbaa !9
  %indvars.iv.next51.3 = add nuw nsw i64 %indvars.iv50, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph31, !llvm.loop !18

._crit_edge35:                                    ; preds = %.lr.ph34, %middle.block
  %.lcssa62 = phi i64 [ %39, %middle.block ], [ %62, %.lr.ph34 ]
  store i64 %.lcssa62, ptr @cur, align 8, !tbaa !9
  br label %53

53:                                               ; preds = %._crit_edge35, %._crit_edge
  %54 = phi i64 [ %.lcssa62, %._crit_edge35 ], [ 0, %._crit_edge ]
  %55 = mul nsw i64 %32, %31
  %56 = sub nsw i64 %55, %54
  store i64 %56, ptr @ans, align 8, !tbaa !9
  %sext = shl i64 %32, 32
  %57 = ashr exact i64 %sext, 32
  %58 = icmp sgt i64 %31, %57
  br i1 %58, label %.lr.ph40, label %._crit_edge41

.lr.ph34:                                         ; preds = %.lr.ph34.preheader66, %.lr.ph34
  %indvars.iv53 = phi i64 [ %indvars.iv.next54, %.lr.ph34 ], [ %indvars.iv53.ph, %.lr.ph34.preheader66 ]
  %59 = phi i64 [ %62, %.lr.ph34 ], [ %.ph, %.lr.ph34.preheader66 ]
  %60 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %indvars.iv53
  %61 = load i64, ptr %60, align 8, !tbaa !9
  %62 = add nsw i64 %59, %61
  %indvars.iv.next54 = add nuw nsw i64 %indvars.iv53, 1
  %exitcond56.not = icmp eq i64 %indvars.iv.next54, %32
  br i1 %exitcond56.not, label %._crit_edge35, label %.lr.ph34, !llvm.loop !19

._crit_edge41:                                    ; preds = %.lr.ph40, %53
  %63 = phi i64 [ %56, %53 ], [ %80, %.lr.ph40 ]
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %63)
  %65 = load i32, ptr @t, align 4, !tbaa !5
  %66 = add nsw i32 %65, -1
  store i32 %66, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %65, 0
  br i1 %.not, label %._crit_edge45, label %.lr.ph44, !llvm.loop !20

.lr.ph40:                                         ; preds = %53, %.lr.ph40
  %indvars.iv57 = phi i64 [ %indvars.iv.next58, %.lr.ph40 ], [ %57, %53 ]
  %67 = phi i64 [ %81, %.lr.ph40 ], [ %31, %53 ]
  %68 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %indvars.iv57
  %69 = load i64, ptr %68, align 8, !tbaa !9
  %70 = load i64, ptr @cur, align 8, !tbaa !9
  %71 = add nsw i64 %70, %69
  %72 = load i64, ptr @h, align 8, !tbaa !9
  %73 = sub nsw i64 %indvars.iv57, %72
  %74 = getelementptr inbounds [1001000 x i64], ptr @dp, i64 0, i64 %73
  %75 = load i64, ptr %74, align 8, !tbaa !9
  %76 = sub nsw i64 %71, %75
  store i64 %76, ptr @cur, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %77 = mul nsw i64 %72, %67
  %78 = sub nsw i64 %77, %76
  store i64 %78, ptr %1, align 8, !tbaa !9
  %79 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @ans, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %80 = load i64, ptr %79, align 8, !tbaa !9
  store i64 %80, ptr @ans, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %indvars.iv.next58 = add nsw i64 %indvars.iv57, 1
  %81 = load i64, ptr @n, align 8, !tbaa !9
  %82 = icmp sgt i64 %81, %indvars.iv.next58
  br i1 %82, label %.lr.ph40, label %._crit_edge41, !llvm.loop !21

._crit_edge45:                                    ; preds = %._crit_edge41, %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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

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

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

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

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = distinct !{!15, !12, !16, !17}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12, !17, !16}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass