; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/220 Division 2/Problem C/C.ll (Z3dfsiiii)

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

@grid = external dso_local global [1000 x [1000 x i32]], align 16
@dp = external dso_local global [1000 x [1000 x i32]], align 16
@color = external dso_local global [1000 x [1000 x i32]], align 16
@mx = external dso_local global i32, align 4
@flag = external dso_local global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z7inrangeii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z3dfsiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #1 {
  %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
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  %15 = load i32, ptr @flag, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %4
  store i32 0, ptr %5, align 4
  br label %205

18:                                               ; preds = %4
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [1000 x [1000 x i32]], ptr @grid, i64 0, i64 %20
  %22 = load i32, ptr %7, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [1000 x i32], ptr %21, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = srem i32 %26, 4
  %28 = add nsw i32 %27, 1
  %29 = icmp ne i32 %25, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %18
  store i32 0, ptr %5, align 4
  br label %205

31:                                               ; preds = %18
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [1000 x [1000 x i32]], ptr @color, i64 0, i64 %33
  %35 = load i32, ptr %7, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [1000 x i32], ptr %34, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = load i32, ptr %9, align 4, !tbaa !5
  %40 = icmp eq i32 %38, %39
  br i1 %40, label %41, label %60

41:                                               ; preds = %31
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1000 x [1000 x i32]], ptr @grid, i64 0, i64 %43
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [1000 x i32], ptr %44, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = icmp eq i32 %48, 1
  br i1 %49, label %50, label %60

50:                                               ; preds = %41
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %52
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [1000 x i32], ptr %53, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = icmp eq i32 %57, -1
  br i1 %58, label %59, label %60

59:                                               ; preds = %50
  store i32 1, ptr @flag, align 4, !tbaa !5
  store i32 0, ptr %5, align 4
  br label %205

60:                                               ; preds = %50, %41, %31
  %61 = load i32, ptr %6, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %62
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1000 x i32], ptr %63, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = icmp sgt i32 %67, 0
  br i1 %68, label %69, label %77

69:                                               ; preds = %60
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %71
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1000 x i32], ptr %72, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  store i32 %76, ptr %5, align 4
  br label %205

77:                                               ; preds = %60
  %78 = load i32, ptr %9, align 4, !tbaa !5
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [1000 x [1000 x i32]], ptr @color, i64 0, i64 %80
  %82 = load i32, ptr %7, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [1000 x i32], ptr %81, i64 0, i64 %83
  store i32 %78, ptr %84, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !5
  %85 = load i32, ptr %6, align 4, !tbaa !5
  %86 = add nsw i32 %85, 1
  %87 = load i32, ptr %7, align 4, !tbaa !5
  %88 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %86, i32 noundef %87)
  br i1 %88, label %89, label %107

89:                                               ; preds = %77
  %90 = load i32, ptr @flag, align 4, !tbaa !5
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %107, label %92

92:                                               ; preds = %89
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  %95 = load i32, ptr %7, align 4, !tbaa !5
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [1000 x [1000 x i32]], ptr @grid, i64 0, i64 %97
  %99 = load i32, ptr %7, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [1000 x i32], ptr %98, i64 0, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = load i32, ptr %9, align 4, !tbaa !5
  %104 = call noundef i32 @_Z3dfsiiii(i32 noundef %94, i32 noundef %95, i32 noundef %102, i32 noundef %103)
  store i32 %104, ptr %11, align 4, !tbaa !5
  %105 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %106 = load i32, ptr %105, align 4, !tbaa !5
  store i32 %106, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %107

107:                                              ; preds = %92, %89, %77
  %108 = load i32, ptr %6, align 4, !tbaa !5
  %109 = sub nsw i32 %108, 1
  %110 = load i32, ptr %7, align 4, !tbaa !5
  %111 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %109, i32 noundef %110)
  br i1 %111, label %112, label %130

112:                                              ; preds = %107
  %113 = load i32, ptr @flag, align 4, !tbaa !5
  %114 = icmp ne i32 %113, 0
  br i1 %114, label %130, label %115

115:                                              ; preds = %112
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %116 = load i32, ptr %6, align 4, !tbaa !5
  %117 = sub nsw i32 %116, 1
  %118 = load i32, ptr %7, align 4, !tbaa !5
  %119 = load i32, ptr %6, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [1000 x [1000 x i32]], ptr @grid, i64 0, i64 %120
  %122 = load i32, ptr %7, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [1000 x i32], ptr %121, i64 0, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  %126 = load i32, ptr %9, align 4, !tbaa !5
  %127 = call noundef i32 @_Z3dfsiiii(i32 noundef %117, i32 noundef %118, i32 noundef %125, i32 noundef %126)
  store i32 %127, ptr %12, align 4, !tbaa !5
  %128 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %129 = load i32, ptr %128, align 4, !tbaa !5
  store i32 %129, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %130

130:                                              ; preds = %115, %112, %107
  %131 = load i32, ptr %6, align 4, !tbaa !5
  %132 = load i32, ptr %7, align 4, !tbaa !5
  %133 = add nsw i32 %132, 1
  %134 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %131, i32 noundef %133)
  br i1 %134, label %135, label %153

135:                                              ; preds = %130
  %136 = load i32, ptr @flag, align 4, !tbaa !5
  %137 = icmp ne i32 %136, 0
  br i1 %137, label %153, label %138

138:                                              ; preds = %135
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %139 = load i32, ptr %6, align 4, !tbaa !5
  %140 = load i32, ptr %7, align 4, !tbaa !5
  %141 = add nsw i32 %140, 1
  %142 = load i32, ptr %6, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [1000 x [1000 x i32]], ptr @grid, i64 0, i64 %143
  %145 = load i32, ptr %7, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [1000 x i32], ptr %144, i64 0, i64 %146
  %148 = load i32, ptr %147, align 4, !tbaa !5
  %149 = load i32, ptr %9, align 4, !tbaa !5
  %150 = call noundef i32 @_Z3dfsiiii(i32 noundef %139, i32 noundef %141, i32 noundef %148, i32 noundef %149)
  store i32 %150, ptr %13, align 4, !tbaa !5
  %151 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %152 = load i32, ptr %151, align 4, !tbaa !5
  store i32 %152, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %153

153:                                              ; preds = %138, %135, %130
  %154 = load i32, ptr %6, align 4, !tbaa !5
  %155 = load i32, ptr %7, align 4, !tbaa !5
  %156 = sub nsw i32 %155, 1
  %157 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %154, i32 noundef %156)
  br i1 %157, label %158, label %176

158:                                              ; preds = %153
  %159 = load i32, ptr @flag, align 4, !tbaa !5
  %160 = icmp ne i32 %159, 0
  br i1 %160, label %176, label %161

161:                                              ; preds = %158
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %162 = load i32, ptr %6, align 4, !tbaa !5
  %163 = load i32, ptr %7, align 4, !tbaa !5
  %164 = sub nsw i32 %163, 1
  %165 = load i32, ptr %6, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [1000 x [1000 x i32]], ptr @grid, i64 0, i64 %166
  %168 = load i32, ptr %7, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [1000 x i32], ptr %167, i64 0, i64 %169
  %171 = load i32, ptr %170, align 4, !tbaa !5
  %172 = load i32, ptr %9, align 4, !tbaa !5
  %173 = call noundef i32 @_Z3dfsiiii(i32 noundef %162, i32 noundef %164, i32 noundef %171, i32 noundef %172)
  store i32 %173, ptr %14, align 4, !tbaa !5
  %174 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %14)
  %175 = load i32, ptr %174, align 4, !tbaa !5
  store i32 %175, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %176

176:                                              ; preds = %161, %158, %153
  %177 = load i32, ptr %6, align 4, !tbaa !5
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [1000 x [1000 x i32]], ptr @grid, i64 0, i64 %178
  %180 = load i32, ptr %7, align 4, !tbaa !5
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [1000 x i32], ptr %179, i64 0, i64 %181
  %183 = load i32, ptr %182, align 4, !tbaa !5
  %184 = icmp eq i32 %183, 4
  br i1 %184, label %185, label %188

185:                                              ; preds = %176
  %186 = load i32, ptr %10, align 4, !tbaa !5
  %187 = add nsw i32 %186, 1
  store i32 %187, ptr %10, align 4, !tbaa !5
  br label %188

188:                                              ; preds = %185, %176
  %189 = load i32, ptr %10, align 4, !tbaa !5
  %190 = load i32, ptr %6, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %191
  %193 = load i32, ptr %7, align 4, !tbaa !5
  %194 = sext i32 %193 to i64
  %195 = getelementptr inbounds [1000 x i32], ptr %192, i64 0, i64 %194
  store i32 %189, ptr %195, align 4, !tbaa !5
  %196 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @mx, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %197 = load i32, ptr %196, align 4, !tbaa !5
  store i32 %197, ptr @mx, align 4, !tbaa !5
  %198 = load i32, ptr %6, align 4, !tbaa !5
  %199 = sext i32 %198 to i64
  %200 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %199
  %201 = load i32, ptr %7, align 4, !tbaa !5
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [1000 x i32], ptr %200, i64 0, i64 %202
  %204 = load i32, ptr %203, align 4, !tbaa !5
  store i32 %204, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %205

205:                                              ; preds = %188, %69, %59, %30, %17
  %206 = load i32, ptr %5, align 4
  ret i32 %206
}

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

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

attributes #0 = { 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 #1 = { 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 #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 = { 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"}


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

@grid = external dso_local local_unnamed_addr global [1000 x [1000 x i32]], align 16
@dp = external dso_local local_unnamed_addr global [1000 x [1000 x i32]], align 16
@color = external dso_local local_unnamed_addr global [1000 x [1000 x i32]], align 16
@mx = external dso_local global i32, align 4
@flag = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z7inrangeii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z3dfsiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %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 = load i32, ptr @flag, align 4, !tbaa !5
  %.not64 = icmp eq i32 %10, 0
  br i1 %.not64, label %11, label %79

11:                                               ; preds = %4
  %12 = sext i32 %0 to i64
  %13 = sext i32 %1 to i64
  %14 = getelementptr inbounds [1000 x [1000 x i32]], ptr @grid, i64 0, i64 %12, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = srem i32 %2, 4
  %17 = add nsw i32 %16, 1
  %.not65 = icmp eq i32 %15, %17
  br i1 %.not65, label %18, label %79

18:                                               ; preds = %11
  %19 = getelementptr inbounds [1000 x [1000 x i32]], ptr @color, i64 0, i64 %12, i64 %13
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = icmp eq i32 %20, %3
  %22 = icmp eq i32 %15, 1
  %or.cond = and i1 %22, %21
  %23 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %12, i64 %13
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = icmp eq i32 %24, -1
  %or.cond70 = select i1 %or.cond, i1 %25, i1 false
  br i1 %or.cond70, label %26, label %._crit_edge

26:                                               ; preds = %18
  store i32 1, ptr @flag, align 4, !tbaa !5
  br label %79

._crit_edge:                                      ; preds = %18
  %27 = getelementptr inbounds [1000 x [1000 x i32]], ptr @dp, i64 0, i64 %12, i64 %13
  %28 = icmp sgt i32 %24, 0
  br i1 %28, label %79, label %29

29:                                               ; preds = %._crit_edge
  store i32 %3, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  %30 = add nsw i32 %0, 1
  %31 = tail call noundef zeroext i1 @_Z7inrangeii(i32 noundef %30, i32 noundef %1)
  %32 = load i32, ptr @flag, align 4
  %33 = icmp eq i32 %32, 0
  %or.cond.not = select i1 %31, i1 %33, i1 false
  br i1 %or.cond.not, label %34, label %39

34:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %35 = load i32, ptr %14, align 4, !tbaa !5
  %36 = tail call noundef i32 @_Z3dfsiiii(i32 noundef %30, i32 noundef %1, i32 noundef %35, i32 noundef %3)
  store i32 %36, ptr %6, align 4, !tbaa !5
  %37 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %38 = load i32, ptr %37, align 4, !tbaa !5
  store i32 %38, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  br label %39

39:                                               ; preds = %34, %29
  %40 = add nsw i32 %0, -1
  %41 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %40, i32 noundef %1)
  %42 = load i32, ptr @flag, align 4
  %43 = icmp eq i32 %42, 0
  %or.cond4.not = select i1 %41, i1 %43, i1 false
  br i1 %or.cond4.not, label %44, label %49

44:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  %45 = load i32, ptr %14, align 4, !tbaa !5
  %46 = call noundef i32 @_Z3dfsiiii(i32 noundef %40, i32 noundef %1, i32 noundef %45, i32 noundef %3)
  store i32 %46, ptr %7, align 4, !tbaa !5
  %47 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %48 = load i32, ptr %47, align 4, !tbaa !5
  store i32 %48, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #3
  br label %49

49:                                               ; preds = %44, %39
  %50 = add nsw i32 %1, 1
  %51 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %0, i32 noundef %50)
  %52 = load i32, ptr @flag, align 4
  %53 = icmp eq i32 %52, 0
  %or.cond7.not = select i1 %51, i1 %53, i1 false
  br i1 %or.cond7.not, label %54, label %59

54:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  %55 = load i32, ptr %14, align 4, !tbaa !5
  %56 = call noundef i32 @_Z3dfsiiii(i32 noundef %0, i32 noundef %50, i32 noundef %55, i32 noundef %3)
  store i32 %56, ptr %8, align 4, !tbaa !5
  %57 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %58 = load i32, ptr %57, align 4, !tbaa !5
  store i32 %58, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  br label %59

59:                                               ; preds = %54, %49
  %60 = add nsw i32 %1, -1
  %61 = call noundef zeroext i1 @_Z7inrangeii(i32 noundef %0, i32 noundef %60)
  %62 = load i32, ptr @flag, align 4
  %63 = icmp eq i32 %62, 0
  %or.cond10.not = select i1 %61, i1 %63, i1 false
  br i1 %or.cond10.not, label %64, label %._crit_edge68

._crit_edge68:                                    ; preds = %59
  %.pre67.pre = load i32, ptr %5, align 4, !tbaa !5
  br label %69

64:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  %65 = load i32, ptr %14, align 4, !tbaa !5
  %66 = call noundef i32 @_Z3dfsiiii(i32 noundef %0, i32 noundef %60, i32 noundef %65, i32 noundef %3)
  store i32 %66, ptr %9, align 4, !tbaa !5
  %67 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %68 = load i32, ptr %67, align 4, !tbaa !5
  store i32 %68, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  br label %69

69:                                               ; preds = %._crit_edge68, %64
  %.pre67 = phi i32 [ %.pre67.pre, %._crit_edge68 ], [ %68, %64 ]
  %70 = load i32, ptr %14, align 4, !tbaa !5
  %71 = icmp eq i32 %70, 4
  br i1 %71, label %72, label %74

72:                                               ; preds = %69
  %73 = add nsw i32 %.pre67, 1
  store i32 %73, ptr %5, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %72, %69
  %75 = phi i32 [ %73, %72 ], [ %.pre67, %69 ]
  store i32 %75, ptr %27, align 4, !tbaa !5
  %76 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @mx, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %77 = load i32, ptr %76, align 4, !tbaa !5
  store i32 %77, ptr @mx, align 4, !tbaa !5
  %78 = load i32, ptr %27, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #3
  br label %79

79:                                               ; preds = %._crit_edge, %11, %4, %74, %26
  %.0 = phi i32 [ 0, %26 ], [ %78, %74 ], [ 0, %4 ], [ 0, %11 ], [ %24, %._crit_edge ]
  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: 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 #2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass