; 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
@dvtot = external dso_local global double, align 8
@particles = external dso_local global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [29 x i8], align 1
@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.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [41 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

; Function Attrs: nounwind uwtable
define dso_local void @printstuff() #3 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca double, 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store double 0.000000e+00, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store double 0.000000e+00, ptr %4, align 8, !tbaa !5
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %58, %0
  %11 = load i32, ptr %1, align 4, !tbaa !9
  %12 = load i32, ptr @N, align 4, !tbaa !9
  %13 = icmp slt i32 %11, %12
  br i1 %13, label %14, label %61

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

58:                                               ; preds = %14
  %59 = load i32, ptr %1, align 4, !tbaa !9
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %1, align 4, !tbaa !9
  br label %10, !llvm.loop !19

61:                                               ; preds = %10
  %62 = load double, ptr %4, align 8, !tbaa !5
  %63 = fmul double %62, 0x3FE0C152382D7365
  store double %63, ptr %4, align 8, !tbaa !5
  %64 = load double, ptr %3, align 8, !tbaa !5
  %65 = fmul double 5.000000e-01, %64
  %66 = load i32, ptr @N, align 4, !tbaa !9
  %67 = sitofp i32 %66 to double
  %68 = fdiv double %65, %67
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %68)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %70 = load double, ptr @xsize, align 8, !tbaa !5
  %71 = load double, ptr @ysize, align 8, !tbaa !5
  %72 = fmul double %70, %71
  %73 = load double, ptr @zsize, align 8, !tbaa !5
  %74 = fmul double %72, %73
  store double %74, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %75 = load i32, ptr @N, align 4, !tbaa !9
  %76 = sitofp i32 %75 to double
  %77 = load double, ptr %5, align 8, !tbaa !5
  %78 = fdiv double %76, %77
  store double %78, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %79 = load double, ptr @dvtot, align 8, !tbaa !5
  %80 = fneg double %79
  %81 = load double, ptr %5, align 8, !tbaa !5
  %82 = fmul double 3.000000e+00, %81
  %83 = load double, ptr @simtime, align 8, !tbaa !5
  %84 = fmul double %82, %83
  %85 = fdiv double %80, %84
  store double %85, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %86 = load double, ptr %6, align 8, !tbaa !5
  store double %86, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %87 = load double, ptr %7, align 8, !tbaa !5
  %88 = load double, ptr %8, align 8, !tbaa !5
  %89 = fadd double %87, %88
  store double %89, ptr %9, align 8, !tbaa !5
  %90 = load double, ptr @simtime, align 8, !tbaa !5
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %90)
  %92 = load double, ptr %4, align 8, !tbaa !5
  %93 = load double, ptr %5, align 8, !tbaa !5
  %94 = fdiv double %92, %93
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, double noundef %94)
  %96 = load double, ptr %7, align 8, !tbaa !5
  %97 = load double, ptr %8, align 8, !tbaa !5
  %98 = load double, ptr %9, align 8, !tbaa !5
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, double noundef %96, double noundef %97, double noundef %98)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  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 }

!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 = !{!14, !6, i64 56}
!19 = distinct !{!19, !20}
!20 = !{!"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
@dvtot = external dso_local local_unnamed_addr global double, align 8
@particles = external dso_local local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [29 x i8], align 1
@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.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1

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

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @printstuff() local_unnamed_addr #2 {
  %1 = load i32, ptr @N, align 4, !tbaa !5
  %2 = icmp sgt i32 %1, 0
  br i1 %2, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %3 = load ptr, ptr @particles, align 8, !tbaa !9
  %wide.trip.count = zext nneg i32 %1 to i64
  br label %4

4:                                                ; preds = %.lr.ph, %4
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %4 ]
  %5 = phi <2 x double> [ zeroinitializer, %.lr.ph ], [ %25, %4 ]
  %6 = getelementptr inbounds %struct.sparticle, ptr %3, i64 %indvars.iv
  %7 = getelementptr inbounds i8, ptr %6, i64 64
  %8 = load double, ptr %7, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %6, i64 24
  %10 = load double, ptr %9, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %6, i64 32
  %12 = load double, ptr %11, align 8, !tbaa !15
  %13 = fmul double %12, %12
  %14 = tail call double @llvm.fmuladd.f64(double %10, double %10, double %13)
  %15 = getelementptr inbounds i8, ptr %6, i64 40
  %16 = load double, ptr %15, align 8, !tbaa !16
  %17 = tail call double @llvm.fmuladd.f64(double %16, double %16, double %14)
  %18 = getelementptr inbounds i8, ptr %6, i64 56
  %19 = load double, ptr %18, align 8, !tbaa !17
  %20 = fmul double %19, %19
  %21 = fmul double %19, %20
  %22 = insertelement <2 x double> poison, double %21, i64 0
  %23 = insertelement <2 x double> %22, double %8, i64 1
  %24 = insertelement <2 x double> <double 8.000000e+00, double poison>, double %17, i64 1
  %25 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %23, <2 x double> %24, <2 x double> %5)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %4, !llvm.loop !18

._crit_edge.loopexit:                             ; preds = %4
  %26 = fmul <2 x double> %25, <double 0x3FE0C152382D7365, double 5.000000e-01>
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %27 = phi <2 x double> [ zeroinitializer, %0 ], [ %26, %._crit_edge.loopexit ]
  %28 = sitofp i32 %1 to double
  %29 = extractelement <2 x double> %27, i64 1
  %30 = fdiv double %29, %28
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %30)
  %32 = load double, ptr @xsize, align 8, !tbaa !20
  %33 = load double, ptr @ysize, align 8, !tbaa !20
  %34 = fmul double %32, %33
  %35 = load double, ptr @zsize, align 8, !tbaa !20
  %36 = load i32, ptr @N, align 4, !tbaa !5
  %37 = sitofp i32 %36 to double
  %38 = load double, ptr @dvtot, align 8, !tbaa !20
  %39 = fneg double %38
  %40 = load double, ptr @simtime, align 8, !tbaa !20
  %41 = fmul double %34, %35
  %42 = fmul double %41, 3.000000e+00
  %43 = fmul double %42, %40
  %44 = insertelement <2 x double> poison, double %37, i64 0
  %45 = insertelement <2 x double> %44, double %39, i64 1
  %46 = insertelement <2 x double> poison, double %41, i64 0
  %47 = insertelement <2 x double> %46, double %43, i64 1
  %48 = fdiv <2 x double> %45, %47
  %49 = extractelement <2 x double> %48, i64 0
  %50 = extractelement <2 x double> %48, i64 1
  %51 = fadd double %49, %50
  %52 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %40)
  %53 = extractelement <2 x double> %27, i64 0
  %54 = fdiv double %53, %41
  %55 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, double noundef %54)
  %56 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %50, double noundef %49, double noundef %51)
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #3

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

!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 = !{!12, !13, i64 56}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!13, !13, i64 0}


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