; LLVM IR from tsotchke/quantum_geometric_tensor :: src/quantum_geometric/core (numerical_backend_cpu)

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

%struct.anon = type { %struct.numerical_config_t, %struct.numerical_metrics_t, i32, i8, i8 }
%struct.numerical_config_t = type { i32, i64, i8, i8, i8, i64, ptr }
%struct.numerical_metrics_t = type { double, double, double, double, i64 }
%struct.ComplexFloat = type { float, float }

@backend_state = external hidden global %struct.anon, align 8

; 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) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

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

declare <2 x float> @complex_add(<2 x float>, <2 x float>) #3

declare <2 x float> @complex_multiply(<2 x float>, <2 x float>) #3

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @numerical_svd(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4, i64 noundef %5) #4 {
  %7 = alloca i1, align 1
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i8, align 1
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i64, align 8
  %18 = alloca float, align 4
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = alloca %struct.ComplexFloat, align 4
  %26 = alloca %struct.ComplexFloat, align 4
  %27 = alloca float, align 4
  %28 = alloca i64, align 8
  %29 = alloca i8, align 1
  %30 = alloca i64, align 8
  %31 = alloca %struct.ComplexFloat, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i64 %4, ptr %12, align 8, !tbaa !9
  store i64 %5, ptr %13, align 8, !tbaa !9
  %32 = load i8, ptr getelementptr inbounds (%struct.anon, ptr @backend_state, i32 0, i32 3), align 4, !tbaa !11, !range !18, !noundef !19
  %33 = trunc i8 %32 to i1
  br i1 %33, label %34, label %46

34:                                               ; preds = %6
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %46

37:                                               ; preds = %34
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %46

40:                                               ; preds = %37
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %46

43:                                               ; preds = %40
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %47, label %46

46:                                               ; preds = %43, %40, %37, %34, %6
  store i32 1, ptr getelementptr inbounds (%struct.anon, ptr @backend_state, i32 0, i32 2), align 8, !tbaa !20
  store i1 false, ptr %7, align 1
  br label %246

47:                                               ; preds = %43
  %48 = load i8, ptr getelementptr inbounds (%struct.anon, ptr @backend_state, i32 0, i32 4), align 1, !tbaa !21, !range !18, !noundef !19
  %49 = trunc i8 %48 to i1
  br i1 %49, label %50, label %70

50:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #7
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = load i64, ptr %12, align 8, !tbaa !9
  %53 = load i64, ptr %13, align 8, !tbaa !9
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  %57 = call zeroext i1 @lapack_svd(ptr noundef %51, i64 noundef %52, i64 noundef %53, ptr noundef %54, ptr noundef %55, ptr noundef %56, i32 noundef 101)
  %58 = zext i1 %57 to i8
  store i8 %58, ptr %14, align 1, !tbaa !22
  %59 = load i8, ptr %14, align 1, !tbaa !22, !range !18, !noundef !19
  %60 = trunc i8 %59 to i1
  br i1 %60, label %68, label %61

61:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  %62 = call i32 @lapack_get_last_status()
  store i32 %62, ptr %15, align 4, !tbaa !23
  %63 = load i32, ptr %15, align 4, !tbaa !23
  switch i32 %63, label %66 [
    i32 -2, label %64
    i32 -4, label %65
  ]

64:                                               ; preds = %61
  store i32 2, ptr getelementptr inbounds (%struct.anon, ptr @backend_state, i32 0, i32 2), align 8, !tbaa !20
  br label %67

65:                                               ; preds = %61
  store i32 4, ptr getelementptr inbounds (%struct.anon, ptr @backend_state, i32 0, i32 2), align 8, !tbaa !20
  br label %67

66:                                               ; preds = %61
  store i32 3, ptr getelementptr inbounds (%struct.anon, ptr @backend_state, i32 0, i32 2), align 8, !tbaa !20
  br label %67

67:                                               ; preds = %66, %65, %64
  store i1 false, ptr %7, align 1
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %69

68:                                               ; preds = %50
  store i32 0, ptr getelementptr inbounds (%struct.anon, ptr @backend_state, i32 0, i32 2), align 8, !tbaa !20
  store i1 true, ptr %7, align 1
  store i32 1, ptr %16, align 4
  br label %69

69:                                               ; preds = %68, %67
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #7
  br label %246

70:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  store i64 100, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  store float 0x3EB0C6F7A0000000, ptr %18, align 4, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %71 = load i64, ptr %12, align 8, !tbaa !9
  %72 = mul i64 %71, 8
  %73 = call noalias ptr @malloc(i64 noundef %72) #8
  store ptr %73, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  %74 = load i64, ptr %12, align 8, !tbaa !9
  %75 = mul i64 %74, 8
  %76 = call noalias ptr @malloc(i64 noundef %75) #8
  store ptr %76, ptr %20, align 8, !tbaa !5
  %77 = load ptr, ptr %19, align 8, !tbaa !5
  %78 = icmp ne ptr %77, null
  br i1 %78, label %79, label %82

79:                                               ; preds = %70
  %80 = load ptr, ptr %20, align 8, !tbaa !5
  %81 = icmp ne ptr %80, null
  br i1 %81, label %85, label %82

82:                                               ; preds = %79, %70
  %83 = load ptr, ptr %19, align 8, !tbaa !5
  call void @free(ptr noundef %83) #7
  %84 = load ptr, ptr %20, align 8, !tbaa !5
  call void @free(ptr noundef %84) #7
  store i32 2, ptr getelementptr inbounds (%struct.anon, ptr @backend_state, i32 0, i32 2), align 8, !tbaa !20
  store i1 false, ptr %7, align 1
  store i32 1, ptr %16, align 4
  br label %245

85:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  store i64 0, ptr %21, align 8, !tbaa !9
  br label %86

86:                                               ; preds = %104, %85
  %87 = load i64, ptr %21, align 8, !tbaa !9
  %88 = load i64, ptr %12, align 8, !tbaa !9
  %89 = icmp ult i64 %87, %88
  br i1 %89, label %91, label %90

90:                                               ; preds = %86
  store i32 3, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  br label %107

91:                                               ; preds = %86
  %92 = load i64, ptr %12, align 8, !tbaa !9
  %93 = uitofp i64 %92 to float
  %94 = call float @sqrtf(float noundef %93) #7
  %95 = fdiv float 1.000000e+00, %94
  %96 = load ptr, ptr %19, align 8, !tbaa !5
  %97 = load i64, ptr %21, align 8, !tbaa !9
  %98 = getelementptr inbounds %struct.ComplexFloat, ptr %96, i64 %97
  %99 = getelementptr inbounds %struct.ComplexFloat, ptr %98, i32 0, i32 0
  store float %95, ptr %99, align 4, !tbaa !26
  %100 = load ptr, ptr %19, align 8, !tbaa !5
  %101 = load i64, ptr %21, align 8, !tbaa !9
  %102 = getelementptr inbounds %struct.ComplexFloat, ptr %100, i64 %101
  %103 = getelementptr inbounds %struct.ComplexFloat, ptr %102, i32 0, i32 1
  store float 0.000000e+00, ptr %103, align 4, !tbaa !28
  br label %104

104:                                              ; preds = %91
  %105 = load i64, ptr %21, align 8, !tbaa !9
  %106 = add i64 %105, 1
  store i64 %106, ptr %21, align 8, !tbaa !9
  br label %86, !llvm.loop !29

107:                                              ; preds = %90
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  store i64 0, ptr %22, align 8, !tbaa !9
  br label %108

108:                                              ; preds = %226, %107
  %109 = load i64, ptr %22, align 8, !tbaa !9
  %110 = icmp ult i64 %109, 100
  br i1 %110, label %112, label %111

111:                                              ; preds = %108
  store i32 6, ptr %16, align 4
  br label %229

112:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  store i64 0, ptr %23, align 8, !tbaa !9
  br label %113

113:                                              ; preds = %159, %112
  %114 = load i64, ptr %23, align 8, !tbaa !9
  %115 = load i64, ptr %12, align 8, !tbaa !9
  %116 = icmp ult i64 %114, %115
  br i1 %116, label %118, label %117

117:                                              ; preds = %113
  store i32 9, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  br label %162

118:                                              ; preds = %113
  %119 = load ptr, ptr %20, align 8, !tbaa !5
  %120 = load i64, ptr %23, align 8, !tbaa !9
  %121 = getelementptr inbounds %struct.ComplexFloat, ptr %119, i64 %120
  %122 = getelementptr inbounds %struct.ComplexFloat, ptr %121, i32 0, i32 1
  store float 0.000000e+00, ptr %122, align 4, !tbaa !28
  %123 = load ptr, ptr %20, align 8, !tbaa !5
  %124 = load i64, ptr %23, align 8, !tbaa !9
  %125 = getelementptr inbounds %struct.ComplexFloat, ptr %123, i64 %124
  %126 = getelementptr inbounds %struct.ComplexFloat, ptr %125, i32 0, i32 0
  store float 0.000000e+00, ptr %126, align 4, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #7
  store i64 0, ptr %24, align 8, !tbaa !9
  br label %127

127:                                              ; preds = %155, %118
  %128 = load i64, ptr %24, align 8, !tbaa !9
  %129 = load i64, ptr %13, align 8, !tbaa !9
  %130 = icmp ult i64 %128, %129
  br i1 %130, label %132, label %131

131:                                              ; preds = %127
  store i32 12, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #7
  br label %158

132:                                              ; preds = %127
  %133 = load ptr, ptr %20, align 8, !tbaa !5
  %134 = load i64, ptr %23, align 8, !tbaa !9
  %135 = getelementptr inbounds %struct.ComplexFloat, ptr %133, i64 %134
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #7
  %136 = load ptr, ptr %20, align 8, !tbaa !5
  %137 = load i64, ptr %23, align 8, !tbaa !9
  %138 = getelementptr inbounds %struct.ComplexFloat, ptr %136, i64 %137
  %139 = load ptr, ptr %8, align 8, !tbaa !5
  %140 = load i64, ptr %23, align 8, !tbaa !9
  %141 = load i64, ptr %13, align 8, !tbaa !9
  %142 = mul i64 %140, %141
  %143 = load i64, ptr %24, align 8, !tbaa !9
  %144 = add i64 %142, %143
  %145 = getelementptr inbounds %struct.ComplexFloat, ptr %139, i64 %144
  %146 = load ptr, ptr %19, align 8, !tbaa !5
  %147 = load i64, ptr %24, align 8, !tbaa !9
  %148 = getelementptr inbounds %struct.ComplexFloat, ptr %146, i64 %147
  %149 = load <2 x float>, ptr %145, align 4
  %150 = load <2 x float>, ptr %148, align 4
  %151 = call <2 x float> @complex_multiply(<2 x float> %149, <2 x float> %150)
  store <2 x float> %151, ptr %26, align 4
  %152 = load <2 x float>, ptr %138, align 4
  %153 = load <2 x float>, ptr %26, align 4
  %154 = call <2 x float> @complex_add(<2 x float> %152, <2 x float> %153)
  store <2 x float> %154, ptr %25, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %135, ptr align 4 %25, i64 8, i1 false), !tbaa.struct !31
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #7
  br label %155

155:                                              ; preds = %132
  %156 = load i64, ptr %24, align 8, !tbaa !9
  %157 = add i64 %156, 1
  store i64 %157, ptr %24, align 8, !tbaa !9
  br label %127, !llvm.loop !32

158:                                              ; preds = %131
  br label %159

159:                                              ; preds = %158
  %160 = load i64, ptr %23, align 8, !tbaa !9
  %161 = add i64 %160, 1
  store i64 %161, ptr %23, align 8, !tbaa !9
  br label %113, !llvm.loop !33

162:                                              ; preds = %117
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #7
  store float 0.000000e+00, ptr %27, align 4, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #7
  store i64 0, ptr %28, align 8, !tbaa !9
  br label %163

163:                                              ; preds = %176, %162
  %164 = load i64, ptr %28, align 8, !tbaa !9
  %165 = load i64, ptr %12, align 8, !tbaa !9
  %166 = icmp ult i64 %164, %165
  br i1 %166, label %168, label %167

167:                                              ; preds = %163
  store i32 15, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #7
  br label %179

168:                                              ; preds = %163
  %169 = load ptr, ptr %20, align 8, !tbaa !5
  %170 = load i64, ptr %28, align 8, !tbaa !9
  %171 = getelementptr inbounds %struct.ComplexFloat, ptr %169, i64 %170
  %172 = load <2 x float>, ptr %171, align 4
  %173 = call float @complex_abs_squared(<2 x float> %172)
  %174 = load float, ptr %27, align 4, !tbaa !24
  %175 = fadd float %174, %173
  store float %175, ptr %27, align 4, !tbaa !24
  br label %176

176:                                              ; preds = %168
  %177 = load i64, ptr %28, align 8, !tbaa !9
  %178 = add i64 %177, 1
  store i64 %178, ptr %28, align 8, !tbaa !9
  br label %163, !llvm.loop !34

179:                                              ; preds = %167
  %180 = load float, ptr %27, align 4, !tbaa !24
  %181 = call float @sqrtf(float noundef %180) #7
  store float %181, ptr %27, align 4, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 1, ptr %29) #7
  store i8 1, ptr %29, align 1, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #7
  store i64 0, ptr %30, align 8, !tbaa !9
  br label %182

182:                                              ; preds = %215, %179
  %183 = load i64, ptr %30, align 8, !tbaa !9
  %184 = load i64, ptr %12, align 8, !tbaa !9
  %185 = icmp ult i64 %183, %184
  br i1 %185, label %187, label %186

186:                                              ; preds = %182
  store i32 18, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #7
  br label %218

187:                                              ; preds = %182
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #7
  %188 = getelementptr inbounds %struct.ComplexFloat, ptr %31, i32 0, i32 0
  %189 = load ptr, ptr %20, align 8, !tbaa !5
  %190 = load i64, ptr %30, align 8, !tbaa !9
  %191 = getelementptr inbounds %struct.ComplexFloat, ptr %189, i64 %190
  %192 = getelementptr inbounds %struct.ComplexFloat, ptr %191, i32 0, i32 0
  %193 = load float, ptr %192, align 4, !tbaa !26
  %194 = load float, ptr %27, align 4, !tbaa !24
  %195 = fdiv float %193, %194
  store float %195, ptr %188, align 4, !tbaa !26
  %196 = getelementptr inbounds %struct.ComplexFloat, ptr %31, i32 0, i32 1
  %197 = load ptr, ptr %20, align 8, !tbaa !5
  %198 = load i64, ptr %30, align 8, !tbaa !9
  %199 = getelementptr inbounds %struct.ComplexFloat, ptr %197, i64 %198
  %200 = getelementptr inbounds %struct.ComplexFloat, ptr %199, i32 0, i32 1
  %201 = load float, ptr %200, align 4, !tbaa !28
  %202 = load float, ptr %27, align 4, !tbaa !24
  %203 = fdiv float %201, %202
  store float %203, ptr %196, align 4, !tbaa !28
  %204 = load ptr, ptr %19, align 8, !tbaa !5
  %205 = load i64, ptr %30, align 8, !tbaa !9
  %206 = getelementptr inbounds %struct.ComplexFloat, ptr %204, i64 %205
  %207 = load <2 x float>, ptr %31, align 4
  %208 = load <2 x float>, ptr %206, align 4
  %209 = call zeroext i1 @complex_is_equal(<2 x float> %207, <2 x float> %208)
  br i1 %209, label %211, label %210

210:                                              ; preds = %187
  store i8 0, ptr %29, align 1, !tbaa !22
  br label %211

211:                                              ; preds = %210, %187
  %212 = load ptr, ptr %19, align 8, !tbaa !5
  %213 = load i64, ptr %30, align 8, !tbaa !9
  %214 = getelementptr inbounds %struct.ComplexFloat, ptr %212, i64 %213
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %214, ptr align 4 %31, i64 8, i1 false), !tbaa.struct !31
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #7
  br label %215

215:                                              ; preds = %211
  %216 = load i64, ptr %30, align 8, !tbaa !9
  %217 = add i64 %216, 1
  store i64 %217, ptr %30, align 8, !tbaa !9
  br label %182, !llvm.loop !35

218:                                              ; preds = %186
  %219 = load i8, ptr %29, align 1, !tbaa !22, !range !18, !noundef !19
  %220 = trunc i8 %219 to i1
  br i1 %220, label %221, label %222

221:                                              ; preds = %218
  store i32 6, ptr %16, align 4
  br label %223

222:                                              ; preds = %218
  store i32 0, ptr %16, align 4
  br label %223

223:                                              ; preds = %222, %221
  call void @llvm.lifetime.end.p0(i64 1, ptr %29) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #7
  %224 = load i32, ptr %16, align 4
  switch i32 %224, label %229 [
    i32 0, label %225
  ]

225:                                              ; preds = %223
  br label %226

226:                                              ; preds = %225
  %227 = load i64, ptr %22, align 8, !tbaa !9
  %228 = add i64 %227, 1
  store i64 %228, ptr %22, align 8, !tbaa !9
  br label %108, !llvm.loop !36

229:                                              ; preds = %223, %111
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  br label %230

230:                                              ; preds = %229
  %231 = load ptr, ptr %9, align 8, !tbaa !5
  %232 = load ptr, ptr %19, align 8, !tbaa !5
  %233 = load i64, ptr %12, align 8, !tbaa !9
  %234 = mul i64 %233, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %231, ptr align 4 %232, i64 %234, i1 false)
  %235 = load ptr, ptr %10, align 8, !tbaa !5
  %236 = getelementptr inbounds float, ptr %235, i64 0
  store float 1.000000e+00, ptr %236, align 4, !tbaa !24
  %237 = load ptr, ptr %11, align 8, !tbaa !5
  %238 = load i64, ptr %13, align 8, !tbaa !9
  %239 = mul i64 %238, 8
  call void @llvm.memset.p0.i64(ptr align 4 %237, i8 0, i64 %239, i1 false)
  %240 = load ptr, ptr %11, align 8, !tbaa !5
  %241 = getelementptr inbounds %struct.ComplexFloat, ptr %240, i64 0
  %242 = getelementptr inbounds %struct.ComplexFloat, ptr %241, i32 0, i32 0
  store float 1.000000e+00, ptr %242, align 4, !tbaa !26
  %243 = load ptr, ptr %19, align 8, !tbaa !5
  call void @free(ptr noundef %243) #7
  %244 = load ptr, ptr %20, align 8, !tbaa !5
  call void @free(ptr noundef %244) #7
  store i32 0, ptr getelementptr inbounds (%struct.anon, ptr @backend_state, i32 0, i32 2), align 8, !tbaa !20
  store i1 true, ptr %7, align 1
  store i32 1, ptr %16, align 4
  br label %245

245:                                              ; preds = %230, %82
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  br label %246

246:                                              ; preds = %245, %69, %46
  %247 = load i1, ptr %7, align 1
  ret i1 %247
}

declare zeroext i1 @lapack_svd(ptr noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #3

declare i32 @lapack_get_last_status() #3

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #5

; Function Attrs: nounwind
declare void @free(ptr noundef) #6

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #6

declare float @complex_abs_squared(<2 x float>) #3

declare zeroext i1 @complex_is_equal(<2 x float>, <2 x float>) #3

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 uwtable "min-legal-vector-width"="64" "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 allocsize(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 "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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !15, i64 84}
!12 = !{!"", !13, i64 0, !16, i64 40, !14, i64 80, !15, i64 84, !15, i64 85}
!13 = !{!"", !14, i64 0, !10, i64 8, !15, i64 16, !15, i64 17, !15, i64 18, !10, i64 24, !6, i64 32}
!14 = !{!"int", !7, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!"", !17, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !10, i64 32}
!17 = !{!"double", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!12, !14, i64 80}
!21 = !{!12, !15, i64 85}
!22 = !{!15, !15, i64 0}
!23 = !{!14, !14, i64 0}
!24 = !{!25, !25, i64 0}
!25 = !{!"float", !7, i64 0}
!26 = !{!27, !25, i64 0}
!27 = !{!"", !25, i64 0, !25, i64 4}
!28 = !{!27, !25, i64 4}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{i64 0, i64 4, !24, i64 4, i64 4, !24}
!32 = distinct !{!32, !30}
!33 = distinct !{!33, !30}
!34 = distinct !{!34, !30}
!35 = distinct !{!35, !30}
!36 = distinct !{!36, !30}


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

%struct.anon = type { %struct.numerical_config_t, %struct.numerical_metrics_t, i32, i8, i8 }
%struct.numerical_config_t = type { i32, i64, i8, i8, i8, i64, ptr }
%struct.numerical_metrics_t = type { double, double, double, double, i64 }
%struct.ComplexFloat = type { float, float }

@backend_state = external hidden local_unnamed_addr global %struct.anon, align 8

; 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) #0

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

declare <2 x float> @complex_add(<2 x float>, <2 x float>) local_unnamed_addr #2

declare <2 x float> @complex_multiply(<2 x float>, <2 x float>) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @numerical_svd(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i64 noundef %4, i64 noundef %5) local_unnamed_addr #3 {
  %7 = load i8, ptr getelementptr inbounds (i8, ptr @backend_state, i64 84), align 4, !tbaa !5, !range !16, !noundef !17
  %8 = trunc nuw i8 %7 to i1
  %9 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %10 = insertelement <4 x ptr> %9, ptr %1, i64 1
  %11 = insertelement <4 x ptr> %10, ptr %2, i64 2
  %12 = insertelement <4 x ptr> %11, ptr %3, i64 3
  %13 = icmp eq <4 x ptr> %12, zeroinitializer
  %14 = bitcast <4 x i1> %13 to i4
  %15 = icmp eq i4 %14, 0
  %op.rdx = and i1 %15, %8
  br i1 %op.rdx, label %16, label %72

16:                                               ; preds = %6
  %17 = load i8, ptr getelementptr inbounds (i8, ptr @backend_state, i64 85), align 1, !tbaa !18, !range !16, !noundef !17
  %18 = trunc nuw i8 %17 to i1
  br i1 %18, label %19, label %25

19:                                               ; preds = %16
  %20 = tail call zeroext i1 @lapack_svd(ptr noundef nonnull %0, i64 noundef %4, i64 noundef %5, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3, i32 noundef 101) #8
  br i1 %20, label %72, label %21

21:                                               ; preds = %19
  %22 = tail call i32 @lapack_get_last_status() #8
  switch i32 %22, label %24 [
    i32 -2, label %72
    i32 -4, label %23
  ]

23:                                               ; preds = %21
  br label %72

24:                                               ; preds = %21
  br label %72

25:                                               ; preds = %16
  %26 = shl i64 %4, 3
  %27 = tail call noalias ptr @malloc(i64 noundef %26) #9
  %28 = tail call noalias ptr @malloc(i64 noundef %26) #9
  %29 = icmp ne ptr %27, null
  %30 = icmp ne ptr %28, null
  %or.cond9 = and i1 %29, %30
  br i1 %or.cond9, label %.preheader111, label %37

.preheader111:                                    ; preds = %25
  %.not = icmp eq i64 %4, 0
  br i1 %.not, label %.split.us, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader111
  %31 = uitofp i64 %4 to float
  %sqrt = tail call float @llvm.sqrt.f32(float %31)
  %32 = fdiv float 1.000000e+00, %sqrt
  %min.iters.check = icmp ult i64 %4, 4
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %.0100112.ph = phi i64 [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %4, -4
  %broadcast.splatinsert = insertelement <2 x float> poison, float %32, i64 0
  %broadcast.splat = shufflevector <2 x float> %broadcast.splatinsert, <2 x float> poison, <2 x i32> zeroinitializer
  %interleaved.vec = shufflevector <2 x float> %broadcast.splat, <2 x float> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %33 = or disjoint i64 %index, 2
  %34 = getelementptr inbounds %struct.ComplexFloat, ptr %27, i64 %index
  %35 = getelementptr inbounds %struct.ComplexFloat, ptr %27, i64 %33
  store <4 x float> %interleaved.vec, ptr %34, align 4, !tbaa !19
  store <4 x float> %interleaved.vec, ptr %35, align 4, !tbaa !19
  %index.next = add nuw i64 %index, 4
  %36 = icmp eq i64 %index.next, %n.vec
  br i1 %36, label %middle.block, label %vector.body, !llvm.loop !21

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %4
  br i1 %cmp.n, label %.preheader109.us.preheader, label %scalar.ph.preheader

37:                                               ; preds = %25
  tail call void @free(ptr noundef %27) #8
  tail call void @free(ptr noundef %28) #8
  br label %72

.preheader109.us.preheader:                       ; preds = %scalar.ph, %middle.block
  %.not160 = icmp eq i64 %5, 0
  br label %.preheader109.us

.preheader109.us:                                 ; preds = %.preheader109.us.preheader, %._crit_edge124.us
  %.099126.us = phi i64 [ %41, %._crit_edge124.us ], [ 0, %.preheader109.us.preheader ]
  br i1 %.not160, label %.lr.ph116.split.us129.preheader, label %.lr.ph114.us.us

.lr.ph116.split.us129.preheader:                  ; preds = %.preheader109.us
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 %28, i8 0, i64 %26, i1 false), !tbaa !19
  br label %.lr.ph119.us.preheader

.lr.ph119.us.preheader:                           ; preds = %._crit_edge.us.us, %.lr.ph116.split.us129.preheader
  br label %.lr.ph119.us

.lr.ph123.us.preheader:                           ; preds = %.lr.ph119.us
  %38 = tail call float @sqrtf(float noundef %53) #8
  %39 = insertelement <2 x float> poison, float %38, i64 0
  %40 = shufflevector <2 x float> %39, <2 x float> poison, <2 x i32> zeroinitializer
  br label %.lr.ph123.us

._crit_edge124.us:                                ; preds = %.lr.ph123.us
  %41 = add nuw nsw i64 %.099126.us, 1
  %42 = icmp ugt i64 %.099126.us, 98
  %or.cond156.not = select i1 %spec.select.us, i1 true, i1 %42
  br i1 %or.cond156.not, label %.split.us, label %.preheader109.us, !llvm.loop !25

.lr.ph123.us:                                     ; preds = %.lr.ph123.us.preheader, %.lr.ph123.us
  %.0121.us = phi i64 [ %49, %.lr.ph123.us ], [ 0, %.lr.ph123.us.preheader ]
  %.091120.us = phi i1 [ %spec.select.us, %.lr.ph123.us ], [ true, %.lr.ph123.us.preheader ]
  %43 = getelementptr inbounds %struct.ComplexFloat, ptr %28, i64 %.0121.us
  %44 = load <2 x float>, ptr %43, align 4, !tbaa !19
  %45 = fdiv <2 x float> %44, %40
  %46 = getelementptr inbounds %struct.ComplexFloat, ptr %27, i64 %.0121.us
  %47 = load <2 x float>, ptr %46, align 4
  %48 = tail call zeroext i1 @complex_is_equal(<2 x float> %45, <2 x float> %47) #8
  %spec.select.us = select i1 %48, i1 %.091120.us, i1 false
  store <2 x float> %45, ptr %46, align 4
  %49 = add nuw i64 %.0121.us, 1
  %exitcond168.not = icmp eq i64 %49, %4
  br i1 %exitcond168.not, label %._crit_edge124.us, label %.lr.ph123.us, !llvm.loop !26

.lr.ph119.us:                                     ; preds = %.lr.ph119.us.preheader, %.lr.ph119.us
  %.092118.us = phi i64 [ %54, %.lr.ph119.us ], [ 0, %.lr.ph119.us.preheader ]
  %.093117.us = phi float [ %53, %.lr.ph119.us ], [ 0.000000e+00, %.lr.ph119.us.preheader ]
  %50 = getelementptr inbounds %struct.ComplexFloat, ptr %28, i64 %.092118.us
  %51 = load <2 x float>, ptr %50, align 4
  %52 = tail call float @complex_abs_squared(<2 x float> %51) #8
  %53 = fadd float %.093117.us, %52
  %54 = add nuw i64 %.092118.us, 1
  %exitcond167.not = icmp eq i64 %54, %4
  br i1 %exitcond167.not, label %.lr.ph123.us.preheader, label %.lr.ph119.us, !llvm.loop !27

.lr.ph114.us.us:                                  ; preds = %.preheader109.us, %._crit_edge.us.us
  %.098115.us.us = phi i64 [ %67, %._crit_edge.us.us ], [ 0, %.preheader109.us ]
  %55 = getelementptr inbounds %struct.ComplexFloat, ptr %28, i64 %.098115.us.us
  store <2 x float> zeroinitializer, ptr %55, align 4, !tbaa !19
  %56 = mul i64 %.098115.us.us, %5
  %57 = getelementptr %struct.ComplexFloat, ptr %0, i64 %56
  br label %58

58:                                               ; preds = %58, %.lr.ph114.us.us
  %.097113.us.us = phi i64 [ 0, %.lr.ph114.us.us ], [ %66, %58 ]
  %59 = getelementptr %struct.ComplexFloat, ptr %57, i64 %.097113.us.us
  %60 = getelementptr inbounds %struct.ComplexFloat, ptr %27, i64 %.097113.us.us
  %61 = load <2 x float>, ptr %59, align 4
  %62 = load <2 x float>, ptr %60, align 4
  %63 = tail call <2 x float> @complex_multiply(<2 x float> %61, <2 x float> %62) #8
  %64 = load <2 x float>, ptr %55, align 4
  %65 = tail call <2 x float> @complex_add(<2 x float> %64, <2 x float> %63) #8
  store <2 x float> %65, ptr %55, align 4
  %66 = add nuw i64 %.097113.us.us, 1
  %exitcond165.not = icmp eq i64 %66, %5
  br i1 %exitcond165.not, label %._crit_edge.us.us, label %58, !llvm.loop !28

._crit_edge.us.us:                                ; preds = %58
  %67 = add nuw i64 %.098115.us.us, 1
  %exitcond166.not = icmp eq i64 %67, %4
  br i1 %exitcond166.not, label %.lr.ph119.us.preheader, label %.lr.ph114.us.us, !llvm.loop !29

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %.0100112 = phi i64 [ %70, %scalar.ph ], [ %.0100112.ph, %scalar.ph.preheader ]
  %68 = getelementptr inbounds %struct.ComplexFloat, ptr %27, i64 %.0100112
  store float %32, ptr %68, align 4, !tbaa !30
  %69 = getelementptr inbounds i8, ptr %68, i64 4
  store float 0.000000e+00, ptr %69, align 4, !tbaa !32
  %70 = add nuw i64 %.0100112, 1
  %exitcond.not = icmp eq i64 %70, %4
  br i1 %exitcond.not, label %.preheader109.us.preheader, label %scalar.ph, !llvm.loop !33

.split.us:                                        ; preds = %._crit_edge124.us, %.preheader111
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 4 %1, ptr nonnull align 4 %27, i64 %26, i1 false)
  store float 1.000000e+00, ptr %2, align 4, !tbaa !19
  %71 = shl i64 %5, 3
  tail call void @llvm.memset.p0.i64(ptr nonnull align 4 %3, i8 0, i64 %71, i1 false)
  store float 1.000000e+00, ptr %3, align 4, !tbaa !30
  tail call void @free(ptr noundef nonnull %27) #8
  tail call void @free(ptr noundef nonnull %28) #8
  br label %72

72:                                               ; preds = %37, %.split.us, %19, %21, %6, %24, %23
  %.sink = phi i32 [ 3, %24 ], [ 4, %23 ], [ 1, %6 ], [ 2, %21 ], [ 0, %19 ], [ 2, %37 ], [ 0, %.split.us ]
  %.2 = phi i1 [ false, %24 ], [ false, %23 ], [ false, %6 ], [ false, %21 ], [ true, %19 ], [ %or.cond9, %37 ], [ %or.cond9, %.split.us ]
  store i32 %.sink, ptr getelementptr inbounds (i8, ptr @backend_state, i64 80), align 8, !tbaa !34
  ret i1 %.2
}

declare zeroext i1 @lapack_svd(ptr noundef, i64 noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @lapack_get_last_status() local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #6

declare float @complex_abs_squared(<2 x float>) local_unnamed_addr #2

declare zeroext i1 @complex_is_equal(<2 x float>, <2 x float>) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.sqrt.f32(float) #7

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nofree nounwind willreturn memory(write) "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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { nounwind }
attributes #9 = { nounwind allocsize(0) }

!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, !12, i64 84}
!6 = !{!"", !7, i64 0, !14, i64 40, !8, i64 80, !12, i64 84, !12, i64 85}
!7 = !{!"", !8, i64 0, !11, i64 8, !12, i64 16, !12, i64 17, !12, i64 18, !11, i64 24, !13, i64 32}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"_Bool", !9, i64 0}
!13 = !{!"any pointer", !9, i64 0}
!14 = !{!"", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !11, i64 32}
!15 = !{!"double", !9, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!6, !12, i64 85}
!19 = !{!20, !20, i64 0}
!20 = !{!"float", !9, i64 0}
!21 = distinct !{!21, !22, !23, !24}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!"llvm.loop.isvectorized", i32 1}
!24 = !{!"llvm.loop.unroll.runtime.disable"}
!25 = distinct !{!25, !22}
!26 = distinct !{!26, !22}
!27 = distinct !{!27, !22}
!28 = distinct !{!28, !22}
!29 = distinct !{!29, !22}
!30 = !{!31, !20, i64 0}
!31 = !{!"", !20, i64 0, !20, i64 4}
!32 = !{!31, !20, i64 4}
!33 = distinct !{!33, !22, !24, !23}
!34 = !{!6, !8, i64 80}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass