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

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

15:                                               ; preds = %11
  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
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  %17 = load i64, ptr %5, align 8, !tbaa !5
  %18 = icmp ne i64 %17, 1
  br i1 %18, label %19, label %34

19:                                               ; preds = %15
  %20 = load i64, ptr %3, align 8, !tbaa !5
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %20)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %29, %19
  %23 = load i64, ptr %6, align 8, !tbaa !5
  %24 = load i64, ptr %3, align 8, !tbaa !5
  %25 = icmp slt i64 %23, %24
  br i1 %25, label %27, label %26

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

27:                                               ; preds = %22
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %29

29:                                               ; preds = %27
  %30 = load i64, ptr %6, align 8, !tbaa !5
  %31 = add nsw i64 %30, 1
  store i64 %31, ptr %6, align 8, !tbaa !5
  br label %22, !llvm.loop !9

32:                                               ; preds = %26
  %33 = call i32 @puts(ptr noundef @.str.4)
  br label %82

34:                                               ; preds = %15
  %35 = load i64, ptr %4, align 8, !tbaa !5
  %36 = icmp sge i64 %35, 2
  br i1 %36, label %37, label %58

37:                                               ; preds = %34
  %38 = load i64, ptr %3, align 8, !tbaa !5
  %39 = srem i64 %38, 2
  %40 = icmp eq i64 %39, 0
  br i1 %40, label %41, label %58

41:                                               ; preds = %37
  %42 = load i64, ptr %3, align 8, !tbaa !5
  %43 = sdiv i64 %42, 2
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %43)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 0, ptr %7, align 8, !tbaa !5
  br label %45

45:                                               ; preds = %53, %41
  %46 = load i64, ptr %7, align 8, !tbaa !5
  %47 = load i64, ptr %3, align 8, !tbaa !5
  %48 = sdiv i64 %47, 2
  %49 = icmp slt i64 %46, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %56

51:                                               ; preds = %45
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %53

53:                                               ; preds = %51
  %54 = load i64, ptr %7, align 8, !tbaa !5
  %55 = add nsw i64 %54, 1
  store i64 %55, ptr %7, align 8, !tbaa !5
  br label %45, !llvm.loop !11

56:                                               ; preds = %50
  %57 = call i32 @puts(ptr noundef @.str.4)
  br label %81

58:                                               ; preds = %37, %34
  %59 = load i64, ptr %4, align 8, !tbaa !5
  %60 = icmp sge i64 %59, 3
  br i1 %60, label %61, label %78

61:                                               ; preds = %58
  %62 = load i64, ptr %3, align 8, !tbaa !5
  %63 = sdiv i64 %62, 2
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i64 noundef %63)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 1, ptr %8, align 8, !tbaa !5
  br label %65

65:                                               ; preds = %73, %61
  %66 = load i64, ptr %8, align 8, !tbaa !5
  %67 = load i64, ptr %3, align 8, !tbaa !5
  %68 = sdiv i64 %67, 2
  %69 = icmp slt i64 %66, %68
  br i1 %69, label %71, label %70

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

71:                                               ; preds = %65
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  br label %73

73:                                               ; preds = %71
  %74 = load i64, ptr %8, align 8, !tbaa !5
  %75 = add nsw i64 %74, 1
  store i64 %75, ptr %8, align 8, !tbaa !5
  br label %65, !llvm.loop !12

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

78:                                               ; preds = %58
  %79 = call i32 @puts(ptr noundef @.str.7)
  store i32 2, ptr %9, align 4
  br label %83, !llvm.loop !13

80:                                               ; preds = %76
  br label %81

81:                                               ; preds = %80, %56
  br label %82

82:                                               ; preds = %81, %32
  store i32 0, ptr %9, align 4
  br label %83

83:                                               ; preds = %82, %78
  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
  %84 = load i32, ptr %9, align 4
  switch i32 %84, label %88 [
    i32 0, label %85
    i32 2, label %11
  ]

85:                                               ; preds = %83
  br label %11, !llvm.loop !13

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

88:                                               ; preds = %83
  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 @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

declare i32 @puts(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}


; 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 [12 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 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
  %5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %6 = load i64, ptr %1, align 8, !tbaa !5
  %7 = add nsw i64 %6, -1
  store i64 %7, ptr %1, align 8, !tbaa !5
  %.not20 = icmp eq i64 %6, 0
  br i1 %.not20, label %._crit_edge23, label %.lr.ph22

.lr.ph22:                                         ; preds = %0, %._crit_edge
  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
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3, ptr noundef nonnull %4)
  %9 = load i64, ptr %4, align 8, !tbaa !5
  %.not9 = icmp eq i64 %9, 1
  br i1 %.not9, label %19, label %10

10:                                               ; preds = %.lr.ph22
  %11 = load i64, ptr %2, align 8, !tbaa !5
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %11)
  %13 = load i64, ptr %2, align 8, !tbaa !5
  %14 = icmp sgt i64 %13, 0
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %10, %.lr.ph
  %.0811 = phi i64 [ %16, %.lr.ph ], [ 0, %10 ]
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %16 = add nuw nsw i64 %.0811, 1
  %17 = load i64, ptr %2, align 8, !tbaa !5
  %18 = icmp slt i64 %16, %17
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !9

19:                                               ; preds = %.lr.ph22
  %20 = load i64, ptr %3, align 8, !tbaa !5
  %21 = icmp sgt i64 %20, 1
  br i1 %21, label %22, label %._crit_edge, !llvm.loop !11

22:                                               ; preds = %19
  %23 = load i64, ptr %2, align 8, !tbaa !5
  %24 = and i64 %23, 1
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %26, label %36

26:                                               ; preds = %22
  %27 = ashr exact i64 %23, 1
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %27)
  %29 = load i64, ptr %2, align 8, !tbaa !5
  %30 = icmp sgt i64 %29, 1
  br i1 %30, label %.lr.ph18, label %._crit_edge

.lr.ph18:                                         ; preds = %26, %.lr.ph18
  %.0716 = phi i64 [ %32, %.lr.ph18 ], [ 0, %26 ]
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %32 = add nuw nsw i64 %.0716, 1
  %33 = load i64, ptr %2, align 8, !tbaa !5
  %34 = sdiv i64 %33, 2
  %35 = icmp slt i64 %32, %34
  br i1 %35, label %.lr.ph18, label %._crit_edge, !llvm.loop !12

36:                                               ; preds = %22
  %.not10 = icmp eq i64 %20, 2
  br i1 %.not10, label %._crit_edge, label %37, !llvm.loop !11

37:                                               ; preds = %36
  %38 = sdiv i64 %23, 2
  %39 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i64 noundef %38)
  %40 = load i64, ptr %2, align 8, !tbaa !5
  %41 = icmp sgt i64 %40, 3
  br i1 %41, label %.lr.ph14, label %._crit_edge

.lr.ph14:                                         ; preds = %37, %.lr.ph14
  %.012 = phi i64 [ %43, %.lr.ph14 ], [ 1, %37 ]
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %43 = add nuw nsw i64 %.012, 1
  %44 = load i64, ptr %2, align 8, !tbaa !5
  %45 = sdiv i64 %44, 2
  %46 = icmp slt i64 %43, %45
  br i1 %46, label %.lr.ph14, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph14, %.lr.ph18, %36, %19, %37, %26, %10
  %.str.4.sink = phi ptr [ @.str.4, %10 ], [ @.str.4, %26 ], [ @.str.4, %37 ], [ @.str.7, %19 ], [ @.str.7, %36 ], [ @.str.4, %.lr.ph18 ], [ @.str.4, %.lr.ph14 ], [ @.str.4, %.lr.ph ]
  %47 = call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.4.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
  %48 = load i64, ptr %1, align 8, !tbaa !5
  %49 = add nsw i64 %48, -1
  store i64 %49, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i64 %48, 0
  br i1 %.not, label %._crit_edge23, label %.lr.ph22

._crit_edge23:                                    ; preds = %._crit_edge, %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 @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

; Function Attrs: nofree nounwind
declare noundef i32 @puts(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}


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