; LLVM IR from DionysiosB/CodeForces :: 0300-0399 (398A-Cards)

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

19:                                               ; preds = %0
  %20 = load i64, ptr %3, align 8, !tbaa !5
  %21 = sub nsw i64 0, %20
  %22 = load i64, ptr %3, align 8, !tbaa !5
  %23 = mul nsw i64 %21, %22
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %23)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %33, %19
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = load i64, ptr %3, align 8, !tbaa !5
  %29 = icmp slt i64 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %36

31:                                               ; preds = %25
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %33

33:                                               ; preds = %31
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %4, align 4, !tbaa !9
  br label %25, !llvm.loop !11

36:                                               ; preds = %30
  %37 = call i32 @puts(ptr noundef @.str.3)
  br label %146

38:                                               ; preds = %0
  %39 = load i64, ptr %3, align 8, !tbaa !5
  %40 = icmp eq i64 %39, 0
  br i1 %40, label %41, label %59

41:                                               ; preds = %38
  %42 = load i64, ptr %2, align 8, !tbaa !5
  %43 = load i64, ptr %2, align 8, !tbaa !5
  %44 = mul nsw i64 %42, %43
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %44)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %54, %41
  %47 = load i32, ptr %5, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = load i64, ptr %2, align 8, !tbaa !5
  %50 = icmp slt i64 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %57

52:                                               ; preds = %46
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %54

54:                                               ; preds = %52
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %5, align 4, !tbaa !9
  br label %46, !llvm.loop !13

57:                                               ; preds = %51
  %58 = call i32 @puts(ptr noundef @.str.3)
  br label %145

59:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %60 = load i64, ptr %2, align 8, !tbaa !5
  %61 = load i64, ptr %3, align 8, !tbaa !5
  %62 = add nsw i64 %60, %61
  %63 = sub nsw i64 0, %62
  %64 = load i64, ptr %2, align 8, !tbaa !5
  %65 = load i64, ptr %3, align 8, !tbaa !5
  %66 = add nsw i64 %64, %65
  %67 = mul nsw i64 %63, %66
  store i64 %67, 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 !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 1, ptr %9, align 8, !tbaa !14
  br label %68

68:                                               ; preds = %141, %59
  %69 = load i64, ptr %9, align 8, !tbaa !14
  %70 = load i64, ptr %2, align 8, !tbaa !5
  %71 = icmp sle i64 %69, %70
  br i1 %71, label %73, label %72

72:                                               ; preds = %68
  store i32 8, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %144

73:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %74 = load i64, ptr %9, align 8, !tbaa !14
  %75 = sub nsw i64 %74, 1
  store i64 %75, ptr %11, align 8, !tbaa !14
  br label %76

76:                                               ; preds = %137, %73
  %77 = load i64, ptr %11, align 8, !tbaa !14
  %78 = load i64, ptr %9, align 8, !tbaa !14
  %79 = add nsw i64 %78, 1
  %80 = icmp sle i64 %77, %79
  br i1 %80, label %82, label %81

81:                                               ; preds = %76
  store i32 11, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %140

82:                                               ; preds = %76
  %83 = load i64, ptr %11, align 8, !tbaa !14
  %84 = icmp slt i64 %83, 1
  br i1 %84, label %89, label %85

85:                                               ; preds = %82
  %86 = load i64, ptr %11, align 8, !tbaa !14
  %87 = load i64, ptr %3, align 8, !tbaa !5
  %88 = icmp sgt i64 %86, %87
  br i1 %88, label %89, label %90

89:                                               ; preds = %85, %82
  br label %137

90:                                               ; preds = %85
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %91 = load i64, ptr %3, align 8, !tbaa !5
  %92 = load i64, ptr %11, align 8, !tbaa !14
  %93 = sdiv i64 %91, %92
  store i64 %93, ptr %12, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %94 = load i64, ptr %3, align 8, !tbaa !5
  %95 = load i64, ptr %11, align 8, !tbaa !14
  %96 = srem i64 %94, %95
  store i64 %96, ptr %13, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %97 = load i64, ptr %11, align 8, !tbaa !14
  %98 = load i64, ptr %13, align 8, !tbaa !14
  %99 = sub nsw i64 %97, %98
  store i64 %99, ptr %14, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  store i64 0, ptr %15, align 8, !tbaa !5
  %100 = load i64, ptr %2, align 8, !tbaa !5
  %101 = load i64, ptr %9, align 8, !tbaa !14
  %102 = sub nsw i64 %100, %101
  %103 = add nsw i64 %102, 1
  %104 = load i64, ptr %2, align 8, !tbaa !5
  %105 = load i64, ptr %9, align 8, !tbaa !14
  %106 = sub nsw i64 %104, %105
  %107 = add nsw i64 %106, 1
  %108 = mul nsw i64 %103, %107
  %109 = load i64, ptr %9, align 8, !tbaa !14
  %110 = sub nsw i64 %109, 1
  %111 = add nsw i64 %108, %110
  %112 = load i64, ptr %15, align 8, !tbaa !5
  %113 = add nsw i64 %112, %111
  store i64 %113, ptr %15, align 8, !tbaa !5
  %114 = load i64, ptr %14, align 8, !tbaa !14
  %115 = load i64, ptr %12, align 8, !tbaa !14
  %116 = mul nsw i64 %114, %115
  %117 = load i64, ptr %12, align 8, !tbaa !14
  %118 = mul nsw i64 %116, %117
  %119 = load i64, ptr %13, align 8, !tbaa !14
  %120 = load i64, ptr %12, align 8, !tbaa !14
  %121 = add nsw i64 1, %120
  %122 = mul nsw i64 %119, %121
  %123 = load i64, ptr %12, align 8, !tbaa !14
  %124 = add nsw i64 1, %123
  %125 = mul nsw i64 %122, %124
  %126 = add nsw i64 %118, %125
  %127 = load i64, ptr %15, align 8, !tbaa !5
  %128 = sub nsw i64 %127, %126
  store i64 %128, ptr %15, align 8, !tbaa !5
  %129 = load i64, ptr %15, align 8, !tbaa !5
  %130 = load i64, ptr %6, align 8, !tbaa !5
  %131 = icmp sgt i64 %129, %130
  br i1 %131, label %132, label %136

132:                                              ; preds = %90
  %133 = load i64, ptr %15, align 8, !tbaa !5
  store i64 %133, ptr %6, align 8, !tbaa !5
  %134 = load i64, ptr %9, align 8, !tbaa !14
  store i64 %134, ptr %7, align 8, !tbaa !14
  %135 = load i64, ptr %11, align 8, !tbaa !14
  store i64 %135, ptr %8, align 8, !tbaa !14
  br label %136

136:                                              ; preds = %132, %90
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %137

137:                                              ; preds = %136, %89
  %138 = load i64, ptr %11, align 8, !tbaa !14
  %139 = add nsw i64 %138, 1
  store i64 %139, ptr %11, align 8, !tbaa !14
  br label %76, !llvm.loop !16

140:                                              ; preds = %81
  br label %141

141:                                              ; preds = %140
  %142 = load i64, ptr %9, align 8, !tbaa !14
  %143 = add nsw i64 %142, 1
  store i64 %143, ptr %9, align 8, !tbaa !14
  br label %68, !llvm.loop !17

144:                                              ; preds = %72
  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
  br label %145

145:                                              ; preds = %144, %57
  br label %146

146:                                              ; preds = %145, %36
  store i32 0, ptr %1, align 4
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #3
  %147 = load i32, ptr %1, align 4
  ret i32 %147
}

; 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

declare i32 @printf(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

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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !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 [10 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [1 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
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  store i64 0, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  store i64 0, ptr %2, align 8, !tbaa !5
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = icmp eq i64 %4, 0
  %6 = load i64, ptr %2, align 8, !tbaa !5
  br i1 %5, label %7, label %16

7:                                                ; preds = %0
  %8 = mul i64 %6, %6
  %9 = sub i64 0, %8
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %9)
  %11 = load i64, ptr %2, align 8, !tbaa !5
  %12 = icmp sgt i64 %11, 0
  br i1 %12, label %.lr.ph61, label %.loopexit51.sink.split

.lr.ph61:                                         ; preds = %7, %.lr.ph61
  %indvars.iv66 = phi i64 [ %indvars.iv.next67, %.lr.ph61 ], [ 0, %7 ]
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %14 = load i64, ptr %2, align 8, !tbaa !5
  %15 = icmp sgt i64 %14, %indvars.iv.next67
  br i1 %15, label %.lr.ph61, label %.loopexit51.sink.split, !llvm.loop !9

16:                                               ; preds = %0
  %17 = icmp eq i64 %6, 0
  br i1 %17, label %18, label %.loopexit51

18:                                               ; preds = %16
  %19 = mul nsw i64 %4, %4
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %19)
  %21 = load i64, ptr %1, align 8, !tbaa !5
  %22 = icmp sgt i64 %21, 0
  br i1 %22, label %.lr.ph58, label %.loopexit51.sink.split

.lr.ph58:                                         ; preds = %18, %.lr.ph58
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph58 ], [ 0, %18 ]
  %23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = load i64, ptr %1, align 8, !tbaa !5
  %25 = icmp sgt i64 %24, %indvars.iv.next
  br i1 %25, label %.lr.ph58, label %.loopexit51.sink.split, !llvm.loop !11

.loopexit51.sink.split:                           ; preds = %.lr.ph58, %.lr.ph61, %18, %7
  %26 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %.loopexit51

.loopexit51:                                      ; preds = %.loopexit51.sink.split, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  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: nofree nounwind
declare noundef i32 @printf(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

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 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: ADCEPass,BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass