; LLVM IR from FSmallenburg/EDMD :: Multi (mdMulti)

; 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, [24 x ptr], i8, double, double, double, i8, i32, i32, i32, i32, ptr, ptr, ptr, i8 }

@N = external dso_local global i32, align 4
@celllist = external dso_local global ptr, 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
@cx = external dso_local global i32, align 4
@cy = external dso_local global i32, align 4
@cz = external dso_local global i32, align 4
@.str.22 = external hidden unnamed_addr constant [19 x i8], align 1
@icxsize = external dso_local global double, align 8
@icysize = external dso_local global double, align 8
@iczsize = 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

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @initcelllist() #3 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  %3 = load double, ptr @xsize, align 8, !tbaa !5
  %4 = fsub double %3, 1.000000e-04
  %5 = fptosi double %4 to i32
  %6 = sitofp i32 %5 to double
  %7 = fdiv double %6, 1.500000e+00
  %8 = fptosi double %7 to i32
  store i32 %8, ptr @cx, align 4, !tbaa !9
  %9 = load double, ptr @ysize, align 8, !tbaa !5
  %10 = fsub double %9, 1.000000e-04
  %11 = fptosi double %10 to i32
  %12 = sitofp i32 %11 to double
  %13 = fdiv double %12, 1.500000e+00
  %14 = fptosi double %13 to i32
  store i32 %14, ptr @cy, align 4, !tbaa !9
  %15 = load double, ptr @zsize, align 8, !tbaa !5
  %16 = fsub double %15, 1.000000e-04
  %17 = fptosi double %16 to i32
  %18 = sitofp i32 %17 to double
  %19 = fdiv double %18, 1.500000e+00
  %20 = fptosi double %19 to i32
  store i32 %20, ptr @cz, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %30, %0
  %22 = load i32, ptr @cx, align 4, !tbaa !9
  %23 = load i32, ptr @cy, align 4, !tbaa !9
  %24 = mul nsw i32 %22, %23
  %25 = load i32, ptr @cz, align 4, !tbaa !9
  %26 = mul nsw i32 %24, %25
  %27 = load i32, ptr @N, align 4, !tbaa !9
  %28 = mul nsw i32 8, %27
  %29 = icmp sgt i32 %26, %28
  br i1 %29, label %30, label %43

30:                                               ; preds = %21
  %31 = load i32, ptr @cx, align 4, !tbaa !9
  %32 = sitofp i32 %31 to double
  %33 = fmul double %32, 9.000000e-01
  %34 = fptosi double %33 to i32
  store i32 %34, ptr @cx, align 4, !tbaa !9
  %35 = load i32, ptr @cy, align 4, !tbaa !9
  %36 = sitofp i32 %35 to double
  %37 = fmul double %36, 9.000000e-01
  %38 = fptosi double %37 to i32
  store i32 %38, ptr @cy, align 4, !tbaa !9
  %39 = load i32, ptr @cz, align 4, !tbaa !9
  %40 = sitofp i32 %39 to double
  %41 = fmul double %40, 9.000000e-01
  %42 = fptosi double %41 to i32
  store i32 %42, ptr @cz, align 4, !tbaa !9
  br label %21, !llvm.loop !11

43:                                               ; preds = %21
  %44 = load i32, ptr @cx, align 4, !tbaa !9
  %45 = load i32, ptr @cy, align 4, !tbaa !9
  %46 = load i32, ptr @cz, align 4, !tbaa !9
  %47 = call i32 (ptr, ...) @printf(ptr noundef @.str.22, i32 noundef %44, i32 noundef %45, i32 noundef %46)
  %48 = load i32, ptr @cx, align 4, !tbaa !9
  %49 = load i32, ptr @cy, align 4, !tbaa !9
  %50 = mul nsw i32 %48, %49
  %51 = load i32, ptr @cz, align 4, !tbaa !9
  %52 = mul nsw i32 %50, %51
  %53 = sext i32 %52 to i64
  %54 = call noalias ptr @calloc(i64 noundef %53, i64 noundef 8) #5
  store ptr %54, ptr @celllist, align 8, !tbaa !13
  %55 = load i32, ptr @cx, align 4, !tbaa !9
  %56 = sitofp i32 %55 to double
  %57 = load double, ptr @xsize, align 8, !tbaa !5
  %58 = fdiv double %56, %57
  store double %58, ptr @icxsize, align 8, !tbaa !5
  %59 = load i32, ptr @cy, align 4, !tbaa !9
  %60 = sitofp i32 %59 to double
  %61 = load double, ptr @ysize, align 8, !tbaa !5
  %62 = fdiv double %60, %61
  store double %62, ptr @icysize, align 8, !tbaa !5
  %63 = load i32, ptr @cz, align 4, !tbaa !9
  %64 = sitofp i32 %63 to double
  %65 = load double, ptr @zsize, align 8, !tbaa !5
  %66 = fdiv double %64, %65
  store double %66, ptr @iczsize, align 8, !tbaa !5
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %67

67:                                               ; preds = %95, %43
  %68 = load i32, ptr %1, align 4, !tbaa !9
  %69 = load i32, ptr @N, align 4, !tbaa !9
  %70 = icmp slt i32 %68, %69
  br i1 %70, label %71, label %98

71:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %72 = load ptr, ptr @particles, align 8, !tbaa !13
  %73 = load i32, ptr %1, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds %struct.sparticle, ptr %72, i64 %74
  store ptr %75, ptr %2, align 8, !tbaa !13
  %76 = load ptr, ptr %2, align 8, !tbaa !13
  %77 = load ptr, ptr %2, align 8, !tbaa !13
  %78 = getelementptr inbounds %struct.sparticle, ptr %77, i32 0, i32 0
  %79 = load double, ptr %78, align 8, !tbaa !15
  %80 = load double, ptr @icxsize, align 8, !tbaa !5
  %81 = fmul double %79, %80
  %82 = fptosi double %81 to i32
  %83 = load ptr, ptr %2, align 8, !tbaa !13
  %84 = getelementptr inbounds %struct.sparticle, ptr %83, i32 0, i32 1
  %85 = load double, ptr %84, align 8, !tbaa !17
  %86 = load double, ptr @icysize, align 8, !tbaa !5
  %87 = fmul double %85, %86
  %88 = fptosi double %87 to i32
  %89 = load ptr, ptr %2, align 8, !tbaa !13
  %90 = getelementptr inbounds %struct.sparticle, ptr %89, i32 0, i32 2
  %91 = load double, ptr %90, align 8, !tbaa !18
  %92 = load double, ptr @iczsize, align 8, !tbaa !5
  %93 = fmul double %91, %92
  %94 = fptosi double %93 to i32
  call void @addtocelllist(ptr noundef %76, i32 noundef %82, i32 noundef %88, i32 noundef %94)
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  br label %95

95:                                               ; preds = %71
  %96 = load i32, ptr %1, align 4, !tbaa !9
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %1, align 4, !tbaa !9
  br label %67, !llvm.loop !19

98:                                               ; preds = %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 #2 = { nounwind allocsize(0,1) "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 }
attributes #5 = { nounwind allocsize(0,1) }

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"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, !7, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !7, i64 296, !10, i64 300, !10, i64 304, !10, i64 308, !10, i64 312, !14, i64 320, !14, i64 328, !14, i64 336, !7, i64 344}
!17 = !{!16, !6, i64 8}
!18 = !{!16, !6, i64 16}
!19 = distinct !{!19, !12}


; 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, [24 x ptr], i8, double, double, double, i8, i32, i32, i32, i32, ptr, ptr, ptr, i8 }

@N = external dso_local local_unnamed_addr global i32, align 4
@celllist = external dso_local local_unnamed_addr global ptr, 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
@cx = external dso_local local_unnamed_addr global i32, align 4
@cy = external dso_local local_unnamed_addr global i32, align 4
@cz = external dso_local local_unnamed_addr global i32, align 4
@.str.22 = external hidden unnamed_addr constant [19 x i8], align 1
@icxsize = external dso_local local_unnamed_addr global double, align 8
@icysize = external dso_local local_unnamed_addr global double, align 8
@iczsize = external dso_local local_unnamed_addr global double, align 8

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @initcelllist() local_unnamed_addr #2 {
  %1 = load double, ptr @xsize, align 8, !tbaa !5
  %2 = load double, ptr @ysize, align 8, !tbaa !5
  %3 = fadd double %2, -1.000000e-04
  %4 = fptosi double %3 to i32
  %5 = sitofp i32 %4 to double
  %6 = fdiv double %5, 1.500000e+00
  %7 = fptosi double %6 to i32
  store i32 %7, ptr @cy, align 4, !tbaa !9
  %8 = load double, ptr @zsize, align 8, !tbaa !5
  %9 = load i32, ptr @N, align 4, !tbaa !9
  %10 = shl nsw i32 %9, 3
  %11 = insertelement <2 x double> poison, double %1, i64 0
  %12 = insertelement <2 x double> %11, double %8, i64 1
  %13 = fadd <2 x double> %12, <double -1.000000e-04, double -1.000000e-04>
  %14 = fptosi <2 x double> %13 to <2 x i32>
  %15 = sitofp <2 x i32> %14 to <2 x double>
  %16 = fdiv <2 x double> %15, <double 1.500000e+00, double 1.500000e+00>
  %17 = fptosi <2 x double> %16 to <2 x i32>
  %18 = extractelement <2 x i32> %17, i64 0
  store i32 %18, ptr @cx, align 4, !tbaa !9
  %19 = extractelement <2 x i32> %17, i64 1
  %20 = mul i32 %18, %19
  %21 = mul i32 %20, %7
  %22 = icmp sgt i32 %21, %10
  br i1 %22, label %.lr.ph, label %36

.lr.ph:                                           ; preds = %0, %.lr.ph
  %23 = phi i32 [ %28, %.lr.ph ], [ %7, %0 ]
  %24 = phi <2 x i32> [ %30, %.lr.ph ], [ %17, %0 ]
  %25 = sitofp <2 x i32> %24 to <2 x double>
  %26 = sitofp i32 %23 to double
  %27 = fmul double %26, 9.000000e-01
  %28 = fptosi double %27 to i32
  %29 = fmul <2 x double> %25, <double 9.000000e-01, double 9.000000e-01>
  %30 = fptosi <2 x double> %29 to <2 x i32>
  %31 = extractelement <2 x i32> %30, i64 0
  %32 = extractelement <2 x i32> %30, i64 1
  %33 = mul i32 %31, %32
  %34 = mul i32 %33, %28
  %35 = icmp sgt i32 %34, %10
  br i1 %35, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph
  store i32 %31, ptr @cx, align 4, !tbaa !9
  store i32 %28, ptr @cy, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %._crit_edge, %0
  %.lcssa = phi i32 [ %28, %._crit_edge ], [ %7, %0 ]
  %37 = phi <2 x i32> [ %30, %._crit_edge ], [ %17, %0 ]
  %38 = extractelement <2 x i32> %37, i64 1
  store i32 %38, ptr @cz, align 4, !tbaa !9
  %39 = extractelement <2 x i32> %37, i64 0
  %40 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.22, i32 noundef %39, i32 noundef %.lcssa, i32 noundef %38)
  %41 = load i32, ptr @cx, align 4, !tbaa !9
  %42 = load i32, ptr @cy, align 4, !tbaa !9
  %43 = mul nsw i32 %42, %41
  %44 = load i32, ptr @cz, align 4, !tbaa !9
  %45 = mul nsw i32 %43, %44
  %46 = sext i32 %45 to i64
  %47 = tail call noalias ptr @calloc(i64 noundef %46, i64 noundef 8) #3
  store ptr %47, ptr @celllist, align 8, !tbaa !13
  %48 = sitofp i32 %41 to double
  %49 = load double, ptr @xsize, align 8, !tbaa !5
  %50 = fdiv double %48, %49
  store double %50, ptr @icxsize, align 8, !tbaa !5
  %51 = sitofp i32 %42 to double
  %52 = load double, ptr @ysize, align 8, !tbaa !5
  %53 = fdiv double %51, %52
  store double %53, ptr @icysize, align 8, !tbaa !5
  %54 = sitofp i32 %44 to double
  %55 = load double, ptr @zsize, align 8, !tbaa !5
  %56 = fdiv double %54, %55
  store double %56, ptr @iczsize, align 8, !tbaa !5
  %57 = load i32, ptr @N, align 4, !tbaa !9
  %58 = icmp sgt i32 %57, 0
  br i1 %58, label %.lr.ph17, label %._crit_edge18

.lr.ph17:                                         ; preds = %36, %.lr.ph17
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph17 ], [ 0, %36 ]
  %59 = load ptr, ptr @particles, align 8, !tbaa !13
  %60 = getelementptr inbounds %struct.sparticle, ptr %59, i64 %indvars.iv
  %61 = load double, ptr %60, align 8, !tbaa !15
  %62 = load double, ptr @icxsize, align 8, !tbaa !5
  %63 = fmul double %61, %62
  %64 = fptosi double %63 to i32
  %65 = getelementptr inbounds i8, ptr %60, i64 8
  %66 = load double, ptr %65, align 8, !tbaa !17
  %67 = load double, ptr @icysize, align 8, !tbaa !5
  %68 = fmul double %66, %67
  %69 = fptosi double %68 to i32
  %70 = getelementptr inbounds i8, ptr %60, i64 16
  %71 = load double, ptr %70, align 8, !tbaa !18
  %72 = load double, ptr @iczsize, align 8, !tbaa !5
  %73 = fmul double %71, %72
  %74 = fptosi double %73 to i32
  tail call void @addtocelllist(ptr noundef nonnull %60, i32 noundef %64, i32 noundef %69, i32 noundef %74)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %75 = load i32, ptr @N, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = icmp slt i64 %indvars.iv.next, %76
  br i1 %77, label %.lr.ph17, label %._crit_edge18, !llvm.loop !19

._crit_edge18:                                    ; preds = %.lr.ph17, %36
  ret void
}

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

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #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 allocsize(0,1) }

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"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, !7, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !7, i64 296, !10, i64 300, !10, i64 304, !10, i64 308, !10, i64 312, !14, i64 320, !14, i64 328, !14, i64 336, !7, i64 344}
!17 = !{!16, !6, i64 8}
!18 = !{!16, !6, i64 16}
!19 = distinct !{!19, !12}


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