; LLVM IR from bonamarton/phys_num :: euler_RK4_moon (euler_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, i32 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store double 0.000000e+00, ptr %9, align 8, !tbaa !11
  %10 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %10, label %11 [
    i32 0, label %13
    i32 1, label %33
    i32 2, label %53
    i32 3, label %65
  ]

11:                                               ; preds = %4
  %12 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %77

13:                                               ; preds = %4
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds double, ptr %14, i64 2
  %16 = load double, ptr %15, align 8, !tbaa !11
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = sitofp i32 %17 to double
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds double, ptr %19, i64 7
  %21 = load double, ptr %20, align 8, !tbaa !11
  %22 = fmul double %18, %21
  %23 = load ptr, ptr %6, 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 10
  %29 = load double, ptr %28, align 8, !tbaa !11
  %30 = fmul double 2.000000e+00, %29
  %31 = fdiv double %26, %30
  %32 = fadd double %16, %31
  store double %32, ptr %9, align 8, !tbaa !11
  br label %77

33:                                               ; preds = %4
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds double, ptr %34, i64 3
  %36 = load double, ptr %35, align 8, !tbaa !11
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = sitofp i32 %37 to double
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds double, ptr %39, i64 7
  %41 = load double, ptr %40, align 8, !tbaa !11
  %42 = fmul double %38, %41
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds double, ptr %43, i64 1
  %45 = load double, ptr %44, align 8, !tbaa !11
  %46 = fmul double %42, %45
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds double, ptr %47, i64 10
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = fmul double 2.000000e+00, %49
  %51 = fdiv double %46, %50
  %52 = fadd double %36, %51
  store double %52, ptr %9, align 8, !tbaa !11
  br label %77

53:                                               ; preds = %4
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds double, ptr %54, i64 7
  %56 = load double, ptr %55, align 8, !tbaa !11
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds double, ptr %57, i64 0
  %59 = load double, ptr %58, align 8, !tbaa !11
  %60 = fmul double %56, %59
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds double, ptr %61, i64 10
  %63 = load double, ptr %62, align 8, !tbaa !11
  %64 = fdiv double %60, %63
  store double %64, ptr %9, align 8, !tbaa !11
  br label %77

65:                                               ; preds = %4
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds double, ptr %66, i64 7
  %68 = load double, ptr %67, align 8, !tbaa !11
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds double, ptr %69, i64 1
  %71 = load double, ptr %70, align 8, !tbaa !11
  %72 = fmul double %68, %71
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds double, ptr %73, i64 10
  %75 = load double, ptr %74, align 8, !tbaa !11
  %76 = fdiv double %72, %75
  store double %76, ptr %9, align 8, !tbaa !11
  br label %77

77:                                               ; preds = %65, %53, %33, %13, %11
  %78 = load double, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  ret double %78
}

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

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 }

!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, i32 noundef %3) local_unnamed_addr #0 {
  switch i32 %2, label %5 [
    i32 0, label %7
    i32 1, label %21
    i32 2, label %36
    i32 3, label %44
  ]

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

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = sitofp i32 %3 to double
  %11 = getelementptr inbounds i8, ptr %0, i64 56
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = fmul double %12, %10
  %14 = load double, ptr %1, align 8, !tbaa !5
  %15 = fmul double %13, %14
  %16 = getelementptr inbounds i8, ptr %0, i64 80
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = fmul double %17, 2.000000e+00
  %19 = fdiv double %15, %18
  %20 = fadd double %9, %19
  br label %53

21:                                               ; preds = %4
  %22 = getelementptr inbounds i8, ptr %1, i64 24
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = sitofp i32 %3 to double
  %25 = getelementptr inbounds i8, ptr %0, i64 56
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = fmul double %26, %24
  %28 = getelementptr inbounds i8, ptr %1, i64 8
  %29 = load double, ptr %28, align 8, !tbaa !5
  %30 = fmul double %27, %29
  %31 = getelementptr inbounds i8, ptr %0, i64 80
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = fmul double %32, 2.000000e+00
  %34 = fdiv double %30, %33
  %35 = fadd double %23, %34
  br label %53

36:                                               ; preds = %4
  %37 = getelementptr inbounds i8, ptr %0, i64 56
  %38 = load double, ptr %37, align 8, !tbaa !5
  %39 = load double, ptr %1, align 8, !tbaa !5
  %40 = fmul double %38, %39
  %41 = getelementptr inbounds i8, ptr %0, i64 80
  %42 = load double, ptr %41, align 8, !tbaa !5
  %43 = fdiv double %40, %42
  br label %53

44:                                               ; preds = %4
  %45 = getelementptr inbounds i8, ptr %0, i64 56
  %46 = load double, ptr %45, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %1, i64 8
  %48 = load double, ptr %47, align 8, !tbaa !5
  %49 = fmul double %46, %48
  %50 = getelementptr inbounds i8, ptr %0, i64 80
  %51 = load double, ptr %50, align 8, !tbaa !5
  %52 = fdiv double %49, %51
  br label %53

53:                                               ; preds = %44, %36, %21, %7, %5
  %.0 = phi double [ 0.000000e+00, %5 ], [ %52, %44 ], [ %43, %36 ], [ %35, %21 ], [ %20, %7 ]
  ret double %.0
}

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

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

!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,SROAPass,TailCallElimPass