; LLVM IR from DionysiosB/CodeForces :: 1726B-MainakAndInterestingSequence (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 [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [9 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 i32, align 4
  %6 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %8

8:                                                ; preds = %75, %73, %0
  %9 = load i64, ptr %2, align 8, !tbaa !5
  %10 = add nsw i64 %9, -1
  store i64 %10, ptr %2, align 8, !tbaa !5
  %11 = icmp ne i64 %9, 0
  br i1 %11, label %12, label %76

12:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3, ptr noundef %4)
  %14 = load i64, ptr %3, align 8, !tbaa !5
  %15 = load i64, ptr %4, align 8, !tbaa !5
  %16 = icmp sgt i64 %14, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %12
  %18 = call i32 @puts(ptr noundef @.str.2)
  store i32 2, ptr %5, align 4
  br label %73, !llvm.loop !9

19:                                               ; preds = %12
  %20 = load i64, ptr %3, align 8, !tbaa !5
  %21 = srem i64 %20, 2
  %22 = icmp eq i64 %21, 0
  br i1 %22, label %23, label %29

23:                                               ; preds = %19
  %24 = load i64, ptr %4, align 8, !tbaa !5
  %25 = srem i64 %24, 2
  %26 = icmp ne i64 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %23
  %28 = call i32 @puts(ptr noundef @.str.2)
  store i32 2, ptr %5, align 4
  br label %73, !llvm.loop !9

29:                                               ; preds = %23, %19
  %30 = load i64, ptr %3, align 8, !tbaa !5
  %31 = icmp eq i64 %30, 1
  br i1 %31, label %32, label %35

32:                                               ; preds = %29
  %33 = load i64, ptr %4, align 8, !tbaa !5
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %33)
  store i32 2, ptr %5, align 4
  br label %73, !llvm.loop !9

35:                                               ; preds = %29
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  %38 = call i32 @puts(ptr noundef @.str.4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %47, %37
  %40 = load i64, ptr %6, align 8, !tbaa !5
  %41 = load i64, ptr %3, align 8, !tbaa !5
  %42 = sub nsw i64 %41, 2
  %43 = icmp slt i64 %40, %42
  br i1 %43, label %45, label %44

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

45:                                               ; preds = %39
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %47

47:                                               ; preds = %45
  %48 = load i64, ptr %6, align 8, !tbaa !5
  %49 = add nsw i64 %48, 1
  store i64 %49, ptr %6, align 8, !tbaa !5
  br label %39, !llvm.loop !11

50:                                               ; preds = %44
  %51 = load i64, ptr %3, align 8, !tbaa !5
  %52 = srem i64 %51, 2
  %53 = icmp ne i64 %52, 0
  br i1 %53, label %54, label %60

54:                                               ; preds = %50
  %55 = load i64, ptr %4, align 8, !tbaa !5
  %56 = load i64, ptr %3, align 8, !tbaa !5
  %57 = sub nsw i64 %55, %56
  %58 = add nsw i64 %57, 1
  %59 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i64 noundef %58)
  br label %72

60:                                               ; preds = %50
  %61 = load i64, ptr %4, align 8, !tbaa !5
  %62 = load i64, ptr %3, align 8, !tbaa !5
  %63 = sub nsw i64 %61, %62
  %64 = add nsw i64 %63, 2
  %65 = sdiv i64 %64, 2
  %66 = load i64, ptr %4, align 8, !tbaa !5
  %67 = load i64, ptr %3, align 8, !tbaa !5
  %68 = sub nsw i64 %66, %67
  %69 = add nsw i64 %68, 2
  %70 = sdiv i64 %69, 2
  %71 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i64 noundef %65, i64 noundef %70)
  br label %72

72:                                               ; preds = %60, %54
  store i32 0, ptr %5, align 4
  br label %73

73:                                               ; preds = %72, %32, %27, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  %74 = load i32, ptr %5, align 4
  switch i32 %74, label %78 [
    i32 0, label %75
    i32 2, label %8
  ]

75:                                               ; preds = %73
  br label %8, !llvm.loop !9

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

78:                                               ; preds = %73
  unreachable
}

; 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !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 [4 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [9 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
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %5 = load i64, ptr %1, align 8, !tbaa !5
  %6 = add nsw i64 %5, -1
  store i64 %6, ptr %1, align 8, !tbaa !5
  %.not10 = icmp eq i64 %5, 0
  br i1 %.not10, label %._crit_edge13, label %.lr.ph12

.lr.ph12:                                         ; preds = %0, %41
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %8 = load i64, ptr %2, align 8, !tbaa !5
  %9 = load i64, ptr %3, align 8, !tbaa !5
  %10 = icmp sgt i64 %8, %9
  br i1 %10, label %11, label %13

11:                                               ; preds = %.lr.ph12
  %12 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %41, !llvm.loop !9

13:                                               ; preds = %.lr.ph12
  %14 = and i64 %8, 1
  %15 = icmp ne i64 %14, 0
  %16 = and i64 %9, 1
  %.not5 = icmp eq i64 %16, 0
  %or.cond = or i1 %15, %.not5
  br i1 %or.cond, label %19, label %17

17:                                               ; preds = %13
  %18 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %41, !llvm.loop !9

19:                                               ; preds = %13
  %20 = icmp eq i64 %8, 1
  br i1 %20, label %21, label %23

21:                                               ; preds = %19
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %9)
  br label %41, !llvm.loop !9

23:                                               ; preds = %19
  %24 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.4)
  %25 = load i64, ptr %2, align 8, !tbaa !5
  %26 = icmp sgt i64 %25, 2
  br i1 %26, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %23
  %.lcssa7 = phi i64 [ %25, %23 ], [ %31, %.lr.ph ]
  %27 = and i64 %.lcssa7, 1
  %.not6 = icmp eq i64 %27, 0
  %28 = load i64, ptr %3, align 8, !tbaa !5
  %reass.sub14 = sub i64 %28, %.lcssa7
  br i1 %.not6, label %37, label %34

.lr.ph:                                           ; preds = %23, %.lr.ph
  %.08 = phi i64 [ %30, %.lr.ph ], [ 0, %23 ]
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %30 = add nuw nsw i64 %.08, 1
  %31 = load i64, ptr %2, align 8, !tbaa !5
  %32 = add nsw i64 %31, -2
  %33 = icmp slt i64 %30, %32
  br i1 %33, label %.lr.ph, label %._crit_edge, !llvm.loop !11

34:                                               ; preds = %._crit_edge
  %35 = add i64 %reass.sub14, 1
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i64 noundef %35)
  br label %41

37:                                               ; preds = %._crit_edge
  %38 = add i64 %reass.sub14, 2
  %39 = sdiv i64 %38, 2
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i64 noundef %39, i64 noundef %39)
  br label %41

41:                                               ; preds = %34, %37, %21, %17, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  %42 = load i64, ptr %1, align 8, !tbaa !5
  %43 = add nsw i64 %42, -1
  store i64 %43, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %42, 0
  br i1 %.not, label %._crit_edge13, label %.lr.ph12

._crit_edge13:                                    ; preds = %41, %0
  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}


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