; 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.b2AABB = type { %struct.b2Vec2, %struct.b2Vec2 }
%struct.b2Vec2 = type { float, float }
%struct.b2Transform = type { %struct.b2Vec2, %struct.b2Rot }
%struct.b2Rot = type { float, float }
%struct.b2Circle = type { %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: inlinehint nounwind uwtable
declare hidden <2 x float> @b2TransformPoint(<2 x float>, <2 x float>, <2 x float>) #1

; Function Attrs: nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @b2ComputeCircleAABB(ptr noundef %0, <2 x float> %1, <2 x float> %2) #2 {
  %4 = alloca %struct.b2AABB, align 4
  %5 = alloca %struct.b2Transform, align 4
  %6 = alloca ptr, align 8
  %7 = alloca %struct.b2Vec2, align 4
  %8 = alloca float, align 4
  %9 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 0
  store <2 x float> %1, ptr %9, align 4
  %10 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 1
  store <2 x float> %2, ptr %10, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.b2Circle, ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 0
  %14 = load <2 x float>, ptr %13, align 4
  %15 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %5, i32 0, i32 1
  %16 = load <2 x float>, ptr %15, align 4
  %17 = load <2 x float>, ptr %12, align 4
  %18 = call <2 x float> @b2TransformPoint(<2 x float> %14, <2 x float> %16, <2 x float> %17)
  store <2 x float> %18, ptr %7, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.b2Circle, ptr %19, i32 0, i32 1
  %21 = load float, ptr %20, align 4, !tbaa !9
  store float %21, ptr %8, align 4, !tbaa !13
  %22 = getelementptr inbounds %struct.b2AABB, ptr %4, i32 0, i32 0
  %23 = getelementptr inbounds %struct.b2Vec2, ptr %22, i32 0, i32 0
  %24 = getelementptr inbounds %struct.b2Vec2, ptr %7, i32 0, i32 0
  %25 = load float, ptr %24, align 4, !tbaa !14
  %26 = load float, ptr %8, align 4, !tbaa !13
  %27 = fsub float %25, %26
  store float %27, ptr %23, align 4, !tbaa !14
  %28 = getelementptr inbounds %struct.b2Vec2, ptr %22, i32 0, i32 1
  %29 = getelementptr inbounds %struct.b2Vec2, ptr %7, i32 0, i32 1
  %30 = load float, ptr %29, align 4, !tbaa !15
  %31 = load float, ptr %8, align 4, !tbaa !13
  %32 = fsub float %30, %31
  store float %32, ptr %28, align 4, !tbaa !15
  %33 = getelementptr inbounds %struct.b2AABB, ptr %4, i32 0, i32 1
  %34 = getelementptr inbounds %struct.b2Vec2, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct.b2Vec2, ptr %7, i32 0, i32 0
  %36 = load float, ptr %35, align 4, !tbaa !14
  %37 = load float, ptr %8, align 4, !tbaa !13
  %38 = fadd float %36, %37
  store float %38, ptr %34, align 4, !tbaa !14
  %39 = getelementptr inbounds %struct.b2Vec2, ptr %33, i32 0, i32 1
  %40 = getelementptr inbounds %struct.b2Vec2, ptr %7, i32 0, i32 1
  %41 = load float, ptr %40, align 4, !tbaa !15
  %42 = load float, ptr %8, align 4, !tbaa !13
  %43 = fadd float %41, %42
  store float %43, ptr %39, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  %44 = load { <2 x float>, <2 x float> }, ptr %4, align 4
  ret { <2 x float>, <2 x float> } %44
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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" }
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, !12, i64 8}
!10 = !{!"b2Circle", !11, i64 0, !12, i64 8}
!11 = !{!"b2Vec2", !12, i64 0, !12, i64 4}
!12 = !{!"float", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!11, !12, i64 0}
!15 = !{!11, !12, i64 4}


; 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: inlinehint nounwind uwtable
declare hidden <2 x float> @b2TransformPoint(<2 x float>, <2 x float>, <2 x float>) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @b2ComputeCircleAABB(ptr nocapture noundef readonly %0, <2 x float> %1, <2 x float> %2) local_unnamed_addr #1 {
  %4 = load <2 x float>, ptr %0, align 4
  %5 = tail call <2 x float> @b2TransformPoint(<2 x float> %1, <2 x float> %2, <2 x float> %4)
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load float, ptr %6, align 4, !tbaa !5
  %8 = insertelement <4 x float> poison, float %7, i64 0
  %9 = shufflevector <4 x float> %8, <4 x float> poison, <2 x i32> zeroinitializer
  %10 = fsub <2 x float> %5, %9
  %11 = shufflevector <4 x float> %8, <4 x float> poison, <2 x i32> zeroinitializer
  %12 = fadd <2 x float> %5, %11
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %10, 0
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %12, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

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 = { 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 8}
!6 = !{!"b2Circle", !7, i64 0, !8, i64 8}
!7 = !{!"b2Vec2", !8, i64 0, !8, i64 4}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}


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