; LLVM IR from tangjz/acm-icpc :: codeforces/complete (1352B)

; 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 [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 1, ptr %2, align 4, !tbaa !5
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %10

10:                                               ; preds = %79, %0
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = icmp sle i32 %11, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %10
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %82

15:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %5, ptr noundef %6)
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = icmp sge i32 %17, %18
  br i1 %19, label %20, label %45

20:                                               ; preds = %15
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = sub nsw i32 %21, %22
  %24 = and i32 %23, 1
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %45, label %26

26:                                               ; preds = %20
  %27 = call i32 @puts(ptr noundef @.str.3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %36, %26
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = sub nsw i32 %30, 1
  %32 = icmp slt i32 %29, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %28
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %39

34:                                               ; preds = %28
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %36

36:                                               ; preds = %34
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %7, align 4, !tbaa !5
  br label %28, !llvm.loop !9

39:                                               ; preds = %33
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = sub nsw i32 %41, 1
  %43 = sub nsw i32 %40, %42
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %43)
  br label %78

45:                                               ; preds = %20, %15
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = add nsw i32 %47, %48
  %50 = icmp sge i32 %46, %49
  br i1 %50, label %51, label %75

51:                                               ; preds = %45
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = and i32 %52, 1
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %75, label %55

55:                                               ; preds = %51
  %56 = call i32 @puts(ptr noundef @.str.3)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %65, %55
  %58 = load i32, ptr %8, align 4, !tbaa !5
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = sub nsw i32 %59, 1
  %61 = icmp slt i32 %58, %60
  br i1 %61, label %63, label %62

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

63:                                               ; preds = %57
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  br label %65

65:                                               ; preds = %63
  %66 = load i32, ptr %8, align 4, !tbaa !5
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %8, align 4, !tbaa !5
  br label %57, !llvm.loop !11

68:                                               ; preds = %62
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %71 = sub nsw i32 %70, 1
  %72 = mul nsw i32 %71, 2
  %73 = sub nsw i32 %69, %72
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %73)
  br label %77

75:                                               ; preds = %51, %45
  %76 = call i32 @puts(ptr noundef @.str.7)
  br label %77

77:                                               ; preds = %75, %68
  br label %78

78:                                               ; preds = %77, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %3, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %3, align 4, !tbaa !5
  br label %10, !llvm.loop !12

82:                                               ; preds = %14
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %83 = load i32, ptr %1, align 4
  ret i32 %83
}

; 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 @puts(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

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 = !{!"int", !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}
!12 = distinct !{!12, !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 [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1

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

._crit_edge29:                                    ; preds = %44, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #3
  ret i32 0

.lr.ph28:                                         ; preds = %0, %44
  %.0826 = phi i32 [ %45, %44 ], [ 1, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %6 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %.not14 = icmp slt i32 %7, %8
  br i1 %.not14, label %25, label %9

9:                                                ; preds = %.lr.ph28
  %10 = sub nsw i32 %7, %8
  %11 = and i32 %10, 1
  %.not15 = icmp eq i32 %11, 0
  br i1 %.not15, label %12, label %25

12:                                               ; preds = %9
  %13 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = add nsw i32 %14, -1
  %16 = icmp sgt i32 %14, 1
  br i1 %16, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %12
  %.lcssa = phi i32 [ %15, %12 ], [ %23, %.lr.ph ]
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sub nsw i32 %17, %.lcssa
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %18)
  br label %44

.lr.ph:                                           ; preds = %12, %.lr.ph
  %.0719 = phi i32 [ %21, %.lr.ph ], [ 0, %12 ]
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %21 = add nuw nsw i32 %.0719, 1
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = add nsw i32 %22, -1
  %24 = icmp slt i32 %21, %23
  br i1 %24, label %.lr.ph, label %._crit_edge, !llvm.loop !9

25:                                               ; preds = %9, %.lr.ph28
  %26 = shl nsw i32 %8, 1
  %.not16 = icmp sge i32 %7, %26
  %27 = and i32 %7, 1
  %.not17 = icmp eq i32 %27, 0
  %or.cond = and i1 %.not17, %.not16
  br i1 %or.cond, label %28, label %42

28:                                               ; preds = %25
  %29 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.3)
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = add nsw i32 %30, -1
  %32 = icmp sgt i32 %30, 1
  br i1 %32, label %.lr.ph22, label %._crit_edge23

._crit_edge23:                                    ; preds = %.lr.ph22, %28
  %.lcssa18 = phi i32 [ %31, %28 ], [ %40, %.lr.ph22 ]
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = shl nsw i32 %.lcssa18, 1
  %35 = sub nsw i32 %33, %34
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %35)
  br label %44

.lr.ph22:                                         ; preds = %28, %.lr.ph22
  %.020 = phi i32 [ %38, %.lr.ph22 ], [ 0, %28 ]
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %38 = add nuw nsw i32 %.020, 1
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = add nsw i32 %39, -1
  %41 = icmp slt i32 %38, %40
  br i1 %41, label %.lr.ph22, label %._crit_edge23, !llvm.loop !11

42:                                               ; preds = %25
  %43 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.7)
  br label %44

44:                                               ; preds = %._crit_edge23, %42, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  %45 = add nuw nsw i32 %.0826, 1
  %46 = load i32, ptr %1, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.0826, %46
  br i1 %.not.not, label %.lr.ph28, label %._crit_edge29, !llvm.loop !12
}

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

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 = !{!"int", !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}
!12 = distinct !{!12, !10}


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