; LLVM IR from FSmallenburg/EDMD :: Cell (mdCell)

; 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.sparticle = type { double, double, double, double, double, double, double, double, double, i8, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, i8 }

@makesnapshots = external dso_local global i32, align 4
@writeinterval = external dso_local global double, align 8
@snapshotinterval = external dso_local global double, align 8
@N = external dso_local global i32, align 4
@simtime = external dso_local global double, align 8
@listcounter1 = external dso_local global i32, align 4
@listcounter2 = external dso_local global i32, align 4
@mergecounter = external dso_local global i32, align 4
@dvtot = external dso_local global double, align 8
@colcounter = external dso_local global i32, align 4
@particles = external dso_local global ptr, align 8
@xsize = external dso_local global double, align 8
@ysize = external dso_local global double, align 8
@zsize = external dso_local global double, align 8
@.str.28 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [32 x i8], align 1
@write.counter = external hidden global i32, align 4
@write.first = external hidden global i32, align 4
@write.lastsnapshottime = external hidden global double, align 8
@write.dvtotlast = external hidden global double, align 8
@write.timelast = external hidden global double, align 8
@.str.31 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [9 x i8], align 1

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

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

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

declare i32 @printf(ptr noundef, ...) #2

declare noalias ptr @fopen(ptr noundef, ptr noundef) #2

declare i32 @fclose(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @update(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @createevent(double noundef, ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #4

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

; Function Attrs: nounwind uwtable
define dso_local void @write() #3 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca [200 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store double 0.000000e+00, ptr %4, align 8, !tbaa !5
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %47, %0
  %13 = load i32, ptr %1, align 4, !tbaa !9
  %14 = load i32, ptr @N, align 4, !tbaa !9
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %16, label %50

16:                                               ; preds = %12
  %17 = load ptr, ptr @particles, align 8, !tbaa !11
  %18 = load i32, ptr %1, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds %struct.sparticle, ptr %17, i64 %19
  store ptr %20, ptr %2, align 8, !tbaa !11
  %21 = load ptr, ptr %2, align 8, !tbaa !11
  %22 = getelementptr inbounds %struct.sparticle, ptr %21, i32 0, i32 8
  %23 = load double, ptr %22, align 8, !tbaa !13
  %24 = load ptr, ptr %2, align 8, !tbaa !11
  %25 = getelementptr inbounds %struct.sparticle, ptr %24, i32 0, i32 3
  %26 = load double, ptr %25, align 8, !tbaa !15
  %27 = load ptr, ptr %2, align 8, !tbaa !11
  %28 = getelementptr inbounds %struct.sparticle, ptr %27, i32 0, i32 3
  %29 = load double, ptr %28, align 8, !tbaa !15
  %30 = load ptr, ptr %2, align 8, !tbaa !11
  %31 = getelementptr inbounds %struct.sparticle, ptr %30, i32 0, i32 4
  %32 = load double, ptr %31, align 8, !tbaa !16
  %33 = load ptr, ptr %2, align 8, !tbaa !11
  %34 = getelementptr inbounds %struct.sparticle, ptr %33, i32 0, i32 4
  %35 = load double, ptr %34, align 8, !tbaa !16
  %36 = fmul double %32, %35
  %37 = call double @llvm.fmuladd.f64(double %26, double %29, double %36)
  %38 = load ptr, ptr %2, align 8, !tbaa !11
  %39 = getelementptr inbounds %struct.sparticle, ptr %38, i32 0, i32 5
  %40 = load double, ptr %39, align 8, !tbaa !17
  %41 = load ptr, ptr %2, align 8, !tbaa !11
  %42 = getelementptr inbounds %struct.sparticle, ptr %41, i32 0, i32 5
  %43 = load double, ptr %42, align 8, !tbaa !17
  %44 = call double @llvm.fmuladd.f64(double %40, double %43, double %37)
  %45 = load double, ptr %4, align 8, !tbaa !5
  %46 = call double @llvm.fmuladd.f64(double %23, double %44, double %45)
  store double %46, ptr %4, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %16
  %48 = load i32, ptr %1, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %1, align 4, !tbaa !9
  br label %12, !llvm.loop !18

50:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %51 = load double, ptr %4, align 8, !tbaa !5
  %52 = fmul double 5.000000e-01, %51
  %53 = load i32, ptr @N, align 4, !tbaa !9
  %54 = sitofp i32 %53 to float
  %55 = fpext float %54 to double
  %56 = fdiv double %52, %55
  %57 = fdiv double %56, 1.500000e+00
  store double %57, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %58 = load double, ptr @xsize, align 8, !tbaa !5
  %59 = load double, ptr @ysize, align 8, !tbaa !5
  %60 = fmul double %58, %59
  %61 = load double, ptr @zsize, align 8, !tbaa !5
  %62 = fmul double %60, %61
  store double %62, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %63 = load i32, ptr @N, align 4, !tbaa !9
  %64 = sitofp i32 %63 to double
  %65 = load double, ptr %6, align 8, !tbaa !5
  %66 = fdiv double %64, %65
  store double %66, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %67 = load double, ptr @dvtot, align 8, !tbaa !5
  %68 = load double, ptr @write.dvtotlast, align 8, !tbaa !5
  %69 = fsub double %67, %68
  %70 = fneg double %69
  %71 = load double, ptr %6, align 8, !tbaa !5
  %72 = fmul double 3.000000e+00, %71
  %73 = load double, ptr @simtime, align 8, !tbaa !5
  %74 = load double, ptr @write.timelast, align 8, !tbaa !5
  %75 = fsub double %73, %74
  %76 = fmul double %72, %75
  %77 = fdiv double %70, %76
  store double %77, ptr %8, align 8, !tbaa !5
  %78 = load double, ptr %7, align 8, !tbaa !5
  %79 = load double, ptr %8, align 8, !tbaa !5
  %80 = fadd double %79, %78
  store double %80, ptr %8, align 8, !tbaa !5
  %81 = load double, ptr @dvtot, align 8, !tbaa !5
  store double %81, ptr @write.dvtotlast, align 8, !tbaa !5
  %82 = load double, ptr @simtime, align 8, !tbaa !5
  store double %82, ptr @write.timelast, align 8, !tbaa !5
  %83 = load i32, ptr @colcounter, align 4, !tbaa !9
  %84 = icmp eq i32 %83, 0
  br i1 %84, label %85, label %86

85:                                               ; preds = %50
  store double 0.000000e+00, ptr %8, align 8, !tbaa !5
  br label %86

86:                                               ; preds = %85, %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %87 = load i32, ptr @listcounter1, align 4, !tbaa !9
  %88 = sitofp i32 %87 to double
  %89 = load i32, ptr @mergecounter, align 4, !tbaa !9
  %90 = sitofp i32 %89 to double
  %91 = fdiv double %88, %90
  store double %91, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %92 = load i32, ptr @listcounter2, align 4, !tbaa !9
  store i32 %92, ptr %10, align 4, !tbaa !9
  %93 = load i32, ptr @mergecounter, align 4, !tbaa !9
  %94 = icmp eq i32 %93, 0
  br i1 %94, label %95, label %96

95:                                               ; preds = %86
  store double 0.000000e+00, ptr %9, align 8, !tbaa !5
  br label %96

96:                                               ; preds = %95, %86
  store i32 0, ptr @mergecounter, align 4, !tbaa !9
  store i32 0, ptr @listcounter2, align 4, !tbaa !9
  store i32 0, ptr @listcounter1, align 4, !tbaa !9
  %97 = load double, ptr @simtime, align 8, !tbaa !5
  %98 = load i32, ptr @colcounter, align 4, !tbaa !9
  %99 = load double, ptr %8, align 8, !tbaa !5
  %100 = load double, ptr %5, align 8, !tbaa !5
  %101 = load double, ptr %9, align 8, !tbaa !5
  %102 = load i32, ptr %10, align 4, !tbaa !9
  %103 = call i32 (ptr, ...) @printf(ptr noundef @.str.31, double noundef %97, i32 noundef %98, double noundef %99, double noundef %100, double noundef %101, i32 noundef %102)
  call void @llvm.lifetime.start.p0(i64 200, ptr %11) #5
  %104 = load i32, ptr @makesnapshots, align 4, !tbaa !9
  %105 = icmp ne i32 %104, 0
  br i1 %105, label %106, label %191

106:                                              ; preds = %96
  %107 = load double, ptr @simtime, align 8, !tbaa !5
  %108 = load double, ptr @write.lastsnapshottime, align 8, !tbaa !5
  %109 = fsub double %107, %108
  %110 = load double, ptr @snapshotinterval, align 8, !tbaa !5
  %111 = fsub double %110, 1.000000e-03
  %112 = fcmp ogt double %109, %111
  br i1 %112, label %113, label %191

113:                                              ; preds = %106
  %114 = getelementptr inbounds [200 x i8], ptr %11, i64 0, i64 0
  %115 = load i32, ptr @N, align 4, !tbaa !9
  %116 = load double, ptr @xsize, align 8, !tbaa !5
  %117 = load double, ptr @ysize, align 8, !tbaa !5
  %118 = fmul double %116, %117
  %119 = load double, ptr @zsize, align 8, !tbaa !5
  %120 = fmul double %118, %119
  %121 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %114, ptr noundef @.str.32, i32 noundef %115, double noundef %120) #5
  %122 = load i32, ptr @write.first, align 4, !tbaa !9
  %123 = icmp ne i32 %122, 0
  br i1 %123, label %124, label %127

124:                                              ; preds = %113
  store i32 0, ptr @write.first, align 4, !tbaa !9
  %125 = getelementptr inbounds [200 x i8], ptr %11, i64 0, i64 0
  %126 = call noalias ptr @fopen(ptr noundef %125, ptr noundef @.str.28)
  store ptr %126, ptr %3, align 8, !tbaa !11
  br label %130

127:                                              ; preds = %113
  %128 = getelementptr inbounds [200 x i8], ptr %11, i64 0, i64 0
  %129 = call noalias ptr @fopen(ptr noundef %128, ptr noundef @.str.33)
  store ptr %129, ptr %3, align 8, !tbaa !11
  br label %130

130:                                              ; preds = %127, %124
  %131 = load ptr, ptr %3, align 8, !tbaa !11
  %132 = load i32, ptr @N, align 4, !tbaa !9
  %133 = load double, ptr @xsize, align 8, !tbaa !5
  %134 = load double, ptr @ysize, align 8, !tbaa !5
  %135 = load double, ptr @zsize, align 8, !tbaa !5
  %136 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %131, ptr noundef @.str.29, i32 noundef %132, double noundef %133, double noundef %134, double noundef %135) #5
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %137

137:                                              ; preds = %184, %130
  %138 = load i32, ptr %1, align 4, !tbaa !9
  %139 = load i32, ptr @N, align 4, !tbaa !9
  %140 = icmp slt i32 %138, %139
  br i1 %140, label %141, label %187

141:                                              ; preds = %137
  %142 = load ptr, ptr @particles, align 8, !tbaa !11
  %143 = load i32, ptr %1, align 4, !tbaa !9
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds %struct.sparticle, ptr %142, i64 %144
  store ptr %145, ptr %2, align 8, !tbaa !11
  %146 = load ptr, ptr %2, align 8, !tbaa !11
  call void @update(ptr noundef %146)
  %147 = load ptr, ptr %3, align 8, !tbaa !11
  %148 = load ptr, ptr %2, align 8, !tbaa !11
  %149 = getelementptr inbounds %struct.sparticle, ptr %148, i32 0, i32 19
  %150 = load i8, ptr %149, align 8, !tbaa !20
  %151 = zext i8 %150 to i32
  %152 = add nsw i32 97, %151
  %153 = load ptr, ptr %2, align 8, !tbaa !11
  %154 = getelementptr inbounds %struct.sparticle, ptr %153, i32 0, i32 0
  %155 = load double, ptr %154, align 8, !tbaa !21
  %156 = load double, ptr @xsize, align 8, !tbaa !5
  %157 = load ptr, ptr %2, align 8, !tbaa !11
  %158 = getelementptr inbounds %struct.sparticle, ptr %157, i32 0, i32 13
  %159 = load i32, ptr %158, align 8, !tbaa !22
  %160 = sitofp i32 %159 to double
  %161 = call double @llvm.fmuladd.f64(double %156, double %160, double %155)
  %162 = load ptr, ptr %2, align 8, !tbaa !11
  %163 = getelementptr inbounds %struct.sparticle, ptr %162, i32 0, i32 1
  %164 = load double, ptr %163, align 8, !tbaa !23
  %165 = load double, ptr @ysize, align 8, !tbaa !5
  %166 = load ptr, ptr %2, align 8, !tbaa !11
  %167 = getelementptr inbounds %struct.sparticle, ptr %166, i32 0, i32 14
  %168 = load i32, ptr %167, align 4, !tbaa !24
  %169 = sitofp i32 %168 to double
  %170 = call double @llvm.fmuladd.f64(double %165, double %169, double %164)
  %171 = load ptr, ptr %2, align 8, !tbaa !11
  %172 = getelementptr inbounds %struct.sparticle, ptr %171, i32 0, i32 2
  %173 = load double, ptr %172, align 8, !tbaa !25
  %174 = load double, ptr @zsize, align 8, !tbaa !5
  %175 = load ptr, ptr %2, align 8, !tbaa !11
  %176 = getelementptr inbounds %struct.sparticle, ptr %175, i32 0, i32 15
  %177 = load i32, ptr %176, align 8, !tbaa !26
  %178 = sitofp i32 %177 to double
  %179 = call double @llvm.fmuladd.f64(double %174, double %178, double %173)
  %180 = load ptr, ptr %2, align 8, !tbaa !11
  %181 = getelementptr inbounds %struct.sparticle, ptr %180, i32 0, i32 7
  %182 = load double, ptr %181, align 8, !tbaa !27
  %183 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %147, ptr noundef @.str.30, i32 noundef %152, double noundef %161, double noundef %170, double noundef %179, double noundef %182) #5
  br label %184

184:                                              ; preds = %141
  %185 = load i32, ptr %1, align 4, !tbaa !9
  %186 = add nsw i32 %185, 1
  store i32 %186, ptr %1, align 4, !tbaa !9
  br label %137, !llvm.loop !28

187:                                              ; preds = %137
  %188 = load ptr, ptr %3, align 8, !tbaa !11
  %189 = call i32 @fclose(ptr noundef %188)
  %190 = load double, ptr @simtime, align 8, !tbaa !5
  store double %190, ptr @write.lastsnapshottime, align 8, !tbaa !5
  br label %191

191:                                              ; preds = %187, %106, %96
  %192 = getelementptr inbounds [200 x i8], ptr %11, i64 0, i64 0
  %193 = load i32, ptr @N, align 4, !tbaa !9
  %194 = load double, ptr @xsize, align 8, !tbaa !5
  %195 = load double, ptr @ysize, align 8, !tbaa !5
  %196 = fmul double %194, %195
  %197 = load double, ptr @zsize, align 8, !tbaa !5
  %198 = fmul double %196, %197
  %199 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %192, ptr noundef @.str.34, i32 noundef %193, double noundef %198) #5
  %200 = load i32, ptr @write.counter, align 4, !tbaa !9
  %201 = icmp eq i32 %200, 0
  br i1 %201, label %202, label %205

202:                                              ; preds = %191
  %203 = getelementptr inbounds [200 x i8], ptr %11, i64 0, i64 0
  %204 = call noalias ptr @fopen(ptr noundef %203, ptr noundef @.str.28)
  store ptr %204, ptr %3, align 8, !tbaa !11
  br label %208

205:                                              ; preds = %191
  %206 = getelementptr inbounds [200 x i8], ptr %11, i64 0, i64 0
  %207 = call noalias ptr @fopen(ptr noundef %206, ptr noundef @.str.33)
  store ptr %207, ptr %3, align 8, !tbaa !11
  br label %208

208:                                              ; preds = %205, %202
  %209 = load ptr, ptr %3, align 8, !tbaa !11
  %210 = load double, ptr @simtime, align 8, !tbaa !5
  %211 = load double, ptr %8, align 8, !tbaa !5
  %212 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %209, ptr noundef @.str.35, double noundef %210, double noundef %211) #5
  %213 = load ptr, ptr %3, align 8, !tbaa !11
  %214 = call i32 @fclose(ptr noundef %213)
  %215 = load i32, ptr @write.counter, align 4, !tbaa !9
  %216 = add nsw i32 %215, 1
  store i32 %216, ptr @write.counter, align 4, !tbaa !9
  %217 = load double, ptr @simtime, align 8, !tbaa !5
  %218 = load double, ptr @writeinterval, align 8, !tbaa !5
  %219 = fadd double %217, %218
  call void @createevent(double noundef %219, ptr noundef null, ptr noundef null, i32 noundef 100)
  call void @llvm.lifetime.end.p0(i64 200, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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"="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 #4 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !6, i64 64}
!14 = !{!"sparticle", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !7, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !7, i64 128}
!15 = !{!14, !6, i64 24}
!16 = !{!14, !6, i64 32}
!17 = !{!14, !6, i64 40}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!14, !7, i64 128}
!21 = !{!14, !6, i64 0}
!22 = !{!14, !10, i64 88}
!23 = !{!14, !6, i64 8}
!24 = !{!14, !10, i64 92}
!25 = !{!14, !6, i64 16}
!26 = !{!14, !10, i64 96}
!27 = !{!14, !6, i64 56}
!28 = distinct !{!28, !19}


; 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.sparticle = type { double, double, double, double, double, double, double, double, double, i8, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, i8 }

@makesnapshots = external dso_local local_unnamed_addr global i32, align 4
@writeinterval = external dso_local local_unnamed_addr global double, align 8
@snapshotinterval = external dso_local local_unnamed_addr global double, align 8
@N = external dso_local local_unnamed_addr global i32, align 4
@simtime = external dso_local local_unnamed_addr global double, align 8
@listcounter1 = external dso_local local_unnamed_addr global i32, align 4
@listcounter2 = external dso_local local_unnamed_addr global i32, align 4
@mergecounter = external dso_local local_unnamed_addr global i32, align 4
@dvtot = external dso_local local_unnamed_addr global double, align 8
@colcounter = external dso_local local_unnamed_addr global i32, align 4
@particles = external dso_local local_unnamed_addr global ptr, align 8
@xsize = external dso_local local_unnamed_addr global double, align 8
@ysize = external dso_local local_unnamed_addr global double, align 8
@zsize = external dso_local local_unnamed_addr global double, align 8
@.str.28 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [32 x i8], align 1
@write.counter = external hidden local_unnamed_addr global i32, align 4
@write.first = external hidden local_unnamed_addr global i32, align 4
@write.lastsnapshottime = external hidden local_unnamed_addr global double, align 8
@write.dvtotlast = external hidden local_unnamed_addr global double, align 8
@write.timelast = external hidden local_unnamed_addr global double, align 8
@.str.31 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [9 x i8], align 1

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @update(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @createevent(double noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @write() local_unnamed_addr #3 {
  %1 = alloca [200 x i8], align 16
  %2 = load i32, ptr @N, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %4 = load ptr, ptr @particles, align 8, !tbaa !9
  %wide.trip.count = zext nneg i32 %2 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %5 = icmp eq i32 %2, 1
  br i1 %5, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %6

6:                                                ; preds = %6, %.lr.ph.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.new ], [ %indvars.iv.next.1, %6 ]
  %.04144 = phi double [ 0.000000e+00, %.lr.ph.new ], [ %32, %6 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %6 ]
  %7 = getelementptr inbounds %struct.sparticle, ptr %4, i64 %indvars.iv
  %8 = getelementptr inbounds i8, ptr %7, i64 64
  %9 = load double, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %7, i64 24
  %11 = load double, ptr %10, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %7, i64 32
  %13 = load double, ptr %12, align 8, !tbaa !15
  %14 = fmul double %13, %13
  %15 = tail call double @llvm.fmuladd.f64(double %11, double %11, double %14)
  %16 = getelementptr inbounds i8, ptr %7, i64 40
  %17 = load double, ptr %16, align 8, !tbaa !16
  %18 = tail call double @llvm.fmuladd.f64(double %17, double %17, double %15)
  %19 = tail call double @llvm.fmuladd.f64(double %9, double %18, double %.04144)
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %20 = getelementptr inbounds %struct.sparticle, ptr %4, i64 %indvars.iv.next
  %21 = getelementptr inbounds i8, ptr %20, i64 64
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = getelementptr inbounds i8, ptr %20, i64 24
  %24 = load double, ptr %23, align 8, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %20, i64 32
  %26 = load double, ptr %25, align 8, !tbaa !15
  %27 = fmul double %26, %26
  %28 = tail call double @llvm.fmuladd.f64(double %24, double %24, double %27)
  %29 = getelementptr inbounds i8, ptr %20, i64 40
  %30 = load double, ptr %29, align 8, !tbaa !16
  %31 = tail call double @llvm.fmuladd.f64(double %30, double %30, double %28)
  %32 = tail call double @llvm.fmuladd.f64(double %22, double %31, double %19)
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %6, !llvm.loop !17

._crit_edge.loopexit.unr-lcssa:                   ; preds = %6, %.lr.ph
  %.lcssa.ph = phi double [ poison, %.lr.ph ], [ %32, %6 ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.1, %6 ]
  %.04144.unr = phi double [ 0.000000e+00, %.lr.ph ], [ %32, %6 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge.loopexit, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %33 = getelementptr inbounds %struct.sparticle, ptr %4, i64 %indvars.iv.unr
  %34 = getelementptr inbounds i8, ptr %33, i64 64
  %35 = load double, ptr %34, align 8, !tbaa !11
  %36 = getelementptr inbounds i8, ptr %33, i64 24
  %37 = load double, ptr %36, align 8, !tbaa !14
  %38 = getelementptr inbounds i8, ptr %33, i64 32
  %39 = load double, ptr %38, align 8, !tbaa !15
  %40 = fmul double %39, %39
  %41 = tail call double @llvm.fmuladd.f64(double %37, double %37, double %40)
  %42 = getelementptr inbounds i8, ptr %33, i64 40
  %43 = load double, ptr %42, align 8, !tbaa !16
  %44 = tail call double @llvm.fmuladd.f64(double %43, double %43, double %41)
  %45 = tail call double @llvm.fmuladd.f64(double %35, double %44, double %.04144.unr)
  br label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %._crit_edge.loopexit.unr-lcssa, %._crit_edge.loopexit.epilog-lcssa
  %.lcssa = phi double [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %45, %._crit_edge.loopexit.epilog-lcssa ]
  %46 = fmul double %.lcssa, 5.000000e-01
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %.041.lcssa = phi double [ 0.000000e+00, %0 ], [ %46, %._crit_edge.loopexit ]
  %47 = sitofp i32 %2 to float
  %48 = fpext float %47 to double
  %49 = fdiv double %.041.lcssa, %48
  %50 = fdiv double %49, 1.500000e+00
  %51 = load double, ptr @xsize, align 8, !tbaa !19
  %52 = load double, ptr @ysize, align 8, !tbaa !19
  %53 = fmul double %51, %52
  %54 = load double, ptr @zsize, align 8, !tbaa !19
  %55 = sitofp i32 %2 to double
  %56 = load double, ptr @dvtot, align 8, !tbaa !19
  %57 = load double, ptr @write.dvtotlast, align 8, !tbaa !19
  %58 = fsub double %56, %57
  %59 = load double, ptr @simtime, align 8, !tbaa !19
  %60 = load double, ptr @write.timelast, align 8, !tbaa !19
  %61 = fsub double %59, %60
  %62 = fmul double %53, %54
  %63 = fmul double %62, 3.000000e+00
  %64 = fmul double %63, %61
  %65 = insertelement <2 x double> poison, double %55, i64 0
  %66 = insertelement <2 x double> %65, double %58, i64 1
  %67 = insertelement <2 x double> poison, double %62, i64 0
  %68 = insertelement <2 x double> %67, double %64, i64 1
  %69 = fdiv <2 x double> %66, %68
  %shift = shufflevector <2 x double> %69, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %70 = fsub <2 x double> %69, %shift
  %71 = extractelement <2 x double> %70, i64 0
  store double %56, ptr @write.dvtotlast, align 8, !tbaa !19
  store double %59, ptr @write.timelast, align 8, !tbaa !19
  %72 = load i32, ptr @colcounter, align 4, !tbaa !5
  %73 = icmp eq i32 %72, 0
  %.038 = select i1 %73, double 0.000000e+00, double %71
  %74 = load i32, ptr @listcounter1, align 4, !tbaa !5
  %75 = sitofp i32 %74 to double
  %76 = load i32, ptr @mergecounter, align 4, !tbaa !5
  %77 = sitofp i32 %76 to double
  %78 = fdiv double %75, %77
  %79 = load i32, ptr @listcounter2, align 4, !tbaa !5
  %80 = icmp eq i32 %76, 0
  %.037 = select i1 %80, double 0.000000e+00, double %78
  store i32 0, ptr @mergecounter, align 4, !tbaa !5
  store i32 0, ptr @listcounter2, align 4, !tbaa !5
  store i32 0, ptr @listcounter1, align 4, !tbaa !5
  %81 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.31, double noundef %59, i32 noundef %72, double noundef %.038, double noundef %50, double noundef %.037, i32 noundef %79)
  call void @llvm.lifetime.start.p0(i64 200, ptr nonnull %1) #4
  %82 = load i32, ptr @makesnapshots, align 4, !tbaa !5
  %.not = icmp eq i32 %82, 0
  br i1 %.not, label %143, label %83

83:                                               ; preds = %._crit_edge
  %84 = load double, ptr @simtime, align 8, !tbaa !19
  %85 = load double, ptr @write.lastsnapshottime, align 8, !tbaa !19
  %86 = fsub double %84, %85
  %87 = load double, ptr @snapshotinterval, align 8, !tbaa !19
  %88 = fadd double %87, -1.000000e-03
  %89 = fcmp ogt double %86, %88
  br i1 %89, label %90, label %143

90:                                               ; preds = %83
  %91 = load i32, ptr @N, align 4, !tbaa !5
  %92 = load double, ptr @xsize, align 8, !tbaa !19
  %93 = load double, ptr @ysize, align 8, !tbaa !19
  %94 = fmul double %92, %93
  %95 = load double, ptr @zsize, align 8, !tbaa !19
  %96 = fmul double %94, %95
  %97 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.32, i32 noundef %91, double noundef %96) #4
  %98 = load i32, ptr @write.first, align 4, !tbaa !5
  %.not43 = icmp eq i32 %98, 0
  br i1 %.not43, label %100, label %99

99:                                               ; preds = %90
  store i32 0, ptr @write.first, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %90, %99
  %.str.33.sink = phi ptr [ @.str.28, %99 ], [ @.str.33, %90 ]
  %101 = call noalias ptr @fopen(ptr noundef nonnull %1, ptr noundef nonnull %.str.33.sink)
  %102 = load i32, ptr @N, align 4, !tbaa !5
  %103 = load double, ptr @xsize, align 8, !tbaa !19
  %104 = load double, ptr @ysize, align 8, !tbaa !19
  %105 = load double, ptr @zsize, align 8, !tbaa !19
  %106 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %101, ptr noundef nonnull @.str.29, i32 noundef %102, double noundef %103, double noundef %104, double noundef %105) #4
  %107 = load i32, ptr @N, align 4, !tbaa !5
  %108 = icmp sgt i32 %107, 0
  br i1 %108, label %.lr.ph49, label %._crit_edge50

.lr.ph49:                                         ; preds = %100, %.lr.ph49
  %indvars.iv52 = phi i64 [ %indvars.iv.next53, %.lr.ph49 ], [ 0, %100 ]
  %109 = load ptr, ptr @particles, align 8, !tbaa !9
  %110 = getelementptr inbounds %struct.sparticle, ptr %109, i64 %indvars.iv52
  tail call void @update(ptr noundef %110)
  %111 = getelementptr inbounds i8, ptr %110, i64 128
  %112 = load i8, ptr %111, align 8, !tbaa !20
  %113 = zext i8 %112 to i32
  %114 = add nuw nsw i32 %113, 97
  %115 = load double, ptr %110, align 8, !tbaa !21
  %116 = load double, ptr @xsize, align 8, !tbaa !19
  %117 = getelementptr inbounds i8, ptr %110, i64 88
  %118 = load i32, ptr %117, align 8, !tbaa !22
  %119 = sitofp i32 %118 to double
  %120 = tail call double @llvm.fmuladd.f64(double %116, double %119, double %115)
  %121 = getelementptr inbounds i8, ptr %110, i64 8
  %122 = load double, ptr %121, align 8, !tbaa !23
  %123 = load double, ptr @ysize, align 8, !tbaa !19
  %124 = getelementptr inbounds i8, ptr %110, i64 92
  %125 = load i32, ptr %124, align 4, !tbaa !24
  %126 = sitofp i32 %125 to double
  %127 = tail call double @llvm.fmuladd.f64(double %123, double %126, double %122)
  %128 = getelementptr inbounds i8, ptr %110, i64 16
  %129 = load double, ptr %128, align 8, !tbaa !25
  %130 = load double, ptr @zsize, align 8, !tbaa !19
  %131 = getelementptr inbounds i8, ptr %110, i64 96
  %132 = load i32, ptr %131, align 8, !tbaa !26
  %133 = sitofp i32 %132 to double
  %134 = tail call double @llvm.fmuladd.f64(double %130, double %133, double %129)
  %135 = getelementptr inbounds i8, ptr %110, i64 56
  %136 = load double, ptr %135, align 8, !tbaa !27
  %137 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %101, ptr noundef nonnull @.str.30, i32 noundef %114, double noundef %120, double noundef %127, double noundef %134, double noundef %136) #4
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %138 = load i32, ptr @N, align 4, !tbaa !5
  %139 = sext i32 %138 to i64
  %140 = icmp slt i64 %indvars.iv.next53, %139
  br i1 %140, label %.lr.ph49, label %._crit_edge50, !llvm.loop !28

._crit_edge50:                                    ; preds = %.lr.ph49, %100
  %141 = tail call i32 @fclose(ptr noundef %101)
  %142 = load double, ptr @simtime, align 8, !tbaa !19
  store double %142, ptr @write.lastsnapshottime, align 8, !tbaa !19
  br label %143

143:                                              ; preds = %._crit_edge50, %83, %._crit_edge
  %144 = load i32, ptr @N, align 4, !tbaa !5
  %145 = load double, ptr @xsize, align 8, !tbaa !19
  %146 = load double, ptr @ysize, align 8, !tbaa !19
  %147 = fmul double %145, %146
  %148 = load double, ptr @zsize, align 8, !tbaa !19
  %149 = fmul double %147, %148
  %150 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.34, i32 noundef %144, double noundef %149) #4
  %151 = load i32, ptr @write.counter, align 4, !tbaa !5
  %152 = icmp eq i32 %151, 0
  %.str.28..str.33 = select i1 %152, ptr @.str.28, ptr @.str.33
  %153 = call noalias ptr @fopen(ptr noundef nonnull %1, ptr noundef nonnull %.str.28..str.33)
  %154 = load double, ptr @simtime, align 8, !tbaa !19
  %155 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %153, ptr noundef nonnull @.str.35, double noundef %154, double noundef %.038) #4
  %156 = tail call i32 @fclose(ptr noundef %153)
  %157 = load i32, ptr @write.counter, align 4, !tbaa !5
  %158 = add nsw i32 %157, 1
  store i32 %158, ptr @write.counter, align 4, !tbaa !5
  %159 = load double, ptr @simtime, align 8, !tbaa !19
  %160 = load double, ptr @writeinterval, align 8, !tbaa !19
  %161 = fadd double %159, %160
  tail call void @createevent(double noundef %161, ptr noundef null, ptr noundef null, i32 noundef 100)
  call void @llvm.lifetime.end.p0(i64 200, ptr nonnull %1) #4
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nofree 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 = { 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 #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !13, i64 64}
!12 = !{!"sparticle", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !7, i64 72, !6, i64 76, !6, i64 80, !6, i64 84, !6, i64 88, !6, i64 92, !6, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !7, i64 128}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !13, i64 24}
!15 = !{!12, !13, i64 32}
!16 = !{!12, !13, i64 40}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!13, !13, i64 0}
!20 = !{!12, !7, i64 128}
!21 = !{!12, !13, i64 0}
!22 = !{!12, !6, i64 88}
!23 = !{!12, !13, i64 8}
!24 = !{!12, !6, i64 92}
!25 = !{!12, !13, i64 16}
!26 = !{!12, !6, i64 96}
!27 = !{!12, !13, i64 56}
!28 = distinct !{!28, !18}


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