; LLVM IR from DionysiosB/CodeForces :: 0400-0499 (414A-MashmokhAndNumbers)

; 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"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = 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 i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %11 = load i64, ptr %2, align 8, !tbaa !5
  %12 = icmp eq i64 %11, 1
  br i1 %12, label %13, label %16

13:                                               ; preds = %0
  %14 = load i64, ptr %3, align 8, !tbaa !5
  %15 = icmp sgt i64 %14, 0
  br i1 %15, label %21, label %16

16:                                               ; preds = %13, %0
  %17 = load i64, ptr %3, align 8, !tbaa !5
  %18 = load i64, ptr %2, align 8, !tbaa !5
  %19 = sdiv i64 %18, 2
  %20 = icmp slt i64 %17, %19
  br i1 %20, label %21, label %23

21:                                               ; preds = %16, %13
  %22 = call i32 @puts(ptr noundef @.str)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %96

23:                                               ; preds = %16
  %24 = load i64, ptr %2, align 8, !tbaa !5
  %25 = icmp eq i64 %24, 1
  br i1 %25, label %26, label %31

26:                                               ; preds = %23
  %27 = load i64, ptr %3, align 8, !tbaa !5
  %28 = icmp eq i64 %27, 0
  br i1 %28, label %29, label %31

29:                                               ; preds = %26
  %30 = call i32 @puts(ptr noundef @.str.1)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %96

31:                                               ; preds = %26, %23
  br label %32

32:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %33 = load i64, ptr %3, align 8, !tbaa !5
  %34 = load i64, ptr %2, align 8, !tbaa !5
  %35 = sub nsw i64 %34, 2
  %36 = sdiv i64 %35, 2
  %37 = sub nsw i64 %33, %36
  store i64 %37, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %38 = load i64, ptr %5, align 8, !tbaa !5
  %39 = mul nsw i64 2, %38
  store i64 %39, ptr %6, align 8, !tbaa !5
  %40 = load i64, ptr %5, align 8, !tbaa !5
  %41 = load i64, ptr %6, align 8, !tbaa !5
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %40, i64 noundef %41)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %43 = load i64, ptr %2, align 8, !tbaa !5
  %44 = sub nsw i64 %43, 2
  store i64 %44, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 2, ptr %8, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %91, %32
  %46 = load i64, ptr %8, align 8, !tbaa !5
  %47 = load i64, ptr %2, align 8, !tbaa !5
  %48 = mul nsw i64 4, %47
  %49 = icmp slt i64 %46, %48
  br i1 %49, label %50, label %53

50:                                               ; preds = %45
  %51 = load i64, ptr %7, align 8, !tbaa !5
  %52 = icmp sgt i64 %51, 0
  br label %53

53:                                               ; preds = %50, %45
  %54 = phi i1 [ false, %45 ], [ %52, %50 ]
  br i1 %54, label %56, label %55

55:                                               ; preds = %53
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %94

56:                                               ; preds = %53
  %57 = load i64, ptr %8, align 8, !tbaa !5
  %58 = load i64, ptr %5, align 8, !tbaa !5
  %59 = icmp eq i64 %57, %58
  br i1 %59, label %74, label %60

60:                                               ; preds = %56
  %61 = load i64, ptr %8, align 8, !tbaa !5
  %62 = load i64, ptr %6, align 8, !tbaa !5
  %63 = icmp eq i64 %61, %62
  br i1 %63, label %74, label %64

64:                                               ; preds = %60
  %65 = load i64, ptr %8, align 8, !tbaa !5
  %66 = add nsw i64 %65, 1
  %67 = load i64, ptr %5, align 8, !tbaa !5
  %68 = icmp eq i64 %66, %67
  br i1 %68, label %74, label %69

69:                                               ; preds = %64
  %70 = load i64, ptr %8, align 8, !tbaa !5
  %71 = add nsw i64 %70, 1
  %72 = load i64, ptr %6, align 8, !tbaa !5
  %73 = icmp eq i64 %71, %72
  br i1 %73, label %74, label %75

74:                                               ; preds = %69, %64, %60, %56
  br label %91

75:                                               ; preds = %69
  %76 = load i64, ptr %7, align 8, !tbaa !5
  %77 = icmp sge i64 %76, 2
  br i1 %77, label %78, label %85

78:                                               ; preds = %75
  %79 = load i64, ptr %8, align 8, !tbaa !5
  %80 = load i64, ptr %8, align 8, !tbaa !5
  %81 = add nsw i64 %80, 1
  %82 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %79, i64 noundef %81)
  %83 = load i64, ptr %7, align 8, !tbaa !5
  %84 = sub nsw i64 %83, 2
  store i64 %84, ptr %7, align 8, !tbaa !5
  br label %90

85:                                               ; preds = %75
  %86 = load i64, ptr %8, align 8, !tbaa !5
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %86)
  %88 = load i64, ptr %7, align 8, !tbaa !5
  %89 = add nsw i64 %88, -1
  store i64 %89, ptr %7, align 8, !tbaa !5
  br label %90

90:                                               ; preds = %85, %78
  br label %91

91:                                               ; preds = %90, %74
  %92 = load i64, ptr %8, align 8, !tbaa !5
  %93 = add nsw i64 %92, 2
  store i64 %93, ptr %8, align 8, !tbaa !5
  br label %45, !llvm.loop !9

94:                                               ; preds = %55
  %95 = call i32 @puts(ptr noundef @.str.4)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %96

96:                                               ; preds = %94, %29, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  %97 = load i32, ptr %1, align 4
  ret i32 %97
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

declare i32 @puts(ptr noundef) #3

declare i32 @printf(ptr noundef, ...) #3

; 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 = { mustprogress 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 #3 = { "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 #4 = { 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"}


; 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"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@_ZSt3cin = external global %"class.std::basic_istream", align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [1 x i8], align 1

; Function Attrs: mustprogress norecurse 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) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %3 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %4 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %5 = load i64, ptr %1, align 8, !tbaa !5
  %6 = icmp eq i64 %5, 1
  %7 = load i64, ptr %2, align 8
  %8 = icmp sgt i64 %7, 0
  %or.cond = select i1 %6, i1 %8, i1 false
  %9 = sdiv i64 %5, 2
  %10 = icmp slt i64 %7, %9
  %or.cond30 = select i1 %or.cond, i1 true, i1 %10
  br i1 %or.cond30, label %._crit_edge, label %11

11:                                               ; preds = %0
  %12 = icmp eq i64 %7, 0
  %or.cond3 = select i1 %6, i1 %12, i1 false
  br i1 %or.cond3, label %._crit_edge, label %13

13:                                               ; preds = %11
  %14 = add nsw i64 %5, -2
  %.neg = sdiv i64 %14, -2
  %15 = add i64 %.neg, %7
  %16 = shl nsw i64 %15, 1
  %17 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %15, i64 noundef %16)
  %18 = load i64, ptr %1, align 8, !tbaa !5
  %19 = icmp sgt i64 %18, 2
  br i1 %19, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %13
  %20 = add nsw i64 %18, -2
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %32
  %.033 = phi i64 [ %33, %32 ], [ 2, %.lr.ph.preheader ]
  %.02432 = phi i64 [ %.1, %32 ], [ %20, %.lr.ph.preheader ]
  %21 = icmp eq i64 %.033, %15
  %22 = icmp eq i64 %.033, %16
  %or.cond31 = or i1 %21, %22
  br i1 %or.cond31, label %32, label %23

23:                                               ; preds = %.lr.ph
  %24 = or disjoint i64 %.033, 1
  %25 = icmp eq i64 %24, %15
  br i1 %25, label %32, label %26

26:                                               ; preds = %23
  %27 = icmp ugt i64 %.02432, 1
  br i1 %27, label %28, label %.thread

28:                                               ; preds = %26
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %.033, i64 noundef %24)
  %30 = add nsw i64 %.02432, -2
  br label %32

.thread:                                          ; preds = %26
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %.033)
  br label %._crit_edge

32:                                               ; preds = %28, %.lr.ph, %23
  %.1 = phi i64 [ %.02432, %.lr.ph ], [ %.02432, %23 ], [ %30, %28 ]
  %33 = add nuw nsw i64 %.033, 2
  %34 = load i64, ptr %1, align 8, !tbaa !5
  %35 = shl nsw i64 %34, 2
  %36 = icmp slt i64 %33, %35
  %37 = icmp ne i64 %.1, 0
  %38 = select i1 %36, i1 %37, i1 false
  br i1 %38, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %32, %13, %.thread, %11, %0
  %.str.4.sink = phi ptr [ @.str, %0 ], [ @.str.1, %11 ], [ @.str.4, %.thread ], [ @.str.4, %13 ], [ @.str.4, %32 ]
  %39 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.4.sink)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  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: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERl(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: nofree nounwind
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; 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 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress 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 #3 = { 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 #4 = { 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,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass