; LLVM IR from bonamarton/phys_num :: euler_RK4_moon (RK4_moon)

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

@.str.7 = external hidden unnamed_addr constant [30 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: nounwind uwtable
define dso_local double @df(ptr noundef %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store double 0.000000e+00, ptr %7, align 8, !tbaa !11
  %8 = load i32, ptr %6, align 4, !tbaa !9
  switch i32 %8, label %9 [
    i32 0, label %11
    i32 1, label %15
    i32 2, label %19
    i32 3, label %38
  ]

9:                                                ; preds = %3
  %10 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %57

11:                                               ; preds = %3
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds double, ptr %12, i64 2
  %14 = load double, ptr %13, align 8, !tbaa !11
  store double %14, ptr %7, align 8, !tbaa !11
  br label %57

15:                                               ; preds = %3
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds double, ptr %16, i64 3
  %18 = load double, ptr %17, align 8, !tbaa !11
  store double %18, ptr %7, align 8, !tbaa !11
  br label %57

19:                                               ; preds = %3
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds double, ptr %20, i64 7
  %22 = load double, ptr %21, align 8, !tbaa !11
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds double, ptr %23, i64 0
  %25 = load double, ptr %24, align 8, !tbaa !11
  %26 = fmul double %22, %25
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds double, ptr %27, i64 0
  %29 = load double, ptr %28, align 8, !tbaa !11
  %30 = call double @pow(double noundef %29, double noundef 2.000000e+00) #4
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds double, ptr %31, i64 1
  %33 = load double, ptr %32, align 8, !tbaa !11
  %34 = call double @pow(double noundef %33, double noundef 2.000000e+00) #4
  %35 = fadd double %30, %34
  %36 = call double @pow(double noundef %35, double noundef 1.500000e+00) #4
  %37 = fdiv double %26, %36
  store double %37, ptr %7, align 8, !tbaa !11
  br label %57

38:                                               ; preds = %3
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds double, ptr %39, i64 7
  %41 = load double, ptr %40, align 8, !tbaa !11
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds double, ptr %42, i64 1
  %44 = load double, ptr %43, align 8, !tbaa !11
  %45 = fmul double %41, %44
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds double, ptr %46, i64 0
  %48 = load double, ptr %47, align 8, !tbaa !11
  %49 = call double @pow(double noundef %48, double noundef 2.000000e+00) #4
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds double, ptr %50, i64 1
  %52 = load double, ptr %51, align 8, !tbaa !11
  %53 = call double @pow(double noundef %52, double noundef 2.000000e+00) #4
  %54 = fadd double %49, %53
  %55 = call double @pow(double noundef %54, double noundef 1.500000e+00) #4
  %56 = fdiv double %45, %55
  store double %56, ptr %7, align 8, !tbaa !11
  br label %57

57:                                               ; preds = %38, %19, %15, %11, %9
  %58 = load double, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret double %58
}

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

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #3

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


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

@.str.7 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local double @df(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
  switch i32 %2, label %4 [
    i32 0, label %6
    i32 1, label %9
    i32 2, label %12
    i32 3, label %23
  ]

4:                                                ; preds = %3
  %5 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  br label %34

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %1, i64 16
  %8 = load double, ptr %7, align 8, !tbaa !5
  br label %34

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %1, i64 24
  %11 = load double, ptr %10, align 8, !tbaa !5
  br label %34

12:                                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %0, i64 56
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = load <2 x double>, ptr %1, align 8, !tbaa !5
  %16 = extractelement <2 x double> %15, i64 0
  %17 = fmul double %14, %16
  %18 = fmul <2 x double> %15, %15
  %shift = shufflevector <2 x double> %18, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %19 = fadd <2 x double> %18, %shift
  %20 = extractelement <2 x double> %19, i64 0
  %21 = tail call double @pow(double noundef %20, double noundef 1.500000e+00) #3
  %22 = fdiv double %17, %21
  br label %34

23:                                               ; preds = %3
  %24 = getelementptr inbounds i8, ptr %0, i64 56
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = load <2 x double>, ptr %1, align 8, !tbaa !5
  %27 = extractelement <2 x double> %26, i64 1
  %28 = fmul double %25, %27
  %29 = fmul <2 x double> %26, %26
  %shift14 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %30 = fadd <2 x double> %shift14, %29
  %31 = extractelement <2 x double> %30, i64 0
  %32 = tail call double @pow(double noundef %31, double noundef 1.500000e+00) #3
  %33 = fdiv double %28, %32
  br label %34

34:                                               ; preds = %23, %12, %9, %6, %4
  %.0 = phi double [ 0.000000e+00, %4 ], [ %33, %23 ], [ %22, %12 ], [ %11, %9 ], [ %8, %6 ]
  ret double %.0
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #2

attributes #0 = { 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 #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 = { mustprogress nofree nounwind willreturn memory(write) "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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass