; LLVM IR from qc-tum/chemtensor :: src/util (integer_linear_algebra)

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

@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [85 x i8], align 1
@__PRETTY_FUNCTION__.integer_hermite_normal_form = external hidden unnamed_addr constant [94 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @integer_hermite_normal_form(i32 noundef %0, ptr noalias noundef %1, ptr noalias noundef %2, ptr noalias noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %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
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !9
  %21 = load ptr, ptr %8, align 8, !tbaa !9
  %22 = load ptr, ptr %7, align 8, !tbaa !9
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = mul nsw i32 %23, %24
  %26 = sext i32 %25 to i64
  %27 = mul i64 %26, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 4 %22, i64 %27, i1 false)
  %28 = load i32, ptr %6, align 4, !tbaa !5
  %29 = load ptr, ptr %9, align 8, !tbaa !9
  call void @integer_matrix_identity(i32 noundef %28, ptr noundef %29)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %298, %4
  %31 = load i32, ptr %10, align 4, !tbaa !5
  %32 = load i32, ptr %6, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  store i32 2, ptr %11, align 4
  br label %301

35:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  br label %36

36:                                               ; preds = %180, %35
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %38, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %39 = load ptr, ptr %8, align 8, !tbaa !9
  %40 = load i32, ptr %10, align 4, !tbaa !5
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = mul nsw i32 %40, %41
  %43 = load i32, ptr %10, align 4, !tbaa !5
  %44 = add nsw i32 %42, %43
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds i32, ptr %39, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = call i32 @llvm.abs.i32(i32 %47, i1 true)
  store i32 %48, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %49 = load i32, ptr %10, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %14, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %82, %37
  %52 = load i32, ptr %14, align 4, !tbaa !5
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  store i32 7, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  br label %85

56:                                               ; preds = %51
  %57 = load ptr, ptr %8, align 8, !tbaa !9
  %58 = load i32, ptr %14, align 4, !tbaa !5
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = mul nsw i32 %58, %59
  %61 = load i32, ptr %10, align 4, !tbaa !5
  %62 = add nsw i32 %60, %61
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds i32, ptr %57, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = call i32 @llvm.abs.i32(i32 %65, i1 true)
  %67 = load i32, ptr %13, align 4, !tbaa !5
  %68 = icmp sgt i32 %66, %67
  br i1 %68, label %69, label %81

69:                                               ; preds = %56
  %70 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %70, ptr %12, align 4, !tbaa !5
  %71 = load ptr, ptr %8, align 8, !tbaa !9
  %72 = load i32, ptr %14, align 4, !tbaa !5
  %73 = load i32, ptr %6, align 4, !tbaa !5
  %74 = mul nsw i32 %72, %73
  %75 = load i32, ptr %10, align 4, !tbaa !5
  %76 = add nsw i32 %74, %75
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds i32, ptr %71, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = call i32 @llvm.abs.i32(i32 %79, i1 true)
  store i32 %80, ptr %13, align 4, !tbaa !5
  br label %81

81:                                               ; preds = %69, %56
  br label %82

82:                                               ; preds = %81
  %83 = load i32, ptr %14, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %14, align 4, !tbaa !5
  br label %51, !llvm.loop !11

85:                                               ; preds = %55
  %86 = load i32, ptr %13, align 4, !tbaa !5
  %87 = icmp eq i32 %86, 0
  br i1 %87, label %88, label %89

88:                                               ; preds = %85
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %178

89:                                               ; preds = %85
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 -1, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %90 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %90, ptr %17, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %127, %89
  %92 = load i32, ptr %17, align 4, !tbaa !5
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = icmp slt i32 %92, %93
  br i1 %94, label %96, label %95

95:                                               ; preds = %91
  store i32 10, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %130

96:                                               ; preds = %91
  %97 = load i32, ptr %17, align 4, !tbaa !5
  %98 = load i32, ptr %12, align 4, !tbaa !5
  %99 = icmp eq i32 %97, %98
  br i1 %99, label %100, label %101

100:                                              ; preds = %96
  br label %127

101:                                              ; preds = %96
  %102 = load ptr, ptr %8, align 8, !tbaa !9
  %103 = load i32, ptr %17, align 4, !tbaa !5
  %104 = load i32, ptr %6, align 4, !tbaa !5
  %105 = mul nsw i32 %103, %104
  %106 = load i32, ptr %10, align 4, !tbaa !5
  %107 = add nsw i32 %105, %106
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds i32, ptr %102, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = call i32 @llvm.abs.i32(i32 %110, i1 true)
  %112 = load i32, ptr %16, align 4, !tbaa !5
  %113 = icmp sgt i32 %111, %112
  br i1 %113, label %114, label %126

114:                                              ; preds = %101
  %115 = load i32, ptr %17, align 4, !tbaa !5
  store i32 %115, ptr %15, align 4, !tbaa !5
  %116 = load ptr, ptr %8, align 8, !tbaa !9
  %117 = load i32, ptr %17, align 4, !tbaa !5
  %118 = load i32, ptr %6, align 4, !tbaa !5
  %119 = mul nsw i32 %117, %118
  %120 = load i32, ptr %10, align 4, !tbaa !5
  %121 = add nsw i32 %119, %120
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds i32, ptr %116, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !5
  %125 = call i32 @llvm.abs.i32(i32 %124, i1 true)
  store i32 %125, ptr %16, align 4, !tbaa !5
  br label %126

126:                                              ; preds = %114, %101
  br label %127

127:                                              ; preds = %126, %100
  %128 = load i32, ptr %17, align 4, !tbaa !5
  %129 = add nsw i32 %128, 1
  store i32 %129, ptr %17, align 4, !tbaa !5
  br label %91, !llvm.loop !13

130:                                              ; preds = %95
  %131 = load i32, ptr %16, align 4, !tbaa !5
  %132 = icmp eq i32 %131, 0
  br i1 %132, label %133, label %134

133:                                              ; preds = %130
  store i32 6, ptr %11, align 4
  br label %177

134:                                              ; preds = %130
  %135 = load ptr, ptr %8, align 8, !tbaa !9
  %136 = load i32, ptr %15, align 4, !tbaa !5
  %137 = load i32, ptr %6, align 4, !tbaa !5
  %138 = mul nsw i32 %136, %137
  %139 = load i32, ptr %10, align 4, !tbaa !5
  %140 = add nsw i32 %138, %139
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds i32, ptr %135, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = icmp ne i32 %143, 0
  br i1 %144, label %145, label %146

145:                                              ; preds = %134
  br label %147

146:                                              ; preds = %134
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 128, ptr noundef @__PRETTY_FUNCTION__.integer_hermite_normal_form) #7
  unreachable

147:                                              ; preds = %145
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %148 = load ptr, ptr %8, align 8, !tbaa !9
  %149 = load i32, ptr %12, align 4, !tbaa !5
  %150 = load i32, ptr %6, align 4, !tbaa !5
  %151 = mul nsw i32 %149, %150
  %152 = load i32, ptr %10, align 4, !tbaa !5
  %153 = add nsw i32 %151, %152
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds i32, ptr %148, i64 %154
  %156 = load i32, ptr %155, align 4, !tbaa !5
  %157 = load ptr, ptr %8, align 8, !tbaa !9
  %158 = load i32, ptr %15, align 4, !tbaa !5
  %159 = load i32, ptr %6, align 4, !tbaa !5
  %160 = mul nsw i32 %158, %159
  %161 = load i32, ptr %10, align 4, !tbaa !5
  %162 = add nsw i32 %160, %161
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds i32, ptr %157, i64 %163
  %165 = load i32, ptr %164, align 4, !tbaa !5
  %166 = sdiv i32 %156, %165
  store i32 %166, ptr %18, align 4, !tbaa !5
  %167 = load i32, ptr %6, align 4, !tbaa !5
  %168 = load i32, ptr %12, align 4, !tbaa !5
  %169 = load i32, ptr %15, align 4, !tbaa !5
  %170 = load i32, ptr %18, align 4, !tbaa !5
  %171 = load ptr, ptr %8, align 8, !tbaa !9
  call void @integer_matrix_subtract_row(i32 noundef %167, i32 noundef %168, i32 noundef %169, i32 noundef %170, ptr noundef %171)
  %172 = load i32, ptr %6, align 4, !tbaa !5
  %173 = load i32, ptr %12, align 4, !tbaa !5
  %174 = load i32, ptr %15, align 4, !tbaa !5
  %175 = load i32, ptr %18, align 4, !tbaa !5
  %176 = load ptr, ptr %9, align 8, !tbaa !9
  call void @integer_matrix_subtract_row(i32 noundef %172, i32 noundef %173, i32 noundef %174, i32 noundef %175, ptr noundef %176)
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  store i32 0, ptr %11, align 4
  br label %177

177:                                              ; preds = %147, %133
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  br label %178

178:                                              ; preds = %177, %88
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  %179 = load i32, ptr %11, align 4
  switch i32 %179, label %295 [
    i32 0, label %180
    i32 6, label %181
  ]

180:                                              ; preds = %178
  br label %36

181:                                              ; preds = %178
  %182 = load i32, ptr %12, align 4, !tbaa !5
  %183 = load i32, ptr %10, align 4, !tbaa !5
  %184 = icmp ne i32 %182, %183
  br i1 %184, label %185, label %194

185:                                              ; preds = %181
  %186 = load i32, ptr %6, align 4, !tbaa !5
  %187 = load i32, ptr %10, align 4, !tbaa !5
  %188 = load i32, ptr %12, align 4, !tbaa !5
  %189 = load ptr, ptr %8, align 8, !tbaa !9
  call void @integer_matrix_swap_rows(i32 noundef %186, i32 noundef %187, i32 noundef %188, ptr noundef %189)
  %190 = load i32, ptr %6, align 4, !tbaa !5
  %191 = load i32, ptr %10, align 4, !tbaa !5
  %192 = load i32, ptr %12, align 4, !tbaa !5
  %193 = load ptr, ptr %9, align 8, !tbaa !9
  call void @integer_matrix_swap_rows(i32 noundef %190, i32 noundef %191, i32 noundef %192, ptr noundef %193)
  br label %194

194:                                              ; preds = %185, %181
  %195 = load ptr, ptr %8, align 8, !tbaa !9
  %196 = load i32, ptr %10, align 4, !tbaa !5
  %197 = load i32, ptr %6, align 4, !tbaa !5
  %198 = mul nsw i32 %196, %197
  %199 = load i32, ptr %10, align 4, !tbaa !5
  %200 = add nsw i32 %198, %199
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds i32, ptr %195, i64 %201
  %203 = load i32, ptr %202, align 4, !tbaa !5
  %204 = icmp slt i32 %203, 0
  br i1 %204, label %205, label %212

205:                                              ; preds = %194
  %206 = load i32, ptr %6, align 4, !tbaa !5
  %207 = load i32, ptr %10, align 4, !tbaa !5
  %208 = load ptr, ptr %8, align 8, !tbaa !9
  call void @integer_matrix_scale_row(i32 noundef %206, i32 noundef %207, i32 noundef -1, ptr noundef %208)
  %209 = load i32, ptr %6, align 4, !tbaa !5
  %210 = load i32, ptr %10, align 4, !tbaa !5
  %211 = load ptr, ptr %9, align 8, !tbaa !9
  call void @integer_matrix_scale_row(i32 noundef %209, i32 noundef %210, i32 noundef -1, ptr noundef %211)
  br label %212

212:                                              ; preds = %205, %194
  %213 = load ptr, ptr %8, align 8, !tbaa !9
  %214 = load i32, ptr %10, align 4, !tbaa !5
  %215 = load i32, ptr %6, align 4, !tbaa !5
  %216 = mul nsw i32 %214, %215
  %217 = load i32, ptr %10, align 4, !tbaa !5
  %218 = add nsw i32 %216, %217
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds i32, ptr %213, i64 %219
  %221 = load i32, ptr %220, align 4, !tbaa !5
  %222 = icmp sgt i32 %221, 0
  br i1 %222, label %223, label %224

223:                                              ; preds = %212
  br label %225

224:                                              ; preds = %212
  call void @__assert_fail(ptr noundef @.str.2, ptr noundef @.str.1, i32 noundef 147, ptr noundef @__PRETTY_FUNCTION__.integer_hermite_normal_form) #7
  unreachable

225:                                              ; preds = %223
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  store i32 0, ptr %19, align 4, !tbaa !5
  br label %226

226:                                              ; preds = %291, %225
  %227 = load i32, ptr %19, align 4, !tbaa !5
  %228 = load i32, ptr %10, align 4, !tbaa !5
  %229 = icmp slt i32 %227, %228
  br i1 %229, label %231, label %230

230:                                              ; preds = %226
  store i32 13, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  br label %294

231:                                              ; preds = %226
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  %232 = load ptr, ptr %8, align 8, !tbaa !9
  %233 = load i32, ptr %19, align 4, !tbaa !5
  %234 = load i32, ptr %6, align 4, !tbaa !5
  %235 = mul nsw i32 %233, %234
  %236 = load i32, ptr %10, align 4, !tbaa !5
  %237 = add nsw i32 %235, %236
  %238 = sext i32 %237 to i64
  %239 = getelementptr inbounds i32, ptr %232, i64 %238
  %240 = load i32, ptr %239, align 4, !tbaa !5
  %241 = load ptr, ptr %8, align 8, !tbaa !9
  %242 = load i32, ptr %10, align 4, !tbaa !5
  %243 = load i32, ptr %6, align 4, !tbaa !5
  %244 = mul nsw i32 %242, %243
  %245 = load i32, ptr %10, align 4, !tbaa !5
  %246 = add nsw i32 %244, %245
  %247 = sext i32 %246 to i64
  %248 = getelementptr inbounds i32, ptr %241, i64 %247
  %249 = load i32, ptr %248, align 4, !tbaa !5
  %250 = sdiv i32 %240, %249
  store i32 %250, ptr %20, align 4, !tbaa !5
  %251 = load ptr, ptr %8, align 8, !tbaa !9
  %252 = load i32, ptr %19, align 4, !tbaa !5
  %253 = load i32, ptr %6, align 4, !tbaa !5
  %254 = mul nsw i32 %252, %253
  %255 = load i32, ptr %10, align 4, !tbaa !5
  %256 = add nsw i32 %254, %255
  %257 = sext i32 %256 to i64
  %258 = getelementptr inbounds i32, ptr %251, i64 %257
  %259 = load i32, ptr %258, align 4, !tbaa !5
  %260 = load i32, ptr %20, align 4, !tbaa !5
  %261 = load ptr, ptr %8, align 8, !tbaa !9
  %262 = load i32, ptr %10, align 4, !tbaa !5
  %263 = load i32, ptr %6, align 4, !tbaa !5
  %264 = mul nsw i32 %262, %263
  %265 = load i32, ptr %10, align 4, !tbaa !5
  %266 = add nsw i32 %264, %265
  %267 = sext i32 %266 to i64
  %268 = getelementptr inbounds i32, ptr %261, i64 %267
  %269 = load i32, ptr %268, align 4, !tbaa !5
  %270 = mul nsw i32 %260, %269
  %271 = sub nsw i32 %259, %270
  %272 = icmp slt i32 %271, 0
  br i1 %272, label %273, label %276

273:                                              ; preds = %231
  %274 = load i32, ptr %20, align 4, !tbaa !5
  %275 = add nsw i32 %274, -1
  store i32 %275, ptr %20, align 4, !tbaa !5
  br label %276

276:                                              ; preds = %273, %231
  %277 = load i32, ptr %20, align 4, !tbaa !5
  %278 = icmp ne i32 %277, 0
  br i1 %278, label %279, label %290

279:                                              ; preds = %276
  %280 = load i32, ptr %6, align 4, !tbaa !5
  %281 = load i32, ptr %19, align 4, !tbaa !5
  %282 = load i32, ptr %10, align 4, !tbaa !5
  %283 = load i32, ptr %20, align 4, !tbaa !5
  %284 = load ptr, ptr %8, align 8, !tbaa !9
  call void @integer_matrix_subtract_row(i32 noundef %280, i32 noundef %281, i32 noundef %282, i32 noundef %283, ptr noundef %284)
  %285 = load i32, ptr %6, align 4, !tbaa !5
  %286 = load i32, ptr %19, align 4, !tbaa !5
  %287 = load i32, ptr %10, align 4, !tbaa !5
  %288 = load i32, ptr %20, align 4, !tbaa !5
  %289 = load ptr, ptr %9, align 8, !tbaa !9
  call void @integer_matrix_subtract_row(i32 noundef %285, i32 noundef %286, i32 noundef %287, i32 noundef %288, ptr noundef %289)
  br label %290

290:                                              ; preds = %279, %276
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  br label %291

291:                                              ; preds = %290
  %292 = load i32, ptr %19, align 4, !tbaa !5
  %293 = add nsw i32 %292, 1
  store i32 %293, ptr %19, align 4, !tbaa !5
  br label %226, !llvm.loop !14

294:                                              ; preds = %230
  store i32 0, ptr %11, align 4
  br label %295

295:                                              ; preds = %294, %178
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  %296 = load i32, ptr %11, align 4
  switch i32 %296, label %301 [
    i32 0, label %297
  ]

297:                                              ; preds = %295
  br label %298

298:                                              ; preds = %297
  %299 = load i32, ptr %10, align 4, !tbaa !5
  %300 = add nsw i32 %299, 1
  store i32 %300, ptr %10, align 4, !tbaa !5
  br label %30, !llvm.loop !15

301:                                              ; preds = %295, %34
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %302 = load i32, ptr %11, align 4
  switch i32 %302, label %306 [
    i32 2, label %303
    i32 1, label %304
  ]

303:                                              ; preds = %301
  store i32 0, ptr %5, align 4
  br label %304

304:                                              ; preds = %303, %301
  %305 = load i32, ptr %5, align 4
  ret i32 %305

306:                                              ; preds = %301
  unreachable
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare hidden void @integer_matrix_identity(i32 noundef, ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #3

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @integer_matrix_subtract_row(i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @integer_matrix_swap_rows(i32 noundef, i32 noundef, i32 noundef, ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @integer_matrix_scale_row(i32 noundef, i32 noundef, i32 noundef, ptr noundef) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { noreturn 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 #5 = { inlinehint 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 #6 = { nounwind }
attributes #7 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !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"

@.str = external hidden unnamed_addr constant [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [85 x i8], align 1
@__PRETTY_FUNCTION__.integer_hermite_normal_form = external hidden unnamed_addr constant [94 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @integer_hermite_normal_form(i32 noundef %0, ptr noalias nocapture noundef readonly %1, ptr noalias noundef %2, ptr noalias noundef %3) local_unnamed_addr #0 {
  %5 = mul nsw i32 %0, %0
  %6 = zext nneg i32 %5 to i64
  %7 = shl nuw nsw i64 %6, 2
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 4 %1, i64 %7, i1 false)
  tail call void @integer_matrix_identity(i32 noundef %0, ptr noundef %3)
  %.not162190 = icmp sgt i32 %0, 0
  br i1 %.not162190, label %.preheader164.lr.ph, label %.thread159

.preheader164.lr.ph:                              ; preds = %4
  %.0143148 = add nuw i32 %0, 1
  %8 = zext nneg i32 %0 to i64
  %9 = zext nneg i32 %0 to i64
  br label %.preheader164

.loopexit:                                        ; preds = %67, %.preheader163
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond217.not = icmp eq i64 %indvars.iv.next205, %8
  br i1 %exitcond217.not, label %.thread159, label %.preheader164, !llvm.loop !5

.preheader164:                                    ; preds = %.preheader164.lr.ph, %.loopexit
  %indvars.iv204 = phi i64 [ 0, %.preheader164.lr.ph ], [ %indvars.iv.next205, %.loopexit ]
  %indvars.iv = phi i64 [ 1, %.preheader164.lr.ph ], [ %indvars.iv.next, %.loopexit ]
  %.not162192 = phi i1 [ true, %.preheader164.lr.ph ], [ %14, %.loopexit ]
  %10 = trunc nuw nsw i64 %indvars.iv204 to i32
  %11 = mul i32 %.0143148, %10
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds i32, ptr %2, i64 %12
  %indvars.iv.next205 = add nuw nsw i64 %indvars.iv204, 1
  %14 = icmp ult i64 %indvars.iv.next205, %9
  %invariant.gep = getelementptr inbounds i32, ptr %2, i64 %indvars.iv204
  %invariant.gep231 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv204
  %15 = getelementptr i32, ptr %2, i64 %indvars.iv204
  %16 = getelementptr i32, ptr %2, i64 %indvars.iv204
  br label %17

17:                                               ; preds = %.preheader164, %42
  %18 = load i32, ptr %13, align 4, !tbaa !7
  %19 = tail call i32 @llvm.abs.i32(i32 %18, i1 true)
  br i1 %14, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %17
  %.0137.lcssa = phi i32 [ %10, %17 ], [ %spec.select, %.lr.ph ]
  %.0135.lcssa = phi i32 [ %19, %17 ], [ %spec.select151, %.lr.ph ]
  %20 = icmp eq i32 %.0135.lcssa, 0
  br i1 %20, label %.thread159, label %.lr.ph184.preheader

.lr.ph184.preheader:                              ; preds = %._crit_edge
  %21 = zext i32 %.0137.lcssa to i64
  br label %.lr.ph184

.lr.ph:                                           ; preds = %17, %.lr.ph
  %indvars.iv201 = phi i64 [ %indvars.iv.next202, %.lr.ph ], [ %indvars.iv, %17 ]
  %.0135178 = phi i32 [ %spec.select151, %.lr.ph ], [ %19, %17 ]
  %.0137177 = phi i32 [ %spec.select, %.lr.ph ], [ %10, %17 ]
  %22 = mul nuw nsw i64 %indvars.iv201, %8
  %gep = getelementptr inbounds i32, ptr %invariant.gep, i64 %22
  %23 = load i32, ptr %gep, align 4, !tbaa !7
  %24 = tail call i32 @llvm.abs.i32(i32 %23, i1 true)
  %25 = icmp sgt i32 %24, %.0135178
  %26 = trunc nuw nsw i64 %indvars.iv201 to i32
  %spec.select = select i1 %25, i32 %26, i32 %.0137177
  %spec.select151 = tail call i32 @llvm.smax.i32(i32 %24, i32 %.0135178)
  %indvars.iv.next202 = add nuw nsw i64 %indvars.iv201, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next202, %8
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge185:                                   ; preds = %35
  %27 = icmp eq i32 %.1131, 0
  br i1 %27, label %48, label %36

.lr.ph184:                                        ; preds = %.lr.ph184.preheader, %35
  %indvars.iv206 = phi i64 [ %indvars.iv204, %.lr.ph184.preheader ], [ %indvars.iv.next207, %35 ]
  %.0130182 = phi i32 [ 0, %.lr.ph184.preheader ], [ %.1131, %35 ]
  %.0132181 = phi i32 [ -1, %.lr.ph184.preheader ], [ %.1133, %35 ]
  %28 = icmp eq i64 %indvars.iv206, %21
  br i1 %28, label %35, label %29

29:                                               ; preds = %.lr.ph184
  %30 = mul nuw nsw i64 %indvars.iv206, %8
  %gep232 = getelementptr inbounds i32, ptr %invariant.gep231, i64 %30
  %31 = load i32, ptr %gep232, align 4, !tbaa !7
  %32 = tail call i32 @llvm.abs.i32(i32 %31, i1 true)
  %33 = icmp sgt i32 %32, %.0130182
  %34 = trunc nuw nsw i64 %indvars.iv206 to i32
  %spec.select152 = select i1 %33, i32 %34, i32 %.0132181
  %spec.select153 = tail call i32 @llvm.smax.i32(i32 %32, i32 %.0130182)
  br label %35

35:                                               ; preds = %29, %.lr.ph184
  %.1133 = phi i32 [ %.0132181, %.lr.ph184 ], [ %spec.select152, %29 ]
  %.1131 = phi i32 [ %.0130182, %.lr.ph184 ], [ %spec.select153, %29 ]
  %indvars.iv.next207 = add nuw nsw i64 %indvars.iv206, 1
  %exitcond210.not = icmp eq i64 %indvars.iv.next207, %8
  br i1 %exitcond210.not, label %._crit_edge185, label %.lr.ph184, !llvm.loop !12

36:                                               ; preds = %._crit_edge185
  %37 = mul nsw i32 %.1133, %0
  %38 = sext i32 %37 to i64
  %39 = getelementptr i32, ptr %15, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !7
  %.not = icmp eq i32 %40, 0
  br i1 %.not, label %41, label %42

41:                                               ; preds = %36
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 128, ptr noundef nonnull @__PRETTY_FUNCTION__.integer_hermite_normal_form) #6
  unreachable

42:                                               ; preds = %36
  %43 = mul nsw i32 %.0137.lcssa, %0
  %44 = sext i32 %43 to i64
  %45 = getelementptr i32, ptr %16, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !7
  %47 = sdiv i32 %46, %40
  tail call void @integer_matrix_subtract_row(i32 noundef %0, i32 noundef %.0137.lcssa, i32 noundef %.1133, i32 noundef %47, ptr noundef nonnull %2)
  tail call void @integer_matrix_subtract_row(i32 noundef %0, i32 noundef %.0137.lcssa, i32 noundef %.1133, i32 noundef %47, ptr noundef %3)
  br label %17

48:                                               ; preds = %._crit_edge185
  %.not149 = icmp eq i64 %indvars.iv204, %21
  br i1 %.not149, label %50, label %49

49:                                               ; preds = %48
  tail call void @integer_matrix_swap_rows(i32 noundef %0, i32 noundef %10, i32 noundef %.0137.lcssa, ptr noundef %2)
  tail call void @integer_matrix_swap_rows(i32 noundef %0, i32 noundef %10, i32 noundef %.0137.lcssa, ptr noundef %3)
  %.pre = load i32, ptr %13, align 4, !tbaa !7
  br label %50

50:                                               ; preds = %49, %48
  %51 = phi i32 [ %.pre, %49 ], [ %18, %48 ]
  %52 = icmp slt i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %50
  tail call void @integer_matrix_scale_row(i32 noundef %0, i32 noundef %10, i32 noundef -1, ptr noundef nonnull %2)
  tail call void @integer_matrix_scale_row(i32 noundef %0, i32 noundef %10, i32 noundef -1, ptr noundef %3)
  %.pr = load i32, ptr %13, align 4, !tbaa !7
  br label %54

54:                                               ; preds = %53, %50
  %55 = phi i32 [ %.pr, %53 ], [ %51, %50 ]
  %56 = icmp sgt i32 %55, 0
  br i1 %56, label %.preheader163, label %57

.preheader163:                                    ; preds = %54
  %.not194 = icmp eq i64 %indvars.iv204, 0
  br i1 %.not194, label %.loopexit, label %.lr.ph189.preheader

.lr.ph189.preheader:                              ; preds = %.preheader163
  %invariant.gep233 = getelementptr inbounds i32, ptr %2, i64 %indvars.iv204
  br label %.lr.ph189

57:                                               ; preds = %54
  tail call void @__assert_fail(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.1, i32 noundef 147, ptr noundef nonnull @__PRETTY_FUNCTION__.integer_hermite_normal_form) #6
  unreachable

.lr.ph189:                                        ; preds = %.lr.ph189.preheader, %67
  %indvars.iv211 = phi i64 [ 0, %.lr.ph189.preheader ], [ %indvars.iv.next212, %67 ]
  %58 = mul nuw nsw i64 %indvars.iv211, %8
  %gep234 = getelementptr inbounds i32, ptr %invariant.gep233, i64 %58
  %59 = load i32, ptr %gep234, align 4, !tbaa !7
  %60 = load i32, ptr %13, align 4, !tbaa !7
  %61 = sdiv i32 %59, %60
  %62 = mul nsw i32 %61, %60
  %63 = icmp slt i32 %59, %62
  %64 = sext i1 %63 to i32
  %spec.select154 = add nsw i32 %61, %64
  %.not150 = icmp eq i32 %spec.select154, 0
  br i1 %.not150, label %67, label %65

65:                                               ; preds = %.lr.ph189
  %66 = trunc nuw nsw i64 %indvars.iv211 to i32
  tail call void @integer_matrix_subtract_row(i32 noundef %0, i32 noundef %66, i32 noundef %10, i32 noundef %spec.select154, ptr noundef nonnull %2)
  tail call void @integer_matrix_subtract_row(i32 noundef %0, i32 noundef %66, i32 noundef %10, i32 noundef %spec.select154, ptr noundef %3)
  br label %67

67:                                               ; preds = %65, %.lr.ph189
  %indvars.iv.next212 = add nuw nsw i64 %indvars.iv211, 1
  %exitcond215.not = icmp eq i64 %indvars.iv.next212, %indvars.iv204
  br i1 %exitcond215.not, label %.loopexit, label %.lr.ph189, !llvm.loop !13

.thread159:                                       ; preds = %.loopexit, %._crit_edge, %4
  %.not162176 = phi i1 [ false, %4 ], [ %.not162192, %._crit_edge ], [ %14, %.loopexit ]
  %spec.select155 = sext i1 %.not162176 to i32
  ret i32 %spec.select155
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
declare hidden void @integer_matrix_identity(i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @integer_matrix_subtract_row(i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @integer_matrix_swap_rows(i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @integer_matrix_scale_row(i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #5

attributes #0 = { 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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { noreturn 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 #4 = { inlinehint 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 #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { noreturn 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = distinct !{!11, !6}
!12 = distinct !{!12, !6}
!13 = distinct !{!13, !6}


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