; LLVM IR from upupming/algorithm :: kick-start/2021/RoundA/C. Rabbit House-linear.ll (Z5solvev)

; 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 [310 x [310 x i32]], align 16
@r = external dso_local global i32, align 4
@c = external dso_local global i32, align 4
@sum = external dso_local global i64, align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z5solvev() #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
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %88, %0
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = load i32, ptr @r, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %91

20:                                               ; preds = %15
  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 = %50, %20
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = load i32, ptr @c, align 4, !tbaa !5
  %24 = icmp slt i32 %22, %23
  br i1 %24, label %26, label %25

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

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

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

53:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %54 = load i32, ptr @c, align 4, !tbaa !5
  %55 = sub nsw i32 %54, 2
  store i32 %55, ptr %5, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %84, %53
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = icmp sge i32 %57, 0
  br i1 %58, label %60, label %59

59:                                               ; preds = %56
  store i32 8, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %87

60:                                               ; preds = %56
  %61 = load i32, ptr %1, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %62
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [310 x i32], ptr %63, i64 0, i64 %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %67 = load i32, ptr %1, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %68
  %70 = load i32, ptr %5, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [310 x i32], ptr %69, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = sub nsw i32 %74, 1
  store i32 %75, ptr %6, align 4, !tbaa !5
  %76 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %66, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = load i32, ptr %1, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %79
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [310 x i32], ptr %80, i64 0, i64 %82
  store i32 %77, ptr %83, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %84

84:                                               ; preds = %60
  %85 = load i32, ptr %5, align 4, !tbaa !5
  %86 = add nsw i32 %85, -1
  store i32 %86, ptr %5, align 4, !tbaa !5
  br label %56, !llvm.loop !11

87:                                               ; preds = %59
  br label %88

88:                                               ; preds = %87
  %89 = load i32, ptr %1, align 4, !tbaa !5
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %1, align 4, !tbaa !5
  br label %15, !llvm.loop !12

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

92:                                               ; preds = %165, %91
  %93 = load i32, ptr %7, align 4, !tbaa !5
  %94 = load i32, ptr @c, align 4, !tbaa !5
  %95 = icmp slt i32 %93, %94
  br i1 %95, label %97, label %96

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

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

98:                                               ; preds = %127, %97
  %99 = load i32, ptr %8, align 4, !tbaa !5
  %100 = load i32, ptr @r, align 4, !tbaa !5
  %101 = icmp slt i32 %99, %100
  br i1 %101, label %103, label %102

102:                                              ; preds = %98
  store i32 14, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %130

103:                                              ; preds = %98
  %104 = load i32, ptr %8, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %105
  %107 = load i32, ptr %7, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [310 x i32], ptr %106, i64 0, i64 %108
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %110 = load i32, ptr %8, align 4, !tbaa !5
  %111 = sub nsw i32 %110, 1
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %112
  %114 = load i32, ptr %7, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [310 x i32], ptr %113, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = sub nsw i32 %117, 1
  store i32 %118, ptr %9, align 4, !tbaa !5
  %119 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %109, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %120 = load i32, ptr %119, align 4, !tbaa !5
  %121 = load i32, ptr %8, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %122
  %124 = load i32, ptr %7, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [310 x i32], ptr %123, i64 0, i64 %125
  store i32 %120, ptr %126, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %127

127:                                              ; preds = %103
  %128 = load i32, ptr %8, align 4, !tbaa !5
  %129 = add nsw i32 %128, 1
  store i32 %129, ptr %8, align 4, !tbaa !5
  br label %98, !llvm.loop !13

130:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %131 = load i32, ptr @r, align 4, !tbaa !5
  %132 = sub nsw i32 %131, 2
  store i32 %132, ptr %10, align 4, !tbaa !5
  br label %133

133:                                              ; preds = %161, %130
  %134 = load i32, ptr %10, align 4, !tbaa !5
  %135 = icmp sge i32 %134, 0
  br i1 %135, label %137, label %136

136:                                              ; preds = %133
  store i32 17, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %164

137:                                              ; preds = %133
  %138 = load i32, ptr %10, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %139
  %141 = load i32, ptr %7, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [310 x i32], ptr %140, i64 0, i64 %142
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %144 = load i32, ptr %10, align 4, !tbaa !5
  %145 = add nsw i32 %144, 1
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %146
  %148 = load i32, ptr %7, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [310 x i32], ptr %147, i64 0, i64 %149
  %151 = load i32, ptr %150, align 4, !tbaa !5
  %152 = sub nsw i32 %151, 1
  store i32 %152, ptr %11, align 4, !tbaa !5
  %153 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %143, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = load i32, ptr %10, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %156
  %158 = load i32, ptr %7, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [310 x i32], ptr %157, i64 0, i64 %159
  store i32 %154, ptr %160, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %161

161:                                              ; preds = %137
  %162 = load i32, ptr %10, align 4, !tbaa !5
  %163 = add nsw i32 %162, -1
  store i32 %163, ptr %10, align 4, !tbaa !5
  br label %133, !llvm.loop !14

164:                                              ; preds = %136
  br label %165

165:                                              ; preds = %164
  %166 = load i32, ptr %7, align 4, !tbaa !5
  %167 = add nsw i32 %166, 1
  store i32 %167, ptr %7, align 4, !tbaa !5
  br label %92, !llvm.loop !15

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

169:                                              ; preds = %195, %168
  %170 = load i32, ptr %13, align 4, !tbaa !5
  %171 = load i32, ptr @r, align 4, !tbaa !5
  %172 = icmp slt i32 %170, %171
  br i1 %172, label %174, label %173

173:                                              ; preds = %169
  store i32 20, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %198

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

175:                                              ; preds = %191, %174
  %176 = load i32, ptr %14, align 4, !tbaa !5
  %177 = load i32, ptr @c, align 4, !tbaa !5
  %178 = icmp slt i32 %176, %177
  br i1 %178, label %180, label %179

179:                                              ; preds = %175
  store i32 23, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %194

180:                                              ; preds = %175
  %181 = load i32, ptr %13, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %182
  %184 = load i32, ptr %14, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [310 x i32], ptr %183, i64 0, i64 %185
  %187 = load i32, ptr %186, align 4, !tbaa !5
  %188 = sext i32 %187 to i64
  %189 = load i64, ptr %12, align 8, !tbaa !16
  %190 = add nsw i64 %189, %188
  store i64 %190, ptr %12, align 8, !tbaa !16
  br label %191

191:                                              ; preds = %180
  %192 = load i32, ptr %14, align 4, !tbaa !5
  %193 = add nsw i32 %192, 1
  store i32 %193, ptr %14, align 4, !tbaa !5
  br label %175, !llvm.loop !18

194:                                              ; preds = %179
  br label %195

195:                                              ; preds = %194
  %196 = load i32, ptr %13, align 4, !tbaa !5
  %197 = add nsw i32 %196, 1
  store i32 %197, ptr %13, align 4, !tbaa !5
  br label %169, !llvm.loop !19

198:                                              ; preds = %173
  %199 = load i64, ptr %12, align 8, !tbaa !16
  %200 = load i64, ptr @sum, align 8, !tbaa !16
  %201 = sub nsw i64 %199, %200
  store i32 1, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  ret i64 %201
}

; Function Attrs: 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)) #2

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

attributes #0 = { 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 #1 = { 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"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = !{!17, !17, i64 0}
!17 = !{!"long long", !7, i64 0}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !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"

@g = external dso_local global [310 x [310 x i32]], align 16
@r = external dso_local local_unnamed_addr global i32, align 4
@c = external dso_local local_unnamed_addr global i32, align 4
@sum = external dso_local local_unnamed_addr global i64, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i64 @_Z5solvev() 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 = load i32, ptr @r, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.preheader57, label %.preheader56

.preheader57:                                     ; preds = %0, %._crit_edge64
  %indvars.iv94 = phi i64 [ %indvars.iv.next95, %._crit_edge64 ], [ 0, %0 ]
  %7 = load i32, ptr @c, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 1
  br i1 %8, label %.lr.ph, label %._crit_edge64

.lr.ph:                                           ; preds = %.preheader57
  %.phi.trans.insert = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %indvars.iv94, i64 0
  %.pre = load i32, ptr %.phi.trans.insert, align 8, !tbaa !5
  br label %15

.preheader56:                                     ; preds = %._crit_edge64, %0
  %9 = phi i32 [ %5, %0 ], [ %24, %._crit_edge64 ]
  %10 = load i32, ptr @c, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.preheader55, label %.preheader54

._crit_edge:                                      ; preds = %15
  %12 = icmp sgt i32 %21, 1
  br i1 %12, label %.lr.ph63, label %._crit_edge64

.lr.ph63:                                         ; preds = %._crit_edge
  %13 = add nsw i32 %21, -2
  %14 = zext nneg i32 %13 to i64
  br label %27

15:                                               ; preds = %.lr.ph, %15
  %16 = phi i32 [ %.pre, %.lr.ph ], [ %20, %15 ]
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %15 ]
  %17 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %indvars.iv94, i64 %indvars.iv
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %18 = add nsw i32 %16, -1
  store i32 %18, ptr %1, align 4, !tbaa !5
  %19 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %17, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %20 = load i32, ptr %19, align 4, !tbaa !5
  store i32 %20, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %21 = load i32, ptr @c, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = icmp slt i64 %indvars.iv.next, %22
  br i1 %23, label %15, label %._crit_edge, !llvm.loop !9

._crit_edge64:                                    ; preds = %27, %.preheader57, %._crit_edge
  %indvars.iv.next95 = add nuw nsw i64 %indvars.iv94, 1
  %24 = load i32, ptr @r, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = icmp slt i64 %indvars.iv.next95, %25
  br i1 %26, label %.preheader57, label %.preheader56, !llvm.loop !11

27:                                               ; preds = %.lr.ph63, %27
  %indvars.iv91 = phi i64 [ %14, %.lr.ph63 ], [ %indvars.iv.next92, %27 ]
  %28 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %indvars.iv94, i64 %indvars.iv91
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %29 = add nuw nsw i64 %indvars.iv91, 1
  %30 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %indvars.iv94, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = add nsw i32 %31, -1
  store i32 %32, ptr %2, align 4, !tbaa !5
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %28, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %34 = load i32, ptr %33, align 4, !tbaa !5
  store i32 %34, ptr %28, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  %indvars.iv.next92 = add nsw i64 %indvars.iv91, -1
  %.not = icmp eq i64 %indvars.iv91, 0
  br i1 %.not, label %._crit_edge64, label %27, !llvm.loop !12

.preheader55:                                     ; preds = %.preheader56, %._crit_edge73
  %indvars.iv103 = phi i64 [ %indvars.iv.next104, %._crit_edge73 ], [ 0, %.preheader56 ]
  %35 = load i32, ptr @r, align 4, !tbaa !5
  %36 = icmp sgt i32 %35, 1
  br i1 %36, label %.lr.ph67, label %._crit_edge73

.lr.ph67:                                         ; preds = %.preheader55
  %.phi.trans.insert114 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 0, i64 %indvars.iv103
  %.pre115 = load i32, ptr %.phi.trans.insert114, align 4, !tbaa !5
  br label %56

.preheader54.loopexit:                            ; preds = %._crit_edge73
  %.pre116 = load i32, ptr @r, align 4, !tbaa !5
  br label %.preheader54

.preheader54:                                     ; preds = %.preheader54.loopexit, %.preheader56
  %37 = phi i32 [ %9, %.preheader56 ], [ %.pre116, %.preheader54.loopexit ]
  %.lcssa58 = phi i32 [ %10, %.preheader56 ], [ %65, %.preheader54.loopexit ]
  %38 = icmp sgt i32 %37, 0
  %39 = icmp sgt i32 %.lcssa58, 0
  %or.cond = and i1 %38, %39
  br i1 %or.cond, label %.preheader.us.preheader, label %._crit_edge83

.preheader.us.preheader:                          ; preds = %.preheader54
  %wide.trip.count112 = zext nneg i32 %37 to i64
  %wide.trip.count = zext nneg i32 %.lcssa58 to i64
  %min.iters.check = icmp ult i32 %.lcssa58, 4
  %n.vec = and i64 %wide.trip.count, 2147483644
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge79.us
  %indvars.iv109 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next110, %._crit_edge79.us ]
  %.04581.us = phi i64 [ 0, %.preheader.us.preheader ], [ %.lcssa, %._crit_edge79.us ]
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.preheader.us
  %40 = insertelement <2 x i64> <i64 poison, i64 0>, i64 %.04581.us, i64 0
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ %40, %vector.ph ], [ %45, %vector.body ]
  %vec.phi128 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %46, %vector.body ]
  %41 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %indvars.iv109, i64 %index
  %42 = getelementptr inbounds i8, ptr %41, i64 8
  %wide.load = load <2 x i32>, ptr %41, align 8, !tbaa !5
  %wide.load129 = load <2 x i32>, ptr %42, align 8, !tbaa !5
  %43 = sext <2 x i32> %wide.load to <2 x i64>
  %44 = sext <2 x i32> %wide.load129 to <2 x i64>
  %45 = add <2 x i64> %vec.phi, %43
  %46 = add <2 x i64> %vec.phi128, %44
  %index.next = add nuw i64 %index, 4
  %47 = icmp eq i64 %index.next, %n.vec
  br i1 %47, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %46, %45
  %48 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  br i1 %cmp.n, label %._crit_edge79.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader.us
  %indvars.iv106.ph = phi i64 [ 0, %.preheader.us ], [ %n.vec, %middle.block ]
  %.176.us.ph = phi i64 [ %.04581.us, %.preheader.us ], [ %48, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv106 = phi i64 [ %indvars.iv.next107, %scalar.ph ], [ %indvars.iv106.ph, %scalar.ph.preheader ]
  %.176.us = phi i64 [ %52, %scalar.ph ], [ %.176.us.ph, %scalar.ph.preheader ]
  %49 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %indvars.iv109, i64 %indvars.iv106
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = add nsw i64 %.176.us, %51
  %indvars.iv.next107 = add nuw nsw i64 %indvars.iv106, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next107, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge79.us, label %scalar.ph, !llvm.loop !16

._crit_edge79.us:                                 ; preds = %scalar.ph, %middle.block
  %.lcssa = phi i64 [ %48, %middle.block ], [ %52, %scalar.ph ]
  %indvars.iv.next110 = add nuw nsw i64 %indvars.iv109, 1
  %exitcond113.not = icmp eq i64 %indvars.iv.next110, %wide.trip.count112
  br i1 %exitcond113.not, label %._crit_edge83, label %.preheader.us, !llvm.loop !17

._crit_edge68:                                    ; preds = %56
  %53 = icmp sgt i32 %62, 1
  br i1 %53, label %.lr.ph72, label %._crit_edge73

.lr.ph72:                                         ; preds = %._crit_edge68
  %54 = add nsw i32 %62, -2
  %55 = zext nneg i32 %54 to i64
  br label %68

56:                                               ; preds = %.lr.ph67, %56
  %57 = phi i32 [ %.pre115, %.lr.ph67 ], [ %61, %56 ]
  %indvars.iv97 = phi i64 [ 1, %.lr.ph67 ], [ %indvars.iv.next98, %56 ]
  %58 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %indvars.iv97, i64 %indvars.iv103
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %59 = add nsw i32 %57, -1
  store i32 %59, ptr %3, align 4, !tbaa !5
  %60 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %58, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %61 = load i32, ptr %60, align 4, !tbaa !5
  store i32 %61, ptr %58, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  %indvars.iv.next98 = add nuw nsw i64 %indvars.iv97, 1
  %62 = load i32, ptr @r, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = icmp slt i64 %indvars.iv.next98, %63
  br i1 %64, label %56, label %._crit_edge68, !llvm.loop !18

._crit_edge73:                                    ; preds = %68, %.preheader55, %._crit_edge68
  %indvars.iv.next104 = add nuw nsw i64 %indvars.iv103, 1
  %65 = load i32, ptr @c, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = icmp slt i64 %indvars.iv.next104, %66
  br i1 %67, label %.preheader55, label %.preheader54.loopexit, !llvm.loop !19

68:                                               ; preds = %.lr.ph72, %68
  %indvars.iv100 = phi i64 [ %55, %.lr.ph72 ], [ %indvars.iv.next101, %68 ]
  %69 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %indvars.iv100, i64 %indvars.iv103
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %70 = add nuw nsw i64 %indvars.iv100, 1
  %71 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %70, i64 %indvars.iv103
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = add nsw i32 %72, -1
  store i32 %73, ptr %4, align 4, !tbaa !5
  %74 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %69, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %75 = load i32, ptr %74, align 4, !tbaa !5
  store i32 %75, ptr %69, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  %indvars.iv.next101 = add nsw i64 %indvars.iv100, -1
  %.not123 = icmp eq i64 %indvars.iv100, 0
  br i1 %.not123, label %._crit_edge73, label %68, !llvm.loop !20

._crit_edge83:                                    ; preds = %._crit_edge79.us, %.preheader54
  %.045.lcssa = phi i64 [ 0, %.preheader54 ], [ %.lcssa, %._crit_edge79.us ]
  %76 = load i64, ptr @sum, align 8, !tbaa !21
  %77 = sub nsw i64 %.045.lcssa, %76
  ret i64 %77
}

; 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

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

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 = { 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}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10, !14, !15}
!14 = !{!"llvm.loop.isvectorized", i32 1}
!15 = !{!"llvm.loop.unroll.runtime.disable"}
!16 = distinct !{!16, !10, !15, !14}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}
!21 = !{!22, !22, i64 0}
!22 = !{!"long long", !7, i64 0}


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