; LLVM IR from DionysiosB/CodeForces :: 1100-1199 (1158A-ThePartyAndSweets)

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

16:                                               ; preds = %40, %0
  %17 = load i64, ptr %9, align 8, !tbaa !5
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %19 = icmp slt i64 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %43

21:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %10)
  %23 = load i64, ptr %10, align 8, !tbaa !5
  %24 = load i64, ptr %4, align 8, !tbaa !5
  %25 = add nsw i64 %24, %23
  store i64 %25, ptr %4, align 8, !tbaa !5
  %26 = load i64, ptr %10, align 8, !tbaa !5
  %27 = load i64, ptr %5, align 8, !tbaa !5
  %28 = icmp sge i64 %26, %27
  br i1 %28, label %29, label %32

29:                                               ; preds = %21
  %30 = load i64, ptr %5, align 8, !tbaa !5
  store i64 %30, ptr %6, align 8, !tbaa !5
  %31 = load i64, ptr %10, align 8, !tbaa !5
  store i64 %31, ptr %5, align 8, !tbaa !5
  br label %39

32:                                               ; preds = %21
  %33 = load i64, ptr %10, align 8, !tbaa !5
  %34 = load i64, ptr %6, align 8, !tbaa !5
  %35 = icmp sge i64 %33, %34
  br i1 %35, label %36, label %38

36:                                               ; preds = %32
  %37 = load i64, ptr %10, align 8, !tbaa !5
  store i64 %37, ptr %6, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %36, %32
  br label %39

39:                                               ; preds = %38, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %40

40:                                               ; preds = %39
  %41 = load i64, ptr %9, align 8, !tbaa !5
  %42 = add nsw i64 %41, 1
  store i64 %42, ptr %9, align 8, !tbaa !5
  br label %16, !llvm.loop !9

43:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store i64 0, ptr %11, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %60, %43
  %45 = load i64, ptr %11, align 8, !tbaa !5
  %46 = load i64, ptr %3, align 8, !tbaa !5
  %47 = icmp slt i64 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %63

49:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %50 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %12)
  %51 = load i64, ptr %12, align 8, !tbaa !5
  %52 = load i64, ptr %7, align 8, !tbaa !5
  %53 = add nsw i64 %52, %51
  store i64 %53, ptr %7, align 8, !tbaa !5
  %54 = load i64, ptr %12, align 8, !tbaa !5
  %55 = load i64, ptr %8, align 8, !tbaa !5
  %56 = icmp sle i64 %54, %55
  br i1 %56, label %57, label %59

57:                                               ; preds = %49
  %58 = load i64, ptr %12, align 8, !tbaa !5
  store i64 %58, ptr %8, align 8, !tbaa !5
  br label %59

59:                                               ; preds = %57, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %60

60:                                               ; preds = %59
  %61 = load i64, ptr %11, align 8, !tbaa !5
  %62 = add nsw i64 %61, 1
  store i64 %62, ptr %11, align 8, !tbaa !5
  br label %44, !llvm.loop !11

63:                                               ; preds = %48
  %64 = load i64, ptr %5, align 8, !tbaa !5
  %65 = load i64, ptr %8, align 8, !tbaa !5
  %66 = icmp sgt i64 %64, %65
  br i1 %66, label %67, label %69

67:                                               ; preds = %63
  %68 = call i32 @puts(ptr noundef @.str.2)
  br label %104

69:                                               ; preds = %63
  %70 = load i64, ptr %5, align 8, !tbaa !5
  %71 = load i64, ptr %8, align 8, !tbaa !5
  %72 = icmp eq i64 %70, %71
  br i1 %72, label %73, label %83

73:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %74 = load i64, ptr %3, align 8, !tbaa !5
  %75 = load i64, ptr %4, align 8, !tbaa !5
  %76 = load i64, ptr %5, align 8, !tbaa !5
  %77 = sub nsw i64 %75, %76
  %78 = mul nsw i64 %74, %77
  %79 = load i64, ptr %7, align 8, !tbaa !5
  %80 = add nsw i64 %78, %79
  store i64 %80, ptr %13, align 8, !tbaa !5
  %81 = load i64, ptr %13, align 8, !tbaa !5
  %82 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %81)
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %103

83:                                               ; preds = %69
  %84 = load i64, ptr %5, align 8, !tbaa !5
  %85 = load i64, ptr %8, align 8, !tbaa !5
  %86 = icmp slt i64 %84, %85
  br i1 %86, label %87, label %102

87:                                               ; preds = %83
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %88 = load i64, ptr %4, align 8, !tbaa !5
  %89 = load i64, ptr %3, align 8, !tbaa !5
  %90 = mul nsw i64 %88, %89
  %91 = load i64, ptr %7, align 8, !tbaa !5
  %92 = add nsw i64 %90, %91
  %93 = load i64, ptr %3, align 8, !tbaa !5
  %94 = sub nsw i64 %93, 1
  %95 = load i64, ptr %5, align 8, !tbaa !5
  %96 = mul nsw i64 %94, %95
  %97 = sub nsw i64 %92, %96
  %98 = load i64, ptr %6, align 8, !tbaa !5
  %99 = sub nsw i64 %97, %98
  store i64 %99, ptr %14, align 8, !tbaa !5
  %100 = load i64, ptr %14, align 8, !tbaa !5
  %101 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %100)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %102

102:                                              ; preds = %87, %83
  br label %103

103:                                              ; preds = %102, %73
  br label %104

104:                                              ; preds = %103, %67
  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 @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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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

.preheader:                                       ; preds = %.lr.ph, %0
  %.031.lcssa = phi i64 [ 0, %0 ], [ %.132, %.lr.ph ]
  %.025.lcssa = phi i64 [ 0, %0 ], [ %.1, %.lr.ph ]
  %.0.lcssa = phi i64 [ 0, %0 ], [ %12, %.lr.ph ]
  %8 = load i64, ptr %2, align 8, !tbaa !5
  %9 = icmp sgt i64 %8, 0
  br i1 %9, label %.lr.ph50, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.044 = phi i64 [ %12, %.lr.ph ], [ 0, %0 ]
  %.02543 = phi i64 [ %.1, %.lr.ph ], [ 0, %0 ]
  %.02742 = phi i64 [ %13, %.lr.ph ], [ 0, %0 ]
  %.03141 = phi i64 [ %.132, %.lr.ph ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %11 = load i64, ptr %3, align 8, !tbaa !5
  %12 = add nsw i64 %11, %.044
  %.not37 = icmp slt i64 %11, %.02543
  %spec.select = call i64 @llvm.smax.i64(i64 %11, i64 %.03141)
  %.132 = select i1 %.not37, i64 %spec.select, i64 %.02543
  %.1 = call i64 @llvm.smax.i64(i64 %11, i64 %.02543)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  %13 = add nuw nsw i64 %.02742, 1
  %14 = load i64, ptr %1, align 8, !tbaa !5
  %15 = icmp slt i64 %13, %14
  br i1 %15, label %.lr.ph, label %.preheader, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph50, %.preheader
  %.030.lcssa = phi i64 [ 0, %.preheader ], [ %19, %.lr.ph50 ]
  %.028.lcssa = phi i64 [ 1000000000, %.preheader ], [ %spec.select39, %.lr.ph50 ]
  %.lcssa = phi i64 [ %8, %.preheader ], [ %21, %.lr.ph50 ]
  %16 = icmp sgt i64 %.025.lcssa, %.028.lcssa
  br i1 %16, label %23, label %25

.lr.ph50:                                         ; preds = %.preheader, %.lr.ph50
  %.02649 = phi i64 [ %20, %.lr.ph50 ], [ 0, %.preheader ]
  %.02848 = phi i64 [ %spec.select39, %.lr.ph50 ], [ 1000000000, %.preheader ]
  %.03047 = phi i64 [ %19, %.lr.ph50 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %4)
  %18 = load i64, ptr %4, align 8, !tbaa !5
  %19 = add nsw i64 %18, %.03047
  %spec.select39 = call i64 @llvm.smin.i64(i64 %18, i64 %.02848)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  %20 = add nuw nsw i64 %.02649, 1
  %21 = load i64, ptr %2, align 8, !tbaa !5
  %22 = icmp slt i64 %20, %21
  br i1 %22, label %.lr.ph50, label %._crit_edge, !llvm.loop !11

23:                                               ; preds = %._crit_edge
  %24 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %39

25:                                               ; preds = %._crit_edge
  %26 = icmp eq i64 %.025.lcssa, %.028.lcssa
  br i1 %26, label %27, label %32

27:                                               ; preds = %25
  %28 = sub nsw i64 %.0.lcssa, %.025.lcssa
  %29 = mul nsw i64 %.lcssa, %28
  %30 = add nsw i64 %29, %.030.lcssa
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %30)
  br label %39

32:                                               ; preds = %25
  %33 = icmp slt i64 %.025.lcssa, %.028.lcssa
  br i1 %33, label %34, label %39

34:                                               ; preds = %32
  %35 = mul nsw i64 %.lcssa, %.0.lcssa
  %.neg54 = sub i64 1, %.lcssa
  %.neg55 = mul i64 %.neg54, %.025.lcssa
  %.neg40 = sub i64 %.030.lcssa, %.031.lcssa
  %36 = add i64 %.neg40, %35
  %37 = add i64 %36, %.neg55
  %38 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %37)
  br label %39

39:                                               ; preds = %27, %34, %32, %23
  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 @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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #3

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


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