; LLVM IR from Ahmed-alkharusi/Interesting-problems- :: The three-body problem (RK4)/Cpp version/Source.ll (Z5deriv6MatrixS_RKdS_S1_)

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

%class.Matrix = type { %class.Array, %class.Array }
%class.Array = type { double, double }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare void @_ZN5ArrayC1Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #1

declare void @_ZN6MatrixC1E5ArrayS0_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef) unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5deriv6MatrixS_RKdS_S1_(ptr dead_on_unwind noalias writable sret(%class.Matrix) align 8 %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca double, align 8
  %20 = alloca double, align 8
  %21 = alloca double, align 8
  %22 = alloca double, align 8
  %23 = alloca %class.Array, align 8
  %24 = alloca %class.Array, align 8
  store ptr %0, ptr %7, align 8
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %25 = getelementptr inbounds %class.Matrix, ptr %1, i32 0, i32 1
  %26 = getelementptr inbounds %class.Array, ptr %25, i32 0, i32 1
  %27 = load double, ptr %26, align 8, !tbaa !9
  store double %27, ptr %13, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %28 = getelementptr inbounds %class.Matrix, ptr %1, i32 0, i32 0
  %29 = getelementptr inbounds %class.Array, ptr %28, i32 0, i32 1
  %30 = load double, ptr %29, align 8, !tbaa !14
  store double %30, ptr %14, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %31 = getelementptr inbounds %class.Matrix, ptr %1, i32 0, i32 1
  %32 = getelementptr inbounds %class.Array, ptr %31, i32 0, i32 0
  %33 = load double, ptr %32, align 8, !tbaa !15
  store double %33, ptr %15, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %34 = getelementptr inbounds %class.Matrix, ptr %1, i32 0, i32 0
  %35 = getelementptr inbounds %class.Array, ptr %34, i32 0, i32 0
  %36 = load double, ptr %35, align 8, !tbaa !16
  store double %36, ptr %16, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %37 = getelementptr inbounds %class.Matrix, ptr %2, i32 0, i32 1
  %38 = getelementptr inbounds %class.Array, ptr %37, i32 0, i32 0
  %39 = load double, ptr %38, align 8, !tbaa !15
  store double %39, ptr %17, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %40 = getelementptr inbounds %class.Matrix, ptr %2, i32 0, i32 0
  %41 = getelementptr inbounds %class.Array, ptr %40, i32 0, i32 0
  %42 = load double, ptr %41, align 8, !tbaa !16
  store double %42, ptr %18, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %43 = getelementptr inbounds %class.Matrix, ptr %4, i32 0, i32 1
  %44 = getelementptr inbounds %class.Array, ptr %43, i32 0, i32 0
  %45 = load double, ptr %44, align 8, !tbaa !15
  store double %45, ptr %19, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %46 = getelementptr inbounds %class.Matrix, ptr %4, i32 0, i32 0
  %47 = getelementptr inbounds %class.Array, ptr %46, i32 0, i32 0
  %48 = load double, ptr %47, align 8, !tbaa !16
  store double %48, ptr %20, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = load double, ptr %49, align 8, !tbaa !13
  %51 = load double, ptr %15, align 8, !tbaa !13
  %52 = load double, ptr %17, align 8, !tbaa !13
  %53 = fsub double %51, %52
  %54 = fmul double %50, %53
  %55 = load double, ptr %15, align 8, !tbaa !13
  %56 = load double, ptr %17, align 8, !tbaa !13
  %57 = fsub double %55, %56
  %58 = call double @pow(double noundef %57, double noundef 2.000000e+00) #4
  %59 = load double, ptr %16, align 8, !tbaa !13
  %60 = load double, ptr %18, align 8, !tbaa !13
  %61 = fsub double %59, %60
  %62 = call double @pow(double noundef %61, double noundef 2.000000e+00) #4
  %63 = fadd double %58, %62
  %64 = call double @pow(double noundef %63, double noundef 1.500000e+00) #4
  %65 = fdiv double %54, %64
  %66 = load ptr, ptr %12, align 8, !tbaa !5
  %67 = load double, ptr %66, align 8, !tbaa !13
  %68 = load double, ptr %15, align 8, !tbaa !13
  %69 = load double, ptr %19, align 8, !tbaa !13
  %70 = fsub double %68, %69
  %71 = fmul double %67, %70
  %72 = load double, ptr %15, align 8, !tbaa !13
  %73 = load double, ptr %19, align 8, !tbaa !13
  %74 = fsub double %72, %73
  %75 = call double @pow(double noundef %74, double noundef 2.000000e+00) #4
  %76 = load double, ptr %16, align 8, !tbaa !13
  %77 = load double, ptr %20, align 8, !tbaa !13
  %78 = fsub double %76, %77
  %79 = call double @pow(double noundef %78, double noundef 2.000000e+00) #4
  %80 = fadd double %75, %79
  %81 = call double @pow(double noundef %80, double noundef 1.500000e+00) #4
  %82 = fdiv double %71, %81
  %83 = fadd double %65, %82
  %84 = fneg double %83
  store double %84, ptr %21, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %85 = load ptr, ptr %10, align 8, !tbaa !5
  %86 = load double, ptr %85, align 8, !tbaa !13
  %87 = load double, ptr %16, align 8, !tbaa !13
  %88 = load double, ptr %18, align 8, !tbaa !13
  %89 = fsub double %87, %88
  %90 = fmul double %86, %89
  %91 = load double, ptr %15, align 8, !tbaa !13
  %92 = load double, ptr %17, align 8, !tbaa !13
  %93 = fsub double %91, %92
  %94 = call double @pow(double noundef %93, double noundef 2.000000e+00) #4
  %95 = load double, ptr %16, align 8, !tbaa !13
  %96 = load double, ptr %18, align 8, !tbaa !13
  %97 = fsub double %95, %96
  %98 = call double @pow(double noundef %97, double noundef 2.000000e+00) #4
  %99 = fadd double %94, %98
  %100 = call double @pow(double noundef %99, double noundef 1.500000e+00) #4
  %101 = fdiv double %90, %100
  %102 = load ptr, ptr %12, align 8, !tbaa !5
  %103 = load double, ptr %102, align 8, !tbaa !13
  %104 = load double, ptr %16, align 8, !tbaa !13
  %105 = load double, ptr %20, align 8, !tbaa !13
  %106 = fsub double %104, %105
  %107 = fmul double %103, %106
  %108 = load double, ptr %15, align 8, !tbaa !13
  %109 = load double, ptr %19, align 8, !tbaa !13
  %110 = fsub double %108, %109
  %111 = call double @pow(double noundef %110, double noundef 2.000000e+00) #4
  %112 = load double, ptr %16, align 8, !tbaa !13
  %113 = load double, ptr %20, align 8, !tbaa !13
  %114 = fsub double %112, %113
  %115 = call double @pow(double noundef %114, double noundef 2.000000e+00) #4
  %116 = fadd double %111, %115
  %117 = call double @pow(double noundef %116, double noundef 1.500000e+00) #4
  %118 = fdiv double %107, %117
  %119 = fadd double %101, %118
  %120 = fneg double %119
  store double %120, ptr %22, align 8, !tbaa !13
  %121 = load double, ptr %13, align 8, !tbaa !13
  %122 = load double, ptr %21, align 8, !tbaa !13
  call void @_ZN5ArrayC1Edd(ptr noundef nonnull align 8 dereferenceable(16) %23, double noundef %121, double noundef %122)
  %123 = load double, ptr %14, align 8, !tbaa !13
  %124 = load double, ptr %22, align 8, !tbaa !13
  call void @_ZN5ArrayC1Edd(ptr noundef nonnull align 8 dereferenceable(16) %24, double noundef %123, double noundef %124)
  call void @_ZN6MatrixC1E5ArrayS0_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef %23, ptr noundef %24)
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind
declare double @pow(double noundef, double 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 = { mustprogress 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 "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++ TBAA"}
!9 = !{!10, !12, i64 24}
!10 = !{!"_ZTS6Matrix", !11, i64 0, !11, i64 16}
!11 = !{!"_ZTS5Array", !12, i64 0, !12, i64 8}
!12 = !{!"double", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !12, i64 8}
!15 = !{!10, !12, i64 16}
!16 = !{!10, !12, 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"

%class.Matrix = type { %class.Array, %class.Array }
%class.Array = type { double, double }

declare void @_ZN5ArrayC1Edd(ptr noundef nonnull align 8 dereferenceable(16), double noundef, double noundef) unnamed_addr #0

declare void @_ZN6MatrixC1E5ArrayS0_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, ptr noundef) unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5deriv6MatrixS_RKdS_S1_(ptr dead_on_unwind noalias writable sret(%class.Matrix) align 8 %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %3, ptr nocapture noundef readonly %4, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %5) local_unnamed_addr #1 {
  %7 = alloca %class.Array, align 8
  %8 = alloca %class.Array, align 8
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = getelementptr inbounds i8, ptr %1, i64 24
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load double, ptr %12, align 8, !tbaa !11
  %14 = load double, ptr %9, align 8, !tbaa !12
  %15 = load double, ptr %1, align 8, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %2, i64 16
  %17 = load double, ptr %16, align 8, !tbaa !12
  %18 = load double, ptr %2, align 8, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %4, i64 16
  %20 = load double, ptr %19, align 8, !tbaa !12
  %21 = load double, ptr %4, align 8, !tbaa !13
  %22 = load double, ptr %3, align 8, !tbaa !14
  %23 = insertelement <2 x double> poison, double %14, i64 0
  %24 = shufflevector <2 x double> %23, <2 x double> poison, <2 x i32> zeroinitializer
  %25 = insertelement <2 x double> poison, double %17, i64 0
  %26 = insertelement <2 x double> %25, double %20, i64 1
  %27 = fsub <2 x double> %24, %26
  %28 = fmul <2 x double> %27, %27
  %29 = insertelement <2 x double> poison, double %22, i64 0
  %30 = insertelement <2 x double> poison, double %15, i64 0
  %31 = shufflevector <2 x double> %30, <2 x double> poison, <2 x i32> zeroinitializer
  %32 = insertelement <2 x double> poison, double %18, i64 0
  %33 = insertelement <2 x double> %32, double %21, i64 1
  %34 = fsub <2 x double> %31, %33
  %35 = fmul <2 x double> %34, %34
  %36 = shufflevector <2 x double> %27, <2 x double> %34, <2 x i32> <i32 1, i32 3>
  %37 = fmul <2 x double> %36, %36
  %38 = fadd <2 x double> %28, %35
  %39 = extractelement <2 x double> %38, i64 0
  %40 = tail call double @pow(double noundef %39, double noundef 1.500000e+00) #3
  %41 = load double, ptr %5, align 8, !tbaa !14
  %42 = insertelement <2 x double> %29, double %41, i64 1
  %43 = fmul <2 x double> %27, %42
  %shift = shufflevector <2 x double> %37, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %44 = fadd <2 x double> %37, %shift
  %45 = extractelement <2 x double> %44, i64 0
  %46 = tail call double @pow(double noundef %45, double noundef 1.500000e+00) #3
  %47 = insertelement <2 x double> poison, double %40, i64 0
  %48 = insertelement <2 x double> %47, double %46, i64 1
  %49 = fdiv <2 x double> %43, %48
  %shift39 = shufflevector <2 x double> %49, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %50 = fadd <2 x double> %49, %shift39
  %51 = extractelement <2 x double> %50, i64 0
  %52 = fneg double %51
  %53 = load double, ptr %3, align 8, !tbaa !14
  %54 = tail call double @pow(double noundef %39, double noundef 1.500000e+00) #3
  %55 = load double, ptr %5, align 8, !tbaa !14
  %56 = insertelement <2 x double> poison, double %53, i64 0
  %57 = insertelement <2 x double> %56, double %55, i64 1
  %58 = fmul <2 x double> %34, %57
  %59 = tail call double @pow(double noundef %45, double noundef 1.500000e+00) #3
  %60 = insertelement <2 x double> poison, double %54, i64 0
  %61 = insertelement <2 x double> %60, double %59, i64 1
  %62 = fdiv <2 x double> %58, %61
  %shift40 = shufflevector <2 x double> %62, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %63 = fadd <2 x double> %62, %shift40
  %64 = extractelement <2 x double> %63, i64 0
  %65 = fneg double %64
  call void @_ZN5ArrayC1Edd(ptr noundef nonnull align 8 dereferenceable(16) %7, double noundef %11, double noundef %52)
  call void @_ZN5ArrayC1Edd(ptr noundef nonnull align 8 dereferenceable(16) %8, double noundef %13, double noundef %65)
  call void @_ZN6MatrixC1E5ArrayS0_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull %7, ptr noundef nonnull %8)
  ret void
}

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

attributes #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 = { mustprogress 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 = { 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, !8, i64 24}
!6 = !{!"_ZTS6Matrix", !7, i64 0, !7, i64 16}
!7 = !{!"_ZTS5Array", !8, i64 0, !8, i64 8}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!6, !8, i64 8}
!12 = !{!6, !8, i64 16}
!13 = !{!6, !8, i64 0}
!14 = !{!8, !8, i64 0}


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