; LLVM IR from DionysiosB/CodeForces :: 1825B-LuoTianyiAndTheTable (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 [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 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
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %15

15:                                               ; preds = %91, %0
  %16 = load i64, ptr %2, align 8, !tbaa !5
  %17 = add nsw i64 %16, -1
  store i64 %17, ptr %2, align 8, !tbaa !5
  %18 = icmp ne i64 %16, 0
  br i1 %18, label %19, label %101

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

21:                                               ; preds = %58, %19
  %22 = load i64, ptr %9, align 8, !tbaa !9
  %23 = load i64, ptr %4, align 8, !tbaa !9
  %24 = load i64, ptr %3, align 8, !tbaa !9
  %25 = mul nsw i64 %23, %24
  %26 = icmp slt i64 %22, %25
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %10)
  %30 = load i64, ptr %10, align 8, !tbaa !9
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = icmp sge i64 %30, %31
  br i1 %32, label %33, label %36

33:                                               ; preds = %28
  %34 = load i64, ptr %5, align 8, !tbaa !9
  store i64 %34, ptr %6, align 8, !tbaa !9
  %35 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %35, ptr %5, align 8, !tbaa !9
  br label %43

36:                                               ; preds = %28
  %37 = load i64, ptr %10, align 8, !tbaa !9
  %38 = load i64, ptr %6, align 8, !tbaa !9
  %39 = icmp sgt i64 %37, %38
  br i1 %39, label %40, label %42

40:                                               ; preds = %36
  %41 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %41, ptr %6, align 8, !tbaa !9
  br label %42

42:                                               ; preds = %40, %36
  br label %43

43:                                               ; preds = %42, %33
  %44 = load i64, ptr %10, align 8, !tbaa !9
  %45 = load i64, ptr %7, align 8, !tbaa !9
  %46 = icmp sle i64 %44, %45
  br i1 %46, label %47, label %50

47:                                               ; preds = %43
  %48 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %48, ptr %8, align 8, !tbaa !9
  %49 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %49, ptr %7, align 8, !tbaa !9
  br label %57

50:                                               ; preds = %43
  %51 = load i64, ptr %10, align 8, !tbaa !9
  %52 = load i64, ptr %8, align 8, !tbaa !9
  %53 = icmp slt i64 %51, %52
  br i1 %53, label %54, label %56

54:                                               ; preds = %50
  %55 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %55, ptr %8, align 8, !tbaa !9
  br label %56

56:                                               ; preds = %54, %50
  br label %57

57:                                               ; preds = %56, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %58

58:                                               ; preds = %57
  %59 = load i64, ptr %9, align 8, !tbaa !9
  %60 = add nsw i64 %59, 1
  store i64 %60, ptr %9, align 8, !tbaa !9
  br label %21, !llvm.loop !11

61:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %62 = load i64, ptr %5, align 8, !tbaa !9
  %63 = load i64, ptr %7, align 8, !tbaa !9
  %64 = sub nsw i64 %62, %63
  store i64 %64, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %65 = load i64, ptr %5, align 8, !tbaa !9
  %66 = load i64, ptr %8, align 8, !tbaa !9
  %67 = sub nsw i64 %65, %66
  store i64 %67, ptr %12, align 8, !tbaa !9
  %68 = load i64, ptr %6, align 8, !tbaa !9
  %69 = load i64, ptr %7, align 8, !tbaa !9
  %70 = sub nsw i64 %68, %69
  %71 = load i64, ptr %12, align 8, !tbaa !9
  %72 = icmp sgt i64 %70, %71
  br i1 %72, label %73, label %77

73:                                               ; preds = %61
  %74 = load i64, ptr %6, align 8, !tbaa !9
  %75 = load i64, ptr %7, align 8, !tbaa !9
  %76 = sub nsw i64 %74, %75
  store i64 %76, ptr %12, align 8, !tbaa !9
  br label %77

77:                                               ; preds = %73, %61
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %78 = load i64, ptr %4, align 8, !tbaa !9
  %79 = load i64, ptr %3, align 8, !tbaa !9
  %80 = mul nsw i64 %78, %79
  %81 = sub nsw i64 %80, 1
  %82 = load i64, ptr %11, align 8, !tbaa !9
  %83 = mul nsw i64 %81, %82
  %84 = load i64, ptr %4, align 8, !tbaa !9
  %85 = load i64, ptr %3, align 8, !tbaa !9
  %86 = icmp slt i64 %84, %85
  br i1 %86, label %87, label %89

87:                                               ; preds = %77
  %88 = load i64, ptr %4, align 8, !tbaa !9
  br label %91

89:                                               ; preds = %77
  %90 = load i64, ptr %3, align 8, !tbaa !9
  br label %91

91:                                               ; preds = %89, %87
  %92 = phi i64 [ %88, %87 ], [ %90, %89 ]
  %93 = sub nsw i64 %92, 1
  %94 = load i64, ptr %11, align 8, !tbaa !9
  %95 = load i64, ptr %12, align 8, !tbaa !9
  %96 = sub nsw i64 %94, %95
  %97 = mul nsw i64 %93, %96
  %98 = sub nsw i64 %83, %97
  store i64 %98, ptr %13, align 8, !tbaa !9
  %99 = load i64, ptr %13, align 8, !tbaa !9
  %100 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %99)
  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 %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
  br label %15, !llvm.loop !13

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

; 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"}
!13 = distinct !{!13, !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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 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
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %6 = load i64, ptr %1, align 8, !tbaa !5
  %7 = add nsw i64 %6, -1
  store i64 %7, ptr %1, align 8, !tbaa !5
  %.not54 = icmp eq i64 %6, 0
  br i1 %.not54, label %._crit_edge57, label %.lr.ph56

.lr.ph56:                                         ; preds = %0, %._crit_edge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %9 = load i64, ptr %3, align 8
  %10 = load i64, ptr %2, align 8
  %11 = mul nsw i64 %10, %9
  %12 = icmp sgt i64 %11, 0
  br i1 %12, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph56
  %.028.lcssa = phi i64 [ 100007, %.lr.ph56 ], [ %.129, %.lr.ph ]
  %.026.lcssa = phi i64 [ 100007, %.lr.ph56 ], [ %.127, %.lr.ph ]
  %.023.lcssa = phi i64 [ -100007, %.lr.ph56 ], [ %.124, %.lr.ph ]
  %.0.lcssa = phi i64 [ -100007, %.lr.ph56 ], [ %.1, %.lr.ph ]
  %.lcssa42 = phi i64 [ %9, %.lr.ph56 ], [ %27, %.lr.ph ]
  %.lcssa41 = phi i64 [ %10, %.lr.ph56 ], [ %28, %.lr.ph ]
  %.lcssa = phi i64 [ %11, %.lr.ph56 ], [ %29, %.lr.ph ]
  %13 = sub nsw i64 %.0.lcssa, %.028.lcssa
  %14 = sub nsw i64 %.0.lcssa, %.026.lcssa
  %15 = sub nsw i64 %.023.lcssa, %.028.lcssa
  %spec.select = call i64 @llvm.smax.i64(i64 %15, i64 %14)
  %16 = add nsw i64 %.lcssa, -1
  %17 = mul nsw i64 %16, %13
  %18 = call i64 @llvm.smin.i64(i64 %.lcssa42, i64 %.lcssa41)
  %19 = add nsw i64 %18, -1
  %.neg = sub i64 %spec.select, %13
  %.neg36 = mul i64 %19, %.neg
  %20 = add i64 %.neg36, %17
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %20)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  %22 = load i64, ptr %1, align 8, !tbaa !5
  %23 = add nsw i64 %22, -1
  store i64 %23, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %22, 0
  br i1 %.not, label %._crit_edge57, label %.lr.ph56, !llvm.loop !9

.lr.ph:                                           ; preds = %.lr.ph56, %.lr.ph
  %.047 = phi i64 [ %.1, %.lr.ph ], [ -100007, %.lr.ph56 ]
  %.02346 = phi i64 [ %.124, %.lr.ph ], [ -100007, %.lr.ph56 ]
  %.02545 = phi i64 [ %26, %.lr.ph ], [ 0, %.lr.ph56 ]
  %.02644 = phi i64 [ %.127, %.lr.ph ], [ 100007, %.lr.ph56 ]
  %.02843 = phi i64 [ %.129, %.lr.ph ], [ 100007, %.lr.ph56 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %4)
  %25 = load i64, ptr %4, align 8, !tbaa !11
  %.not37 = icmp slt i64 %25, %.047
  %spec.select39 = call i64 @llvm.smax.i64(i64 %25, i64 %.02346)
  %.124 = select i1 %.not37, i64 %spec.select39, i64 %.047
  %.1 = call i64 @llvm.smax.i64(i64 %25, i64 %.047)
  %.not38 = icmp sgt i64 %25, %.02843
  %spec.select40 = call i64 @llvm.smin.i64(i64 %25, i64 %.02644)
  %.129 = call i64 @llvm.smin.i64(i64 %25, i64 %.02843)
  %.127 = select i1 %.not38, i64 %spec.select40, i64 %.02843
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  %26 = add nuw nsw i64 %.02545, 1
  %27 = load i64, ptr %3, align 8
  %28 = load i64, ptr %2, align 8
  %29 = mul nsw i64 %28, %27
  %30 = icmp slt i64 %26, %29
  br i1 %30, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge57:                                    ; preds = %._crit_edge, %0
  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

; 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", !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 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}


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