; LLVM IR from ange-yaghi/simple-2d-constraint-solver :: src/rigid_body.ll (ZNK7atg_scs9RigidBody6energyEv)

; 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.atg_scs::RigidBody" = type <{ double, double, double, double, double, double, double, double, i32, [4 x i8] }>

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZNK7atg_scs9RigidBody6energyEv(ptr noundef nonnull align 8 dereferenceable(68) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca double, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %7 = getelementptr inbounds %"struct.atg_scs::RigidBody", ptr %6, i32 0, i32 2
  %8 = load double, ptr %7, align 8, !tbaa !9
  %9 = getelementptr inbounds %"struct.atg_scs::RigidBody", ptr %6, i32 0, i32 2
  %10 = load double, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %"struct.atg_scs::RigidBody", ptr %6, i32 0, i32 3
  %12 = load double, ptr %11, align 8, !tbaa !13
  %13 = getelementptr inbounds %"struct.atg_scs::RigidBody", ptr %6, i32 0, i32 3
  %14 = load double, ptr %13, align 8, !tbaa !13
  %15 = fmul double %12, %14
  %16 = call double @llvm.fmuladd.f64(double %8, double %10, double %15)
  store double %16, ptr %3, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %17 = getelementptr inbounds %"struct.atg_scs::RigidBody", ptr %6, i32 0, i32 6
  %18 = load double, ptr %17, align 8, !tbaa !15
  %19 = fmul double 5.000000e-01, %18
  %20 = load double, ptr %3, align 8, !tbaa !14
  %21 = fmul double %19, %20
  store double %21, ptr %4, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %22 = getelementptr inbounds %"struct.atg_scs::RigidBody", ptr %6, i32 0, i32 7
  %23 = load double, ptr %22, align 8, !tbaa !16
  %24 = fmul double 5.000000e-01, %23
  %25 = getelementptr inbounds %"struct.atg_scs::RigidBody", ptr %6, i32 0, i32 5
  %26 = load double, ptr %25, align 8, !tbaa !17
  %27 = fmul double %24, %26
  %28 = getelementptr inbounds %"struct.atg_scs::RigidBody", ptr %6, i32 0, i32 5
  %29 = load double, ptr %28, align 8, !tbaa !17
  %30 = fmul double %27, %29
  store double %30, ptr %5, align 8, !tbaa !14
  %31 = load double, ptr %4, align 8, !tbaa !14
  %32 = load double, ptr %5, align 8, !tbaa !14
  %33 = fadd double %31, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret double %33
}

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

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

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

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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++ TBAA"}
!9 = !{!10, !11, i64 16}
!10 = !{!"_ZTSN7atg_scs9RigidBodyE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !12, i64 64}
!11 = !{!"double", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !11, i64 24}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !11, i64 48}
!16 = !{!10, !11, i64 56}
!17 = !{!10, !11, i64 40}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef double @_ZNK7atg_scs9RigidBody6energyEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(68) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = load double, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load double, ptr %4, align 8, !tbaa !11
  %6 = fmul double %5, %5
  %7 = tail call double @llvm.fmuladd.f64(double %3, double %3, double %6)
  %8 = getelementptr inbounds i8, ptr %0, i64 56
  %9 = load double, ptr %8, align 8, !tbaa !12
  %10 = fmul double %9, 5.000000e-01
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = load <2 x double>, ptr %11, align 8, !tbaa !13
  %13 = extractelement <2 x double> %12, i64 0
  %14 = fmul double %10, %13
  %15 = insertelement <2 x double> <double poison, double 5.000000e-01>, double %14, i64 0
  %16 = fmul <2 x double> %12, %15
  %17 = extractelement <2 x double> %16, i64 1
  %18 = fmul double %17, %7
  %19 = extractelement <2 x double> %16, i64 0
  %20 = fadd double %18, %19
  ret double %20
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = { mustprogress 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 16}
!6 = !{!"_ZTSN7atg_scs9RigidBodyE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !10, i64 64}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 24}
!12 = !{!6, !7, i64 56}
!13 = !{!7, !7, i64 0}


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