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

@cxsize = external dso_local global double, align 8
@cysize = external dso_local global double, align 8
@czsize = external dso_local global double, align 8

; 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

; Function Attrs: nounwind uwtable
define dso_local void @findcrossing(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca i32, align 4
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.sparticle, ptr %9, i32 0, i32 3
  %11 = load double, ptr %10, align 8, !tbaa !9
  store double %11, ptr %6, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.sparticle, ptr %12, i32 0, i32 4
  %14 = load double, ptr %13, align 8, !tbaa !14
  store double %14, ptr %7, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.sparticle, ptr %15, i32 0, i32 5
  %17 = load double, ptr %16, align 8, !tbaa !15
  store double %17, ptr %8, align 8, !tbaa !13
  %18 = load double, ptr %6, align 8, !tbaa !13
  %19 = fcmp olt double %18, 0.000000e+00
  br i1 %19, label %20, label %33

20:                                               ; preds = %1
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.sparticle, ptr %21, i32 0, i32 10
  %23 = load i32, ptr %22, align 4, !tbaa !16
  %24 = sitofp i32 %23 to double
  %25 = load double, ptr @cxsize, align 8, !tbaa !13
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.sparticle, ptr %26, i32 0, i32 0
  %28 = load double, ptr %27, align 8, !tbaa !17
  %29 = fneg double %28
  %30 = call double @llvm.fmuladd.f64(double %24, double %25, double %29)
  %31 = load double, ptr %6, align 8, !tbaa !13
  %32 = fdiv double %30, %31
  store double %32, ptr %4, align 8, !tbaa !13
  store i32 -1, ptr %5, align 4, !tbaa !18
  br label %47

33:                                               ; preds = %1
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.sparticle, ptr %34, i32 0, i32 10
  %36 = load i32, ptr %35, align 4, !tbaa !16
  %37 = add nsw i32 %36, 1
  %38 = sitofp i32 %37 to double
  %39 = load double, ptr @cxsize, align 8, !tbaa !13
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.sparticle, ptr %40, i32 0, i32 0
  %42 = load double, ptr %41, align 8, !tbaa !17
  %43 = fneg double %42
  %44 = call double @llvm.fmuladd.f64(double %38, double %39, double %43)
  %45 = load double, ptr %6, align 8, !tbaa !13
  %46 = fdiv double %44, %45
  store double %46, ptr %4, align 8, !tbaa !13
  store i32 1, ptr %5, align 4, !tbaa !18
  br label %47

47:                                               ; preds = %33, %20
  %48 = load double, ptr %7, align 8, !tbaa !13
  %49 = fcmp olt double %48, 0.000000e+00
  br i1 %49, label %50, label %71

50:                                               ; preds = %47
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.sparticle, ptr %51, i32 0, i32 11
  %53 = load i32, ptr %52, align 8, !tbaa !19
  %54 = sitofp i32 %53 to double
  %55 = load double, ptr @cysize, align 8, !tbaa !13
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.sparticle, ptr %56, i32 0, i32 1
  %58 = load double, ptr %57, align 8, !tbaa !20
  %59 = fneg double %58
  %60 = call double @llvm.fmuladd.f64(double %54, double %55, double %59)
  store double %60, ptr %3, align 8, !tbaa !13
  %61 = load double, ptr %3, align 8, !tbaa !13
  %62 = load double, ptr %4, align 8, !tbaa !13
  %63 = load double, ptr %7, align 8, !tbaa !13
  %64 = fmul double %62, %63
  %65 = fcmp ogt double %61, %64
  br i1 %65, label %66, label %70

66:                                               ; preds = %50
  store i32 -2, ptr %5, align 4, !tbaa !18
  %67 = load double, ptr %3, align 8, !tbaa !13
  %68 = load double, ptr %7, align 8, !tbaa !13
  %69 = fdiv double %67, %68
  store double %69, ptr %4, align 8, !tbaa !13
  br label %70

70:                                               ; preds = %66, %50
  br label %93

71:                                               ; preds = %47
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.sparticle, ptr %72, i32 0, i32 11
  %74 = load i32, ptr %73, align 8, !tbaa !19
  %75 = add nsw i32 %74, 1
  %76 = sitofp i32 %75 to double
  %77 = load double, ptr @cysize, align 8, !tbaa !13
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.sparticle, ptr %78, i32 0, i32 1
  %80 = load double, ptr %79, align 8, !tbaa !20
  %81 = fneg double %80
  %82 = call double @llvm.fmuladd.f64(double %76, double %77, double %81)
  store double %82, ptr %3, align 8, !tbaa !13
  %83 = load double, ptr %3, align 8, !tbaa !13
  %84 = load double, ptr %4, align 8, !tbaa !13
  %85 = load double, ptr %7, align 8, !tbaa !13
  %86 = fmul double %84, %85
  %87 = fcmp olt double %83, %86
  br i1 %87, label %88, label %92

88:                                               ; preds = %71
  store i32 2, ptr %5, align 4, !tbaa !18
  %89 = load double, ptr %3, align 8, !tbaa !13
  %90 = load double, ptr %7, align 8, !tbaa !13
  %91 = fdiv double %89, %90
  store double %91, ptr %4, align 8, !tbaa !13
  br label %92

92:                                               ; preds = %88, %71
  br label %93

93:                                               ; preds = %92, %70
  %94 = load double, ptr %8, align 8, !tbaa !13
  %95 = fcmp olt double %94, 0.000000e+00
  br i1 %95, label %96, label %117

96:                                               ; preds = %93
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.sparticle, ptr %97, i32 0, i32 12
  %99 = load i32, ptr %98, align 4, !tbaa !21
  %100 = sitofp i32 %99 to double
  %101 = load double, ptr @czsize, align 8, !tbaa !13
  %102 = load ptr, ptr %2, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.sparticle, ptr %102, i32 0, i32 2
  %104 = load double, ptr %103, align 8, !tbaa !22
  %105 = fneg double %104
  %106 = call double @llvm.fmuladd.f64(double %100, double %101, double %105)
  store double %106, ptr %3, align 8, !tbaa !13
  %107 = load double, ptr %3, align 8, !tbaa !13
  %108 = load double, ptr %4, align 8, !tbaa !13
  %109 = load double, ptr %8, align 8, !tbaa !13
  %110 = fmul double %108, %109
  %111 = fcmp ogt double %107, %110
  br i1 %111, label %112, label %116

112:                                              ; preds = %96
  store i32 -3, ptr %5, align 4, !tbaa !18
  %113 = load double, ptr %3, align 8, !tbaa !13
  %114 = load double, ptr %8, align 8, !tbaa !13
  %115 = fdiv double %113, %114
  store double %115, ptr %4, align 8, !tbaa !13
  br label %116

116:                                              ; preds = %112, %96
  br label %139

117:                                              ; preds = %93
  %118 = load ptr, ptr %2, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.sparticle, ptr %118, i32 0, i32 12
  %120 = load i32, ptr %119, align 4, !tbaa !21
  %121 = add nsw i32 %120, 1
  %122 = sitofp i32 %121 to double
  %123 = load double, ptr @czsize, align 8, !tbaa !13
  %124 = load ptr, ptr %2, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.sparticle, ptr %124, i32 0, i32 2
  %126 = load double, ptr %125, align 8, !tbaa !22
  %127 = fneg double %126
  %128 = call double @llvm.fmuladd.f64(double %122, double %123, double %127)
  store double %128, ptr %3, align 8, !tbaa !13
  %129 = load double, ptr %3, align 8, !tbaa !13
  %130 = load double, ptr %4, align 8, !tbaa !13
  %131 = load double, ptr %8, align 8, !tbaa !13
  %132 = fmul double %130, %131
  %133 = fcmp olt double %129, %132
  br i1 %133, label %134, label %138

134:                                              ; preds = %117
  store i32 3, ptr %5, align 4, !tbaa !18
  %135 = load double, ptr %3, align 8, !tbaa !13
  %136 = load double, ptr %8, align 8, !tbaa !13
  %137 = fdiv double %135, %136
  store double %137, ptr %4, align 8, !tbaa !13
  br label %138

138:                                              ; preds = %134, %117
  br label %139

139:                                              ; preds = %138, %116
  %140 = load ptr, ptr %2, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.sparticle, ptr %140, i32 0, i32 6
  %142 = load double, ptr %141, align 8, !tbaa !23
  %143 = load double, ptr %4, align 8, !tbaa !13
  %144 = fadd double %142, %143
  %145 = load ptr, ptr %2, align 8, !tbaa !5
  %146 = load ptr, ptr %2, align 8, !tbaa !5
  %147 = load i32, ptr %5, align 4, !tbaa !18
  call void @createevent(double noundef %144, ptr noundef %145, ptr noundef %146, i32 noundef %147)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

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

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

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

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


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

@cxsize = external dso_local local_unnamed_addr global double, align 8
@cysize = external dso_local local_unnamed_addr global double, align 8
@czsize = external dso_local local_unnamed_addr global double, align 8

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

; Function Attrs: nounwind uwtable
define dso_local void @findcrossing(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = load double, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = load double, ptr %4, align 8, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  %7 = load double, ptr %6, align 8, !tbaa !13
  %8 = fcmp uge double %3, 0.000000e+00
  %9 = getelementptr inbounds i8, ptr %0, i64 76
  %10 = load i32, ptr %9, align 4, !tbaa !14
  %11 = zext i1 %8 to i32
  %.sink60 = add nsw i32 %10, %11
  %.044 = select i1 %8, i32 1, i32 -1
  %12 = sitofp i32 %.sink60 to double
  %13 = load double, ptr @cxsize, align 8, !tbaa !15
  %14 = load double, ptr %0, align 8, !tbaa !16
  %15 = fneg double %14
  %16 = tail call double @llvm.fmuladd.f64(double %12, double %13, double %15)
  %.0 = fdiv double %16, %3
  %17 = fcmp olt double %5, 0.000000e+00
  %18 = getelementptr inbounds i8, ptr %0, i64 80
  %19 = load i32, ptr %18, align 8, !tbaa !17
  br i1 %17, label %20, label %31

20:                                               ; preds = %1
  %21 = sitofp i32 %19 to double
  %22 = load double, ptr @cysize, align 8, !tbaa !15
  %23 = getelementptr inbounds i8, ptr %0, i64 8
  %24 = load double, ptr %23, align 8, !tbaa !18
  %25 = fneg double %24
  %26 = tail call double @llvm.fmuladd.f64(double %21, double %22, double %25)
  %27 = fmul double %5, %.0
  %28 = fcmp ogt double %26, %27
  br i1 %28, label %29, label %43

29:                                               ; preds = %20
  %30 = fdiv double %26, %5
  br label %43

31:                                               ; preds = %1
  %32 = add nsw i32 %19, 1
  %33 = sitofp i32 %32 to double
  %34 = load double, ptr @cysize, align 8, !tbaa !15
  %35 = getelementptr inbounds i8, ptr %0, i64 8
  %36 = load double, ptr %35, align 8, !tbaa !18
  %37 = fneg double %36
  %38 = tail call double @llvm.fmuladd.f64(double %33, double %34, double %37)
  %39 = fmul double %5, %.0
  %40 = fcmp olt double %38, %39
  br i1 %40, label %41, label %43

41:                                               ; preds = %31
  %42 = fdiv double %38, %5
  br label %43

43:                                               ; preds = %31, %41, %20, %29
  %.145 = phi i32 [ -2, %29 ], [ %.044, %20 ], [ 2, %41 ], [ %.044, %31 ]
  %.1 = phi double [ %30, %29 ], [ %.0, %20 ], [ %42, %41 ], [ %.0, %31 ]
  %44 = fcmp olt double %7, 0.000000e+00
  %45 = getelementptr inbounds i8, ptr %0, i64 84
  %46 = load i32, ptr %45, align 4, !tbaa !19
  br i1 %44, label %47, label %58

47:                                               ; preds = %43
  %48 = sitofp i32 %46 to double
  %49 = load double, ptr @czsize, align 8, !tbaa !15
  %50 = getelementptr inbounds i8, ptr %0, i64 16
  %51 = load double, ptr %50, align 8, !tbaa !20
  %52 = fneg double %51
  %53 = tail call double @llvm.fmuladd.f64(double %48, double %49, double %52)
  %54 = fmul double %7, %.1
  %55 = fcmp ogt double %53, %54
  br i1 %55, label %56, label %70

56:                                               ; preds = %47
  %57 = fdiv double %53, %7
  br label %70

58:                                               ; preds = %43
  %59 = add nsw i32 %46, 1
  %60 = sitofp i32 %59 to double
  %61 = load double, ptr @czsize, align 8, !tbaa !15
  %62 = getelementptr inbounds i8, ptr %0, i64 16
  %63 = load double, ptr %62, align 8, !tbaa !20
  %64 = fneg double %63
  %65 = tail call double @llvm.fmuladd.f64(double %60, double %61, double %64)
  %66 = fmul double %7, %.1
  %67 = fcmp olt double %65, %66
  br i1 %67, label %68, label %70

68:                                               ; preds = %58
  %69 = fdiv double %65, %7
  br label %70

70:                                               ; preds = %58, %68, %47, %56
  %.246 = phi i32 [ -3, %56 ], [ %.145, %47 ], [ 3, %68 ], [ %.145, %58 ]
  %.2 = phi double [ %57, %56 ], [ %.1, %47 ], [ %69, %68 ], [ %.1, %58 ]
  %71 = getelementptr inbounds i8, ptr %0, i64 48
  %72 = load double, ptr %71, align 8, !tbaa !21
  %73 = fadd double %.2, %72
  tail call void @createevent(double noundef %73, ptr noundef nonnull %0, ptr noundef nonnull %0, i32 noundef %.246)
  ret void
}

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

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

!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 24}
!6 = !{!"sparticle", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !8, i64 72, !10, i64 76, !10, i64 80, !10, i64 84, !10, i64 88, !10, i64 92, !10, i64 96, !11, i64 104, !11, i64 112, !11, i64 120, !8, i64 128}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 32}
!13 = !{!6, !7, i64 40}
!14 = !{!6, !10, i64 76}
!15 = !{!7, !7, i64 0}
!16 = !{!6, !7, i64 0}
!17 = !{!6, !10, i64 80}
!18 = !{!6, !7, i64 8}
!19 = !{!6, !10, i64 84}
!20 = !{!6, !7, i64 16}
!21 = !{!6, !7, i64 48}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass