; LLVM IR from iostapyshyn/gravity :: physics (physics_update)

; 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.particle = type { double, double, double, double, double, [3 x double] }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }

@array = external dso_local global <{ %struct.particle, %struct.particle, %struct.particle, [117 x %struct.particle] }>, align 16
@lock = external dso_local global %union.pthread_mutex_t, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @update() #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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @check() #0

; Function Attrs: nounwind uwtable
declare dso_local float @particle_radius(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @physics_update() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca %struct.particle, align 8
  %8 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %357, %0
  %10 = load i32, ptr %1, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 120
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  store i32 2, ptr %2, align 4
  br label %360

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [120 x %struct.particle], ptr @array, i64 0, i64 %15
  store ptr %16, ptr %3, align 8, !tbaa !9
  %17 = load ptr, ptr %3, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.particle, ptr %17, i32 0, i32 4
  %19 = load double, ptr %18, align 8, !tbaa !11
  %20 = fcmp une double %19, 0.000000e+00
  br i1 %20, label %22, label %21

21:                                               ; preds = %13
  store i32 4, ptr %2, align 4
  br label %354

22:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %332, %22
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = icmp slt i32 %24, 120
  br i1 %25, label %27, label %26

26:                                               ; preds = %23
  store i32 5, ptr %2, align 4
  br label %335

27:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [120 x %struct.particle], ptr @array, i64 0, i64 %29
  store ptr %30, ptr %5, align 8, !tbaa !9
  %31 = load ptr, ptr %5, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.particle, ptr %31, i32 0, i32 4
  %33 = load double, ptr %32, align 8, !tbaa !11
  %34 = fcmp une double %33, 0.000000e+00
  br i1 %34, label %36, label %35

35:                                               ; preds = %27
  store i32 7, ptr %2, align 4
  br label %329

36:                                               ; preds = %27
  %37 = load i32, ptr %1, align 4, !tbaa !5
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = icmp eq i32 %37, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %36
  store i32 7, ptr %2, align 4
  br label %329

41:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %42 = load ptr, ptr %3, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.particle, ptr %42, i32 0, i32 0
  %44 = load double, ptr %43, align 8, !tbaa !14
  %45 = load ptr, ptr %5, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.particle, ptr %45, i32 0, i32 0
  %47 = load double, ptr %46, align 8, !tbaa !14
  %48 = fsub double %44, %47
  %49 = load ptr, ptr %3, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.particle, ptr %49, i32 0, i32 0
  %51 = load double, ptr %50, align 8, !tbaa !14
  %52 = load ptr, ptr %5, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct.particle, ptr %52, i32 0, i32 0
  %54 = load double, ptr %53, align 8, !tbaa !14
  %55 = fsub double %51, %54
  %56 = load ptr, ptr %3, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct.particle, ptr %56, i32 0, i32 1
  %58 = load double, ptr %57, align 8, !tbaa !15
  %59 = load ptr, ptr %5, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct.particle, ptr %59, i32 0, i32 1
  %61 = load double, ptr %60, align 8, !tbaa !15
  %62 = fsub double %58, %61
  %63 = load ptr, ptr %3, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.particle, ptr %63, i32 0, i32 1
  %65 = load double, ptr %64, align 8, !tbaa !15
  %66 = load ptr, ptr %5, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct.particle, ptr %66, i32 0, i32 1
  %68 = load double, ptr %67, align 8, !tbaa !15
  %69 = fsub double %65, %68
  %70 = fmul double %62, %69
  %71 = call double @llvm.fmuladd.f64(double %48, double %55, double %70)
  %72 = call double @sqrt(double noundef %71) #5
  store double %72, ptr %6, align 8, !tbaa !16
  %73 = load ptr, ptr %3, align 8, !tbaa !9
  %74 = call float @particle_radius(ptr noundef %73)
  %75 = load ptr, ptr %5, align 8, !tbaa !9
  %76 = call float @particle_radius(ptr noundef %75)
  %77 = fadd float %74, %76
  %78 = fpext float %77 to double
  %79 = load double, ptr %6, align 8, !tbaa !16
  %80 = fcmp olt double %78, %79
  br i1 %80, label %81, label %124

81:                                               ; preds = %41
  %82 = load ptr, ptr %5, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct.particle, ptr %82, i32 0, i32 4
  %84 = load double, ptr %83, align 8, !tbaa !11
  %85 = fmul double 1.000000e-04, %84
  %86 = load double, ptr %6, align 8, !tbaa !16
  %87 = load double, ptr %6, align 8, !tbaa !16
  %88 = fmul double %86, %87
  %89 = fdiv double %85, %88
  %90 = load ptr, ptr %5, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct.particle, ptr %90, i32 0, i32 0
  %92 = load double, ptr %91, align 8, !tbaa !14
  %93 = load ptr, ptr %3, align 8, !tbaa !9
  %94 = getelementptr inbounds %struct.particle, ptr %93, i32 0, i32 0
  %95 = load double, ptr %94, align 8, !tbaa !14
  %96 = fsub double %92, %95
  %97 = load double, ptr %6, align 8, !tbaa !16
  %98 = fdiv double %96, %97
  %99 = load ptr, ptr %3, align 8, !tbaa !9
  %100 = getelementptr inbounds %struct.particle, ptr %99, i32 0, i32 2
  %101 = load double, ptr %100, align 8, !tbaa !17
  %102 = call double @llvm.fmuladd.f64(double %89, double %98, double %101)
  store double %102, ptr %100, align 8, !tbaa !17
  %103 = load ptr, ptr %5, align 8, !tbaa !9
  %104 = getelementptr inbounds %struct.particle, ptr %103, i32 0, i32 4
  %105 = load double, ptr %104, align 8, !tbaa !11
  %106 = fmul double 1.000000e-04, %105
  %107 = load double, ptr %6, align 8, !tbaa !16
  %108 = load double, ptr %6, align 8, !tbaa !16
  %109 = fmul double %107, %108
  %110 = fdiv double %106, %109
  %111 = load ptr, ptr %5, align 8, !tbaa !9
  %112 = getelementptr inbounds %struct.particle, ptr %111, i32 0, i32 1
  %113 = load double, ptr %112, align 8, !tbaa !15
  %114 = load ptr, ptr %3, align 8, !tbaa !9
  %115 = getelementptr inbounds %struct.particle, ptr %114, i32 0, i32 1
  %116 = load double, ptr %115, align 8, !tbaa !15
  %117 = fsub double %113, %116
  %118 = load double, ptr %6, align 8, !tbaa !16
  %119 = fdiv double %117, %118
  %120 = load ptr, ptr %3, align 8, !tbaa !9
  %121 = getelementptr inbounds %struct.particle, ptr %120, i32 0, i32 3
  %122 = load double, ptr %121, align 8, !tbaa !18
  %123 = call double @llvm.fmuladd.f64(double %110, double %119, double %122)
  store double %123, ptr %121, align 8, !tbaa !18
  br label %327

124:                                              ; preds = %41
  call void @llvm.lifetime.start.p0(i64 64, ptr %7) #5
  %125 = load ptr, ptr %3, align 8, !tbaa !9
  %126 = getelementptr inbounds %struct.particle, ptr %125, i32 0, i32 4
  %127 = load double, ptr %126, align 8, !tbaa !11
  %128 = load ptr, ptr %3, align 8, !tbaa !9
  %129 = getelementptr inbounds %struct.particle, ptr %128, i32 0, i32 0
  %130 = load double, ptr %129, align 8, !tbaa !14
  %131 = load ptr, ptr %5, align 8, !tbaa !9
  %132 = getelementptr inbounds %struct.particle, ptr %131, i32 0, i32 4
  %133 = load double, ptr %132, align 8, !tbaa !11
  %134 = load ptr, ptr %5, align 8, !tbaa !9
  %135 = getelementptr inbounds %struct.particle, ptr %134, i32 0, i32 0
  %136 = load double, ptr %135, align 8, !tbaa !14
  %137 = fmul double %133, %136
  %138 = call double @llvm.fmuladd.f64(double %127, double %130, double %137)
  %139 = load ptr, ptr %3, align 8, !tbaa !9
  %140 = getelementptr inbounds %struct.particle, ptr %139, i32 0, i32 4
  %141 = load double, ptr %140, align 8, !tbaa !11
  %142 = load ptr, ptr %5, align 8, !tbaa !9
  %143 = getelementptr inbounds %struct.particle, ptr %142, i32 0, i32 4
  %144 = load double, ptr %143, align 8, !tbaa !11
  %145 = fadd double %141, %144
  %146 = fdiv double %138, %145
  %147 = getelementptr inbounds %struct.particle, ptr %7, i32 0, i32 0
  store double %146, ptr %147, align 8, !tbaa !14
  %148 = load ptr, ptr %3, align 8, !tbaa !9
  %149 = getelementptr inbounds %struct.particle, ptr %148, i32 0, i32 4
  %150 = load double, ptr %149, align 8, !tbaa !11
  %151 = load ptr, ptr %3, align 8, !tbaa !9
  %152 = getelementptr inbounds %struct.particle, ptr %151, i32 0, i32 1
  %153 = load double, ptr %152, align 8, !tbaa !15
  %154 = load ptr, ptr %5, align 8, !tbaa !9
  %155 = getelementptr inbounds %struct.particle, ptr %154, i32 0, i32 4
  %156 = load double, ptr %155, align 8, !tbaa !11
  %157 = load ptr, ptr %5, align 8, !tbaa !9
  %158 = getelementptr inbounds %struct.particle, ptr %157, i32 0, i32 1
  %159 = load double, ptr %158, align 8, !tbaa !15
  %160 = fmul double %156, %159
  %161 = call double @llvm.fmuladd.f64(double %150, double %153, double %160)
  %162 = load ptr, ptr %3, align 8, !tbaa !9
  %163 = getelementptr inbounds %struct.particle, ptr %162, i32 0, i32 4
  %164 = load double, ptr %163, align 8, !tbaa !11
  %165 = load ptr, ptr %5, align 8, !tbaa !9
  %166 = getelementptr inbounds %struct.particle, ptr %165, i32 0, i32 4
  %167 = load double, ptr %166, align 8, !tbaa !11
  %168 = fadd double %164, %167
  %169 = fdiv double %161, %168
  %170 = getelementptr inbounds %struct.particle, ptr %7, i32 0, i32 1
  store double %169, ptr %170, align 8, !tbaa !15
  %171 = load ptr, ptr %3, align 8, !tbaa !9
  %172 = getelementptr inbounds %struct.particle, ptr %171, i32 0, i32 4
  %173 = load double, ptr %172, align 8, !tbaa !11
  %174 = load ptr, ptr %3, align 8, !tbaa !9
  %175 = getelementptr inbounds %struct.particle, ptr %174, i32 0, i32 2
  %176 = load double, ptr %175, align 8, !tbaa !17
  %177 = load ptr, ptr %5, align 8, !tbaa !9
  %178 = getelementptr inbounds %struct.particle, ptr %177, i32 0, i32 4
  %179 = load double, ptr %178, align 8, !tbaa !11
  %180 = load ptr, ptr %5, align 8, !tbaa !9
  %181 = getelementptr inbounds %struct.particle, ptr %180, i32 0, i32 2
  %182 = load double, ptr %181, align 8, !tbaa !17
  %183 = fmul double %179, %182
  %184 = call double @llvm.fmuladd.f64(double %173, double %176, double %183)
  %185 = load ptr, ptr %3, align 8, !tbaa !9
  %186 = getelementptr inbounds %struct.particle, ptr %185, i32 0, i32 4
  %187 = load double, ptr %186, align 8, !tbaa !11
  %188 = load ptr, ptr %5, align 8, !tbaa !9
  %189 = getelementptr inbounds %struct.particle, ptr %188, i32 0, i32 4
  %190 = load double, ptr %189, align 8, !tbaa !11
  %191 = fadd double %187, %190
  %192 = fdiv double %184, %191
  %193 = getelementptr inbounds %struct.particle, ptr %7, i32 0, i32 2
  store double %192, ptr %193, align 8, !tbaa !17
  %194 = load ptr, ptr %3, align 8, !tbaa !9
  %195 = getelementptr inbounds %struct.particle, ptr %194, i32 0, i32 4
  %196 = load double, ptr %195, align 8, !tbaa !11
  %197 = load ptr, ptr %3, align 8, !tbaa !9
  %198 = getelementptr inbounds %struct.particle, ptr %197, i32 0, i32 3
  %199 = load double, ptr %198, align 8, !tbaa !18
  %200 = load ptr, ptr %5, align 8, !tbaa !9
  %201 = getelementptr inbounds %struct.particle, ptr %200, i32 0, i32 4
  %202 = load double, ptr %201, align 8, !tbaa !11
  %203 = load ptr, ptr %5, align 8, !tbaa !9
  %204 = getelementptr inbounds %struct.particle, ptr %203, i32 0, i32 3
  %205 = load double, ptr %204, align 8, !tbaa !18
  %206 = fmul double %202, %205
  %207 = call double @llvm.fmuladd.f64(double %196, double %199, double %206)
  %208 = load ptr, ptr %3, align 8, !tbaa !9
  %209 = getelementptr inbounds %struct.particle, ptr %208, i32 0, i32 4
  %210 = load double, ptr %209, align 8, !tbaa !11
  %211 = load ptr, ptr %5, align 8, !tbaa !9
  %212 = getelementptr inbounds %struct.particle, ptr %211, i32 0, i32 4
  %213 = load double, ptr %212, align 8, !tbaa !11
  %214 = fadd double %210, %213
  %215 = fdiv double %207, %214
  %216 = getelementptr inbounds %struct.particle, ptr %7, i32 0, i32 3
  store double %215, ptr %216, align 8, !tbaa !18
  %217 = load ptr, ptr %3, align 8, !tbaa !9
  %218 = getelementptr inbounds %struct.particle, ptr %217, i32 0, i32 4
  %219 = load double, ptr %218, align 8, !tbaa !11
  %220 = load ptr, ptr %5, align 8, !tbaa !9
  %221 = getelementptr inbounds %struct.particle, ptr %220, i32 0, i32 4
  %222 = load double, ptr %221, align 8, !tbaa !11
  %223 = fadd double %219, %222
  %224 = getelementptr inbounds %struct.particle, ptr %7, i32 0, i32 4
  store double %223, ptr %224, align 8, !tbaa !11
  %225 = load ptr, ptr %3, align 8, !tbaa !9
  %226 = getelementptr inbounds %struct.particle, ptr %225, i32 0, i32 4
  %227 = load double, ptr %226, align 8, !tbaa !11
  %228 = load ptr, ptr %3, align 8, !tbaa !9
  %229 = getelementptr inbounds %struct.particle, ptr %228, i32 0, i32 5
  %230 = getelementptr inbounds [3 x double], ptr %229, i64 0, i64 0
  %231 = load double, ptr %230, align 8, !tbaa !16
  %232 = load ptr, ptr %5, align 8, !tbaa !9
  %233 = getelementptr inbounds %struct.particle, ptr %232, i32 0, i32 4
  %234 = load double, ptr %233, align 8, !tbaa !11
  %235 = load ptr, ptr %5, align 8, !tbaa !9
  %236 = getelementptr inbounds %struct.particle, ptr %235, i32 0, i32 5
  %237 = getelementptr inbounds [3 x double], ptr %236, i64 0, i64 0
  %238 = load double, ptr %237, align 8, !tbaa !16
  %239 = fmul double %234, %238
  %240 = call double @llvm.fmuladd.f64(double %227, double %231, double %239)
  %241 = load ptr, ptr %3, align 8, !tbaa !9
  %242 = getelementptr inbounds %struct.particle, ptr %241, i32 0, i32 4
  %243 = load double, ptr %242, align 8, !tbaa !11
  %244 = load ptr, ptr %5, align 8, !tbaa !9
  %245 = getelementptr inbounds %struct.particle, ptr %244, i32 0, i32 4
  %246 = load double, ptr %245, align 8, !tbaa !11
  %247 = fadd double %243, %246
  %248 = fdiv double %240, %247
  %249 = getelementptr inbounds %struct.particle, ptr %7, i32 0, i32 5
  %250 = getelementptr inbounds [3 x double], ptr %249, i64 0, i64 0
  store double %248, ptr %250, align 8, !tbaa !16
  %251 = load ptr, ptr %3, align 8, !tbaa !9
  %252 = getelementptr inbounds %struct.particle, ptr %251, i32 0, i32 4
  %253 = load double, ptr %252, align 8, !tbaa !11
  %254 = load ptr, ptr %3, align 8, !tbaa !9
  %255 = getelementptr inbounds %struct.particle, ptr %254, i32 0, i32 5
  %256 = getelementptr inbounds [3 x double], ptr %255, i64 0, i64 1
  %257 = load double, ptr %256, align 8, !tbaa !16
  %258 = load ptr, ptr %5, align 8, !tbaa !9
  %259 = getelementptr inbounds %struct.particle, ptr %258, i32 0, i32 4
  %260 = load double, ptr %259, align 8, !tbaa !11
  %261 = load ptr, ptr %5, align 8, !tbaa !9
  %262 = getelementptr inbounds %struct.particle, ptr %261, i32 0, i32 5
  %263 = getelementptr inbounds [3 x double], ptr %262, i64 0, i64 1
  %264 = load double, ptr %263, align 8, !tbaa !16
  %265 = fmul double %260, %264
  %266 = call double @llvm.fmuladd.f64(double %253, double %257, double %265)
  %267 = load ptr, ptr %3, align 8, !tbaa !9
  %268 = getelementptr inbounds %struct.particle, ptr %267, i32 0, i32 4
  %269 = load double, ptr %268, align 8, !tbaa !11
  %270 = load ptr, ptr %5, align 8, !tbaa !9
  %271 = getelementptr inbounds %struct.particle, ptr %270, i32 0, i32 4
  %272 = load double, ptr %271, align 8, !tbaa !11
  %273 = fadd double %269, %272
  %274 = fdiv double %266, %273
  %275 = getelementptr inbounds %struct.particle, ptr %7, i32 0, i32 5
  %276 = getelementptr inbounds [3 x double], ptr %275, i64 0, i64 1
  store double %274, ptr %276, align 8, !tbaa !16
  %277 = load ptr, ptr %3, align 8, !tbaa !9
  %278 = getelementptr inbounds %struct.particle, ptr %277, i32 0, i32 4
  %279 = load double, ptr %278, align 8, !tbaa !11
  %280 = load ptr, ptr %3, align 8, !tbaa !9
  %281 = getelementptr inbounds %struct.particle, ptr %280, i32 0, i32 5
  %282 = getelementptr inbounds [3 x double], ptr %281, i64 0, i64 2
  %283 = load double, ptr %282, align 8, !tbaa !16
  %284 = load ptr, ptr %5, align 8, !tbaa !9
  %285 = getelementptr inbounds %struct.particle, ptr %284, i32 0, i32 4
  %286 = load double, ptr %285, align 8, !tbaa !11
  %287 = load ptr, ptr %5, align 8, !tbaa !9
  %288 = getelementptr inbounds %struct.particle, ptr %287, i32 0, i32 5
  %289 = getelementptr inbounds [3 x double], ptr %288, i64 0, i64 2
  %290 = load double, ptr %289, align 8, !tbaa !16
  %291 = fmul double %286, %290
  %292 = call double @llvm.fmuladd.f64(double %279, double %283, double %291)
  %293 = load ptr, ptr %3, align 8, !tbaa !9
  %294 = getelementptr inbounds %struct.particle, ptr %293, i32 0, i32 4
  %295 = load double, ptr %294, align 8, !tbaa !11
  %296 = load ptr, ptr %5, align 8, !tbaa !9
  %297 = getelementptr inbounds %struct.particle, ptr %296, i32 0, i32 4
  %298 = load double, ptr %297, align 8, !tbaa !11
  %299 = fadd double %295, %298
  %300 = fdiv double %292, %299
  %301 = getelementptr inbounds %struct.particle, ptr %7, i32 0, i32 5
  %302 = getelementptr inbounds [3 x double], ptr %301, i64 0, i64 2
  store double %300, ptr %302, align 8, !tbaa !16
  %303 = call i32 @pthread_mutex_lock(ptr noundef @lock) #5
  %304 = load ptr, ptr %3, align 8, !tbaa !9
  %305 = getelementptr inbounds %struct.particle, ptr %304, i32 0, i32 4
  store double 0.000000e+00, ptr %305, align 8, !tbaa !11
  %306 = load ptr, ptr %5, align 8, !tbaa !9
  %307 = getelementptr inbounds %struct.particle, ptr %306, i32 0, i32 4
  store double 0.000000e+00, ptr %307, align 8, !tbaa !11
  %308 = call zeroext i1 @check()
  br i1 %308, label %309, label %325

309:                                              ; preds = %124
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %310

310:                                              ; preds = %318, %309
  %311 = load i32, ptr %8, align 4, !tbaa !5
  %312 = sext i32 %311 to i64
  %313 = getelementptr inbounds [120 x %struct.particle], ptr @array, i64 0, i64 %312
  %314 = getelementptr inbounds %struct.particle, ptr %313, i32 0, i32 4
  %315 = load double, ptr %314, align 16, !tbaa !11
  %316 = fcmp une double %315, 0.000000e+00
  br i1 %316, label %317, label %321

317:                                              ; preds = %310
  br label %318

318:                                              ; preds = %317
  %319 = load i32, ptr %8, align 4, !tbaa !5
  %320 = add nsw i32 %319, 1
  store i32 %320, ptr %8, align 4, !tbaa !5
  br label %310, !llvm.loop !19

321:                                              ; preds = %310
  %322 = load i32, ptr %8, align 4, !tbaa !5
  %323 = sext i32 %322 to i64
  %324 = getelementptr inbounds [120 x %struct.particle], ptr @array, i64 0, i64 %323
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %324, ptr align 8 %7, i64 64, i1 false), !tbaa.struct !21
  call void @update()
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %325

325:                                              ; preds = %321, %124
  %326 = call i32 @pthread_mutex_unlock(ptr noundef @lock) #5
  store i32 1, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 64, ptr %7) #5
  br label %328

327:                                              ; preds = %81
  store i32 0, ptr %2, align 4
  br label %328

328:                                              ; preds = %327, %325
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %329

329:                                              ; preds = %328, %40, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  %330 = load i32, ptr %2, align 4
  switch i32 %330, label %335 [
    i32 0, label %331
    i32 7, label %332
  ]

331:                                              ; preds = %329
  br label %332

332:                                              ; preds = %331, %329
  %333 = load i32, ptr %4, align 4, !tbaa !5
  %334 = add nsw i32 %333, 1
  store i32 %334, ptr %4, align 4, !tbaa !5
  br label %23, !llvm.loop !23

335:                                              ; preds = %329, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %336 = load i32, ptr %2, align 4
  switch i32 %336, label %354 [
    i32 5, label %337
  ]

337:                                              ; preds = %335
  %338 = call i32 @pthread_mutex_lock(ptr noundef @lock) #5
  %339 = load ptr, ptr %3, align 8, !tbaa !9
  %340 = getelementptr inbounds %struct.particle, ptr %339, i32 0, i32 2
  %341 = load double, ptr %340, align 8, !tbaa !17
  %342 = load ptr, ptr %3, align 8, !tbaa !9
  %343 = getelementptr inbounds %struct.particle, ptr %342, i32 0, i32 0
  %344 = load double, ptr %343, align 8, !tbaa !14
  %345 = fadd double %344, %341
  store double %345, ptr %343, align 8, !tbaa !14
  %346 = load ptr, ptr %3, align 8, !tbaa !9
  %347 = getelementptr inbounds %struct.particle, ptr %346, i32 0, i32 3
  %348 = load double, ptr %347, align 8, !tbaa !18
  %349 = load ptr, ptr %3, align 8, !tbaa !9
  %350 = getelementptr inbounds %struct.particle, ptr %349, i32 0, i32 1
  %351 = load double, ptr %350, align 8, !tbaa !15
  %352 = fadd double %351, %348
  store double %352, ptr %350, align 8, !tbaa !15
  %353 = call i32 @pthread_mutex_unlock(ptr noundef @lock) #5
  store i32 0, ptr %2, align 4
  br label %354

354:                                              ; preds = %337, %335, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  %355 = load i32, ptr %2, align 4
  switch i32 %355, label %360 [
    i32 0, label %356
    i32 4, label %357
  ]

356:                                              ; preds = %354
  br label %357

357:                                              ; preds = %356, %354
  %358 = load i32, ptr %1, align 4, !tbaa !5
  %359 = add nsw i32 %358, 1
  store i32 %359, ptr %1, align 4, !tbaa !5
  br label %9, !llvm.loop !24

360:                                              ; preds = %354, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  %361 = load i32, ptr %2, align 4
  switch i32 %361, label %363 [
    i32 2, label %362
    i32 1, label %362
  ]

362:                                              ; preds = %360, %360
  ret void

363:                                              ; preds = %360
  unreachable
}

; Function Attrs: nounwind
declare double @sqrt(double noundef) #2

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

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) #2

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

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) #2

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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{!12, !13, i64 32}
!12 = !{!"particle", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !7, i64 40}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !13, i64 0}
!15 = !{!12, !13, i64 8}
!16 = !{!13, !13, i64 0}
!17 = !{!12, !13, i64 16}
!18 = !{!12, !13, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{i64 0, i64 8, !16, i64 8, i64 8, !16, i64 16, i64 8, !16, i64 24, i64 8, !16, i64 32, i64 8, !16, i64 40, i64 24, !22}
!22 = !{!7, !7, i64 0}
!23 = distinct !{!23, !20}
!24 = distinct !{!24, !20}


; 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.particle = type { double, double, double, double, double, [3 x double] }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }

@array = external dso_local global <{ %struct.particle, %struct.particle, %struct.particle, [117 x %struct.particle] }>, align 16
@lock = external dso_local global %union.pthread_mutex_t, align 8

; Function Attrs: nounwind uwtable
declare dso_local void @update() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @check() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local float @particle_radius(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @physics_update() local_unnamed_addr #0 {
  br label %1

1:                                                ; preds = %0, %110
  %indvars.iv122 = phi i64 [ 0, %0 ], [ %indvars.iv.next123, %110 ]
  %2 = getelementptr inbounds [120 x %struct.particle], ptr @array, i64 0, i64 %indvars.iv122
  %3 = getelementptr inbounds i8, ptr %2, i64 32
  %4 = load double, ptr %3, align 16, !tbaa !5
  %5 = fcmp une double %4, 0.000000e+00
  br i1 %5, label %.preheader101, label %110

.preheader101:                                    ; preds = %1
  %6 = getelementptr inbounds i8, ptr %2, i64 8
  %7 = getelementptr inbounds i8, ptr %2, i64 16
  br label %8

8:                                                ; preds = %.preheader101, %101
  %indvars.iv = phi i64 [ 0, %.preheader101 ], [ %indvars.iv.next, %101 ]
  %9 = getelementptr inbounds [120 x %struct.particle], ptr @array, i64 0, i64 %indvars.iv
  %10 = getelementptr inbounds i8, ptr %9, i64 32
  %11 = load double, ptr %10, align 16, !tbaa !5
  %12 = fcmp oeq double %11, 0.000000e+00
  %13 = icmp eq i64 %indvars.iv122, %indvars.iv
  %or.cond = or i1 %13, %12
  br i1 %or.cond, label %101, label %14

14:                                               ; preds = %8
  %15 = load double, ptr %2, align 16, !tbaa !10
  %16 = load double, ptr %9, align 16, !tbaa !10
  %17 = fsub double %15, %16
  %18 = load double, ptr %6, align 8, !tbaa !11
  %19 = getelementptr inbounds i8, ptr %9, i64 8
  %20 = load double, ptr %19, align 8, !tbaa !11
  %21 = fsub double %18, %20
  %22 = fmul double %21, %21
  %23 = tail call double @llvm.fmuladd.f64(double %17, double %17, double %22)
  %sqrt = tail call double @llvm.sqrt.f64(double %23)
  %24 = tail call float @particle_radius(ptr noundef nonnull %2)
  %25 = tail call float @particle_radius(ptr noundef nonnull %9)
  %26 = fadd float %24, %25
  %27 = fpext float %26 to double
  %28 = fcmp ogt double %sqrt, %27
  br i1 %28, label %29, label %44

29:                                               ; preds = %14
  %30 = load double, ptr %10, align 16, !tbaa !5
  %31 = fmul double %30, 1.000000e-04
  %32 = fmul double %sqrt, %sqrt
  %33 = fdiv double %31, %32
  %34 = load <2 x double>, ptr %9, align 16, !tbaa !12
  %35 = load <2 x double>, ptr %2, align 16, !tbaa !12
  %36 = fsub <2 x double> %34, %35
  %37 = insertelement <2 x double> poison, double %sqrt, i64 0
  %38 = shufflevector <2 x double> %37, <2 x double> poison, <2 x i32> zeroinitializer
  %39 = fdiv <2 x double> %36, %38
  %40 = load <2 x double>, ptr %7, align 16, !tbaa !12
  %41 = insertelement <2 x double> poison, double %33, i64 0
  %42 = shufflevector <2 x double> %41, <2 x double> poison, <2 x i32> zeroinitializer
  %43 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %42, <2 x double> %39, <2 x double> %40)
  store <2 x double> %43, ptr %7, align 16, !tbaa !12
  br label %101

44:                                               ; preds = %14
  %45 = getelementptr inbounds i8, ptr %2, i64 24
  %46 = getelementptr inbounds i8, ptr %9, i64 8
  %47 = getelementptr inbounds i8, ptr %2, i64 32
  %48 = load double, ptr %2, align 8, !tbaa !10
  %49 = load double, ptr %9, align 8, !tbaa !10
  %50 = load double, ptr %6, align 8, !tbaa !11
  %51 = load double, ptr %46, align 8, !tbaa !11
  %52 = load double, ptr %7, align 8, !tbaa !13
  %53 = getelementptr inbounds i8, ptr %9, i64 16
  %54 = load double, ptr %53, align 8, !tbaa !13
  %55 = getelementptr inbounds i8, ptr %9, i64 24
  %56 = load <2 x double>, ptr %45, align 8, !tbaa !12
  %57 = shufflevector <2 x double> %56, <2 x double> poison, <2 x i32> <i32 1, i32 0>
  %58 = load <2 x double>, ptr %55, align 8, !tbaa !12
  %59 = shufflevector <2 x double> %58, <2 x double> poison, <2 x i32> <i32 1, i32 0>
  %60 = extractelement <2 x double> %56, i64 1
  %61 = extractelement <2 x double> %58, i64 1
  %62 = fadd <2 x double> %57, %59
  %63 = extractelement <2 x double> %62, i64 0
  %64 = insertelement <2 x double> %58, double %49, i64 0
  %65 = insertelement <2 x double> %59, double %51, i64 1
  %66 = fmul <2 x double> %64, %65
  %67 = insertelement <2 x double> %56, double %48, i64 0
  %68 = insertelement <2 x double> %57, double %50, i64 1
  %69 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %67, <2 x double> %68, <2 x double> %66)
  %70 = shufflevector <2 x double> %62, <2 x double> poison, <2 x i32> zeroinitializer
  %71 = fdiv <2 x double> %69, %70
  %72 = insertelement <2 x double> %58, double %54, i64 0
  %73 = fmul <2 x double> %72, %59
  %74 = insertelement <2 x double> %56, double %52, i64 0
  %75 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %74, <2 x double> %57, <2 x double> %73)
  %76 = fdiv <2 x double> %75, %70
  %77 = getelementptr inbounds i8, ptr %2, i64 40
  %78 = getelementptr inbounds i8, ptr %9, i64 40
  %79 = load <2 x double>, ptr %77, align 8, !tbaa !12
  %80 = load <2 x double>, ptr %78, align 8, !tbaa !12
  %81 = shufflevector <2 x double> %58, <2 x double> poison, <2 x i32> <i32 1, i32 1>
  %82 = fmul <2 x double> %81, %80
  %83 = shufflevector <2 x double> %56, <2 x double> poison, <2 x i32> <i32 1, i32 1>
  %84 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %83, <2 x double> %79, <2 x double> %82)
  %85 = fdiv <2 x double> %84, %70
  %86 = getelementptr inbounds i8, ptr %2, i64 56
  %87 = load double, ptr %86, align 8, !tbaa !12
  %88 = getelementptr inbounds i8, ptr %9, i64 56
  %89 = load double, ptr %88, align 8, !tbaa !12
  %90 = fmul double %61, %89
  %91 = tail call double @llvm.fmuladd.f64(double %60, double %87, double %90)
  %92 = fdiv double %91, %63
  %93 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull @lock) #4
  store double 0.000000e+00, ptr %47, align 8, !tbaa !5
  store double 0.000000e+00, ptr %10, align 8, !tbaa !5
  %94 = tail call zeroext i1 @check()
  br i1 %94, label %.preheader, label %108

.preheader:                                       ; preds = %44, %.preheader
  %indvars.iv126 = phi i64 [ %indvars.iv.next127, %.preheader ], [ 0, %44 ]
  %95 = getelementptr inbounds [120 x %struct.particle], ptr @array, i64 0, i64 %indvars.iv126
  %96 = getelementptr inbounds i8, ptr %95, i64 32
  %97 = load double, ptr %96, align 16, !tbaa !5
  %98 = fcmp une double %97, 0.000000e+00
  %indvars.iv.next127 = add nuw nsw i64 %indvars.iv126, 1
  br i1 %98, label %.preheader, label %99, !llvm.loop !14

99:                                               ; preds = %.preheader
  %100 = getelementptr inbounds i8, ptr %95, i64 32
  store <2 x double> %71, ptr %95, align 16, !tbaa !12
  %.sroa.5.0..sroa_idx = getelementptr inbounds i8, ptr %95, i64 16
  store <2 x double> %76, ptr %.sroa.5.0..sroa_idx, align 16, !tbaa !12
  store double %63, ptr %100, align 16, !tbaa !12
  %.sroa.8.0..sroa_idx = getelementptr inbounds i8, ptr %95, i64 40
  store <2 x double> %85, ptr %.sroa.8.0..sroa_idx, align 8
  %.sroa.10.0..sroa_idx = getelementptr inbounds i8, ptr %95, i64 56
  store double %92, ptr %.sroa.10.0..sroa_idx, align 8, !tbaa !16
  tail call void @update()
  br label %108

101:                                              ; preds = %8, %29
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 120
  br i1 %exitcond.not, label %102, label %8, !llvm.loop !17

102:                                              ; preds = %101
  %103 = tail call i32 @pthread_mutex_lock(ptr noundef nonnull @lock) #4
  %104 = load <2 x double>, ptr %7, align 16, !tbaa !12
  %105 = load <2 x double>, ptr %2, align 16, !tbaa !12
  %106 = fadd <2 x double> %104, %105
  store <2 x double> %106, ptr %2, align 16, !tbaa !12
  %107 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull @lock) #4
  br label %110

108:                                              ; preds = %44, %99
  %109 = tail call i32 @pthread_mutex_unlock(ptr noundef nonnull @lock) #4
  br label %.loopexit

110:                                              ; preds = %102, %1
  %indvars.iv.next123 = add nuw nsw i64 %indvars.iv122, 1
  %exitcond125.not = icmp eq i64 %indvars.iv.next123, 120
  br i1 %exitcond125.not, label %.loopexit, label %1, !llvm.loop !18

.loopexit:                                        ; preds = %110, %108
  ret void
}

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

; Function Attrs: nounwind
declare i32 @pthread_mutex_lock(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @pthread_mutex_unlock(ptr noundef) local_unnamed_addr #2

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

; 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 speculatable willreturn memory(none) }
attributes #2 = { 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 #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, !7, i64 32}
!6 = !{!"particle", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !8, i64 40}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !7, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!8, !8, i64 0}
!17 = distinct !{!17, !15}
!18 = distinct !{!18, !15}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass