; LLVM IR from DionysiosB/CodeForces :: 1744D-DivisibilityBy2n (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 [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 i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %12

12:                                               ; preds = %77, %0
  %13 = load i64, ptr %2, align 8, !tbaa !5
  %14 = add nsw i64 %13, -1
  store i64 %14, ptr %2, align 8, !tbaa !5
  %15 = icmp ne i64 %13, 0
  br i1 %15, label %16, label %80

16:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 0, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %35, %16
  %19 = load i64, ptr %5, align 8, !tbaa !5
  %20 = load i64, ptr %3, align 8, !tbaa !5
  %21 = icmp slt i64 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  br label %38

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %6)
  br label %25

25:                                               ; preds = %29, %23
  %26 = load i64, ptr %6, align 8, !tbaa !5
  %27 = srem i64 %26, 2
  %28 = icmp eq i64 %27, 0
  br i1 %28, label %29, label %34

29:                                               ; preds = %25
  %30 = load i64, ptr %4, align 8, !tbaa !5
  %31 = add nsw i64 %30, 1
  store i64 %31, ptr %4, align 8, !tbaa !5
  %32 = load i64, ptr %6, align 8, !tbaa !5
  %33 = sdiv i64 %32, 2
  store i64 %33, ptr %6, align 8, !tbaa !5
  br label %25, !llvm.loop !9

34:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %35

35:                                               ; preds = %34
  %36 = load i64, ptr %5, align 8, !tbaa !5
  %37 = add nsw i64 %36, 1
  store i64 %37, ptr %5, align 8, !tbaa !5
  br label %18, !llvm.loop !11

38:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 0, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %39 = load i64, ptr %3, align 8, !tbaa !5
  store i64 %39, ptr %8, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %67, %38
  %41 = load i64, ptr %4, align 8, !tbaa !5
  %42 = load i64, ptr %3, align 8, !tbaa !5
  %43 = icmp slt i64 %41, %42
  br i1 %43, label %44, label %47

44:                                               ; preds = %40
  %45 = load i64, ptr %8, align 8, !tbaa !5
  %46 = icmp sge i64 %45, 1
  br label %47

47:                                               ; preds = %44, %40
  %48 = phi i1 [ false, %40 ], [ %46, %44 ]
  br i1 %48, label %50, label %49

49:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %70

50:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store i64 0, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %51 = load i64, ptr %8, align 8, !tbaa !5
  store i64 %51, ptr %10, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %56, %50
  %53 = load i64, ptr %10, align 8, !tbaa !5
  %54 = srem i64 %53, 2
  %55 = icmp eq i64 %54, 0
  br i1 %55, label %56, label %61

56:                                               ; preds = %52
  %57 = load i64, ptr %9, align 8, !tbaa !5
  %58 = add nsw i64 %57, 1
  store i64 %58, ptr %9, align 8, !tbaa !5
  %59 = load i64, ptr %10, align 8, !tbaa !5
  %60 = sdiv i64 %59, 2
  store i64 %60, ptr %10, align 8, !tbaa !5
  br label %52, !llvm.loop !12

61:                                               ; preds = %52
  %62 = load i64, ptr %9, align 8, !tbaa !5
  %63 = load i64, ptr %4, align 8, !tbaa !5
  %64 = add nsw i64 %63, %62
  store i64 %64, ptr %4, align 8, !tbaa !5
  %65 = load i64, ptr %7, align 8, !tbaa !5
  %66 = add nsw i64 %65, 1
  store i64 %66, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %67

67:                                               ; preds = %61
  %68 = load i64, ptr %8, align 8, !tbaa !5
  %69 = add nsw i64 %68, -1
  store i64 %69, ptr %8, align 8, !tbaa !5
  br label %40, !llvm.loop !13

70:                                               ; preds = %49
  %71 = load i64, ptr %4, align 8, !tbaa !5
  %72 = load i64, ptr %3, align 8, !tbaa !5
  %73 = icmp slt i64 %71, %72
  br i1 %73, label %74, label %75

74:                                               ; preds = %70
  br label %77

75:                                               ; preds = %70
  %76 = load i64, ptr %7, align 8, !tbaa !5
  br label %77

77:                                               ; preds = %75, %74
  %78 = phi i64 [ -1, %74 ], [ %76, %75 ]
  %79 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %78)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %12, !llvm.loop !14

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

; 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

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

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

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}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !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 [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
  %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
  %.not43 = icmp eq i64 %5, 0
  br i1 %.not43, label %._crit_edge46, label %.lr.ph45

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

.preheader22:                                     ; preds = %._crit_edge
  %10 = icmp slt i64 %.1.lcssa, %22
  %11 = icmp sgt i64 %22, 0
  %12 = and i1 %10, %11
  br i1 %12, label %.preheader, label %._crit_edge40

.lr.ph29:                                         ; preds = %.lr.ph45, %._crit_edge
  %.01927 = phi i64 [ %21, %._crit_edge ], [ 0, %.lr.ph45 ]
  %.02026 = phi i64 [ %.1.lcssa, %._crit_edge ], [ 0, %.lr.ph45 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %3)
  %.promoted = load i64, ptr %3, align 8, !tbaa !5
  %14 = and i64 %.promoted, 1
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph29, %.lr.ph
  %.124 = phi i64 [ %17, %.lr.ph ], [ %.02026, %.lr.ph29 ]
  %16 = phi i64 [ %18, %.lr.ph ], [ %.promoted, %.lr.ph29 ]
  %17 = add nsw i64 %.124, 1
  %18 = ashr exact i64 %16, 1
  %19 = and i64 %16, 2
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph29
  %.1.lcssa = phi i64 [ %.02026, %.lr.ph29 ], [ %17, %.lr.ph ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  %21 = add nuw nsw i64 %.01927, 1
  %22 = load i64, ptr %2, align 8, !tbaa !5
  %23 = icmp slt i64 %21, %22
  br i1 %23, label %.lr.ph29, label %.preheader22, !llvm.loop !11

.preheader:                                       ; preds = %.preheader22, %._crit_edge35
  %.01739 = phi i64 [ %36, %._crit_edge35 ], [ %22, %.preheader22 ]
  %.01838 = phi i64 [ %35, %._crit_edge35 ], [ 0, %.preheader22 ]
  %.237 = phi i64 [ %34, %._crit_edge35 ], [ %.1.lcssa, %.preheader22 ]
  %24 = and i64 %.01739, 1
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %.lr.ph34, label %._crit_edge35

._crit_edge40:                                    ; preds = %._crit_edge35, %.preheader22
  %.018.lcssa = phi i64 [ 0, %.preheader22 ], [ %35, %._crit_edge35 ]
  %.lcssa23 = phi i1 [ %10, %.preheader22 ], [ %37, %._crit_edge35 ]
  %cond.fr = freeze i1 %.lcssa23
  %spec.select = select i1 %cond.fr, i64 -1, i64 %.018.lcssa
  br label %._crit_edge40.thread

._crit_edge40.thread:                             ; preds = %._crit_edge40, %.lr.ph45
  %26 = phi i64 [ 0, %.lr.ph45 ], [ %spec.select, %._crit_edge40 ]
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %26)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  %28 = load i64, ptr %1, align 8, !tbaa !5
  %29 = add nsw i64 %28, -1
  store i64 %29, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %28, 0
  br i1 %.not, label %._crit_edge46, label %.lr.ph45, !llvm.loop !12

.lr.ph34:                                         ; preds = %.preheader, %.lr.ph34
  %.033 = phi i64 [ %31, %.lr.ph34 ], [ %.01739, %.preheader ]
  %.01632 = phi i64 [ %30, %.lr.ph34 ], [ 0, %.preheader ]
  %30 = add nuw nsw i64 %.01632, 1
  %31 = lshr exact i64 %.033, 1
  %32 = and i64 %.033, 2
  %33 = icmp eq i64 %32, 0
  br i1 %33, label %.lr.ph34, label %._crit_edge35, !llvm.loop !13

._crit_edge35:                                    ; preds = %.lr.ph34, %.preheader
  %.016.lcssa = phi i64 [ 0, %.preheader ], [ %30, %.lr.ph34 ]
  %34 = add nsw i64 %.016.lcssa, %.237
  %35 = add nuw nsw i64 %.01838, 1
  %36 = add nsw i64 %.01739, -1
  %37 = icmp slt i64 %34, %22
  %38 = icmp sgt i64 %.01739, 1
  %39 = and i1 %37, %38
  br i1 %39, label %.preheader, label %._crit_edge40, !llvm.loop !14

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

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

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}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}


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