; LLVM IR from reyadussalahin/problem-solving :: math/basic/uva/F12108 (Solution)

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

@mode = external dso_local global [12 x i32], align 16
@a = external dso_local global [12 x i32], align 16
@b = external dso_local global [12 x i32], align 16
@c = external dso_local global [12 x i32], align 16
@.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 [13 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
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 1, ptr %3, align 4, !tbaa !5
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %13

13:                                               ; preds = %169, %0
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %16, label %173

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

17:                                               ; preds = %60, %16
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %63

22:                                               ; preds = %17
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [12 x i32], ptr @a, i64 0, i64 %24
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [12 x i32], ptr @b, i64 0, i64 %27
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [12 x i32], ptr @c, i64 0, i64 %30
  %32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %25, ptr noundef %28, ptr noundef %31)
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [12 x i32], ptr @c, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [12 x i32], ptr @a, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = icmp sgt i32 %36, %40
  br i1 %41, label %42, label %55

42:                                               ; preds = %22
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [12 x i32], ptr @mode, i64 0, i64 %44
  store i32 1, ptr %45, align 4, !tbaa !5
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [12 x i32], ptr @a, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [12 x i32], ptr @c, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sub nsw i32 %53, %49
  store i32 %54, ptr %52, align 4, !tbaa !5
  br label %59

55:                                               ; preds = %22
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [12 x i32], ptr @mode, i64 0, i64 %57
  store i32 0, ptr %58, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %55, %42
  br label %60

60:                                               ; preds = %59
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %4, align 4, !tbaa !5
  br label %17, !llvm.loop !9

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

64:                                               ; preds = %161, %63
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = icmp sle i32 %65, 1000000
  br i1 %66, label %68, label %67

67:                                               ; preds = %64
  store i32 8, ptr %7, align 4
  br label %164

68:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %87, %68
  %70 = load i32, ptr %10, align 4, !tbaa !5
  %71 = load i32, ptr %2, align 4, !tbaa !5
  %72 = icmp slt i32 %70, %71
  br i1 %72, label %74, label %73

73:                                               ; preds = %69
  store i32 11, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %90

74:                                               ; preds = %69
  %75 = load i32, ptr %10, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [12 x i32], ptr @mode, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %83

80:                                               ; preds = %74
  %81 = load i32, ptr %8, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %8, align 4, !tbaa !5
  br label %86

83:                                               ; preds = %74
  %84 = load i32, ptr %9, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %9, align 4, !tbaa !5
  br label %86

86:                                               ; preds = %83, %80
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %10, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %10, align 4, !tbaa !5
  br label %69, !llvm.loop !11

90:                                               ; preds = %73
  %91 = load i32, ptr %8, align 4, !tbaa !5
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %95, label %93

93:                                               ; preds = %90
  %94 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %94, ptr %5, align 4, !tbaa !5
  store i32 8, ptr %7, align 4
  br label %158

95:                                               ; preds = %90
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %154, %95
  %97 = load i32, ptr %11, align 4, !tbaa !5
  %98 = load i32, ptr %2, align 4, !tbaa !5
  %99 = icmp slt i32 %97, %98
  br i1 %99, label %101, label %100

100:                                              ; preds = %96
  store i32 14, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %157

101:                                              ; preds = %96
  %102 = load i32, ptr %11, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [12 x i32], ptr @c, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %104, align 4, !tbaa !5
  %107 = load i32, ptr %11, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [12 x i32], ptr @mode, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = icmp ne i32 %110, 0
  br i1 %111, label %112, label %130

112:                                              ; preds = %101
  %113 = load i32, ptr %11, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [12 x i32], ptr @c, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !5
  %117 = load i32, ptr %11, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [12 x i32], ptr @b, i64 0, i64 %118
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = icmp sgt i32 %116, %120
  br i1 %121, label %122, label %129

122:                                              ; preds = %112
  %123 = load i32, ptr %11, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [12 x i32], ptr @c, i64 0, i64 %124
  store i32 1, ptr %125, align 4, !tbaa !5
  %126 = load i32, ptr %11, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [12 x i32], ptr @mode, i64 0, i64 %127
  store i32 0, ptr %128, align 4, !tbaa !5
  br label %129

129:                                              ; preds = %122, %112
  br label %153

130:                                              ; preds = %101
  %131 = load i32, ptr %11, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [12 x i32], ptr @c, i64 0, i64 %132
  %134 = load i32, ptr %133, align 4, !tbaa !5
  %135 = load i32, ptr %11, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [12 x i32], ptr @a, i64 0, i64 %136
  %138 = load i32, ptr %137, align 4, !tbaa !5
  %139 = icmp sgt i32 %134, %138
  br i1 %139, label %140, label %152

140:                                              ; preds = %130
  %141 = load i32, ptr %8, align 4, !tbaa !5
  %142 = load i32, ptr %9, align 4, !tbaa !5
  %143 = icmp sgt i32 %141, %142
  br i1 %143, label %144, label %148

144:                                              ; preds = %140
  %145 = load i32, ptr %11, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [12 x i32], ptr @mode, i64 0, i64 %146
  store i32 1, ptr %147, align 4, !tbaa !5
  br label %148

148:                                              ; preds = %144, %140
  %149 = load i32, ptr %11, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [12 x i32], ptr @c, i64 0, i64 %150
  store i32 1, ptr %151, align 4, !tbaa !5
  br label %152

152:                                              ; preds = %148, %130
  br label %153

153:                                              ; preds = %152, %129
  br label %154

154:                                              ; preds = %153
  %155 = load i32, ptr %11, align 4, !tbaa !5
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr %11, align 4, !tbaa !5
  br label %96, !llvm.loop !12

157:                                              ; preds = %100
  store i32 0, ptr %7, align 4
  br label %158

158:                                              ; preds = %157, %93
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %159 = load i32, ptr %7, align 4
  switch i32 %159, label %164 [
    i32 0, label %160
  ]

160:                                              ; preds = %158
  br label %161

161:                                              ; preds = %160
  %162 = load i32, ptr %6, align 4, !tbaa !5
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr %6, align 4, !tbaa !5
  br label %64, !llvm.loop !13

164:                                              ; preds = %158, %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %165

165:                                              ; preds = %164
  %166 = load i32, ptr %3, align 4, !tbaa !5
  %167 = load i32, ptr %5, align 4, !tbaa !5
  %168 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %166, i32 noundef %167)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %169

169:                                              ; preds = %165
  %170 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  %171 = load i32, ptr %3, align 4, !tbaa !5
  %172 = add nsw i32 %171, 1
  store i32 %172, ptr %3, align 4, !tbaa !5
  br label %13, !llvm.loop !14

173:                                              ; preds = %13
  store i32 0, ptr %1, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %174 = load i32, ptr %1, align 4
  ret i32 %174
}

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

@mode = external dso_local local_unnamed_addr global [12 x i32], align 16
@a = external dso_local global [12 x i32], align 16
@b = external dso_local global [12 x i32], align 16
@c = external dso_local global [12 x i32], align 16
@.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 [13 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %2 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %3 = load i32, ptr %1, align 4, !tbaa !5
  %.not86 = icmp eq i32 %3, 0
  br i1 %.not86, label %._crit_edge, label %.preheader57

.preheader57:                                     ; preds = %0, %.thread
  %4 = phi i32 [ %64, %.thread ], [ %3, %0 ]
  %.04887 = phi i32 [ %63, %.thread ], [ 1, %0 ]
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %.preheader56

.preheader56:                                     ; preds = %56, %.preheader57
  %.lcssa = phi i32 [ %4, %.preheader57 ], [ %58, %56 ]
  %.lcssa.fr = freeze i32 %.lcssa
  %6 = icmp sgt i32 %.lcssa.fr, 0
  br i1 %6, label %.preheader55.us.preheader, label %.thread

.preheader55.us.preheader:                        ; preds = %.preheader56
  %wide.trip.count99 = zext nneg i32 %.lcssa.fr to i64
  %wide.trip.count104 = zext nneg i32 %.lcssa.fr to i64
  %min.iters.check = icmp ult i32 %.lcssa.fr, 8
  %n.vec = and i64 %wide.trip.count99, 2147483640
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count99
  br label %.lr.ph62.us.preheader

.lr.ph62.us.preheader:                            ; preds = %._crit_edge67.us, %.preheader55.us.preheader
  %.04468.us = phi i32 [ %46, %._crit_edge67.us ], [ 1, %.preheader55.us.preheader ]
  br i1 %min.iters.check, label %.lr.ph62.us.preheader115, label %vector.body

.lr.ph62.us.preheader115:                         ; preds = %middle.block, %.lr.ph62.us.preheader
  %indvars.iv96.ph = phi i64 [ 0, %.lr.ph62.us.preheader ], [ %n.vec, %middle.block ]
  %.04060.us.ph = phi i32 [ 0, %.lr.ph62.us.preheader ], [ %22, %middle.block ]
  %.04159.us.ph = phi i32 [ 0, %.lr.ph62.us.preheader ], [ %23, %middle.block ]
  br label %.lr.ph62.us

vector.body:                                      ; preds = %.lr.ph62.us.preheader, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.lr.ph62.us.preheader ]
  %vec.phi = phi <4 x i32> [ %19, %vector.body ], [ zeroinitializer, %.lr.ph62.us.preheader ]
  %vec.phi109 = phi <4 x i32> [ %20, %vector.body ], [ zeroinitializer, %.lr.ph62.us.preheader ]
  %vec.phi110 = phi <4 x i32> [ %13, %vector.body ], [ zeroinitializer, %.lr.ph62.us.preheader ]
  %vec.phi111 = phi <4 x i32> [ %14, %vector.body ], [ zeroinitializer, %.lr.ph62.us.preheader ]
  %7 = getelementptr inbounds [12 x i32], ptr @mode, i64 0, i64 %index
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  %wide.load = load <4 x i32>, ptr %7, align 16, !tbaa !5
  %wide.load112 = load <4 x i32>, ptr %8, align 16, !tbaa !5
  %9 = icmp ne <4 x i32> %wide.load, zeroinitializer
  %10 = icmp ne <4 x i32> %wide.load112, zeroinitializer
  %11 = zext <4 x i1> %9 to <4 x i32>
  %12 = zext <4 x i1> %10 to <4 x i32>
  %13 = add <4 x i32> %vec.phi110, %11
  %14 = add <4 x i32> %vec.phi111, %12
  %15 = xor <4 x i1> %9, <i1 true, i1 true, i1 true, i1 true>
  %16 = xor <4 x i1> %10, <i1 true, i1 true, i1 true, i1 true>
  %17 = zext <4 x i1> %15 to <4 x i32>
  %18 = zext <4 x i1> %16 to <4 x i32>
  %19 = add <4 x i32> %vec.phi, %17
  %20 = add <4 x i32> %vec.phi109, %18
  %index.next = add nuw i64 %index, 8
  %21 = icmp eq i64 %index.next, %n.vec
  br i1 %21, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %20, %19
  %22 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %bin.rdx113 = add <4 x i32> %14, %13
  %23 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx113)
  br i1 %cmp.n, label %._crit_edge.us, label %.lr.ph62.us.preheader115

._crit_edge.us:                                   ; preds = %.lr.ph62.us, %middle.block
  %.142.us.lcssa = phi i32 [ %23, %middle.block ], [ %.142.us, %.lr.ph62.us ]
  %.1.us.lcssa = phi i32 [ %22, %middle.block ], [ %.1.us, %.lr.ph62.us ]
  %.not49.not.us = icmp eq i32 %.142.us.lcssa, 0
  br i1 %.not49.not.us, label %.thread, label %.preheader.us

24:                                               ; preds = %.preheader.us, %40
  %indvars.iv101 = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next102, %40 ]
  %25 = getelementptr inbounds [12 x i32], ptr @c, i64 0, i64 %indvars.iv101
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %25, align 4, !tbaa !5
  %28 = getelementptr inbounds [12 x i32], ptr @mode, i64 0, i64 %indvars.iv101
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %.not50.us = icmp eq i32 %29, 0
  br i1 %.not50.us, label %34, label %30

30:                                               ; preds = %24
  %31 = getelementptr inbounds [12 x i32], ptr @b, i64 0, i64 %indvars.iv101
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %.not52.us = icmp slt i32 %26, %32
  br i1 %.not52.us, label %40, label %33

33:                                               ; preds = %30
  store i32 1, ptr %25, align 4, !tbaa !5
  store i32 0, ptr %28, align 4, !tbaa !5
  br label %40

34:                                               ; preds = %24
  %35 = getelementptr inbounds [12 x i32], ptr @a, i64 0, i64 %indvars.iv101
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %.not51.us = icmp slt i32 %26, %36
  br i1 %.not51.us, label %40, label %37

37:                                               ; preds = %34
  br i1 %45, label %38, label %39

38:                                               ; preds = %37
  store i32 1, ptr %28, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %38, %37
  store i32 1, ptr %25, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %39, %34, %33, %30
  %indvars.iv.next102 = add nuw nsw i64 %indvars.iv101, 1
  %exitcond105.not = icmp eq i64 %indvars.iv.next102, %wide.trip.count104
  br i1 %exitcond105.not, label %._crit_edge67.us, label %24, !llvm.loop !13

.lr.ph62.us:                                      ; preds = %.lr.ph62.us.preheader115, %.lr.ph62.us
  %indvars.iv96 = phi i64 [ %indvars.iv.next97, %.lr.ph62.us ], [ %indvars.iv96.ph, %.lr.ph62.us.preheader115 ]
  %.04060.us = phi i32 [ %.1.us, %.lr.ph62.us ], [ %.04060.us.ph, %.lr.ph62.us.preheader115 ]
  %.04159.us = phi i32 [ %.142.us, %.lr.ph62.us ], [ %.04159.us.ph, %.lr.ph62.us.preheader115 ]
  %41 = getelementptr inbounds [12 x i32], ptr @mode, i64 0, i64 %indvars.iv96
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %.not53.us = icmp ne i32 %42, 0
  %43 = zext i1 %.not53.us to i32
  %.142.us = add nuw nsw i32 %.04159.us, %43
  %not..not53.us = xor i1 %.not53.us, true
  %44 = zext i1 %not..not53.us to i32
  %.1.us = add nuw nsw i32 %.04060.us, %44
  %indvars.iv.next97 = add nuw nsw i64 %indvars.iv96, 1
  %exitcond100.not = icmp eq i64 %indvars.iv.next97, %wide.trip.count99
  br i1 %exitcond100.not, label %._crit_edge.us, label %.lr.ph62.us, !llvm.loop !14

.preheader.us:                                    ; preds = %._crit_edge.us
  %45 = icmp ugt i32 %.142.us.lcssa, %.1.us.lcssa
  br label %24

._crit_edge67.us:                                 ; preds = %40
  %46 = add nuw nsw i32 %.04468.us, 1
  %exitcond106.not = icmp eq i32 %46, 1000001
  br i1 %exitcond106.not, label %.thread, label %.lr.ph62.us.preheader, !llvm.loop !15

.lr.ph:                                           ; preds = %.preheader57, %56
  %indvars.iv = phi i64 [ %indvars.iv.next, %56 ], [ 0, %.preheader57 ]
  %47 = getelementptr inbounds [12 x i32], ptr @a, i64 0, i64 %indvars.iv
  %48 = getelementptr inbounds [12 x i32], ptr @b, i64 0, i64 %indvars.iv
  %49 = getelementptr inbounds [12 x i32], ptr @c, i64 0, i64 %indvars.iv
  %50 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %47, ptr noundef nonnull %48, ptr noundef nonnull %49)
  %51 = load i32, ptr %49, align 4, !tbaa !5
  %52 = load i32, ptr %47, align 4, !tbaa !5
  %53 = icmp sgt i32 %51, %52
  br i1 %53, label %54, label %56

54:                                               ; preds = %.lr.ph
  %55 = sub nsw i32 %51, %52
  store i32 %55, ptr %49, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %.lr.ph, %54
  %.sink = phi i32 [ 1, %54 ], [ 0, %.lr.ph ]
  %57 = getelementptr inbounds [12 x i32], ptr @mode, i64 0, i64 %indvars.iv
  store i32 %.sink, ptr %57, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %58 = load i32, ptr %1, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = icmp slt i64 %indvars.iv.next, %59
  br i1 %60, label %.lr.ph, label %.preheader56, !llvm.loop !16

.thread:                                          ; preds = %._crit_edge.us, %._crit_edge67.us, %.preheader56
  %.us-phi = phi i32 [ 1, %.preheader56 ], [ -1, %._crit_edge67.us ], [ %.04468.us, %._crit_edge.us ]
  %61 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.04887, i32 noundef %.us-phi)
  %62 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %63 = add nuw nsw i32 %.04887, 1
  %64 = load i32, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %64, 0
  br i1 %.not, label %._crit_edge, label %.preheader57, !llvm.loop !17

._crit_edge:                                      ; preds = %.thread, %0
  call void @llvm.lifetime.end.p0(i64 4, 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: 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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #3

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10, !12, !11}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass