; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/59 Beta Division 2/Problem D (D)

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

@g = external dso_local global [101 x [101 x i32]], align 16
@a = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@c = external dso_local global i32, align 4
@d = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i8, align 1
  %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
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @a, ptr noundef @b)
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @c, ptr noundef @d)
  call void @llvm.lifetime.start.p0(i64 1, ptr %2) #5
  store i8 0, ptr %2, align 1, !tbaa !5
  %18 = load i32, ptr @b, align 4, !tbaa !9
  %19 = load i32, ptr @d, align 4, !tbaa !9
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %0
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @a, ptr noundef nonnull align 4 dereferenceable(4) @c) #5
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @b, ptr noundef nonnull align 4 dereferenceable(4) @d) #5
  store i8 1, ptr %2, align 1, !tbaa !5
  br label %22

22:                                               ; preds = %21, %0
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %23 = load i32, ptr @d, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %3, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %50, %22
  %26 = load i32, ptr %3, align 4, !tbaa !9
  %27 = load i32, ptr @b, align 4, !tbaa !9
  %28 = icmp sle i32 %26, %27
  br i1 %28, label %30, label %29

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

30:                                               ; preds = %25
  %31 = load i32, ptr %3, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [101 x [101 x i32]], ptr @g, i64 0, i64 %32
  %34 = getelementptr inbounds [101 x i32], ptr %33, i64 0, i64 0
  %35 = load i32, ptr @a, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i32, ptr %34, i64 %36
  %38 = getelementptr inbounds i32, ptr %37, i64 1
  %39 = load i32, ptr %3, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [101 x [101 x i32]], ptr @g, i64 0, i64 %40
  %42 = getelementptr inbounds [101 x i32], ptr %41, i64 0, i64 0
  %43 = load i32, ptr @a, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i32, ptr %42, i64 %44
  %46 = load i32, ptr @c, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr %45, i64 %47
  %49 = getelementptr inbounds i32, ptr %48, i64 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 -1, ptr %4, align 4, !tbaa !9
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef %38, ptr noundef %49, ptr noundef nonnull align 4 dereferenceable(4) %4)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %50

50:                                               ; preds = %30
  %51 = load i32, ptr %3, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %3, align 4, !tbaa !9
  br label %25, !llvm.loop !11

53:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %54 = load i32, ptr @b, align 4, !tbaa !9
  store i32 %54, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %55 = load i32, ptr @b, align 4, !tbaa !9
  %56 = load i32, ptr @d, align 4, !tbaa !9
  %57 = sub nsw i32 %55, %56
  %58 = srem i32 %57, 2
  %59 = icmp eq i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %53
  br label %63

61:                                               ; preds = %53
  %62 = load i32, ptr @a, align 4, !tbaa !9
  br label %63

63:                                               ; preds = %61, %60
  %64 = phi i32 [ 1, %60 ], [ %62, %61 ]
  store i32 %64, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %65 = load i32, ptr @b, align 4, !tbaa !9
  %66 = load i32, ptr @d, align 4, !tbaa !9
  %67 = sub nsw i32 %65, %66
  %68 = srem i32 %67, 2
  %69 = icmp eq i32 %68, 0
  %70 = zext i1 %69 to i64
  %71 = select i1 %69, i32 1, i32 -1
  store i32 %71, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %72 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %82, %63
  %74 = load i32, ptr %10, align 4, !tbaa !9
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = icmp sle i32 %74, %75
  br i1 %76, label %78, label %77

77:                                               ; preds = %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %85

78:                                               ; preds = %73
  %79 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %9)
  %80 = load i32, ptr %9, align 4, !tbaa !9
  %81 = load i32, ptr %10, align 4, !tbaa !9
  call void @_Z5paintRiS_S_ii(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %7, i32 noundef %80, i32 noundef %81)
  br label %82

82:                                               ; preds = %78
  %83 = load i32, ptr %10, align 4, !tbaa !9
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %10, align 4, !tbaa !9
  br label %73, !llvm.loop !13

85:                                               ; preds = %77
  %86 = load i8, ptr %2, align 1, !tbaa !5, !range !14, !noundef !15
  %87 = trunc i8 %86 to i1
  br i1 %87, label %88, label %115

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

89:                                               ; preds = %111, %88
  %90 = load i32, ptr %11, align 4, !tbaa !9
  %91 = load i32, ptr @b, align 4, !tbaa !9
  %92 = icmp sle i32 %90, %91
  br i1 %92, label %94, label %93

93:                                               ; preds = %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %114

94:                                               ; preds = %89
  %95 = load i32, ptr %11, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [101 x [101 x i32]], ptr @g, i64 0, i64 %96
  %98 = getelementptr inbounds [101 x i32], ptr %97, i64 0, i64 0
  %99 = getelementptr inbounds i32, ptr %98, i64 1
  %100 = load i32, ptr %11, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [101 x [101 x i32]], ptr @g, i64 0, i64 %101
  %103 = getelementptr inbounds [101 x i32], ptr %102, i64 0, i64 0
  %104 = getelementptr inbounds i32, ptr %103, i64 1
  %105 = load i32, ptr @a, align 4, !tbaa !9
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds i32, ptr %104, i64 %106
  %108 = load i32, ptr @c, align 4, !tbaa !9
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds i32, ptr %107, i64 %109
  call void @_ZSt7reverseIPiEvT_S1_(ptr noundef %99, ptr noundef %110)
  br label %111

111:                                              ; preds = %94
  %112 = load i32, ptr %11, align 4, !tbaa !9
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %11, align 4, !tbaa !9
  br label %89, !llvm.loop !16

114:                                              ; preds = %93
  br label %115

115:                                              ; preds = %114, %85
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %116 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @b, ptr noundef nonnull align 4 dereferenceable(4) @d)
  %117 = load i32, ptr %116, align 4, !tbaa !9
  store i32 %117, ptr %12, align 4, !tbaa !9
  %118 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 1, ptr %13, align 4, !tbaa !9
  br label %119

119:                                              ; preds = %162, %115
  %120 = load i32, ptr %13, align 4, !tbaa !9
  %121 = load i32, ptr %12, align 4, !tbaa !9
  %122 = icmp sle i32 %120, %121
  br i1 %122, label %124, label %123

123:                                              ; preds = %119
  store i32 11, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %165

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

125:                                              ; preds = %157, %124
  %126 = load i32, ptr %15, align 4, !tbaa !9
  %127 = load i32, ptr @a, align 4, !tbaa !9
  %128 = load i32, ptr @c, align 4, !tbaa !9
  %129 = add nsw i32 %127, %128
  %130 = icmp sle i32 %126, %129
  br i1 %130, label %132, label %131

131:                                              ; preds = %125
  store i32 14, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %160

132:                                              ; preds = %125
  %133 = load i32, ptr %13, align 4, !tbaa !9
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [101 x [101 x i32]], ptr @g, i64 0, i64 %134
  %136 = load i32, ptr %15, align 4, !tbaa !9
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [101 x i32], ptr %135, i64 0, i64 %137
  %139 = load i32, ptr %138, align 4, !tbaa !9
  %140 = icmp ne i32 %139, -1
  br i1 %140, label %141, label %152

141:                                              ; preds = %132
  %142 = load i32, ptr %13, align 4, !tbaa !9
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [101 x [101 x i32]], ptr @g, i64 0, i64 %143
  %145 = load i32, ptr %15, align 4, !tbaa !9
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [101 x i32], ptr %144, i64 0, i64 %146
  %148 = load i32, ptr %147, align 4, !tbaa !9
  %149 = add nsw i32 97, %148
  %150 = sub nsw i32 %149, 1
  %151 = trunc i32 %150 to i8
  br label %153

152:                                              ; preds = %132
  br label %153

153:                                              ; preds = %152, %141
  %154 = phi i8 [ %151, %141 ], [ 46, %152 ]
  %155 = sext i8 %154 to i32
  %156 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %155)
  br label %157

157:                                              ; preds = %153
  %158 = load i32, ptr %15, align 4, !tbaa !9
  %159 = add nsw i32 %158, 1
  store i32 %159, ptr %15, align 4, !tbaa !9
  br label %125, !llvm.loop !17

160:                                              ; preds = %131
  %161 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %162

162:                                              ; preds = %160
  %163 = load i32, ptr %13, align 4, !tbaa !9
  %164 = add nsw i32 %163, 1
  store i32 %164, ptr %13, align 4, !tbaa !9
  br label %119, !llvm.loop !18

165:                                              ; preds = %123
  store i32 0, ptr %1, align 4
  store i32 1, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #5
  %166 = load i32, ptr %1, align 4
  ret i32 %166
}

declare i32 @__isoc99_scanf(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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #4

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z5paintRiS_S_ii(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIPiEvT_S1_(ptr noundef, ptr noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

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 = { inlinehint mustprogress 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 #4 = { inlinehint mustprogress 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 #5 = { 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}


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

@g = external dso_local global [101 x [101 x i32]], align 16
@a = external dso_local global i32, align 4
@b = external dso_local global i32, align 4
@c = external dso_local global i32, align 4
@d = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #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 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @a, ptr noundef nonnull @b)
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @c, ptr noundef nonnull @d)
  %9 = load i32, ptr @b, align 4, !tbaa !5
  %10 = load i32, ptr @d, align 4, !tbaa !5
  %11 = icmp sge i32 %9, %10
  br i1 %11, label %13, label %12

12:                                               ; preds = %0
  tail call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @a, ptr noundef nonnull align 4 dereferenceable(4) @c) #5
  tail call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @b, ptr noundef nonnull align 4 dereferenceable(4) @d) #5
  %.pre = load i32, ptr @d, align 4, !tbaa !5
  %.pre63 = load i32, ptr @b, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %12, %0
  %14 = phi i32 [ %.pre63, %12 ], [ %9, %0 ]
  %15 = phi i32 [ %.pre, %12 ], [ %10, %0 ]
  %.not.not33 = icmp slt i32 %15, %14
  br i1 %.not.not33, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %13
  %16 = sext i32 %15 to i64
  br label %.lr.ph

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre64 = load i32, ptr @d, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %13
  %17 = phi i32 [ %15, %13 ], [ %.pre64, %._crit_edge.loopexit ]
  %.lcssa = phi i32 [ %14, %13 ], [ %35, %._crit_edge.loopexit ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  store i32 %.lcssa, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %18 = sub nsw i32 %.lcssa, %17
  %19 = and i32 %18, 1
  %20 = icmp eq i32 %19, 0
  %21 = load i32, ptr @a, align 4
  %22 = select i1 %20, i32 1, i32 %21
  store i32 %22, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %23 = select i1 %20, i32 1, i32 -1
  store i32 %23, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  %24 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %5)
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %.not35 = icmp slt i32 %25, 1
  br i1 %.not35, label %._crit_edge39, label %.lr.ph38

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %16, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %26 = getelementptr inbounds [101 x [101 x i32]], ptr @g, i64 0, i64 %indvars.iv.next
  %27 = load i32, ptr @a, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr %26, i64 %28
  %30 = getelementptr inbounds i8, ptr %29, i64 4
  %31 = load i32, ptr @c, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds i32, ptr %29, i64 %32
  %34 = getelementptr inbounds i8, ptr %33, i64 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  store i32 -1, ptr %1, align 4, !tbaa !5
  call void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef nonnull %30, ptr noundef nonnull %34, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %35 = load i32, ptr @b, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %.not.not = icmp slt i64 %indvars.iv.next, %36
  br i1 %.not.not, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !9

._crit_edge39:                                    ; preds = %.lr.ph38, %._crit_edge
  %37 = load i32, ptr @b, align 4
  %.not2840 = icmp slt i32 %37, 1
  %or.cond = select i1 %11, i1 true, i1 %.not2840
  br i1 %or.cond, label %.loopexit, label %.lr.ph42

.lr.ph38:                                         ; preds = %._crit_edge, %.lr.ph38
  %.02436 = phi i32 [ %40, %.lr.ph38 ], [ 1, %._crit_edge ]
  %38 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %6)
  %39 = load i32, ptr %6, align 4, !tbaa !5
  call void @_Z5paintRiS_S_ii(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4, i32 noundef %39, i32 noundef %.02436)
  %40 = add nuw nsw i32 %.02436, 1
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %.not.not51 = icmp slt i32 %.02436, %41
  br i1 %.not.not51, label %.lr.ph38, label %._crit_edge39, !llvm.loop !11

.lr.ph42:                                         ; preds = %._crit_edge39, %.lr.ph42
  %indvars.iv54 = phi i64 [ %indvars.iv.next55, %.lr.ph42 ], [ 1, %._crit_edge39 ]
  %42 = getelementptr inbounds [101 x [101 x i32]], ptr @g, i64 0, i64 %indvars.iv54, i64 1
  %43 = load i32, ptr @a, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i32, ptr %42, i64 %44
  %46 = load i32, ptr @c, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr %45, i64 %47
  call void @_ZSt7reverseIPiEvT_S1_(ptr noundef nonnull %42, ptr noundef nonnull %48)
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %49 = load i32, ptr @b, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %.not28.not = icmp slt i64 %indvars.iv54, %50
  br i1 %.not28.not, label %.lr.ph42, label %.loopexit, !llvm.loop !12

.loopexit:                                        ; preds = %.lr.ph42, %._crit_edge39
  %51 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @b, ptr noundef nonnull align 4 dereferenceable(4) @d)
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %.not2947 = icmp slt i32 %52, 1
  br i1 %.not2947, label %._crit_edge49, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.loopexit
  %54 = add nuw i32 %52, 1
  %wide.trip.count = zext i32 %54 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge46
  %indvars.iv60 = phi i64 [ 1, %.preheader.preheader ], [ %indvars.iv.next61, %._crit_edge46 ]
  %55 = load i32, ptr @a, align 4, !tbaa !5
  %56 = load i32, ptr @c, align 4, !tbaa !5
  %57 = add nsw i32 %56, %55
  %.not3043 = icmp slt i32 %57, 1
  br i1 %.not3043, label %._crit_edge46, label %.lr.ph45

._crit_edge49:                                    ; preds = %._crit_edge46, %.loopexit
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  ret i32 0

._crit_edge46:                                    ; preds = %.lr.ph45, %.preheader
  %58 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next61, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge49, label %.preheader, !llvm.loop !13

.lr.ph45:                                         ; preds = %.preheader, %.lr.ph45
  %indvars.iv57 = phi i64 [ %indvars.iv.next58, %.lr.ph45 ], [ 1, %.preheader ]
  %59 = getelementptr inbounds [101 x [101 x i32]], ptr @g, i64 0, i64 %indvars.iv60, i64 %indvars.iv57
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %.not31 = icmp eq i32 %60, -1
  %61 = shl i32 %60, 24
  %62 = add i32 %61, 1610612736
  %63 = ashr exact i32 %62, 24
  %64 = select i1 %.not31, i32 46, i32 %63
  %65 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %64)
  %indvars.iv.next58 = add nuw nsw i64 %indvars.iv57, 1
  %66 = load i32, ptr @a, align 4, !tbaa !5
  %67 = load i32, ptr @c, align 4, !tbaa !5
  %68 = add nsw i32 %67, %66
  %69 = sext i32 %68 to i64
  %.not30.not = icmp slt i64 %indvars.iv57, %69
  br i1 %.not30.not, label %.lr.ph45, label %._crit_edge46, !llvm.loop !14
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIPiiEvT_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z5paintRiS_S_ii(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt7reverseIPiEvT_S1_(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

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 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress 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 #4 = { inlinehint mustprogress 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 #5 = { 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}


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