; LLVM IR from sourceryinstitute/MORFEUS-Source :: src/FV/src/mesh_optimize/OptMS (SMgrad3d)

; 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.DERIV_TYPE = type { double, [3 x double] }

; Function Attrs: nounwind uwtable
declare dso_local i32 @g_ad_vCross(ptr noundef, ptr noundef, ptr noundef) #0

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @g_ad_dMagnitude(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @g_ad_vUnitNormal(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca [3 x %struct.DERIV_TYPE], align 16
  %11 = alloca [3 x %struct.DERIV_TYPE], align 16
  %12 = alloca %struct.DERIV_TYPE, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 96, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 96, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %177, %4
  %20 = load i32, ptr %17, align 4, !tbaa !9
  %21 = icmp slt i32 %20, 3
  br i1 %21, label %22, label %180

22:                                               ; preds = %19
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load i32, ptr %17, align 4, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds %struct.DERIV_TYPE, ptr %23, i64 %25
  %27 = getelementptr inbounds %struct.DERIV_TYPE, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds [3 x double], ptr %27, i64 0, i64 0
  %29 = load double, ptr %28, align 8, !tbaa !11
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i32, ptr %17, align 4, !tbaa !9
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds %struct.DERIV_TYPE, ptr %30, i64 %32
  %34 = getelementptr inbounds %struct.DERIV_TYPE, ptr %33, i32 0, i32 1
  %35 = getelementptr inbounds [3 x double], ptr %34, i64 0, i64 0
  %36 = load double, ptr %35, align 8, !tbaa !11
  %37 = fsub double %29, %36
  %38 = load i32, ptr %17, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [3 x %struct.DERIV_TYPE], ptr %10, i64 0, i64 %39
  %41 = getelementptr inbounds %struct.DERIV_TYPE, ptr %40, i32 0, i32 1
  %42 = getelementptr inbounds [3 x double], ptr %41, i64 0, i64 0
  store double %37, ptr %42, align 8, !tbaa !11
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load i32, ptr %17, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds %struct.DERIV_TYPE, ptr %43, i64 %45
  %47 = getelementptr inbounds %struct.DERIV_TYPE, ptr %46, i32 0, i32 1
  %48 = getelementptr inbounds [3 x double], ptr %47, i64 0, i64 0
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load i32, ptr %17, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds %struct.DERIV_TYPE, ptr %50, i64 %52
  %54 = getelementptr inbounds %struct.DERIV_TYPE, ptr %53, i32 0, i32 1
  %55 = getelementptr inbounds [3 x double], ptr %54, i64 0, i64 0
  %56 = load double, ptr %55, align 8, !tbaa !11
  %57 = fsub double %49, %56
  %58 = load i32, ptr %17, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [3 x %struct.DERIV_TYPE], ptr %11, i64 0, i64 %59
  %61 = getelementptr inbounds %struct.DERIV_TYPE, ptr %60, i32 0, i32 1
  %62 = getelementptr inbounds [3 x double], ptr %61, i64 0, i64 0
  store double %57, ptr %62, align 8, !tbaa !11
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = load i32, ptr %17, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds %struct.DERIV_TYPE, ptr %63, i64 %65
  %67 = getelementptr inbounds %struct.DERIV_TYPE, ptr %66, i32 0, i32 1
  %68 = getelementptr inbounds [3 x double], ptr %67, i64 0, i64 1
  %69 = load double, ptr %68, align 8, !tbaa !11
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = load i32, ptr %17, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %struct.DERIV_TYPE, ptr %70, i64 %72
  %74 = getelementptr inbounds %struct.DERIV_TYPE, ptr %73, i32 0, i32 1
  %75 = getelementptr inbounds [3 x double], ptr %74, i64 0, i64 1
  %76 = load double, ptr %75, align 8, !tbaa !11
  %77 = fsub double %69, %76
  %78 = load i32, ptr %17, align 4, !tbaa !9
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [3 x %struct.DERIV_TYPE], ptr %10, i64 0, i64 %79
  %81 = getelementptr inbounds %struct.DERIV_TYPE, ptr %80, i32 0, i32 1
  %82 = getelementptr inbounds [3 x double], ptr %81, i64 0, i64 1
  store double %77, ptr %82, align 8, !tbaa !11
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = load i32, ptr %17, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds %struct.DERIV_TYPE, ptr %83, i64 %85
  %87 = getelementptr inbounds %struct.DERIV_TYPE, ptr %86, i32 0, i32 1
  %88 = getelementptr inbounds [3 x double], ptr %87, i64 0, i64 1
  %89 = load double, ptr %88, align 8, !tbaa !11
  %90 = load ptr, ptr %5, align 8, !tbaa !5
  %91 = load i32, ptr %17, align 4, !tbaa !9
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds %struct.DERIV_TYPE, ptr %90, i64 %92
  %94 = getelementptr inbounds %struct.DERIV_TYPE, ptr %93, i32 0, i32 1
  %95 = getelementptr inbounds [3 x double], ptr %94, i64 0, i64 1
  %96 = load double, ptr %95, align 8, !tbaa !11
  %97 = fsub double %89, %96
  %98 = load i32, ptr %17, align 4, !tbaa !9
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [3 x %struct.DERIV_TYPE], ptr %11, i64 0, i64 %99
  %101 = getelementptr inbounds %struct.DERIV_TYPE, ptr %100, i32 0, i32 1
  %102 = getelementptr inbounds [3 x double], ptr %101, i64 0, i64 1
  store double %97, ptr %102, align 8, !tbaa !11
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = load i32, ptr %17, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds %struct.DERIV_TYPE, ptr %103, i64 %105
  %107 = getelementptr inbounds %struct.DERIV_TYPE, ptr %106, i32 0, i32 1
  %108 = getelementptr inbounds [3 x double], ptr %107, i64 0, i64 2
  %109 = load double, ptr %108, align 8, !tbaa !11
  %110 = load ptr, ptr %5, align 8, !tbaa !5
  %111 = load i32, ptr %17, align 4, !tbaa !9
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds %struct.DERIV_TYPE, ptr %110, i64 %112
  %114 = getelementptr inbounds %struct.DERIV_TYPE, ptr %113, i32 0, i32 1
  %115 = getelementptr inbounds [3 x double], ptr %114, i64 0, i64 2
  %116 = load double, ptr %115, align 8, !tbaa !11
  %117 = fsub double %109, %116
  %118 = load i32, ptr %17, align 4, !tbaa !9
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [3 x %struct.DERIV_TYPE], ptr %10, i64 0, i64 %119
  %121 = getelementptr inbounds %struct.DERIV_TYPE, ptr %120, i32 0, i32 1
  %122 = getelementptr inbounds [3 x double], ptr %121, i64 0, i64 2
  store double %117, ptr %122, align 8, !tbaa !11
  %123 = load ptr, ptr %7, align 8, !tbaa !5
  %124 = load i32, ptr %17, align 4, !tbaa !9
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds %struct.DERIV_TYPE, ptr %123, i64 %125
  %127 = getelementptr inbounds %struct.DERIV_TYPE, ptr %126, i32 0, i32 1
  %128 = getelementptr inbounds [3 x double], ptr %127, i64 0, i64 2
  %129 = load double, ptr %128, align 8, !tbaa !11
  %130 = load ptr, ptr %5, align 8, !tbaa !5
  %131 = load i32, ptr %17, align 4, !tbaa !9
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds %struct.DERIV_TYPE, ptr %130, i64 %132
  %134 = getelementptr inbounds %struct.DERIV_TYPE, ptr %133, i32 0, i32 1
  %135 = getelementptr inbounds [3 x double], ptr %134, i64 0, i64 2
  %136 = load double, ptr %135, align 8, !tbaa !11
  %137 = fsub double %129, %136
  %138 = load i32, ptr %17, align 4, !tbaa !9
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [3 x %struct.DERIV_TYPE], ptr %11, i64 0, i64 %139
  %141 = getelementptr inbounds %struct.DERIV_TYPE, ptr %140, i32 0, i32 1
  %142 = getelementptr inbounds [3 x double], ptr %141, i64 0, i64 2
  store double %137, ptr %142, align 8, !tbaa !11
  %143 = load ptr, ptr %6, align 8, !tbaa !5
  %144 = load i32, ptr %17, align 4, !tbaa !9
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds %struct.DERIV_TYPE, ptr %143, i64 %145
  %147 = getelementptr inbounds %struct.DERIV_TYPE, ptr %146, i32 0, i32 0
  %148 = load double, ptr %147, align 8, !tbaa !13
  %149 = load ptr, ptr %5, align 8, !tbaa !5
  %150 = load i32, ptr %17, align 4, !tbaa !9
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds %struct.DERIV_TYPE, ptr %149, i64 %151
  %153 = getelementptr inbounds %struct.DERIV_TYPE, ptr %152, i32 0, i32 0
  %154 = load double, ptr %153, align 8, !tbaa !13
  %155 = fsub double %148, %154
  %156 = load i32, ptr %17, align 4, !tbaa !9
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [3 x %struct.DERIV_TYPE], ptr %10, i64 0, i64 %157
  %159 = getelementptr inbounds %struct.DERIV_TYPE, ptr %158, i32 0, i32 0
  store double %155, ptr %159, align 16, !tbaa !13
  %160 = load ptr, ptr %7, align 8, !tbaa !5
  %161 = load i32, ptr %17, align 4, !tbaa !9
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds %struct.DERIV_TYPE, ptr %160, i64 %162
  %164 = getelementptr inbounds %struct.DERIV_TYPE, ptr %163, i32 0, i32 0
  %165 = load double, ptr %164, align 8, !tbaa !13
  %166 = load ptr, ptr %5, align 8, !tbaa !5
  %167 = load i32, ptr %17, align 4, !tbaa !9
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds %struct.DERIV_TYPE, ptr %166, i64 %168
  %170 = getelementptr inbounds %struct.DERIV_TYPE, ptr %169, i32 0, i32 0
  %171 = load double, ptr %170, align 8, !tbaa !13
  %172 = fsub double %165, %171
  %173 = load i32, ptr %17, align 4, !tbaa !9
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [3 x %struct.DERIV_TYPE], ptr %11, i64 0, i64 %174
  %176 = getelementptr inbounds %struct.DERIV_TYPE, ptr %175, i32 0, i32 0
  store double %172, ptr %176, align 16, !tbaa !13
  br label %177

177:                                              ; preds = %22
  %178 = load i32, ptr %17, align 4, !tbaa !9
  %179 = add nsw i32 %178, 1
  store i32 %179, ptr %17, align 4, !tbaa !9
  br label %19, !llvm.loop !15

180:                                              ; preds = %19
  %181 = getelementptr inbounds [3 x %struct.DERIV_TYPE], ptr %10, i64 0, i64 0
  %182 = getelementptr inbounds [3 x %struct.DERIV_TYPE], ptr %11, i64 0, i64 0
  %183 = load ptr, ptr %8, align 8, !tbaa !5
  %184 = call i32 @g_ad_vCross(ptr noundef %181, ptr noundef %182, ptr noundef %183)
  %185 = load ptr, ptr %8, align 8, !tbaa !5
  %186 = call i32 @g_ad_dMagnitude(ptr noundef %12, ptr noundef %185)
  %187 = getelementptr inbounds %struct.DERIV_TYPE, ptr %12, i32 0, i32 0
  %188 = load double, ptr %187, align 8, !tbaa !13
  %189 = fdiv double 1.000000e+00, %188
  store double %189, ptr %13, align 8, !tbaa !11
  %190 = load double, ptr %13, align 8, !tbaa !11
  %191 = load ptr, ptr %8, align 8, !tbaa !5
  %192 = getelementptr inbounds %struct.DERIV_TYPE, ptr %191, i64 0
  %193 = getelementptr inbounds %struct.DERIV_TYPE, ptr %192, i32 0, i32 0
  %194 = load double, ptr %193, align 8, !tbaa !13
  %195 = fmul double %194, %190
  store double %195, ptr %193, align 8, !tbaa !13
  %196 = load double, ptr %13, align 8, !tbaa !11
  %197 = load ptr, ptr %8, align 8, !tbaa !5
  %198 = getelementptr inbounds %struct.DERIV_TYPE, ptr %197, i64 1
  %199 = getelementptr inbounds %struct.DERIV_TYPE, ptr %198, i32 0, i32 0
  %200 = load double, ptr %199, align 8, !tbaa !13
  %201 = fmul double %200, %196
  store double %201, ptr %199, align 8, !tbaa !13
  %202 = load double, ptr %13, align 8, !tbaa !11
  %203 = load ptr, ptr %8, align 8, !tbaa !5
  %204 = getelementptr inbounds %struct.DERIV_TYPE, ptr %203, i64 2
  %205 = getelementptr inbounds %struct.DERIV_TYPE, ptr %204, i32 0, i32 0
  %206 = load double, ptr %205, align 8, !tbaa !13
  %207 = fmul double %206, %202
  store double %207, ptr %205, align 8, !tbaa !13
  %208 = load ptr, ptr %8, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.DERIV_TYPE, ptr %208, i64 0
  %210 = getelementptr inbounds %struct.DERIV_TYPE, ptr %209, i32 0, i32 0
  %211 = load double, ptr %210, align 8, !tbaa !13
  %212 = fneg double %211
  %213 = load double, ptr %13, align 8, !tbaa !11
  %214 = fmul double %212, %213
  store double %214, ptr %14, align 8, !tbaa !11
  %215 = load ptr, ptr %8, align 8, !tbaa !5
  %216 = getelementptr inbounds %struct.DERIV_TYPE, ptr %215, i64 1
  %217 = getelementptr inbounds %struct.DERIV_TYPE, ptr %216, i32 0, i32 0
  %218 = load double, ptr %217, align 8, !tbaa !13
  %219 = fneg double %218
  %220 = load double, ptr %13, align 8, !tbaa !11
  %221 = fmul double %219, %220
  store double %221, ptr %15, align 8, !tbaa !11
  %222 = load ptr, ptr %8, align 8, !tbaa !5
  %223 = getelementptr inbounds %struct.DERIV_TYPE, ptr %222, i64 2
  %224 = getelementptr inbounds %struct.DERIV_TYPE, ptr %223, i32 0, i32 0
  %225 = load double, ptr %224, align 8, !tbaa !13
  %226 = fneg double %225
  %227 = load double, ptr %13, align 8, !tbaa !11
  %228 = fmul double %226, %227
  store double %228, ptr %16, align 8, !tbaa !11
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %229

229:                                              ; preds = %299, %180
  %230 = load i32, ptr %18, align 4, !tbaa !9
  %231 = icmp slt i32 %230, 3
  br i1 %231, label %232, label %302

232:                                              ; preds = %229
  %233 = load double, ptr %13, align 8, !tbaa !11
  %234 = load ptr, ptr %8, align 8, !tbaa !5
  %235 = getelementptr inbounds %struct.DERIV_TYPE, ptr %234, i64 0
  %236 = getelementptr inbounds %struct.DERIV_TYPE, ptr %235, i32 0, i32 1
  %237 = load i32, ptr %18, align 4, !tbaa !9
  %238 = sext i32 %237 to i64
  %239 = getelementptr inbounds [3 x double], ptr %236, i64 0, i64 %238
  %240 = load double, ptr %239, align 8, !tbaa !11
  %241 = load double, ptr %14, align 8, !tbaa !11
  %242 = getelementptr inbounds %struct.DERIV_TYPE, ptr %12, i32 0, i32 1
  %243 = load i32, ptr %18, align 4, !tbaa !9
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [3 x double], ptr %242, i64 0, i64 %244
  %246 = load double, ptr %245, align 8, !tbaa !11
  %247 = fmul double %241, %246
  %248 = call double @llvm.fmuladd.f64(double %233, double %240, double %247)
  %249 = load ptr, ptr %8, align 8, !tbaa !5
  %250 = getelementptr inbounds %struct.DERIV_TYPE, ptr %249, i64 0
  %251 = getelementptr inbounds %struct.DERIV_TYPE, ptr %250, i32 0, i32 1
  %252 = load i32, ptr %18, align 4, !tbaa !9
  %253 = sext i32 %252 to i64
  %254 = getelementptr inbounds [3 x double], ptr %251, i64 0, i64 %253
  store double %248, ptr %254, align 8, !tbaa !11
  %255 = load double, ptr %13, align 8, !tbaa !11
  %256 = load ptr, ptr %8, align 8, !tbaa !5
  %257 = getelementptr inbounds %struct.DERIV_TYPE, ptr %256, i64 1
  %258 = getelementptr inbounds %struct.DERIV_TYPE, ptr %257, i32 0, i32 1
  %259 = load i32, ptr %18, align 4, !tbaa !9
  %260 = sext i32 %259 to i64
  %261 = getelementptr inbounds [3 x double], ptr %258, i64 0, i64 %260
  %262 = load double, ptr %261, align 8, !tbaa !11
  %263 = load double, ptr %15, align 8, !tbaa !11
  %264 = getelementptr inbounds %struct.DERIV_TYPE, ptr %12, i32 0, i32 1
  %265 = load i32, ptr %18, align 4, !tbaa !9
  %266 = sext i32 %265 to i64
  %267 = getelementptr inbounds [3 x double], ptr %264, i64 0, i64 %266
  %268 = load double, ptr %267, align 8, !tbaa !11
  %269 = fmul double %263, %268
  %270 = call double @llvm.fmuladd.f64(double %255, double %262, double %269)
  %271 = load ptr, ptr %8, align 8, !tbaa !5
  %272 = getelementptr inbounds %struct.DERIV_TYPE, ptr %271, i64 1
  %273 = getelementptr inbounds %struct.DERIV_TYPE, ptr %272, i32 0, i32 1
  %274 = load i32, ptr %18, align 4, !tbaa !9
  %275 = sext i32 %274 to i64
  %276 = getelementptr inbounds [3 x double], ptr %273, i64 0, i64 %275
  store double %270, ptr %276, align 8, !tbaa !11
  %277 = load double, ptr %13, align 8, !tbaa !11
  %278 = load ptr, ptr %8, align 8, !tbaa !5
  %279 = getelementptr inbounds %struct.DERIV_TYPE, ptr %278, i64 2
  %280 = getelementptr inbounds %struct.DERIV_TYPE, ptr %279, i32 0, i32 1
  %281 = load i32, ptr %18, align 4, !tbaa !9
  %282 = sext i32 %281 to i64
  %283 = getelementptr inbounds [3 x double], ptr %280, i64 0, i64 %282
  %284 = load double, ptr %283, align 8, !tbaa !11
  %285 = load double, ptr %16, align 8, !tbaa !11
  %286 = getelementptr inbounds %struct.DERIV_TYPE, ptr %12, i32 0, i32 1
  %287 = load i32, ptr %18, align 4, !tbaa !9
  %288 = sext i32 %287 to i64
  %289 = getelementptr inbounds [3 x double], ptr %286, i64 0, i64 %288
  %290 = load double, ptr %289, align 8, !tbaa !11
  %291 = fmul double %285, %290
  %292 = call double @llvm.fmuladd.f64(double %277, double %284, double %291)
  %293 = load ptr, ptr %8, align 8, !tbaa !5
  %294 = getelementptr inbounds %struct.DERIV_TYPE, ptr %293, i64 2
  %295 = getelementptr inbounds %struct.DERIV_TYPE, ptr %294, i32 0, i32 1
  %296 = load i32, ptr %18, align 4, !tbaa !9
  %297 = sext i32 %296 to i64
  %298 = getelementptr inbounds [3 x double], ptr %295, i64 0, i64 %297
  store double %292, ptr %298, align 8, !tbaa !11
  br label %299

299:                                              ; preds = %232
  %300 = load i32, ptr %18, align 4, !tbaa !9
  %301 = add nsw i32 %300, 1
  store i32 %301, ptr %18, align 4, !tbaa !9
  br label %229, !llvm.loop !17

302:                                              ; preds = %229
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 96, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 96, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i32 0
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"DERIV_TYPE", !12, i64 0, !7, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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.DERIV_TYPE = type { double, [3 x double] }

; Function Attrs: nounwind uwtable
declare dso_local i32 @g_ad_vCross(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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: nounwind uwtable
declare dso_local i32 @g_ad_dMagnitude(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @g_ad_vUnitNormal(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca [3 x %struct.DERIV_TYPE], align 16
  %6 = alloca [3 x %struct.DERIV_TYPE], align 16
  %7 = alloca %struct.DERIV_TYPE, align 8
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #4
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = getelementptr inbounds i8, ptr %5, i64 16
  %11 = getelementptr inbounds i8, ptr %2, i64 16
  %12 = getelementptr inbounds i8, ptr %6, i64 16
  %13 = load <2 x double>, ptr %9, align 8, !tbaa !5
  %14 = load <2 x double>, ptr %8, align 8, !tbaa !5
  %15 = fsub <2 x double> %14, %13
  store <2 x double> %15, ptr %10, align 16, !tbaa !5
  %16 = load <2 x double>, ptr %11, align 8, !tbaa !5
  %17 = fsub <2 x double> %16, %13
  store <2 x double> %17, ptr %12, align 16, !tbaa !5
  %18 = load <2 x double>, ptr %0, align 8, !tbaa !5
  %19 = load <2 x double>, ptr %1, align 8, !tbaa !5
  %20 = fsub <2 x double> %19, %18
  store <2 x double> %20, ptr %5, align 16, !tbaa !5
  %21 = load <2 x double>, ptr %2, align 8, !tbaa !5
  %22 = fsub <2 x double> %21, %18
  store <2 x double> %22, ptr %6, align 16, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %1, i64 32
  %24 = getelementptr inbounds i8, ptr %0, i64 32
  %25 = getelementptr inbounds i8, ptr %5, i64 32
  %26 = getelementptr inbounds i8, ptr %2, i64 32
  %27 = getelementptr inbounds i8, ptr %6, i64 32
  %28 = getelementptr inbounds i8, ptr %1, i64 48
  %29 = getelementptr inbounds i8, ptr %0, i64 48
  %30 = getelementptr inbounds i8, ptr %5, i64 48
  %31 = getelementptr inbounds i8, ptr %2, i64 48
  %32 = getelementptr inbounds i8, ptr %6, i64 48
  %33 = load <2 x double>, ptr %29, align 8, !tbaa !5
  %34 = load <2 x double>, ptr %28, align 8, !tbaa !5
  %35 = fsub <2 x double> %34, %33
  store <2 x double> %35, ptr %30, align 16, !tbaa !5
  %36 = load <2 x double>, ptr %31, align 8, !tbaa !5
  %37 = fsub <2 x double> %36, %33
  store <2 x double> %37, ptr %32, align 16, !tbaa !5
  %38 = load <2 x double>, ptr %24, align 8, !tbaa !5
  %39 = load <2 x double>, ptr %23, align 8, !tbaa !5
  %40 = fsub <2 x double> %39, %38
  store <2 x double> %40, ptr %25, align 16, !tbaa !5
  %41 = load <2 x double>, ptr %26, align 8, !tbaa !5
  %42 = fsub <2 x double> %41, %38
  store <2 x double> %42, ptr %27, align 16, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %1, i64 64
  %44 = getelementptr inbounds i8, ptr %0, i64 64
  %45 = getelementptr inbounds i8, ptr %5, i64 64
  %46 = getelementptr inbounds i8, ptr %2, i64 64
  %47 = getelementptr inbounds i8, ptr %6, i64 64
  %48 = getelementptr inbounds i8, ptr %1, i64 80
  %49 = getelementptr inbounds i8, ptr %0, i64 80
  %50 = getelementptr inbounds i8, ptr %5, i64 80
  %51 = getelementptr inbounds i8, ptr %2, i64 80
  %52 = getelementptr inbounds i8, ptr %6, i64 80
  %53 = load <2 x double>, ptr %49, align 8, !tbaa !5
  %54 = load <2 x double>, ptr %48, align 8, !tbaa !5
  %55 = fsub <2 x double> %54, %53
  store <2 x double> %55, ptr %50, align 16, !tbaa !5
  %56 = load <2 x double>, ptr %51, align 8, !tbaa !5
  %57 = fsub <2 x double> %56, %53
  store <2 x double> %57, ptr %52, align 16, !tbaa !5
  %58 = load <2 x double>, ptr %44, align 8, !tbaa !5
  %59 = load <2 x double>, ptr %43, align 8, !tbaa !5
  %60 = fsub <2 x double> %59, %58
  store <2 x double> %60, ptr %45, align 16, !tbaa !5
  %61 = load <2 x double>, ptr %46, align 8, !tbaa !5
  %62 = fsub <2 x double> %61, %58
  store <2 x double> %62, ptr %47, align 16, !tbaa !5
  %63 = call i32 @g_ad_vCross(ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef %3)
  %64 = call i32 @g_ad_dMagnitude(ptr noundef nonnull %7, ptr noundef %3)
  %65 = load double, ptr %7, align 8, !tbaa !9
  %66 = fdiv double 1.000000e+00, %65
  %67 = load double, ptr %3, align 8, !tbaa !9
  %68 = fmul double %67, %66
  store double %68, ptr %3, align 8, !tbaa !9
  %69 = getelementptr inbounds i8, ptr %3, i64 32
  %70 = load double, ptr %69, align 8, !tbaa !9
  %71 = fmul double %66, %70
  store double %71, ptr %69, align 8, !tbaa !9
  %72 = getelementptr inbounds i8, ptr %3, i64 64
  %73 = load double, ptr %72, align 8, !tbaa !9
  %74 = fmul double %66, %73
  store double %74, ptr %72, align 8, !tbaa !9
  %75 = fneg double %68
  %76 = fmul double %66, %75
  %77 = fneg double %71
  %78 = fmul double %66, %77
  %79 = fneg double %74
  %80 = fmul double %66, %79
  %81 = getelementptr inbounds i8, ptr %3, i64 8
  %82 = getelementptr inbounds i8, ptr %7, i64 8
  %83 = getelementptr inbounds i8, ptr %3, i64 40
  %84 = getelementptr inbounds i8, ptr %3, i64 72
  %85 = load <2 x double>, ptr %82, align 8, !tbaa !5
  %86 = load <2 x double>, ptr %81, align 8, !tbaa !5
  %87 = insertelement <2 x double> poison, double %76, i64 0
  %88 = shufflevector <2 x double> %87, <2 x double> poison, <2 x i32> zeroinitializer
  %89 = fmul <2 x double> %88, %85
  %90 = insertelement <2 x double> poison, double %66, i64 0
  %91 = shufflevector <2 x double> %90, <2 x double> poison, <2 x i32> zeroinitializer
  %92 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %91, <2 x double> %86, <2 x double> %89)
  store <2 x double> %92, ptr %81, align 8, !tbaa !5
  %93 = load <2 x double>, ptr %83, align 8, !tbaa !5
  %94 = insertelement <2 x double> poison, double %78, i64 0
  %95 = shufflevector <2 x double> %94, <2 x double> poison, <2 x i32> zeroinitializer
  %96 = fmul <2 x double> %95, %85
  %97 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %91, <2 x double> %93, <2 x double> %96)
  store <2 x double> %97, ptr %83, align 8, !tbaa !5
  %98 = load <2 x double>, ptr %84, align 8, !tbaa !5
  %99 = insertelement <2 x double> poison, double %80, i64 0
  %100 = shufflevector <2 x double> %99, <2 x double> poison, <2 x i32> zeroinitializer
  %101 = fmul <2 x double> %100, %85
  %102 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %91, <2 x double> %98, <2 x double> %101)
  store <2 x double> %102, ptr %84, align 8, !tbaa !5
  %103 = getelementptr inbounds i8, ptr %3, i64 24
  %104 = load double, ptr %103, align 8, !tbaa !5
  %105 = getelementptr inbounds i8, ptr %7, i64 24
  %106 = load double, ptr %105, align 8, !tbaa !5
  %107 = fmul double %76, %106
  %108 = call double @llvm.fmuladd.f64(double %66, double %104, double %107)
  store double %108, ptr %103, align 8, !tbaa !5
  %109 = getelementptr inbounds i8, ptr %3, i64 56
  %110 = load double, ptr %109, align 8, !tbaa !5
  %111 = fmul double %78, %106
  %112 = call double @llvm.fmuladd.f64(double %66, double %110, double %111)
  store double %112, ptr %109, align 8, !tbaa !5
  %113 = getelementptr inbounds i8, ptr %3, i64 88
  %114 = load double, ptr %113, align 8, !tbaa !5
  %115 = fmul double %80, %106
  %116 = call double @llvm.fmuladd.f64(double %66, double %114, double %115)
  store double %116, ptr %113, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %5) #4
  ret i32 0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #3

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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"DERIV_TYPE", !6, i64 0, !7, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass