; LLVM IR from tangjz/acm-icpc :: codeforces/complete (471A)

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

@a = external dso_local global [10 x i32], align 16
@x = 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 [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 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
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %17, %0
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 6
  br i1 %8, label %10, label %9

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

10:                                               ; preds = %6
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @x)
  %12 = load i32, ptr @x, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [10 x i32], ptr @a, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = add nsw i32 %15, 1
  store i32 %16, ptr %14, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %10
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = add nsw i32 %18, 1
  store i32 %19, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !9

20:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %58, %20
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = icmp sle i32 %22, 9
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  store i32 5, ptr %4, align 4
  br label %61

25:                                               ; preds = %21
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [10 x i32], ptr @a, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = icmp sge i32 %29, 4
  br i1 %30, label %31, label %57

31:                                               ; preds = %25
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [10 x i32], ptr @a, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = sub nsw i32 %35, 4
  store i32 %36, ptr %34, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %50, %31
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = icmp sle i32 %38, 9
  br i1 %39, label %41, label %40

40:                                               ; preds = %37
  store i32 8, ptr %4, align 4
  br label %53

41:                                               ; preds = %37
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [10 x i32], ptr @a, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = icmp eq i32 %45, 2
  br i1 %46, label %47, label %49

47:                                               ; preds = %41
  %48 = call i32 @puts(ptr noundef @.str.1)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %53

49:                                               ; preds = %41
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %5, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %5, align 4, !tbaa !5
  br label %37, !llvm.loop !11

53:                                               ; preds = %47, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  %54 = load i32, ptr %4, align 4
  switch i32 %54, label %61 [
    i32 8, label %55
  ]

55:                                               ; preds = %53
  %56 = call i32 @puts(ptr noundef @.str.2)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %61

57:                                               ; preds = %25
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %3, align 4, !tbaa !5
  br label %21, !llvm.loop !12

61:                                               ; preds = %55, %53, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  %62 = load i32, ptr %4, align 4
  switch i32 %62, label %67 [
    i32 5, label %63
    i32 1, label %65
  ]

63:                                               ; preds = %61
  %64 = call i32 @puts(ptr noundef @.str.3)
  store i32 0, ptr %1, align 4
  br label %65

65:                                               ; preds = %63, %61
  %66 = load i32, ptr %1, align 4
  ret i32 %66

67:                                               ; preds = %61
  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

; 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 = !{!"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}


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

@a = external dso_local local_unnamed_addr global [10 x i32], align 16
@x = 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 [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader.preheader:
  %0 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x)
  %1 = load i32, ptr @x, align 4, !tbaa !5
  %2 = sext i32 %1 to i64
  %3 = getelementptr inbounds [10 x i32], ptr @a, i64 0, i64 %2
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = add nsw i32 %4, 1
  store i32 %5, ptr %3, align 4, !tbaa !5
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x)
  %7 = load i32, ptr @x, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [10 x i32], ptr @a, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = add nsw i32 %10, 1
  store i32 %11, ptr %9, align 4, !tbaa !5
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x)
  %13 = load i32, ptr @x, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [10 x i32], ptr @a, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %15, align 4, !tbaa !5
  %18 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x)
  %19 = load i32, ptr @x, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [10 x i32], ptr @a, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %21, align 4, !tbaa !5
  %24 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x)
  %25 = load i32, ptr @x, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [10 x i32], ptr @a, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %27, align 4, !tbaa !5
  %30 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x)
  %31 = load i32, ptr @x, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [10 x i32], ptr @a, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %33, align 4, !tbaa !5
  %36 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !5
  %37 = icmp sgt i32 %36, 3
  br i1 %37, label %54, label %.preheader.1

.preheader.1:                                     ; preds = %.preheader.preheader
  %38 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 8), align 8, !tbaa !5
  %39 = icmp sgt i32 %38, 3
  br i1 %39, label %54, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %40 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 12), align 4, !tbaa !5
  %41 = icmp sgt i32 %40, 3
  br i1 %41, label %54, label %.preheader.3

.preheader.3:                                     ; preds = %.preheader.2
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 16), align 16, !tbaa !5
  %43 = icmp sgt i32 %42, 3
  br i1 %43, label %54, label %.preheader.4

.preheader.4:                                     ; preds = %.preheader.3
  %44 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 20), align 4, !tbaa !5
  %45 = icmp sgt i32 %44, 3
  br i1 %45, label %54, label %.preheader.5

.preheader.5:                                     ; preds = %.preheader.4
  %46 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 24), align 8, !tbaa !5
  %47 = icmp sgt i32 %46, 3
  br i1 %47, label %54, label %.preheader.6

.preheader.6:                                     ; preds = %.preheader.5
  %48 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 28), align 4, !tbaa !5
  %49 = icmp sgt i32 %48, 3
  br i1 %49, label %54, label %.preheader.7

.preheader.7:                                     ; preds = %.preheader.6
  %50 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 32), align 16, !tbaa !5
  %51 = icmp sgt i32 %50, 3
  br i1 %51, label %54, label %.preheader.8

.preheader.8:                                     ; preds = %.preheader.7
  %52 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 36), align 4, !tbaa !5
  %53 = icmp sgt i32 %52, 3
  br i1 %53, label %54, label %.thread19

54:                                               ; preds = %.preheader.8, %.preheader.7, %.preheader.6, %.preheader.5, %.preheader.4, %.preheader.3, %.preheader.2, %.preheader.1, %.preheader.preheader
  %.lcssa29 = phi i64 [ 1, %.preheader.preheader ], [ 2, %.preheader.1 ], [ 3, %.preheader.2 ], [ 4, %.preheader.3 ], [ 5, %.preheader.4 ], [ 6, %.preheader.5 ], [ 7, %.preheader.6 ], [ 8, %.preheader.7 ], [ 9, %.preheader.8 ]
  %.lcssa = phi i32 [ %36, %.preheader.preheader ], [ %38, %.preheader.1 ], [ %40, %.preheader.2 ], [ %42, %.preheader.3 ], [ %44, %.preheader.4 ], [ %46, %.preheader.5 ], [ %48, %.preheader.6 ], [ %50, %.preheader.7 ], [ %52, %.preheader.8 ]
  %55 = getelementptr inbounds [10 x i32], ptr @a, i64 0, i64 %.lcssa29
  %56 = add nsw i32 %.lcssa, -4
  store i32 %56, ptr %55, align 4, !tbaa !5
  %57 = load <8 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4
  %.fr = freeze <8 x i32> %57
  %58 = icmp eq <8 x i32> %.fr, <i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2, i32 2>
  %59 = load i32, ptr getelementptr inbounds (i8, ptr @a, i64 36), align 4
  %60 = icmp eq i32 %59, 2
  %61 = bitcast <8 x i1> %58 to i8
  %62 = icmp ne i8 %61, 0
  %op.rdx = select i1 %62, i1 true, i1 %60
  %.str.1..str.2 = select i1 %op.rdx, ptr @.str.1, ptr @.str.2
  br label %.thread19

.thread19:                                        ; preds = %54, %.preheader.8
  %.str.1.sink = phi ptr [ @.str.3, %.preheader.8 ], [ %.str.1..str.2, %54 ]
  %63 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) %.str.1.sink)
  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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass