; LLVM IR from DionysiosB/CodeForces :: 0001-0099 (79A-BusGame)

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

6:                                                ; preds = %69, %0
  br label %7

7:                                                ; preds = %6
  %8 = load i64, ptr %2, align 8, !tbaa !5
  %9 = icmp sge i64 %8, 2
  br i1 %9, label %10, label %18

10:                                               ; preds = %7
  %11 = load i64, ptr %3, align 8, !tbaa !5
  %12 = icmp sge i64 %11, 2
  br i1 %12, label %13, label %18

13:                                               ; preds = %10
  %14 = load i64, ptr %2, align 8, !tbaa !5
  %15 = sub nsw i64 %14, 2
  store i64 %15, ptr %2, align 8, !tbaa !5
  %16 = load i64, ptr %3, align 8, !tbaa !5
  %17 = sub nsw i64 %16, 2
  store i64 %17, ptr %3, align 8, !tbaa !5
  br label %38

18:                                               ; preds = %10, %7
  %19 = load i64, ptr %2, align 8, !tbaa !5
  %20 = icmp sge i64 %19, 1
  br i1 %20, label %21, label %29

21:                                               ; preds = %18
  %22 = load i64, ptr %3, align 8, !tbaa !5
  %23 = icmp sge i64 %22, 12
  br i1 %23, label %24, label %29

24:                                               ; preds = %21
  %25 = load i64, ptr %2, align 8, !tbaa !5
  %26 = sub nsw i64 %25, 1
  store i64 %26, ptr %2, align 8, !tbaa !5
  %27 = load i64, ptr %3, align 8, !tbaa !5
  %28 = sub nsw i64 %27, 12
  store i64 %28, ptr %3, align 8, !tbaa !5
  br label %37

29:                                               ; preds = %21, %18
  %30 = load i64, ptr %3, align 8, !tbaa !5
  %31 = icmp sge i64 %30, 22
  br i1 %31, label %32, label %35

32:                                               ; preds = %29
  %33 = load i64, ptr %3, align 8, !tbaa !5
  %34 = sub nsw i64 %33, 22
  store i64 %34, ptr %3, align 8, !tbaa !5
  br label %36

35:                                               ; preds = %29
  store i8 1, ptr %4, align 1, !tbaa !9
  br label %70

36:                                               ; preds = %32
  br label %37

37:                                               ; preds = %36, %24
  br label %38

38:                                               ; preds = %37, %13
  %39 = load i64, ptr %3, align 8, !tbaa !5
  %40 = icmp sge i64 %39, 22
  br i1 %40, label %41, label %44

41:                                               ; preds = %38
  %42 = load i64, ptr %3, align 8, !tbaa !5
  %43 = sub nsw i64 %42, 22
  store i64 %43, ptr %3, align 8, !tbaa !5
  br label %69

44:                                               ; preds = %38
  %45 = load i64, ptr %3, align 8, !tbaa !5
  %46 = icmp sge i64 %45, 12
  br i1 %46, label %47, label %55

47:                                               ; preds = %44
  %48 = load i64, ptr %2, align 8, !tbaa !5
  %49 = icmp sge i64 %48, 1
  br i1 %49, label %50, label %55

50:                                               ; preds = %47
  %51 = load i64, ptr %2, align 8, !tbaa !5
  %52 = sub nsw i64 %51, 1
  store i64 %52, ptr %2, align 8, !tbaa !5
  %53 = load i64, ptr %3, align 8, !tbaa !5
  %54 = sub nsw i64 %53, 12
  store i64 %54, ptr %3, align 8, !tbaa !5
  br label %68

55:                                               ; preds = %47, %44
  %56 = load i64, ptr %3, align 8, !tbaa !5
  %57 = icmp sge i64 %56, 2
  br i1 %57, label %58, label %66

58:                                               ; preds = %55
  %59 = load i64, ptr %2, align 8, !tbaa !5
  %60 = icmp sge i64 %59, 2
  br i1 %60, label %61, label %66

61:                                               ; preds = %58
  %62 = load i64, ptr %2, align 8, !tbaa !5
  %63 = sub nsw i64 %62, 2
  store i64 %63, ptr %2, align 8, !tbaa !5
  %64 = load i64, ptr %3, align 8, !tbaa !5
  %65 = sub nsw i64 %64, 2
  store i64 %65, ptr %3, align 8, !tbaa !5
  br label %67

66:                                               ; preds = %58, %55
  store i8 0, ptr %4, align 1, !tbaa !9
  br label %70

67:                                               ; preds = %61
  br label %68

68:                                               ; preds = %67, %50
  br label %69

69:                                               ; preds = %68, %41
  br label %6, !llvm.loop !11

70:                                               ; preds = %66, %35
  %71 = load i8, ptr %4, align 1, !tbaa !9, !range !13, !noundef !14
  %72 = trunc i8 %71 to i1
  br i1 %72, label %73, label %75

73:                                               ; preds = %70
  %74 = call i32 @puts(ptr noundef @.str.1)
  br label %77

75:                                               ; preds = %70
  %76 = call i32 @puts(ptr noundef @.str.2)
  br label %77

77:                                               ; preds = %75, %73
  %78 = phi i32 [ %74, %73 ], [ %76, %75 ]
  call void @llvm.lifetime.end.p0(i64 1, 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

declare i32 @puts(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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{i8 0, i8 2}
!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 [8 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 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)
  %.promoted = load i64, ptr %1, align 8
  %.promoted14 = load i64, ptr %2, align 8
  br label %4

4:                                                ; preds = %.backedge, %0
  %5 = phi i64 [ %.promoted14, %0 ], [ %.be, %.backedge ]
  %6 = phi i64 [ %.promoted, %0 ], [ %.be15, %.backedge ]
  %7 = icmp sgt i64 %6, 1
  %8 = icmp sgt i64 %5, 1
  %or.cond = select i1 %7, i1 %8, i1 false
  br i1 %or.cond, label %9, label %12

9:                                                ; preds = %4
  %10 = add nsw i64 %6, -2
  store i64 %10, ptr %1, align 8, !tbaa !5
  %11 = add nsw i64 %5, -2
  store i64 %11, ptr %2, align 8, !tbaa !5
  br label %22

12:                                               ; preds = %4
  %13 = icmp sgt i64 %6, 0
  %14 = icmp sgt i64 %5, 11
  %or.cond3 = select i1 %13, i1 %14, i1 false
  br i1 %or.cond3, label %15, label %18

15:                                               ; preds = %12
  %16 = add nsw i64 %6, -1
  store i64 %16, ptr %1, align 8, !tbaa !5
  %17 = add nsw i64 %5, -12
  store i64 %17, ptr %2, align 8, !tbaa !5
  br label %22

18:                                               ; preds = %12
  %19 = icmp sgt i64 %5, 21
  br i1 %19, label %20, label %.critedge

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

22:                                               ; preds = %15, %20, %9
  %23 = phi i64 [ %16, %15 ], [ %6, %20 ], [ %10, %9 ]
  %24 = phi i64 [ %17, %15 ], [ %21, %20 ], [ %11, %9 ]
  %25 = icmp ugt i64 %24, 21
  br i1 %25, label %26, label %28

26:                                               ; preds = %22
  %27 = add nsw i64 %24, -22
  store i64 %27, ptr %2, align 8, !tbaa !5
  br label %.backedge

28:                                               ; preds = %22
  %29 = icmp ugt i64 %24, 11
  %30 = icmp sgt i64 %23, 0
  %or.cond5 = select i1 %29, i1 %30, i1 false
  br i1 %or.cond5, label %31, label %34

31:                                               ; preds = %28
  %32 = add nsw i64 %23, -1
  store i64 %32, ptr %1, align 8, !tbaa !5
  %33 = add nsw i64 %24, -12
  store i64 %33, ptr %2, align 8, !tbaa !5
  br label %.backedge

.backedge:                                        ; preds = %31, %37, %26
  %.be = phi i64 [ %33, %31 ], [ %39, %37 ], [ %27, %26 ]
  %.be15 = phi i64 [ %32, %31 ], [ %38, %37 ], [ %23, %26 ]
  br label %4, !llvm.loop !9

34:                                               ; preds = %28
  %35 = icmp ugt i64 %24, 1
  %36 = icmp sgt i64 %23, 1
  %or.cond7 = select i1 %35, i1 %36, i1 false
  br i1 %or.cond7, label %37, label %.critedge

37:                                               ; preds = %34
  %38 = add nsw i64 %23, -2
  store i64 %38, ptr %1, align 8, !tbaa !5
  %39 = add nsw i64 %24, -2
  store i64 %39, ptr %2, align 8, !tbaa !5
  br label %.backedge

.critedge:                                        ; preds = %34, %18
  %.str.2.sink = phi ptr [ @.str.1, %18 ], [ @.str.2, %34 ]
  %40 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.2.sink)
  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: 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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass