; LLVM IR from DionysiosB/CodeForces :: 0001-0099 (58B-Coins)

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  store i64 0, ptr %2, align 8, !tbaa !5
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %11 = load i64, ptr %2, align 8, !tbaa !5
  %12 = add nsw i64 %11, 1
  %13 = call noalias noundef nonnull ptr @_Znam(i64 noundef %12) #6
  store ptr %13, ptr %3, align 8, !tbaa !9
  %14 = load ptr, ptr %3, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %14, i64 1
  store i8 0, ptr %15, align 1, !tbaa !11
  %16 = load ptr, ptr %3, align 8, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %16, i64 0
  store i8 0, ptr %17, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store i64 2, ptr %4, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %27, %0
  %19 = load i64, ptr %4, align 8, !tbaa !5
  %20 = load i64, ptr %2, align 8, !tbaa !5
  %21 = icmp sle i64 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %30

23:                                               ; preds = %18
  %24 = load ptr, ptr %3, align 8, !tbaa !9
  %25 = load i64, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %24, i64 %25
  store i8 1, ptr %26, align 1, !tbaa !11
  br label %27

27:                                               ; preds = %23
  %28 = load i64, ptr %4, align 8, !tbaa !5
  %29 = add nsw i64 %28, 1
  store i64 %29, ptr %4, align 8, !tbaa !5
  br label %18, !llvm.loop !13

30:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 2, ptr %5, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %68, %30
  %32 = load i64, ptr %5, align 8, !tbaa !5
  %33 = sitofp i64 %32 to double
  %34 = load i64, ptr %2, align 8, !tbaa !5
  %35 = sitofp i64 %34 to double
  %36 = call double @sqrt(double noundef %35) #5
  %37 = fcmp ole double %33, %36
  br i1 %37, label %39, label %38

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

39:                                               ; preds = %31
  %40 = load ptr, ptr %3, align 8, !tbaa !9
  %41 = load i64, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %40, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !11, !range !15, !noundef !16
  %44 = trunc i8 %43 to i1
  br i1 %44, label %46, label %45

45:                                               ; preds = %39
  br label %68

46:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %47 = load i64, ptr %5, align 8, !tbaa !5
  %48 = mul nsw i64 2, %47
  %49 = trunc i64 %48 to i32
  store i32 %49, ptr %7, align 4, !tbaa !17
  br label %50

50:                                               ; preds = %61, %46
  %51 = load i32, ptr %7, align 4, !tbaa !17
  %52 = sext i32 %51 to i64
  %53 = load i64, ptr %2, align 8, !tbaa !5
  %54 = icmp sle i64 %52, %53
  br i1 %54, label %56, label %55

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

56:                                               ; preds = %50
  %57 = load ptr, ptr %3, align 8, !tbaa !9
  %58 = load i32, ptr %7, align 4, !tbaa !17
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i8, ptr %57, i64 %59
  store i8 0, ptr %60, align 1, !tbaa !11
  br label %61

61:                                               ; preds = %56
  %62 = load i64, ptr %5, align 8, !tbaa !5
  %63 = load i32, ptr %7, align 4, !tbaa !17
  %64 = sext i32 %63 to i64
  %65 = add nsw i64 %64, %62
  %66 = trunc i64 %65 to i32
  store i32 %66, ptr %7, align 4, !tbaa !17
  br label %50, !llvm.loop !19

67:                                               ; preds = %55
  br label %68

68:                                               ; preds = %67, %45
  %69 = load i64, ptr %5, align 8, !tbaa !5
  %70 = add nsw i64 %69, 1
  store i64 %70, ptr %5, align 8, !tbaa !5
  br label %31, !llvm.loop !20

71:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 2, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %72 = load i64, ptr %2, align 8, !tbaa !5
  store i64 %72, ptr %9, align 8, !tbaa !5
  %73 = load i64, ptr %9, align 8, !tbaa !5
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %73)
  br label %75

75:                                               ; preds = %107, %90, %71
  %76 = load i64, ptr %9, align 8, !tbaa !5
  %77 = icmp sgt i64 %76, 1
  br i1 %77, label %78, label %82

78:                                               ; preds = %75
  %79 = load i64, ptr %8, align 8, !tbaa !5
  %80 = load i64, ptr %2, align 8, !tbaa !5
  %81 = icmp sle i64 %79, %80
  br label %82

82:                                               ; preds = %78, %75
  %83 = phi i1 [ false, %75 ], [ %81, %78 ]
  br i1 %83, label %84, label %108

84:                                               ; preds = %82
  %85 = load ptr, ptr %3, align 8, !tbaa !9
  %86 = load i64, ptr %8, align 8, !tbaa !5
  %87 = getelementptr inbounds i8, ptr %85, i64 %86
  %88 = load i8, ptr %87, align 1, !tbaa !11, !range !15, !noundef !16
  %89 = trunc i8 %88 to i1
  br i1 %89, label %93, label %90

90:                                               ; preds = %84
  %91 = load i64, ptr %8, align 8, !tbaa !5
  %92 = add nsw i64 %91, 1
  store i64 %92, ptr %8, align 8, !tbaa !5
  br label %75, !llvm.loop !21

93:                                               ; preds = %84
  %94 = load i64, ptr %9, align 8, !tbaa !5
  %95 = load i64, ptr %8, align 8, !tbaa !5
  %96 = srem i64 %94, %95
  %97 = icmp eq i64 %96, 0
  br i1 %97, label %98, label %104

98:                                               ; preds = %93
  %99 = load i64, ptr %8, align 8, !tbaa !5
  %100 = load i64, ptr %9, align 8, !tbaa !5
  %101 = sdiv i64 %100, %99
  store i64 %101, ptr %9, align 8, !tbaa !5
  %102 = load i64, ptr %9, align 8, !tbaa !5
  %103 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %102)
  br label %107

104:                                              ; preds = %93
  %105 = load i64, ptr %8, align 8, !tbaa !5
  %106 = add nsw i64 %105, 1
  store i64 %106, ptr %8, align 8, !tbaa !5
  br label %107

107:                                              ; preds = %104, %98
  br label %75, !llvm.loop !21

108:                                              ; preds = %82
  %109 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  %110 = load i32, ptr %1, align 4
  ret i32 %110
}

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

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #3

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

; Function Attrs: nounwind
declare double @sqrt(double noundef) #4

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 = { nobuiltin allocsize(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 "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 #5 = { nounwind }
attributes #6 = { builtin allocsize(0) }

!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", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}


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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  store i64 0, ptr %1, align 8, !tbaa !5
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = load i64, ptr %1, align 8, !tbaa !5
  %4 = add nsw i64 %3, 1
  %5 = call noalias noundef nonnull ptr @_Znam(i64 noundef %4) #7
  %6 = getelementptr inbounds i8, ptr %5, i64 1
  store i8 0, ptr %6, align 1, !tbaa !9
  store i8 0, ptr %5, align 1, !tbaa !9
  %.not36 = icmp slt i64 %3, 2
  br i1 %.not36, label %.preheader, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %0
  %scevgep = getelementptr i8, ptr %5, i64 2
  %7 = add nsw i64 %3, -1
  call void @llvm.memset.p0.i64(ptr align 1 %scevgep, i8 1, i64 %7, i1 false), !tbaa !9
  br label %.preheader

.preheader:                                       ; preds = %.lr.ph.preheader, %0
  %8 = sitofp i64 %3 to double
  %9 = call double @sqrt(double noundef %8) #6
  %10 = fcmp ult double %9, 2.000000e+00
  br i1 %10, label %._crit_edge, label %.lr.ph42

._crit_edge:                                      ; preds = %.loopexit, %.preheader
  %11 = load i64, ptr %1, align 8, !tbaa !5
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %11)
  %13 = icmp sgt i64 %11, 1
  %14 = load i64, ptr %1, align 8
  %15 = icmp sgt i64 %14, 1
  %16 = select i1 %13, i1 %15, i1 false
  br i1 %16, label %.lr.ph44.split.preheader, label %.outer._crit_edge

.lr.ph44.split.preheader:                         ; preds = %._crit_edge, %.outer
  %17 = phi i64 [ %45, %.outer ], [ %14, %._crit_edge ]
  %.0.ph47 = phi i64 [ %.1, %.outer ], [ %11, %._crit_edge ]
  %.028.ph46 = phi i64 [ %.129, %.outer ], [ 2, %._crit_edge ]
  br label %.lr.ph44.split

.lr.ph42:                                         ; preds = %.preheader, %.loopexit
  %.03141 = phi i64 [ %28, %.loopexit ], [ 2, %.preheader ]
  %18 = getelementptr inbounds i8, ptr %5, i64 %.03141
  %19 = load i8, ptr %18, align 1, !tbaa !9, !range !11, !noundef !12
  %20 = trunc nuw i8 %19 to i1
  %.pre = load i64, ptr %1, align 8, !tbaa !5
  br i1 %20, label %21, label %.loopexit

21:                                               ; preds = %.lr.ph42
  %.031.tr = trunc i64 %.03141 to i32
  %22 = shl i32 %.031.tr, 1
  %23 = sext i32 %22 to i64
  %.not3438 = icmp slt i64 %.pre, %23
  br i1 %.not3438, label %.loopexit, label %.lr.ph40

.lr.ph40:                                         ; preds = %21, %.lr.ph40
  %24 = phi i64 [ %27, %.lr.ph40 ], [ %23, %21 ]
  %.03039 = phi i32 [ %26, %.lr.ph40 ], [ %22, %21 ]
  %25 = getelementptr inbounds i8, ptr %5, i64 %24
  store i8 0, ptr %25, align 1, !tbaa !9
  %26 = add i32 %.03039, %.031.tr
  %27 = sext i32 %26 to i64
  %.not34 = icmp slt i64 %.pre, %27
  br i1 %.not34, label %.loopexit, label %.lr.ph40, !llvm.loop !13

.loopexit:                                        ; preds = %.lr.ph40, %21, %.lr.ph42
  %28 = add nuw nsw i64 %.03141, 1
  %29 = uitofp nneg i64 %28 to double
  %30 = sitofp i64 %.pre to double
  %31 = call double @sqrt(double noundef %30) #6
  %32 = fcmp ult double %31, %29
  br i1 %32, label %._crit_edge, label %.lr.ph42, !llvm.loop !15

.lr.ph44.split:                                   ; preds = %.lr.ph44.split.preheader, %36
  %.02843 = phi i64 [ %37, %36 ], [ %.028.ph46, %.lr.ph44.split.preheader ]
  %33 = getelementptr inbounds i8, ptr %5, i64 %.02843
  %34 = load i8, ptr %33, align 1, !tbaa !9, !range !11, !noundef !12
  %35 = trunc nuw i8 %34 to i1
  br i1 %35, label %.split.us, label %36

36:                                               ; preds = %.lr.ph44.split
  %37 = add nsw i64 %.02843, 1
  %.not.not48 = icmp slt i64 %.02843, %17
  br i1 %.not.not48, label %.lr.ph44.split, label %.outer._crit_edge, !llvm.loop !16

.split.us:                                        ; preds = %.lr.ph44.split
  %38 = srem i64 %.0.ph47, %.02843
  %39 = sdiv i64 %.0.ph47, %.02843
  %40 = icmp eq i64 %38, 0
  br i1 %40, label %41, label %43

41:                                               ; preds = %.split.us
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %39)
  %.pre51 = load i64, ptr %1, align 8
  br label %.outer

43:                                               ; preds = %.split.us
  %44 = add nsw i64 %.02843, 1
  br label %.outer

.outer:                                           ; preds = %43, %41
  %45 = phi i64 [ %.pre51, %41 ], [ %17, %43 ]
  %.129 = phi i64 [ %.02843, %41 ], [ %44, %43 ]
  %.1 = phi i64 [ %39, %41 ], [ %.0.ph47, %43 ]
  %46 = icmp sgt i64 %.1, 1
  %47 = icmp sle i64 %.129, %45
  %48 = select i1 %46, i1 %47, i1 false
  br i1 %48, label %.lr.ph44.split.preheader, label %.outer._crit_edge, !llvm.loop !16

.outer._crit_edge:                                ; preds = %.outer, %36, %._crit_edge
  %49 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  ret i32 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: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #3

; 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 nofree nounwind willreturn memory(write)
declare double @sqrt(double noundef) local_unnamed_addr #4

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

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

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 = { 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 = { nobuiltin allocsize(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 = { mustprogress nofree nounwind willreturn memory(write) "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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }

!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", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; Effective O3 passes: DivRemPairsPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass