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

@N = external dso_local global i32, align 4
@simtime = external dso_local global double, align 8
@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.27 = external hidden unnamed_addr constant [17 x i8], align 1
@.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

; 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 noalias ptr @fopen(ptr noundef, ptr noundef) #2

declare i32 @fclose(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @outputsnapshot() #3 {
  %1 = alloca [200 x i8], align 16
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 200, ptr %1) #5
  %6 = getelementptr inbounds [200 x i8], ptr %1, i64 0, i64 0
  %7 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %6, ptr noundef @.str.27) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  %8 = getelementptr inbounds [200 x i8], ptr %1, i64 0, i64 0
  %9 = call noalias ptr @fopen(ptr noundef %8, ptr noundef @.str.28)
  store ptr %9, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = load i32, ptr @N, align 4, !tbaa !9
  %12 = load double, ptr @xsize, align 8, !tbaa !11
  %13 = load double, ptr @ysize, align 8, !tbaa !11
  %14 = load double, ptr @zsize, align 8, !tbaa !11
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef @.str.29, i32 noundef %11, double noundef %12, double noundef %13, double noundef %14) #5
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %94, %0
  %17 = load i32, ptr %3, align 4, !tbaa !9
  %18 = load i32, ptr @N, align 4, !tbaa !9
  %19 = icmp slt i32 %17, %18
  br i1 %19, label %20, label %97

20:                                               ; preds = %16
  %21 = load ptr, ptr @particles, align 8, !tbaa !5
  %22 = load i32, ptr %3, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds %struct.sparticle, ptr %21, i64 %23
  store ptr %24, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %25 = load double, ptr @simtime, align 8, !tbaa !11
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.sparticle, ptr %26, i32 0, i32 6
  %28 = load double, ptr %27, align 8, !tbaa !13
  %29 = fsub double %25, %28
  store double %29, ptr %5, align 8, !tbaa !11
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.sparticle, ptr %30, i32 0, i32 3
  %32 = load double, ptr %31, align 8, !tbaa !15
  %33 = load double, ptr %5, align 8, !tbaa !11
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.sparticle, ptr %34, i32 0, i32 0
  %36 = load double, ptr %35, align 8, !tbaa !16
  %37 = call double @llvm.fmuladd.f64(double %32, double %33, double %36)
  store double %37, ptr %35, align 8, !tbaa !16
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.sparticle, ptr %38, i32 0, i32 4
  %40 = load double, ptr %39, align 8, !tbaa !17
  %41 = load double, ptr %5, align 8, !tbaa !11
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.sparticle, ptr %42, i32 0, i32 1
  %44 = load double, ptr %43, align 8, !tbaa !18
  %45 = call double @llvm.fmuladd.f64(double %40, double %41, double %44)
  store double %45, ptr %43, align 8, !tbaa !18
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.sparticle, ptr %46, i32 0, i32 5
  %48 = load double, ptr %47, align 8, !tbaa !19
  %49 = load double, ptr %5, align 8, !tbaa !11
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.sparticle, ptr %50, i32 0, i32 2
  %52 = load double, ptr %51, align 8, !tbaa !20
  %53 = call double @llvm.fmuladd.f64(double %48, double %49, double %52)
  store double %53, ptr %51, align 8, !tbaa !20
  %54 = load double, ptr @simtime, align 8, !tbaa !11
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.sparticle, ptr %55, i32 0, i32 6
  store double %54, ptr %56, align 8, !tbaa !13
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.sparticle, ptr %58, i32 0, i32 19
  %60 = load i8, ptr %59, align 8, !tbaa !21
  %61 = zext i8 %60 to i32
  %62 = add nsw i32 97, %61
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.sparticle, ptr %63, i32 0, i32 0
  %65 = load double, ptr %64, align 8, !tbaa !16
  %66 = load double, ptr @xsize, align 8, !tbaa !11
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.sparticle, ptr %67, i32 0, i32 13
  %69 = load i32, ptr %68, align 8, !tbaa !22
  %70 = sitofp i32 %69 to double
  %71 = call double @llvm.fmuladd.f64(double %66, double %70, double %65)
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.sparticle, ptr %72, i32 0, i32 1
  %74 = load double, ptr %73, align 8, !tbaa !18
  %75 = load double, ptr @ysize, align 8, !tbaa !11
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.sparticle, ptr %76, i32 0, i32 14
  %78 = load i32, ptr %77, align 4, !tbaa !23
  %79 = sitofp i32 %78 to double
  %80 = call double @llvm.fmuladd.f64(double %75, double %79, double %74)
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.sparticle, ptr %81, i32 0, i32 2
  %83 = load double, ptr %82, align 8, !tbaa !20
  %84 = load double, ptr @zsize, align 8, !tbaa !11
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.sparticle, ptr %85, i32 0, i32 15
  %87 = load i32, ptr %86, align 8, !tbaa !24
  %88 = sitofp i32 %87 to double
  %89 = call double @llvm.fmuladd.f64(double %84, double %88, double %83)
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.sparticle, ptr %90, i32 0, i32 7
  %92 = load double, ptr %91, align 8, !tbaa !25
  %93 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %57, ptr noundef @.str.30, i32 noundef %62, double noundef %71, double noundef %80, double noundef %89, double noundef %92) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %94

94:                                               ; preds = %20
  %95 = load i32, ptr %3, align 4, !tbaa !9
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %3, align 4, !tbaa !9
  br label %16, !llvm.loop !26

97:                                               ; preds = %16
  %98 = load ptr, ptr %2, align 8, !tbaa !5
  %99 = call i32 @fclose(ptr noundef %98)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 200, ptr %1) #5
  ret void
}

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

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

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 = !{!"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 48}
!14 = !{!"sparticle", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !12, i64 56, !12, i64 64, !7, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !7, i64 128}
!15 = !{!14, !12, i64 24}
!16 = !{!14, !12, i64 0}
!17 = !{!14, !12, i64 32}
!18 = !{!14, !12, i64 8}
!19 = !{!14, !12, i64 40}
!20 = !{!14, !12, i64 16}
!21 = !{!14, !7, i64 128}
!22 = !{!14, !10, i64 88}
!23 = !{!14, !10, i64 92}
!24 = !{!14, !10, i64 96}
!25 = !{!14, !12, i64 56}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


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

@N = external dso_local local_unnamed_addr global i32, align 4
@simtime = external dso_local local_unnamed_addr global double, align 8
@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.27 = external hidden unnamed_addr constant [17 x i8], align 1
@.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

; 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 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: nofree nounwind uwtable
define dso_local void @outputsnapshot() local_unnamed_addr #3 {
  %1 = alloca [200 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 200, ptr nonnull %1) #5
  %2 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %1, ptr noundef nonnull dereferenceable(1) @.str.27) #5
  %3 = call noalias ptr @fopen(ptr noundef nonnull %1, ptr noundef nonnull @.str.28)
  %4 = load i32, ptr @N, align 4, !tbaa !5
  %5 = load double, ptr @xsize, align 8, !tbaa !9
  %6 = load double, ptr @ysize, align 8, !tbaa !9
  %7 = load double, ptr @zsize, align 8, !tbaa !9
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %3, ptr noundef nonnull @.str.29, i32 noundef %4, double noundef %5, double noundef %6, double noundef %7) #5
  %9 = load i32, ptr @N, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %11 = load ptr, ptr @particles, align 8, !tbaa !11
  %12 = getelementptr inbounds %struct.sparticle, ptr %11, i64 %indvars.iv
  %13 = load double, ptr @simtime, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %12, i64 48
  %15 = load double, ptr %14, align 8, !tbaa !13
  %16 = fsub double %13, %15
  %17 = getelementptr inbounds i8, ptr %12, i64 24
  %18 = load <2 x double>, ptr %17, align 8, !tbaa !9
  %19 = load <2 x double>, ptr %12, align 8, !tbaa !9
  %20 = insertelement <2 x double> poison, double %16, i64 0
  %21 = shufflevector <2 x double> %20, <2 x double> poison, <2 x i32> zeroinitializer
  %22 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %18, <2 x double> %21, <2 x double> %19)
  store <2 x double> %22, ptr %12, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %12, i64 40
  %24 = load double, ptr %23, align 8, !tbaa !15
  %25 = getelementptr inbounds i8, ptr %12, i64 16
  %26 = load double, ptr %25, align 8, !tbaa !16
  %27 = tail call double @llvm.fmuladd.f64(double %24, double %16, double %26)
  store double %27, ptr %25, align 8, !tbaa !16
  %28 = load double, ptr @simtime, align 8, !tbaa !9
  store double %28, ptr %14, align 8, !tbaa !13
  %29 = getelementptr inbounds i8, ptr %12, i64 128
  %30 = load i8, ptr %29, align 8, !tbaa !17
  %31 = zext i8 %30 to i32
  %32 = add nuw nsw i32 %31, 97
  %33 = load double, ptr @xsize, align 8, !tbaa !9
  %34 = getelementptr inbounds i8, ptr %12, i64 88
  %35 = load i32, ptr %34, align 8, !tbaa !18
  %36 = sitofp i32 %35 to double
  %37 = extractelement <2 x double> %22, i64 0
  %38 = tail call double @llvm.fmuladd.f64(double %33, double %36, double %37)
  %39 = load double, ptr @ysize, align 8, !tbaa !9
  %40 = getelementptr inbounds i8, ptr %12, i64 92
  %41 = load i32, ptr %40, align 4, !tbaa !19
  %42 = sitofp i32 %41 to double
  %43 = extractelement <2 x double> %22, i64 1
  %44 = tail call double @llvm.fmuladd.f64(double %39, double %42, double %43)
  %45 = load double, ptr @zsize, align 8, !tbaa !9
  %46 = getelementptr inbounds i8, ptr %12, i64 96
  %47 = load i32, ptr %46, align 8, !tbaa !20
  %48 = sitofp i32 %47 to double
  %49 = tail call double @llvm.fmuladd.f64(double %45, double %48, double %27)
  %50 = getelementptr inbounds i8, ptr %12, i64 56
  %51 = load double, ptr %50, align 8, !tbaa !21
  %52 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %3, ptr noundef nonnull @.str.30, i32 noundef %32, double noundef %38, double noundef %44, double noundef %49, double noundef %51) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %53 = load i32, ptr @N, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = icmp slt i64 %indvars.iv.next, %54
  br i1 %55, label %.lr.ph, label %._crit_edge, !llvm.loop !22

._crit_edge:                                      ; preds = %.lr.ph, %0
  %56 = tail call i32 @fclose(ptr noundef %3)
  call void @llvm.lifetime.end.p0(i64 200, ptr nonnull %1) #5
  ret void
}

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #4

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 = { nofree 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !10, i64 48}
!14 = !{!"sparticle", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !7, i64 72, !6, i64 76, !6, i64 80, !6, i64 84, !6, i64 88, !6, i64 92, !6, i64 96, !12, i64 104, !12, i64 112, !12, i64 120, !7, i64 128}
!15 = !{!14, !10, i64 40}
!16 = !{!14, !10, i64 16}
!17 = !{!14, !7, i64 128}
!18 = !{!14, !6, i64 88}
!19 = !{!14, !6, i64 92}
!20 = !{!14, !6, i64 96}
!21 = !{!14, !10, i64 56}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass