; LLVM IR from erincatto/box2d :: src (geometry)

; 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.b2MassData = type { float, %struct.b2Vec2, float }
%struct.b2Vec2 = type { float, float }
%struct.b2Capsule = type { %struct.b2Vec2, %struct.b2Vec2, float }

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @b2Sub(<2 x float>, <2 x float>) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden float @b2Dot(<2 x float>, <2 x float>) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; Function Attrs: nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @b2ComputeCapsuleMass(ptr noundef %0, float noundef %1) #4 {
  %3 = alloca %struct.b2MassData, align 4
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca %struct.b2Vec2, align 4
  %9 = alloca %struct.b2Vec2, align 4
  %10 = alloca float, align 4
  %11 = alloca %struct.b2Vec2, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.b2Capsule, ptr %19, i32 0, i32 2
  %21 = load float, ptr %20, align 4, !tbaa !11
  store float %21, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %22 = load float, ptr %6, align 4, !tbaa !9
  %23 = load float, ptr %6, align 4, !tbaa !9
  %24 = fmul float %22, %23
  store float %24, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.b2Capsule, ptr %25, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %26, i64 8, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.b2Capsule, ptr %27, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %28, i64 8, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %29 = load <2 x float>, ptr %9, align 4
  %30 = load <2 x float>, ptr %8, align 4
  %31 = call <2 x float> @b2Sub(<2 x float> %29, <2 x float> %30)
  store <2 x float> %31, ptr %11, align 4
  %32 = load <2 x float>, ptr %11, align 4
  %33 = call float @b2Length(<2 x float> %32)
  store float %33, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %34 = load float, ptr %10, align 4, !tbaa !9
  %35 = load float, ptr %10, align 4, !tbaa !9
  %36 = fmul float %34, %35
  store float %36, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %37 = load float, ptr %5, align 4, !tbaa !9
  %38 = load float, ptr %6, align 4, !tbaa !9
  %39 = fmul float 0x400921FB60000000, %38
  %40 = load float, ptr %6, align 4, !tbaa !9
  %41 = fmul float %39, %40
  %42 = fmul float %37, %41
  store float %42, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %43 = load float, ptr %5, align 4, !tbaa !9
  %44 = load float, ptr %6, align 4, !tbaa !9
  %45 = fmul float 2.000000e+00, %44
  %46 = load float, ptr %10, align 4, !tbaa !9
  %47 = fmul float %45, %46
  %48 = fmul float %43, %47
  store float %48, ptr %14, align 4, !tbaa !9
  %49 = load float, ptr %13, align 4, !tbaa !9
  %50 = load float, ptr %14, align 4, !tbaa !9
  %51 = fadd float %49, %50
  %52 = getelementptr inbounds %struct.b2MassData, ptr %3, i32 0, i32 0
  store float %51, ptr %52, align 4, !tbaa !15
  %53 = getelementptr inbounds %struct.b2Vec2, ptr %8, i32 0, i32 0
  %54 = load float, ptr %53, align 4, !tbaa !17
  %55 = getelementptr inbounds %struct.b2Vec2, ptr %9, i32 0, i32 0
  %56 = load float, ptr %55, align 4, !tbaa !17
  %57 = fadd float %54, %56
  %58 = fmul float 5.000000e-01, %57
  %59 = getelementptr inbounds %struct.b2MassData, ptr %3, i32 0, i32 1
  %60 = getelementptr inbounds %struct.b2Vec2, ptr %59, i32 0, i32 0
  store float %58, ptr %60, align 4, !tbaa !18
  %61 = getelementptr inbounds %struct.b2Vec2, ptr %8, i32 0, i32 1
  %62 = load float, ptr %61, align 4, !tbaa !19
  %63 = getelementptr inbounds %struct.b2Vec2, ptr %9, i32 0, i32 1
  %64 = load float, ptr %63, align 4, !tbaa !19
  %65 = fadd float %62, %64
  %66 = fmul float 5.000000e-01, %65
  %67 = getelementptr inbounds %struct.b2MassData, ptr %3, i32 0, i32 1
  %68 = getelementptr inbounds %struct.b2Vec2, ptr %67, i32 0, i32 1
  store float %66, ptr %68, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %69 = load float, ptr %6, align 4, !tbaa !9
  %70 = fmul float 4.000000e+00, %69
  %71 = fdiv float %70, 0x4022D97C80000000
  store float %71, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %72 = load float, ptr %10, align 4, !tbaa !9
  %73 = fmul float 5.000000e-01, %72
  store float %73, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %74 = load float, ptr %13, align 4, !tbaa !9
  %75 = load float, ptr %7, align 4, !tbaa !9
  %76 = load float, ptr %16, align 4, !tbaa !9
  %77 = load float, ptr %16, align 4, !tbaa !9
  %78 = fmul float %76, %77
  %79 = call float @llvm.fmuladd.f32(float 5.000000e-01, float %75, float %78)
  %80 = load float, ptr %16, align 4, !tbaa !9
  %81 = fmul float 2.000000e+00, %80
  %82 = load float, ptr %15, align 4, !tbaa !9
  %83 = call float @llvm.fmuladd.f32(float %81, float %82, float %79)
  %84 = fmul float %74, %83
  store float %84, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %85 = load float, ptr %14, align 4, !tbaa !9
  %86 = load float, ptr %7, align 4, !tbaa !9
  %87 = load float, ptr %12, align 4, !tbaa !9
  %88 = call float @llvm.fmuladd.f32(float 4.000000e+00, float %86, float %87)
  %89 = fmul float %85, %88
  %90 = fdiv float %89, 1.200000e+01
  store float %90, ptr %18, align 4, !tbaa !9
  %91 = load float, ptr %17, align 4, !tbaa !9
  %92 = load float, ptr %18, align 4, !tbaa !9
  %93 = fadd float %91, %92
  %94 = getelementptr inbounds %struct.b2MassData, ptr %3, i32 0, i32 2
  store float %93, ptr %94, align 4, !tbaa !21
  %95 = getelementptr inbounds %struct.b2MassData, ptr %3, i32 0, i32 0
  %96 = load float, ptr %95, align 4, !tbaa !15
  %97 = getelementptr inbounds %struct.b2MassData, ptr %3, i32 0, i32 1
  %98 = getelementptr inbounds %struct.b2MassData, ptr %3, i32 0, i32 1
  %99 = load <2 x float>, ptr %97, align 4
  %100 = load <2 x float>, ptr %98, align 4
  %101 = call float @b2Dot(<2 x float> %99, <2 x float> %100)
  %102 = getelementptr inbounds %struct.b2MassData, ptr %3, i32 0, i32 2
  %103 = load float, ptr %102, align 4, !tbaa !21
  %104 = call float @llvm.fmuladd.f32(float %96, float %101, float %103)
  store float %104, ptr %102, align 4, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %105 = load { <2 x float>, <2 x float> }, ptr %3, align 4
  ret { <2 x float>, <2 x float> } %105
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden float @b2Length(<2 x float>) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint nounwind uwtable "min-legal-vector-width"="64" "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) }
attributes #4 = { nounwind uwtable "min-legal-vector-width"="64" "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 #5 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"b2Capsule", !13, i64 0, !13, i64 8, !10, i64 16}
!13 = !{!"b2Vec2", !10, i64 0, !10, i64 4}
!14 = !{i64 0, i64 4, !9, i64 4, i64 4, !9}
!15 = !{!16, !10, i64 0}
!16 = !{!"b2MassData", !10, i64 0, !13, i64 4, !10, i64 12}
!17 = !{!13, !10, i64 0}
!18 = !{!16, !10, i64 4}
!19 = !{!13, !10, i64 4}
!20 = !{!16, !10, i64 8}
!21 = !{!16, !10, i64 12}


; 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.b2MassData = type { float, %struct.b2Vec2, float }
%struct.b2Vec2 = type { float, float }

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @b2Sub(<2 x float>, <2 x float>) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden float @b2Dot(<2 x float>, <2 x float>) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @b2ComputeCapsuleMass(ptr nocapture noundef readonly %0, float noundef %1) local_unnamed_addr #2 {
  %3 = alloca %struct.b2MassData, align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load float, ptr %4, align 4, !tbaa !5
  %6 = fmul float %5, %5
  %.sroa.017.0.copyload = load <2 x float>, ptr %0, align 4
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %.sroa.015.0.copyload = load <2 x float>, ptr %7, align 4
  %8 = tail call <2 x float> @b2Sub(<2 x float> %.sroa.015.0.copyload, <2 x float> %.sroa.017.0.copyload)
  %9 = tail call float @b2Length(<2 x float> %8)
  %10 = fmul float %9, %9
  %11 = fmul float %5, 0x400921FB60000000
  %12 = fmul float %5, %11
  %13 = fmul float %12, %1
  %14 = fmul float %5, 2.000000e+00
  %15 = fmul float %14, %9
  %16 = fmul float %15, %1
  %17 = fadd float %13, %16
  store float %17, ptr %3, align 8, !tbaa !11
  %18 = fadd <2 x float> %.sroa.017.0.copyload, %.sroa.015.0.copyload
  %19 = fmul <2 x float> %18, <float 5.000000e-01, float 5.000000e-01>
  %.4.sroa_idx46 = getelementptr inbounds i8, ptr %3, i64 4
  store <2 x float> %19, ptr %.4.sroa_idx46, align 4, !tbaa !13
  %20 = fmul float %5, 4.000000e+00
  %21 = fdiv float %20, 0x4022D97C80000000
  %22 = fmul float %9, 5.000000e-01
  %23 = fmul float %22, %22
  %24 = tail call float @llvm.fmuladd.f32(float %6, float 5.000000e-01, float %23)
  %25 = fmul float %22, 2.000000e+00
  %26 = tail call float @llvm.fmuladd.f32(float %25, float %21, float %24)
  %27 = fmul float %13, %26
  %28 = tail call float @llvm.fmuladd.f32(float %6, float 4.000000e+00, float %10)
  %29 = fmul float %16, %28
  %30 = fdiv float %29, 1.200000e+01
  %31 = fadd float %30, %27
  %.4.sroa_idx = getelementptr inbounds i8, ptr %3, i64 4
  %.4..4..4..4. = load <2 x float>, ptr %.4.sroa_idx, align 4
  %32 = tail call float @b2Dot(<2 x float> %.4..4..4..4., <2 x float> %.4..4..4..4.)
  %33 = tail call float @llvm.fmuladd.f32(float %17, float %32, float %31)
  %.12.sroa_idx47 = getelementptr inbounds i8, ptr %3, i64 12
  store float %33, ptr %.12.sroa_idx47, align 4, !tbaa !14
  %.0..0..0..0..fca.0.load = load <2 x float>, ptr %3, align 8
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %.0..0..0..0..fca.0.load, 0
  %.8.sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  %.8..8..8..8..fca.1.load = load <2 x float>, ptr %.8.sroa_idx, align 8
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %.8..8..8..8..fca.1.load, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden float @b2Length(<2 x float>) local_unnamed_addr #0

attributes #0 = { inlinehint nounwind uwtable "min-legal-vector-width"="64" "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) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="64" "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, !8, i64 16}
!6 = !{!"b2Capsule", !7, i64 0, !7, i64 8, !8, i64 16}
!7 = !{!"b2Vec2", !8, i64 0, !8, i64 4}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!12, !8, i64 0}
!12 = !{!"b2MassData", !8, i64 0, !7, i64 4, !8, i64 12}
!13 = !{!8, !8, i64 0}
!14 = !{!12, !8, i64 12}


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