; LLVM IR from FSmallenburg/EDMD :: Grow (mdgrow)

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

@time = external dso_local global double, align 8
@dvtot = external dso_local global double, align 8
@particles = external dso_local global [100000 x %struct.sparticle], align 16
@.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 = %56, %0
  %11 = load i32, ptr %1, align 4, !tbaa !9
  %12 = icmp slt i32 %11, 100000
  br i1 %12, label %13, label %59

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

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

59:                                               ; preds = %10
  %60 = load double, ptr %4, align 8, !tbaa !5
  %61 = fmul double %60, 0x3FE0C152382D7365
  store double %61, ptr %4, align 8, !tbaa !5
  %62 = load double, ptr %3, align 8, !tbaa !5
  %63 = fmul double 5.000000e-01, %62
  %64 = fdiv double %63, 1.000000e+05
  %65 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, double noundef %64)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %66 = load double, ptr @xsize, align 8, !tbaa !5
  %67 = load double, ptr @ysize, align 8, !tbaa !5
  %68 = fmul double %66, %67
  %69 = load double, ptr @zsize, align 8, !tbaa !5
  %70 = fmul double %68, %69
  store double %70, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %71 = load double, ptr %5, align 8, !tbaa !5
  %72 = fdiv double 1.000000e+05, %71
  store double %72, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %73 = load double, ptr @dvtot, align 8, !tbaa !5
  %74 = fneg double %73
  %75 = load double, ptr %5, align 8, !tbaa !5
  %76 = fmul double 3.000000e+00, %75
  %77 = load double, ptr @time, align 8, !tbaa !5
  %78 = fmul double %76, %77
  %79 = fdiv double %74, %78
  store double %79, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %80 = load double, ptr %6, align 8, !tbaa !5
  store double %80, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %81 = load double, ptr %7, align 8, !tbaa !5
  %82 = load double, ptr %8, align 8, !tbaa !5
  %83 = fadd double %81, %82
  store double %83, ptr %9, align 8, !tbaa !5
  %84 = load double, ptr @time, align 8, !tbaa !5
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, double noundef %84)
  %86 = load double, ptr %4, align 8, !tbaa !5
  %87 = load double, ptr %5, align 8, !tbaa !5
  %88 = fdiv double %86, %87
  %89 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, double noundef %88)
  %90 = load double, ptr %7, align 8, !tbaa !5
  %91 = load double, ptr %8, align 8, !tbaa !5
  %92 = load double, ptr %9, align 8, !tbaa !5
  %93 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, double noundef %90, double noundef %91, double noundef %92)
  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 304}
!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, !6, i64 72, !7, i64 80, !7, i64 272, !6, i64 280, !6, i64 288, !6, i64 296, !6, i64 304, !7, i64 312, !7, i64 313, !7, i64 314, !7, i64 315, !10, i64 316, !10, i64 320, !10, i64 324, !12, i64 328, !10, i64 336, !12, i64 344, !12, i64 352, !10, i64 360, !7, i64 364}
!15 = !{!14, !6, i64 24}
!16 = !{!14, !6, i64 32}
!17 = !{!14, !6, i64 40}
!18 = !{!14, !6, i64 288}
!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, double, [24 x ptr], i8, double, double, double, double, i8, i8, i8, i8, i32, i32, i32, ptr, i32, ptr, ptr, i32, i8 }

@time = 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 [100000 x %struct.sparticle], align 16
@.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 {
  br label %1

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

23:                                               ; preds = %1
  %24 = extractelement <2 x double> %22, i64 1
  %25 = fmul double %24, 0x3FE0C152382D7365
  %26 = extractelement <2 x double> %22, i64 0
  %27 = fmul double %26, 5.000000e-01
  %28 = fdiv double %27, 1.000000e+05
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, double noundef %28)
  %30 = load double, ptr @xsize, align 8, !tbaa !18
  %31 = load double, ptr @ysize, align 8, !tbaa !18
  %32 = fmul double %30, %31
  %33 = load double, ptr @zsize, align 8, !tbaa !18
  %34 = load double, ptr @dvtot, align 8, !tbaa !18
  %35 = fneg double %34
  %36 = load double, ptr @time, align 8, !tbaa !18
  %37 = fmul double %32, %33
  %38 = fmul double %37, 3.000000e+00
  %39 = fmul double %38, %36
  %40 = insertelement <2 x double> <double 1.000000e+05, double poison>, double %35, i64 1
  %41 = insertelement <2 x double> poison, double %37, i64 0
  %42 = insertelement <2 x double> %41, double %39, i64 1
  %43 = fdiv <2 x double> %40, %42
  %44 = extractelement <2 x double> %43, i64 0
  %45 = extractelement <2 x double> %43, i64 1
  %46 = fadd double %44, %45
  %47 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, double noundef %36)
  %48 = fdiv double %25, %37
  %49 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, double noundef %48)
  %50 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, double noundef %45, double noundef %44, double noundef %46)
  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, !7, i64 304}
!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, !7, i64 72, !8, i64 80, !8, i64 272, !7, i64 280, !7, i64 288, !7, i64 296, !7, i64 304, !8, i64 312, !8, i64 313, !8, i64 314, !8, i64 315, !10, i64 316, !10, i64 320, !10, i64 324, !11, i64 328, !10, i64 336, !11, i64 344, !11, i64 352, !10, i64 360, !8, i64 364}
!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 24}
!13 = !{!6, !7, i64 32}
!14 = !{!6, !7, i64 40}
!15 = !{!6, !7, i64 288}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!7, !7, i64 0}


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