; LLVM IR from lzyrapx/Competitive-Programming :: LibreOJ (6083（数学）)

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

@ans = external dso_local global [10 x i64], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z4calcxxx(i64 noundef, i64 noundef, i64 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 i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  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
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %9

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

12:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %61

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  store i64 %15, ptr %5, align 8, !tbaa !9
  br label %16

16:                                               ; preds = %49, %13
  %17 = load i64, ptr %5, align 8, !tbaa !9
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = icmp sle i64 %17, %19
  br i1 %20, label %21, label %52

21:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %22 = load i64, ptr %5, align 8, !tbaa !9
  store i64 %22, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %23 = load i64, ptr %5, align 8, !tbaa !9
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = sdiv i64 %23, %25
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  %29 = sext i32 %28 to i64
  %30 = mul nsw i64 %26, %29
  %31 = sub nsw i64 %30, 1
  store i64 %31, ptr %7, align 8, !tbaa !9
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = load i64, ptr %6, align 8, !tbaa !9
  %35 = load i64, ptr %7, align 8, !tbaa !9
  %36 = call noundef i64 @_Z4calcxxx(i64 noundef %33, i64 noundef %34, i64 noundef %35)
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = sub nsw i32 %37, 1
  %39 = sext i32 %38 to i64
  %40 = load i64, ptr %6, align 8, !tbaa !9
  %41 = load i64, ptr %7, align 8, !tbaa !9
  %42 = call noundef i64 @_Z4calcxxx(i64 noundef %39, i64 noundef %40, i64 noundef %41)
  %43 = sub nsw i64 %36, %42
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [10 x i64], ptr @ans, i64 0, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !9
  %48 = add nsw i64 %47, %43
  store i64 %48, ptr %46, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %49

49:                                               ; preds = %21
  %50 = load i64, ptr %5, align 8, !tbaa !9
  %51 = mul nsw i64 %50, 10
  store i64 %51, ptr %5, align 8, !tbaa !9
  br label %16, !llvm.loop !11

52:                                               ; preds = %16
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [10 x i64], ptr @ans, i64 0, i64 %54
  %56 = load i64, ptr %55, align 8, !tbaa !9
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %56)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %58

58:                                               ; preds = %52
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %4, align 4, !tbaa !5
  br label %9, !llvm.loop !13

61:                                               ; preds = %12
  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 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 = !{!"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}


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

@ans = external dso_local local_unnamed_addr global [10 x i64], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z4calcxxx(i64 noundef, i64 noundef, i64 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 uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  br label %5

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

5:                                                ; preds = %0, %._crit_edge
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next.pre-phi, %._crit_edge ]
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = sext i32 %6 to i64
  %.not17 = icmp sgt i64 %indvars.iv, %7
  br i1 %.not17, label %.._crit_edge_crit_edge, label %.lr.ph

.._crit_edge_crit_edge:                           ; preds = %5
  %.phi.trans.insert = getelementptr inbounds [10 x i64], ptr @ans, i64 0, i64 %indvars.iv
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !9
  %.pre21 = add nuw nsw i64 %indvars.iv, 1
  br label %._crit_edge

.lr.ph:                                           ; preds = %5
  %8 = add nuw nsw i64 %indvars.iv, 1
  %9 = getelementptr inbounds [10 x i64], ptr @ans, i64 0, i64 %indvars.iv
  br label %10

10:                                               ; preds = %.lr.ph, %10
  %11 = phi i64 [ %7, %.lr.ph ], [ %25, %10 ]
  %.01518 = phi i64 [ %indvars.iv, %.lr.ph ], [ %23, %10 ]
  %12 = udiv i64 %.01518, %indvars.iv
  %13 = mul nuw nsw i64 %12, %8
  %14 = add nsw i64 %13, -1
  %15 = call noundef i64 @_Z4calcxxx(i64 noundef %11, i64 noundef %.01518, i64 noundef %14)
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = add nsw i32 %16, -1
  %18 = sext i32 %17 to i64
  %19 = call noundef i64 @_Z4calcxxx(i64 noundef %18, i64 noundef %.01518, i64 noundef %14)
  %20 = sub i64 %15, %19
  %21 = load i64, ptr %9, align 8, !tbaa !9
  %22 = add nsw i64 %20, %21
  store i64 %22, ptr %9, align 8, !tbaa !9
  %23 = mul nuw nsw i64 %.01518, 10
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %.not = icmp sgt i64 %23, %25
  br i1 %.not, label %._crit_edge, label %10, !llvm.loop !11

._crit_edge:                                      ; preds = %10, %.._crit_edge_crit_edge
  %indvars.iv.next.pre-phi = phi i64 [ %.pre21, %.._crit_edge_crit_edge ], [ %8, %10 ]
  %26 = phi i64 [ %.pre, %.._crit_edge_crit_edge ], [ %22, %10 ]
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %26)
  %exitcond.not = icmp eq i64 %indvars.iv.next.pre-phi, 10
  br i1 %exitcond.not, label %4, label %5, !llvm.loop !13
}

; 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 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 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 = !{!"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}


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