; LLVM IR from Izaron/ACM-ICPC :: Timus Online Judge/Volume 2/1118. Nontrivial Numbers (main)

; 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 [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

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

12:                                               ; preds = %20, %0
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 1000005
  br i1 %14, label %16, label %15

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

16:                                               ; preds = %12
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [1000005 x x86_fp80], ptr %2, i64 0, i64 %18
  store x86_fp80 0xK00000000000000000000, ptr %19, align 16, !tbaa !9
  br label %20

20:                                               ; preds = %16
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %3, align 4, !tbaa !5
  br label %12, !llvm.loop !11

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

24:                                               ; preds = %48, %23
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = icmp sle i32 %25, 1000000
  br i1 %26, label %28, label %27

27:                                               ; preds = %24
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %51

28:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = mul nsw i32 %29, 2
  store i32 %30, ptr %6, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %43, %28
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = icmp sle i32 %32, 1000000
  br i1 %33, label %35, label %34

34:                                               ; preds = %31
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %47

35:                                               ; preds = %31
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sitofp i32 %36 to x86_fp80
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1000005 x x86_fp80], ptr %2, i64 0, i64 %39
  %41 = load x86_fp80, ptr %40, align 16, !tbaa !9
  %42 = fadd x86_fp80 %41, %37
  store x86_fp80 %42, ptr %40, align 16, !tbaa !9
  br label %43

43:                                               ; preds = %35
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = load i32, ptr %6, align 4, !tbaa !5
  %46 = add nsw i32 %45, %44
  store i32 %46, ptr %6, align 4, !tbaa !5
  br label %31, !llvm.loop !13

47:                                               ; preds = %34
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %4, align 4, !tbaa !5
  br label %24, !llvm.loop !14

51:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %52 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %7, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #3
  store x86_fp80 0xK401CEE6B280000000000, ptr %9, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #3
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = sitofp i32 %53 to x86_fp80
  store x86_fp80 %54, ptr %11, align 16, !tbaa !9
  br label %55

55:                                               ; preds = %82, %51
  %56 = load x86_fp80, ptr %11, align 16, !tbaa !9
  %57 = load i32, ptr %8, align 4, !tbaa !5
  %58 = sitofp i32 %57 to x86_fp80
  %59 = fcmp ole x86_fp80 %56, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %55
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #3
  br label %85

61:                                               ; preds = %55
  %62 = load x86_fp80, ptr %11, align 16, !tbaa !9
  %63 = fptosi x86_fp80 %62 to i32
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [1000005 x x86_fp80], ptr %2, i64 0, i64 %64
  %66 = load x86_fp80, ptr %65, align 16, !tbaa !9
  %67 = load x86_fp80, ptr %11, align 16, !tbaa !9
  %68 = fdiv x86_fp80 %66, %67
  %69 = load x86_fp80, ptr %9, align 16, !tbaa !9
  %70 = fcmp olt x86_fp80 %68, %69
  br i1 %70, label %71, label %81

71:                                               ; preds = %61
  %72 = load x86_fp80, ptr %11, align 16, !tbaa !9
  %73 = fptosi x86_fp80 %72 to i32
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1000005 x x86_fp80], ptr %2, i64 0, i64 %74
  %76 = load x86_fp80, ptr %75, align 16, !tbaa !9
  %77 = load x86_fp80, ptr %11, align 16, !tbaa !9
  %78 = fdiv x86_fp80 %76, %77
  store x86_fp80 %78, ptr %9, align 16, !tbaa !9
  %79 = load x86_fp80, ptr %11, align 16, !tbaa !9
  %80 = fptosi x86_fp80 %79 to i32
  store i32 %80, ptr %10, align 4, !tbaa !5
  br label %81

81:                                               ; preds = %71, %61
  br label %82

82:                                               ; preds = %81
  %83 = load x86_fp80, ptr %11, align 16, !tbaa !9
  %84 = fadd x86_fp80 %83, 0xK3FFF8000000000000000
  store x86_fp80 %84, ptr %11, align 16, !tbaa !9
  br label %55, !llvm.loop !15

85:                                               ; preds = %60
  %86 = load i32, ptr %10, align 4, !tbaa !5
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %86)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 16000080, ptr %2) #3
  %88 = load i32, ptr %1, align 4
  ret i32 %88
}

; 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

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !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 [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [1000005 x x86_fp80], align 16
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 16000080, ptr nonnull %1) #4
  br label %4

4:                                                ; preds = %4, %0
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next.4, %4 ]
  %5 = getelementptr inbounds [1000005 x x86_fp80], ptr %1, i64 0, i64 %indvars.iv
  store x86_fp80 0xK00000000000000000000, ptr %5, align 16, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %6 = getelementptr inbounds [1000005 x x86_fp80], ptr %1, i64 0, i64 %indvars.iv.next
  store x86_fp80 0xK00000000000000000000, ptr %6, align 16, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %7 = getelementptr inbounds [1000005 x x86_fp80], ptr %1, i64 0, i64 %indvars.iv.next.1
  store x86_fp80 0xK00000000000000000000, ptr %7, align 16, !tbaa !5
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %8 = getelementptr inbounds [1000005 x x86_fp80], ptr %1, i64 0, i64 %indvars.iv.next.2
  store x86_fp80 0xK00000000000000000000, ptr %8, align 16, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %9 = getelementptr inbounds [1000005 x x86_fp80], ptr %1, i64 0, i64 %indvars.iv.next.3
  store x86_fp80 0xK00000000000000000000, ptr %9, align 16, !tbaa !5
  %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv, 5
  %exitcond.not.4 = icmp eq i64 %indvars.iv.next.4, 1000005
  br i1 %exitcond.not.4, label %.preheader, label %4, !llvm.loop !9

10:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %12 = load i32, ptr %2, align 4, !tbaa !11
  %13 = sitofp i32 %12 to x86_fp80
  %14 = load i32, ptr %3, align 4, !tbaa !11
  %15 = sitofp i32 %14 to x86_fp80
  %16 = fcmp ole x86_fp80 %13, %15
  call void @llvm.assume(i1 %16)
  br label %.lr.ph34

.preheader:                                       ; preds = %4, %._crit_edge
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %._crit_edge ], [ 1, %4 ]
  %indvars.iv37 = phi i64 [ %indvars.iv.next38, %._crit_edge ], [ 2, %4 ]
  %indvars44 = trunc i64 %indvars.iv39 to i32
  %17 = icmp ult i32 %indvars44, 500001
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %18 = uitofp nneg i32 %indvars44 to x86_fp80
  br label %19

._crit_edge:                                      ; preds = %19, %.preheader
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 2
  %exitcond45.not = icmp eq i64 %indvars.iv.next40, 1000001
  br i1 %exitcond45.not, label %10, label %.preheader, !llvm.loop !13

19:                                               ; preds = %.lr.ph, %19
  %indvars.iv41 = phi i64 [ %indvars.iv37, %.lr.ph ], [ %indvars.iv.next42, %19 ]
  %20 = getelementptr inbounds [1000005 x x86_fp80], ptr %1, i64 0, i64 %indvars.iv41
  %21 = load x86_fp80, ptr %20, align 16, !tbaa !5
  %22 = fadd x86_fp80 %21, %18
  store x86_fp80 %22, ptr %20, align 16, !tbaa !5
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, %indvars.iv39
  %23 = icmp ult i64 %indvars.iv.next42, 1000001
  br i1 %23, label %19, label %._crit_edge, !llvm.loop !14

._crit_edge35:                                    ; preds = %.lr.ph34
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %.1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 16000080, ptr nonnull %1) #4
  ret i32 0

.lr.ph34:                                         ; preds = %10, %.lr.ph34
  %.032 = phi x86_fp80 [ %31, %.lr.ph34 ], [ %13, %10 ]
  %.02131 = phi i32 [ %.1, %.lr.ph34 ], [ undef, %10 ]
  %.02230 = phi x86_fp80 [ %.123, %.lr.ph34 ], [ 0xK401CEE6B280000000000, %10 ]
  %25 = fptosi x86_fp80 %.032 to i32
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [1000005 x x86_fp80], ptr %1, i64 0, i64 %26
  %28 = load x86_fp80, ptr %27, align 16, !tbaa !5
  %29 = fdiv x86_fp80 %28, %.032
  %30 = fcmp olt x86_fp80 %29, %.02230
  %.123 = select i1 %30, x86_fp80 %29, x86_fp80 %.02230
  %.1 = select i1 %30, i32 %25, i32 %.02131
  %31 = fadd x86_fp80 %.032, 0xK3FFF8000000000000000
  %32 = fcmp ugt x86_fp80 %31, %15
  br i1 %32, label %._crit_edge35, label %.lr.ph34, !llvm.loop !15
}

; 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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef) #3

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


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