; LLVM IR from DionysiosB/CodeForces :: 1873B-GoodKid (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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 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 i64, align 8
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %11

11:                                               ; preds = %70, %0
  %12 = load i64, ptr %2, align 8, !tbaa !5
  %13 = add nsw i64 %12, -1
  store i64 %13, ptr %2, align 8, !tbaa !5
  %14 = icmp ne i64 %12, 0
  br i1 %14, label %15, label %71

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 10, ptr %5, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %17

17:                                               ; preds = %45, %15
  %18 = load i64, ptr %7, align 8, !tbaa !5
  %19 = load i32, ptr %3, align 4, !tbaa !11
  %20 = sext i32 %19 to i64
  %21 = icmp slt i64 %18, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %17
  store i32 4, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %48

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %9)
  %25 = load i64, ptr %9, align 8, !tbaa !5
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %23
  %28 = load i32, ptr %6, align 4, !tbaa !11
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %6, align 4, !tbaa !11
  store i32 6, ptr %8, align 4
  br label %42

30:                                               ; preds = %23
  %31 = load i64, ptr %9, align 8, !tbaa !5
  %32 = load i64, ptr %4, align 8, !tbaa !9
  %33 = mul nsw i64 %32, %31
  store i64 %33, ptr %4, align 8, !tbaa !9
  %34 = load i64, ptr %9, align 8, !tbaa !5
  %35 = load i32, ptr %5, align 4, !tbaa !11
  %36 = sext i32 %35 to i64
  %37 = icmp slt i64 %34, %36
  br i1 %37, label %38, label %41

38:                                               ; preds = %30
  %39 = load i64, ptr %9, align 8, !tbaa !5
  %40 = trunc i64 %39 to i32
  store i32 %40, ptr %5, align 4, !tbaa !11
  br label %41

41:                                               ; preds = %38, %30
  store i32 0, ptr %8, align 4
  br label %42

42:                                               ; preds = %41, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  %43 = load i32, ptr %8, align 4
  switch i32 %43, label %73 [
    i32 0, label %44
    i32 6, label %45
  ]

44:                                               ; preds = %42
  br label %45

45:                                               ; preds = %44, %42
  %46 = load i64, ptr %7, align 8, !tbaa !5
  %47 = add nsw i64 %46, 1
  store i64 %47, ptr %7, align 8, !tbaa !5
  br label %17, !llvm.loop !13

48:                                               ; preds = %22
  %49 = load i32, ptr %6, align 4, !tbaa !11
  %50 = icmp sgt i32 %49, 1
  br i1 %50, label %51, label %53

51:                                               ; preds = %48
  %52 = call i32 @puts(ptr noundef @.str.2)
  br label %70

53:                                               ; preds = %48
  %54 = load i32, ptr %6, align 4, !tbaa !11
  %55 = icmp eq i32 %54, 1
  br i1 %55, label %56, label %59

56:                                               ; preds = %53
  %57 = load i64, ptr %4, align 8, !tbaa !9
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %57)
  br label %69

59:                                               ; preds = %53
  %60 = load i64, ptr %4, align 8, !tbaa !9
  %61 = load i32, ptr %5, align 4, !tbaa !11
  %62 = add nsw i32 %61, 1
  %63 = sext i32 %62 to i64
  %64 = mul nsw i64 %60, %63
  %65 = load i32, ptr %5, align 4, !tbaa !11
  %66 = sext i32 %65 to i64
  %67 = sdiv i64 %64, %66
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %67)
  br label %69

69:                                               ; preds = %59, %56
  br label %70

70:                                               ; preds = %69, %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %11, !llvm.loop !15

71:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  %72 = load i32, ptr %1, align 4
  ret i32 %72

73:                                               ; preds = %42
  unreachable
}

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare i32 @puts(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 = !{!"long", !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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !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 [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %5 = load i64, ptr %1, align 8, !tbaa !5
  %6 = add nsw i64 %5, -1
  store i64 %6, ptr %1, align 8, !tbaa !5
  %.not24 = icmp eq i64 %5, 0
  br i1 %.not24, label %._crit_edge27, label %.lr.ph26

.lr.ph26:                                         ; preds = %0, %38
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2)
  %8 = load i32, ptr %2, align 4, !tbaa !9
  %9 = icmp sgt i32 %8, 0
  br i1 %9, label %.lr.ph, label %.thread

._crit_edge:                                      ; preds = %21
  %10 = icmp sgt i32 %.1, 1
  br i1 %10, label %26, label %28

.lr.ph:                                           ; preds = %.lr.ph26, %21
  %.021 = phi i64 [ %22, %21 ], [ 0, %.lr.ph26 ]
  %.01220 = phi i32 [ %.1, %21 ], [ 0, %.lr.ph26 ]
  %.01319 = phi i32 [ %.2, %21 ], [ 10, %.lr.ph26 ]
  %.01518 = phi i64 [ %.116, %21 ], [ 1, %.lr.ph26 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %3)
  %12 = load i64, ptr %3, align 8, !tbaa !5
  %13 = icmp eq i64 %12, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %.lr.ph
  %15 = add nsw i32 %.01220, 1
  br label %21

16:                                               ; preds = %.lr.ph
  %17 = mul nsw i64 %12, %.01518
  %18 = sext i32 %.01319 to i64
  %19 = icmp slt i64 %12, %18
  %20 = trunc i64 %12 to i32
  %spec.select = select i1 %19, i32 %20, i32 %.01319
  br label %21

21:                                               ; preds = %16, %14
  %.116 = phi i64 [ %.01518, %14 ], [ %17, %16 ]
  %.2 = phi i32 [ %.01319, %14 ], [ %spec.select, %16 ]
  %.1 = phi i32 [ %15, %14 ], [ %.01220, %16 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  %22 = add nuw nsw i64 %.021, 1
  %23 = load i32, ptr %2, align 4, !tbaa !9
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %22, %24
  br i1 %25, label %.lr.ph, label %._crit_edge, !llvm.loop !11

26:                                               ; preds = %._crit_edge
  %27 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %38

28:                                               ; preds = %._crit_edge
  %29 = icmp eq i32 %.1, 1
  br i1 %29, label %30, label %.thread

30:                                               ; preds = %28
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %.116)
  br label %38

.thread:                                          ; preds = %.lr.ph26, %28
  %.015.lcssa3138 = phi i64 [ %.116, %28 ], [ 1, %.lr.ph26 ]
  %.013.lcssa3237 = phi i32 [ %.2, %28 ], [ 10, %.lr.ph26 ]
  %32 = add nsw i32 %.013.lcssa3237, 1
  %33 = sext i32 %32 to i64
  %34 = mul nsw i64 %.015.lcssa3138, %33
  %35 = sext i32 %.013.lcssa3237 to i64
  %36 = sdiv i64 %34, %35
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %36)
  br label %38

38:                                               ; preds = %30, %.thread, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  %39 = load i64, ptr %1, align 8, !tbaa !5
  %40 = add nsw i64 %39, -1
  store i64 %40, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %39, 0
  br i1 %.not, label %._crit_edge27, label %.lr.ph26, !llvm.loop !13

._crit_edge27:                                    ; preds = %38, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  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: 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 @puts(ptr nocapture noundef readonly) local_unnamed_addr #2

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

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 = { 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", !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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass