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

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

; Function Attrs: nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @b2GetSweepTransform(ptr noundef %0, float noundef %1) #0 {
  %3 = alloca %struct.b2Transform, align 4
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca %struct.b2Vec2, align 4
  %7 = alloca %struct.b2Vec2, align 4
  %8 = alloca %struct.b2Vec2, align 4
  %9 = alloca %struct.b2Rot, align 4
  %10 = alloca %struct.b2Rot, align 4
  %11 = alloca %struct.b2Vec2, align 4
  %12 = alloca %struct.b2Vec2, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  %13 = getelementptr inbounds %struct.b2Transform, ptr %3, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %14 = load float, ptr %5, align 4, !tbaa !9
  %15 = fsub float 1.000000e+00, %14
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.b2Sweep, ptr %16, i32 0, i32 1
  %18 = load <2 x float>, ptr %17, align 4
  %19 = call <2 x float> @b2MulSV(float noundef %15, <2 x float> %18)
  store <2 x float> %19, ptr %7, align 4
  %20 = load float, ptr %5, align 4, !tbaa !9
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.b2Sweep, ptr %21, i32 0, i32 2
  %23 = load <2 x float>, ptr %22, align 4
  %24 = call <2 x float> @b2MulSV(float noundef %20, <2 x float> %23)
  store <2 x float> %24, ptr %8, align 4
  %25 = load <2 x float>, ptr %7, align 4
  %26 = load <2 x float>, ptr %8, align 4
  %27 = call <2 x float> @b2Add(<2 x float> %25, <2 x float> %26)
  store <2 x float> %27, ptr %6, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %28 = getelementptr inbounds %struct.b2Rot, ptr %9, i32 0, i32 0
  %29 = load float, ptr %5, align 4, !tbaa !9
  %30 = fsub float 1.000000e+00, %29
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.b2Sweep, ptr %31, i32 0, i32 3
  %33 = getelementptr inbounds %struct.b2Rot, ptr %32, i32 0, i32 0
  %34 = load float, ptr %33, align 4, !tbaa !12
  %35 = load float, ptr %5, align 4, !tbaa !9
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.b2Sweep, ptr %36, i32 0, i32 4
  %38 = getelementptr inbounds %struct.b2Rot, ptr %37, i32 0, i32 0
  %39 = load float, ptr %38, align 4, !tbaa !16
  %40 = fmul float %35, %39
  %41 = call float @llvm.fmuladd.f32(float %30, float %34, float %40)
  store float %41, ptr %28, align 4, !tbaa !17
  %42 = getelementptr inbounds %struct.b2Rot, ptr %9, i32 0, i32 1
  %43 = load float, ptr %5, align 4, !tbaa !9
  %44 = fsub float 1.000000e+00, %43
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.b2Sweep, ptr %45, i32 0, i32 3
  %47 = getelementptr inbounds %struct.b2Rot, ptr %46, i32 0, i32 1
  %48 = load float, ptr %47, align 4, !tbaa !18
  %49 = load float, ptr %5, align 4, !tbaa !9
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.b2Sweep, ptr %50, i32 0, i32 4
  %52 = getelementptr inbounds %struct.b2Rot, ptr %51, i32 0, i32 1
  %53 = load float, ptr %52, align 4, !tbaa !19
  %54 = fmul float %49, %53
  %55 = call float @llvm.fmuladd.f32(float %44, float %48, float %54)
  store float %55, ptr %42, align 4, !tbaa !20
  %56 = getelementptr inbounds %struct.b2Transform, ptr %3, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %57 = load <2 x float>, ptr %9, align 4
  %58 = call <2 x float> @b2NormalizeRot(<2 x float> %57)
  store <2 x float> %58, ptr %10, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %56, ptr align 4 %10, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %59 = getelementptr inbounds %struct.b2Transform, ptr %3, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %60 = getelementptr inbounds %struct.b2Transform, ptr %3, i32 0, i32 0
  %61 = getelementptr inbounds %struct.b2Transform, ptr %3, i32 0, i32 1
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.b2Sweep, ptr %62, i32 0, i32 0
  %64 = load <2 x float>, ptr %61, align 4
  %65 = load <2 x float>, ptr %63, align 4
  %66 = call <2 x float> @b2RotateVector(<2 x float> %64, <2 x float> %65)
  store <2 x float> %66, ptr %12, align 4
  %67 = load <2 x float>, ptr %60, align 4
  %68 = load <2 x float>, ptr %12, align 4
  %69 = call <2 x float> @b2Sub(<2 x float> %67, <2 x float> %68)
  store <2 x float> %69, ptr %11, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %59, ptr align 4 %11, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  %70 = load { <2 x float>, <2 x float> }, ptr %3, align 4
  ret { <2 x float>, <2 x float> } %70
}

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

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

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

; 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) #3

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

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

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

; 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 <2 x float> @b2RotateVector(<2 x float>, <2 x float>) #2

attributes #0 = { 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 = { nocallback nofree nosync 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 nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{i64 0, i64 4, !9, i64 4, i64 4, !9}
!12 = !{!13, !10, i64 24}
!13 = !{!"b2Sweep", !14, i64 0, !14, i64 8, !14, i64 16, !15, i64 24, !15, i64 32}
!14 = !{!"b2Vec2", !10, i64 0, !10, i64 4}
!15 = !{!"b2Rot", !10, i64 0, !10, i64 4}
!16 = !{!13, !10, i64 32}
!17 = !{!15, !10, i64 0}
!18 = !{!13, !10, i64 28}
!19 = !{!13, !10, i64 36}
!20 = !{!15, !10, 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: nounwind uwtable
define dso_local { <2 x float>, <2 x float> } @b2GetSweepTransform(ptr nocapture noundef readonly %0, float noundef %1) local_unnamed_addr #0 {
  %3 = fsub float 1.000000e+00, %1
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load <2 x float>, ptr %4, align 4
  %6 = tail call <2 x float> @b2MulSV(float noundef %3, <2 x float> %5)
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load <2 x float>, ptr %7, align 4
  %9 = tail call <2 x float> @b2MulSV(float noundef %1, <2 x float> %8)
  %10 = tail call <2 x float> @b2Add(<2 x float> %6, <2 x float> %9)
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  %13 = load <2 x float>, ptr %11, align 4, !tbaa !5
  %14 = load <2 x float>, ptr %12, align 4, !tbaa !5
  %15 = insertelement <2 x float> poison, float %1, i64 0
  %16 = shufflevector <2 x float> %15, <2 x float> poison, <2 x i32> zeroinitializer
  %17 = fmul <2 x float> %14, %16
  %18 = insertelement <2 x float> poison, float %3, i64 0
  %19 = shufflevector <2 x float> %18, <2 x float> poison, <2 x i32> zeroinitializer
  %20 = tail call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %19, <2 x float> %13, <2 x float> %17)
  %21 = tail call <2 x float> @b2NormalizeRot(<2 x float> %20)
  %22 = load <2 x float>, ptr %0, align 4
  %23 = tail call <2 x float> @b2RotateVector(<2 x float> %21, <2 x float> %22)
  %24 = tail call <2 x float> @b2Sub(<2 x float> %10, <2 x float> %23)
  %.fca.0.insert = insertvalue { <2 x float>, <2 x float> } poison, <2 x float> %24, 0
  %.fca.1.insert = insertvalue { <2 x float>, <2 x float> } %.fca.0.insert, <2 x float> %21, 1
  ret { <2 x float>, <2 x float> } %.fca.1.insert
}

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

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #2

attributes #0 = { 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 = { 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 = { 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, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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