; LLVM IR from DionysiosB/CodeForces :: 0100-0199 (152B-Steps)

; 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 [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 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 i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  store i64 1000000000, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store i64 0, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 0, ptr %4, align 8, !tbaa !9
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !9
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %5, ptr noundef %6)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 0, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !5
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %8)
  br label %17

17:                                               ; preds = %76, %0
  %18 = load i64, ptr %8, align 8, !tbaa !5
  %19 = add nsw i64 %18, -1
  store i64 %19, ptr %8, align 8, !tbaa !5
  %20 = icmp ne i64 %18, 0
  br i1 %20, label %21, label %90

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 0, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 0, ptr %10, align 8, !tbaa !5
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %9, ptr noundef %10)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store i64 1000000000, ptr %11, align 8, !tbaa !5
  %23 = load i64, ptr %9, align 8, !tbaa !5
  %24 = icmp sgt i64 %23, 0
  br i1 %24, label %25, label %31

25:                                               ; preds = %21
  %26 = load i64, ptr %3, align 8, !tbaa !9
  %27 = load i64, ptr %5, align 8, !tbaa !9
  %28 = sub nsw i64 %26, %27
  %29 = load i64, ptr %9, align 8, !tbaa !5
  %30 = sdiv i64 %28, %29
  store i64 %30, ptr %11, align 8, !tbaa !5
  br label %41

31:                                               ; preds = %21
  %32 = load i64, ptr %9, align 8, !tbaa !5
  %33 = icmp slt i64 %32, 0
  br i1 %33, label %34, label %40

34:                                               ; preds = %31
  %35 = load i64, ptr %5, align 8, !tbaa !9
  %36 = sub nsw i64 %35, 1
  %37 = load i64, ptr %9, align 8, !tbaa !5
  %38 = sub nsw i64 0, %37
  %39 = sdiv i64 %36, %38
  store i64 %39, ptr %11, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %34, %31
  br label %41

41:                                               ; preds = %40, %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store i64 1000000000, ptr %12, align 8, !tbaa !5
  %42 = load i64, ptr %10, align 8, !tbaa !5
  %43 = icmp sgt i64 %42, 0
  br i1 %43, label %44, label %50

44:                                               ; preds = %41
  %45 = load i64, ptr %4, align 8, !tbaa !9
  %46 = load i64, ptr %6, align 8, !tbaa !9
  %47 = sub nsw i64 %45, %46
  %48 = load i64, ptr %10, align 8, !tbaa !5
  %49 = sdiv i64 %47, %48
  store i64 %49, ptr %12, align 8, !tbaa !5
  br label %60

50:                                               ; preds = %41
  %51 = load i64, ptr %10, align 8, !tbaa !5
  %52 = icmp slt i64 %51, 0
  br i1 %52, label %53, label %59

53:                                               ; preds = %50
  %54 = load i64, ptr %6, align 8, !tbaa !9
  %55 = sub nsw i64 %54, 1
  %56 = load i64, ptr %10, align 8, !tbaa !5
  %57 = sub nsw i64 0, %56
  %58 = sdiv i64 %55, %57
  store i64 %58, ptr %12, align 8, !tbaa !5
  br label %59

59:                                               ; preds = %53, %50
  br label %60

60:                                               ; preds = %59, %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  store i64 0, ptr %13, align 8, !tbaa !5
  %61 = load i64, ptr %11, align 8, !tbaa !5
  %62 = icmp sgt i64 %61, 0
  br i1 %62, label %63, label %76

63:                                               ; preds = %60
  %64 = load i64, ptr %12, align 8, !tbaa !5
  %65 = icmp sgt i64 %64, 0
  br i1 %65, label %66, label %76

66:                                               ; preds = %63
  %67 = load i64, ptr %11, align 8, !tbaa !5
  %68 = load i64, ptr %12, align 8, !tbaa !5
  %69 = icmp slt i64 %67, %68
  br i1 %69, label %70, label %72

70:                                               ; preds = %66
  %71 = load i64, ptr %11, align 8, !tbaa !5
  br label %74

72:                                               ; preds = %66
  %73 = load i64, ptr %12, align 8, !tbaa !5
  br label %74

74:                                               ; preds = %72, %70
  %75 = phi i64 [ %71, %70 ], [ %73, %72 ]
  store i64 %75, ptr %13, align 8, !tbaa !5
  br label %76

76:                                               ; preds = %74, %63, %60
  %77 = load i64, ptr %13, align 8, !tbaa !5
  %78 = load i64, ptr %9, align 8, !tbaa !5
  %79 = mul nsw i64 %77, %78
  %80 = load i64, ptr %5, align 8, !tbaa !9
  %81 = add nsw i64 %80, %79
  store i64 %81, ptr %5, align 8, !tbaa !9
  %82 = load i64, ptr %13, align 8, !tbaa !5
  %83 = load i64, ptr %10, align 8, !tbaa !5
  %84 = mul nsw i64 %82, %83
  %85 = load i64, ptr %6, align 8, !tbaa !9
  %86 = add nsw i64 %85, %84
  store i64 %86, ptr %6, align 8, !tbaa !9
  %87 = load i64, ptr %13, align 8, !tbaa !5
  %88 = load i64, ptr %7, align 8, !tbaa !9
  %89 = add nsw i64 %88, %87
  store i64 %89, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %17, !llvm.loop !11

90:                                               ; preds = %17
  %91 = load i64, ptr %7, align 8, !tbaa !9
  %92 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %91)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  ret i32 0
}

; 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 @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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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 [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 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 i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  store i64 0, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  store i64 0, ptr %2, align 8, !tbaa !5
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  store i64 0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  store i64 0, ptr %4, align 8, !tbaa !5
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %3, ptr noundef nonnull %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store i64 0, ptr %5, align 8, !tbaa !9
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %5)
  %11 = load i64, ptr %5, align 8, !tbaa !9
  %12 = add nsw i64 %11, -1
  store i64 %12, ptr %5, align 8, !tbaa !9
  %.not18 = icmp eq i64 %11, 0
  br i1 %.not18, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0, %42
  %.01419 = phi i64 [ %51, %42 ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  store i64 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  store i64 0, ptr %7, align 8, !tbaa !9
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %6, ptr noundef nonnull %7)
  %14 = load i64, ptr %6, align 8, !tbaa !9
  %15 = icmp sgt i64 %14, 0
  br i1 %15, label %16, label %21

16:                                               ; preds = %.lr.ph
  %17 = load i64, ptr %1, align 8, !tbaa !5
  %18 = load i64, ptr %3, align 8, !tbaa !5
  %19 = sub nsw i64 %17, %18
  %20 = sdiv i64 %19, %14
  br label %28

21:                                               ; preds = %.lr.ph
  %22 = icmp slt i64 %14, 0
  br i1 %22, label %23, label %28

23:                                               ; preds = %21
  %24 = load i64, ptr %3, align 8, !tbaa !5
  %25 = add nsw i64 %24, -1
  %26 = sub nsw i64 0, %14
  %27 = sdiv i64 %25, %26
  br label %28

28:                                               ; preds = %21, %23, %16
  %.013 = phi i64 [ %20, %16 ], [ %27, %23 ], [ 1000000000, %21 ]
  %29 = load i64, ptr %7, align 8, !tbaa !9
  %30 = icmp sgt i64 %29, 0
  %31 = load i64, ptr %4, align 8, !tbaa !5
  br i1 %30, label %32, label %36

32:                                               ; preds = %28
  %33 = load i64, ptr %2, align 8, !tbaa !5
  %34 = sub nsw i64 %33, %31
  %35 = sdiv i64 %34, %29
  br label %42

36:                                               ; preds = %28
  %37 = icmp slt i64 %29, 0
  br i1 %37, label %38, label %42

38:                                               ; preds = %36
  %39 = add nsw i64 %31, -1
  %40 = sub nsw i64 0, %29
  %41 = sdiv i64 %39, %40
  br label %42

42:                                               ; preds = %36, %38, %32
  %.012 = phi i64 [ %35, %32 ], [ %41, %38 ], [ 1000000000, %36 ]
  %43 = icmp sgt i64 %.013, 0
  %44 = icmp sgt i64 %.012, 0
  %or.cond = select i1 %43, i1 %44, i1 false
  %45 = call i64 @llvm.smin.i64(i64 %.013, i64 %.012)
  %.0 = select i1 %or.cond, i64 %45, i64 0
  %46 = mul nsw i64 %.0, %14
  %47 = load i64, ptr %3, align 8, !tbaa !5
  %48 = add nsw i64 %46, %47
  store i64 %48, ptr %3, align 8, !tbaa !5
  %49 = mul nsw i64 %.0, %29
  %50 = add nsw i64 %49, %31
  store i64 %50, ptr %4, align 8, !tbaa !5
  %51 = add nuw nsw i64 %.0, %.01419
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  %52 = load i64, ptr %5, align 8, !tbaa !9
  %53 = add nsw i64 %52, -1
  store i64 %53, ptr %5, align 8, !tbaa !9
  %.not = icmp eq i64 %52, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %42, %0
  %.014.lcssa = phi i64 [ 0, %0 ], [ %51, %42 ]
  %54 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %.014.lcssa)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  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 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #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 speculatable willreturn memory(none) }
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 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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