; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (2068)

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

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z1Cii(i32 noundef, i32 noundef) #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca [13 x i64], align 16
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 104, ptr %5) #4
  %6 = getelementptr inbounds [13 x i64], ptr %5, i64 0, i64 0
  store i64 1, ptr %6, align 16, !tbaa !5
  %7 = getelementptr inbounds [13 x i64], ptr %5, i64 0, i64 1
  store i64 0, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds [13 x i64], ptr %5, i64 0, i64 2
  store i64 1, ptr %8, align 16, !tbaa !5
  %9 = getelementptr inbounds [13 x i64], ptr %5, i64 0, i64 3
  store i64 2, ptr %9, align 8, !tbaa !5
  store i32 4, ptr %2, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %32, %0
  %11 = load i32, ptr %2, align 4, !tbaa !9
  %12 = icmp sle i32 %11, 12
  br i1 %12, label %13, label %35

13:                                               ; preds = %10
  %14 = load i32, ptr %2, align 4, !tbaa !9
  %15 = sub nsw i32 %14, 1
  %16 = sext i32 %15 to i64
  %17 = load i32, ptr %2, align 4, !tbaa !9
  %18 = sub nsw i32 %17, 1
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [13 x i64], ptr %5, i64 0, i64 %19
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = load i32, ptr %2, align 4, !tbaa !9
  %23 = sub nsw i32 %22, 2
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [13 x i64], ptr %5, i64 0, i64 %24
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = add nsw i64 %21, %26
  %28 = mul nsw i64 %16, %27
  %29 = load i32, ptr %2, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [13 x i64], ptr %5, i64 0, i64 %30
  store i64 %28, ptr %31, align 8, !tbaa !5
  br label %32

32:                                               ; preds = %13
  %33 = load i32, ptr %2, align 4, !tbaa !9
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %2, align 4, !tbaa !9
  br label %10, !llvm.loop !11

35:                                               ; preds = %10
  br label %36

36:                                               ; preds = %65, %35
  %37 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3)
  %38 = icmp ne i32 %37, -1
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  %40 = load i32, ptr %3, align 4, !tbaa !9
  %41 = icmp ne i32 %40, 0
  br label %42

42:                                               ; preds = %39, %36
  %43 = phi i1 [ false, %36 ], [ %41, %39 ]
  br i1 %43, label %44, label %68

44:                                               ; preds = %42
  store i64 0, ptr %4, align 8, !tbaa !5
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %62, %44
  %46 = load i32, ptr %2, align 4, !tbaa !9
  %47 = load i32, ptr %3, align 4, !tbaa !9
  %48 = sdiv i32 %47, 2
  %49 = icmp sle i32 %46, %48
  br i1 %49, label %50, label %65

50:                                               ; preds = %45
  %51 = load i32, ptr %2, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [13 x i64], ptr %5, i64 0, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !5
  %55 = load i32, ptr %3, align 4, !tbaa !9
  %56 = load i32, ptr %2, align 4, !tbaa !9
  %57 = call noundef i32 @_Z1Cii(i32 noundef %55, i32 noundef %56)
  %58 = sext i32 %57 to i64
  %59 = mul nsw i64 %54, %58
  %60 = load i64, ptr %4, align 8, !tbaa !5
  %61 = add nsw i64 %60, %59
  store i64 %61, ptr %4, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %50
  %63 = load i32, ptr %2, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %2, align 4, !tbaa !9
  br label %45, !llvm.loop !13

65:                                               ; preds = %45
  %66 = load i64, ptr %4, align 8, !tbaa !5
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %66)
  br label %36, !llvm.loop !14

68:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 104, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 0
}

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

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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"

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z1Cii(i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
.preheader13:
  %0 = alloca i32, align 4
  %1 = alloca [13 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %1) #4
  store i64 1, ptr %1, align 16, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %1, i64 8
  store i64 0, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 16
  store i64 1, ptr %3, align 16, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 24
  store i64 2, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 32
  store i64 9, ptr %5, align 16, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 40
  store i64 44, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 48
  store i64 265, ptr %7, align 16, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 56
  store i64 1854, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %1, i64 64
  store i64 14833, ptr %9, align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 72
  store i64 133496, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 80
  store i64 1334961, ptr %11, align 16, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %1, i64 88
  store i64 14684570, ptr %12, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 96
  store i64 176214841, ptr %13, align 16, !tbaa !5
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %0)
  %15 = icmp ne i32 %14, -1
  %16 = load i32, ptr %0, align 4
  %17 = icmp ne i32 %16, 0
  %18 = select i1 %15, i1 %17, i1 false
  br i1 %18, label %.preheader, label %._crit_edge18

.preheader:                                       ; preds = %.preheader13, %._crit_edge
  %19 = phi i32 [ %34, %._crit_edge ], [ %16, %.preheader13 ]
  %.not15 = icmp slt i32 %19, -1
  br i1 %.not15, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
  %20 = phi i32 [ %28, %.lr.ph ], [ %19, %.preheader ]
  %.017 = phi i64 [ %27, %.lr.ph ], [ 0, %.preheader ]
  %21 = getelementptr inbounds [13 x i64], ptr %1, i64 0, i64 %indvars.iv
  %22 = load i64, ptr %21, align 8, !tbaa !5
  %23 = trunc nuw nsw i64 %indvars.iv to i32
  %24 = call noundef i32 @_Z1Cii(i32 noundef %20, i32 noundef %23)
  %25 = sext i32 %24 to i64
  %26 = mul nsw i64 %22, %25
  %27 = add nsw i64 %26, %.017
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = load i32, ptr %0, align 4, !tbaa !9
  %29 = sdiv i32 %28, 2
  %30 = sext i32 %29 to i64
  %.not.not = icmp slt i64 %indvars.iv, %30
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.0.lcssa = phi i64 [ 0, %.preheader ], [ %27, %.lr.ph ]
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %.0.lcssa)
  %32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %0)
  %33 = icmp ne i32 %32, -1
  %34 = load i32, ptr %0, align 4
  %35 = icmp ne i32 %34, 0
  %36 = select i1 %33, i1 %35, i1 false
  br i1 %36, label %.preheader, label %._crit_edge18, !llvm.loop !13

._crit_edge18:                                    ; preds = %._crit_edge, %.preheader13
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %1) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %0) #4
  ret i32 0
}

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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