; LLVM IR from DionysiosB/CodeForces :: 0100-0199 (145B-LuckyNumber2)

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

14:                                               ; preds = %0
  %15 = load i64, ptr %5, align 8, !tbaa !5
  %16 = load i64, ptr %4, align 8, !tbaa !5
  %17 = add nsw i64 %16, 1
  %18 = icmp sgt i64 %15, %17
  br i1 %18, label %19, label %21

19:                                               ; preds = %14, %0
  %20 = call i32 @puts(ptr noundef @.str.1)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %93

21:                                               ; preds = %14
  %22 = load i64, ptr %4, align 8, !tbaa !5
  %23 = load i64, ptr %2, align 8, !tbaa !5
  %24 = sub nsw i64 %23, %22
  store i64 %24, ptr %2, align 8, !tbaa !5
  %25 = load i64, ptr %4, align 8, !tbaa !5
  %26 = load i64, ptr %3, align 8, !tbaa !5
  %27 = sub nsw i64 %26, %25
  store i64 %27, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  store i8 0, ptr %7, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #3
  store i8 0, ptr %8, align 1, !tbaa !9
  %28 = load i64, ptr %4, align 8, !tbaa !5
  %29 = load i64, ptr %5, align 8, !tbaa !5
  %30 = icmp eq i64 %28, %29
  br i1 %30, label %31, label %41

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

34:                                               ; preds = %31
  %35 = load i64, ptr %2, align 8, !tbaa !5
  %36 = add nsw i64 %35, -1
  store i64 %36, ptr %2, align 8, !tbaa !5
  store i8 1, ptr %8, align 1, !tbaa !9
  br label %40

37:                                               ; preds = %31
  store i8 1, ptr %7, align 1, !tbaa !9
  %38 = load i64, ptr %3, align 8, !tbaa !5
  %39 = add nsw i64 %38, -1
  store i64 %39, ptr %3, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %37, %34
  br label %51

41:                                               ; preds = %21
  %42 = load i64, ptr %5, align 8, !tbaa !5
  %43 = load i64, ptr %4, align 8, !tbaa !5
  %44 = icmp sgt i64 %42, %43
  br i1 %44, label %45, label %50

45:                                               ; preds = %41
  %46 = load i64, ptr %2, align 8, !tbaa !5
  %47 = add nsw i64 %46, -1
  store i64 %47, ptr %2, align 8, !tbaa !5
  %48 = load i64, ptr %3, align 8, !tbaa !5
  %49 = add nsw i64 %48, -1
  store i64 %49, ptr %3, align 8, !tbaa !5
  store i8 1, ptr %7, align 1, !tbaa !9
  store i8 1, ptr %8, align 1, !tbaa !9
  br label %50

50:                                               ; preds = %45, %41
  br label %51

51:                                               ; preds = %50, %40
  %52 = load i64, ptr %2, align 8, !tbaa !5
  %53 = icmp slt i64 %52, 0
  br i1 %53, label %57, label %54

54:                                               ; preds = %51
  %55 = load i64, ptr %3, align 8, !tbaa !5
  %56 = icmp slt i64 %55, 0
  br i1 %56, label %57, label %59

57:                                               ; preds = %54, %51
  %58 = call i32 @puts(ptr noundef @.str.1)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %92

59:                                               ; preds = %54
  %60 = load i8, ptr %7, align 1, !tbaa !9, !range !11, !noundef !12
  %61 = trunc i8 %60 to i1
  br i1 %61, label %62, label %64

62:                                               ; preds = %59
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %64

64:                                               ; preds = %62, %59
  br label %65

65:                                               ; preds = %69, %64
  %66 = load i64, ptr %2, align 8, !tbaa !5
  %67 = add nsw i64 %66, -1
  store i64 %67, ptr %2, align 8, !tbaa !5
  %68 = icmp ne i64 %66, 0
  br i1 %68, label %69, label %71

69:                                               ; preds = %65
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %65, !llvm.loop !13

71:                                               ; preds = %65
  br label %72

72:                                               ; preds = %76, %71
  %73 = load i64, ptr %4, align 8, !tbaa !5
  %74 = add nsw i64 %73, -1
  store i64 %74, ptr %4, align 8, !tbaa !5
  %75 = icmp ne i64 %73, 0
  br i1 %75, label %76, label %78

76:                                               ; preds = %72
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %72, !llvm.loop !15

78:                                               ; preds = %72
  br label %79

79:                                               ; preds = %83, %78
  %80 = load i64, ptr %3, align 8, !tbaa !5
  %81 = add nsw i64 %80, -1
  store i64 %81, ptr %3, align 8, !tbaa !5
  %82 = icmp ne i64 %80, 0
  br i1 %82, label %83, label %85

83:                                               ; preds = %79
  %84 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %79, !llvm.loop !16

85:                                               ; preds = %79
  %86 = load i8, ptr %8, align 1, !tbaa !9, !range !11, !noundef !12
  %87 = trunc i8 %86 to i1
  br i1 %87, label %88, label %90

88:                                               ; preds = %85
  %89 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %90

90:                                               ; preds = %88, %85
  %91 = call i32 @puts(ptr noundef @.str.5)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  br label %92

92:                                               ; preds = %90, %57
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  br label %93

93:                                               ; preds = %92, %19
  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
  %94 = load i32, ptr %1, align 4
  ret i32 %94
}

; 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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

12:                                               ; preds = %0
  %13 = load i64, ptr %1, align 8, !tbaa !5
  %14 = sub nsw i64 %13, %6
  store i64 %14, ptr %1, align 8, !tbaa !5
  %15 = load i64, ptr %2, align 8, !tbaa !5
  %16 = sub nsw i64 %15, %6
  store i64 %16, ptr %2, align 8, !tbaa !5
  %17 = icmp eq i64 %6, %7
  br i1 %17, label %18, label %24

18:                                               ; preds = %12
  %19 = icmp sgt i64 %14, 0
  br i1 %19, label %20, label %22

20:                                               ; preds = %18
  %21 = add nsw i64 %14, -1
  store i64 %21, ptr %1, align 8, !tbaa !5
  br label %29

22:                                               ; preds = %18
  %23 = add nsw i64 %16, -1
  store i64 %23, ptr %2, align 8, !tbaa !5
  br label %29

24:                                               ; preds = %12
  %25 = icmp sgt i64 %7, %6
  br i1 %25, label %26, label %29

26:                                               ; preds = %24
  %27 = add nsw i64 %14, -1
  store i64 %27, ptr %1, align 8, !tbaa !5
  %28 = add nsw i64 %16, -1
  store i64 %28, ptr %2, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %24, %26, %20, %22
  %30 = phi i64 [ %16, %20 ], [ %23, %22 ], [ %28, %26 ], [ %16, %24 ]
  %31 = phi i64 [ %21, %20 ], [ %14, %22 ], [ %27, %26 ], [ %14, %24 ]
  %.04 = phi i1 [ false, %20 ], [ true, %22 ], [ true, %26 ], [ false, %24 ]
  %.0 = phi i1 [ true, %20 ], [ false, %22 ], [ true, %26 ], [ false, %24 ]
  %32 = icmp slt i64 %31, 0
  %33 = icmp slt i64 %30, 0
  %or.cond = select i1 %32, i1 true, i1 %33
  br i1 %or.cond, label %55, label %34

34:                                               ; preds = %29
  br i1 %.04, label %35, label %37

35:                                               ; preds = %34
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %.pre = load i64, ptr %1, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %35, %34
  %38 = phi i64 [ %.pre, %35 ], [ %31, %34 ]
  %39 = add nsw i64 %38, -1
  store i64 %39, ptr %1, align 8, !tbaa !5
  %.not15 = icmp eq i64 %38, 0
  br i1 %.not15, label %.preheader14, label %.lr.ph

.preheader14:                                     ; preds = %.lr.ph, %37
  %40 = load i64, ptr %3, align 8, !tbaa !5
  %41 = add nsw i64 %40, -1
  store i64 %41, ptr %3, align 8, !tbaa !5
  %.not1016 = icmp eq i64 %40, 0
  br i1 %.not1016, label %.preheader, label %.lr.ph17

.lr.ph:                                           ; preds = %37, %.lr.ph
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %43 = load i64, ptr %1, align 8, !tbaa !5
  %44 = add nsw i64 %43, -1
  store i64 %44, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %43, 0
  br i1 %.not, label %.preheader14, label %.lr.ph, !llvm.loop !9

.preheader:                                       ; preds = %.lr.ph17, %.preheader14
  %45 = load i64, ptr %2, align 8, !tbaa !5
  %46 = add nsw i64 %45, -1
  store i64 %46, ptr %2, align 8, !tbaa !5
  %.not1118 = icmp eq i64 %45, 0
  br i1 %.not1118, label %._crit_edge, label %.lr.ph19

.lr.ph17:                                         ; preds = %.preheader14, %.lr.ph17
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %48 = load i64, ptr %3, align 8, !tbaa !5
  %49 = add nsw i64 %48, -1
  store i64 %49, ptr %3, align 8, !tbaa !5
  %.not10 = icmp eq i64 %48, 0
  br i1 %.not10, label %.preheader, label %.lr.ph17, !llvm.loop !11

.lr.ph19:                                         ; preds = %.preheader, %.lr.ph19
  %50 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %51 = load i64, ptr %2, align 8, !tbaa !5
  %52 = add nsw i64 %51, -1
  store i64 %52, ptr %2, align 8, !tbaa !5
  %.not11 = icmp eq i64 %51, 0
  br i1 %.not11, label %._crit_edge, label %.lr.ph19, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph19, %.preheader
  br i1 %.0, label %53, label %55

53:                                               ; preds = %._crit_edge
  %54 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %55

55:                                               ; preds = %._crit_edge, %53, %29, %0
  %.str.1.sink = phi ptr [ @.str.1, %0 ], [ @.str.1, %29 ], [ @.str.5, %53 ], [ @.str.5, %._crit_edge ]
  %56 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.1.sink)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  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 @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 = !{!"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}
!12 = distinct !{!12, !10}


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