; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/268 Division 1/Problem A (A)

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

@n = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %9 = load i32, ptr @n, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 4
  br i1 %10, label %11, label %13

11:                                               ; preds = %0
  %12 = call i32 @puts(ptr noundef @.str.1)
  store i32 0, ptr %1, align 4
  br label %84

13:                                               ; preds = %0
  %14 = call i32 @puts(ptr noundef @.str.2)
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %16 = srem i32 %15, 2
  %17 = icmp eq i32 %16, 0
  br i1 %17, label %18, label %50

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

22:                                               ; preds = %32, %18
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = load i32, ptr @n, align 4, !tbaa !5
  %25 = icmp sle i32 %23, %24
  br i1 %25, label %27, label %26

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

27:                                               ; preds = %22
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sub nsw i32 %29, 1
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %28, i32 noundef %30)
  br label %32

32:                                               ; preds = %27
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = add nsw i32 %33, 2
  store i32 %34, ptr %2, align 4, !tbaa !5
  br label %22, !llvm.loop !9

35:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = sub nsw i32 %36, 4
  %38 = sdiv i32 %37, 2
  store i32 %38, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %46, %35
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = icmp sle i32 %40, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %49

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

46:                                               ; preds = %44
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %4, align 4, !tbaa !5
  br label %39, !llvm.loop !11

49:                                               ; preds = %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %83

50:                                               ; preds = %13
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 7, ptr %5, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %65, %50
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = load i32, ptr @n, align 4, !tbaa !5
  %58 = icmp sle i32 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %68

60:                                               ; preds = %55
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = load i32, ptr %5, align 4, !tbaa !5
  %63 = sub nsw i32 %62, 1
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %61, i32 noundef %63)
  br label %65

65:                                               ; preds = %60
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = add nsw i32 %66, 2
  store i32 %67, ptr %5, align 4, !tbaa !5
  br label %55, !llvm.loop !12

68:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %69 = load i32, ptr @n, align 4, !tbaa !5
  %70 = sub nsw i32 %69, 5
  %71 = sdiv i32 %70, 2
  store i32 %71, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %79, %68
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = icmp sle i32 %73, %74
  br i1 %75, label %77, label %76

76:                                               ; preds = %72
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %82

77:                                               ; preds = %72
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %79

79:                                               ; preds = %77
  %80 = load i32, ptr %7, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %7, align 4, !tbaa !5
  br label %72, !llvm.loop !13

82:                                               ; preds = %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %83

83:                                               ; preds = %82, %49
  store i32 0, ptr %1, align 4
  br label %84

84:                                               ; preds = %83, %11
  %85 = load i32, ptr %1, align 4
  ret i32 %85
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

declare i32 @puts(ptr noundef) #1

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { "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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !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"

@n = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp slt i32 %2, 4
  br i1 %3, label %4, label %6

4:                                                ; preds = %0
  %5 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %.loopexit

6:                                                ; preds = %0
  %7 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = and i32 %8, 1
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %24

11:                                               ; preds = %6
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %.not2232 = icmp slt i32 %15, 6
  br i1 %.not2232, label %.loopexit, label %.lr.ph35

._crit_edge36:                                    ; preds = %.lr.ph35
  %.not2338 = icmp slt i32 %21, 6
  br i1 %.not2338, label %.loopexit, label %.lr.ph41.preheader

.lr.ph41.preheader:                               ; preds = %._crit_edge36
  %16 = add nsw i32 %21, -4
  %17 = lshr i32 %16, 1
  br label %.lr.ph41

.lr.ph35:                                         ; preds = %11, %.lr.ph35
  %.01833 = phi i32 [ %20, %.lr.ph35 ], [ 6, %11 ]
  %18 = add nsw i32 %.01833, -1
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef %.01833, i32 noundef %18)
  %20 = add nuw nsw i32 %.01833, 2
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %.not22 = icmp sgt i32 %20, %21
  br i1 %.not22, label %._crit_edge36, label %.lr.ph35, !llvm.loop !9

.lr.ph41:                                         ; preds = %.lr.ph41.preheader, %.lr.ph41
  %.01739 = phi i32 [ %23, %.lr.ph41 ], [ 1, %.lr.ph41.preheader ]
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %23 = add nuw nsw i32 %.01739, 1
  %exitcond46.not = icmp eq i32 %.01739, %17
  br i1 %exitcond46.not, label %.loopexit, label %.lr.ph41, !llvm.loop !11

24:                                               ; preds = %6
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  %26 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %27 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %29 = load i32, ptr @n, align 4, !tbaa !5
  %.not26 = icmp slt i32 %29, 7
  br i1 %.not26, label %.loopexit, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph
  %.not2128 = icmp slt i32 %35, 7
  br i1 %.not2128, label %.loopexit, label %.lr.ph31.preheader

.lr.ph31.preheader:                               ; preds = %._crit_edge
  %30 = add nsw i32 %35, -5
  %31 = lshr i32 %30, 1
  br label %.lr.ph31

.lr.ph:                                           ; preds = %24, %.lr.ph
  %.01627 = phi i32 [ %34, %.lr.ph ], [ 7, %24 ]
  %32 = add nsw i32 %.01627, -1
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef %.01627, i32 noundef %32)
  %34 = add nuw nsw i32 %.01627, 2
  %35 = load i32, ptr @n, align 4, !tbaa !5
  %.not = icmp sgt i32 %34, %35
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

.lr.ph31:                                         ; preds = %.lr.ph31.preheader, %.lr.ph31
  %.029 = phi i32 [ %37, %.lr.ph31 ], [ 1, %.lr.ph31.preheader ]
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %37 = add nuw nsw i32 %.029, 1
  %exitcond.not = icmp eq i32 %.029, %31
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph31, !llvm.loop !13

.loopexit:                                        ; preds = %.lr.ph31, %.lr.ph41, %24, %11, %._crit_edge, %._crit_edge36, %4
  ret i32 0
}

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { 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" }

!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 = !{!"int", !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,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass