; LLVM IR from ashishzero/karma :: src/modules/core/lin_maths.ll (Z23enclosing_circle_circleRK6CircleS1_)

; 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.Circle = type { %union.Vec2, float }
%union.Vec2 = type { %struct.anon.1 }
%struct.anon.1 = type { float, float }

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_Z8vec2_dot4Vec2S_(<2 x float>, <2 x float>) #1

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

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

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Zmi4Vec2S_(<2 x float>, <2 x float>) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZpLR4Vec2S_(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Zmlf4Vec2(float noundef, <2 x float>) #4

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @_Z23enclosing_circle_circleRK6CircleS1_(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %1) #5 {
  %3 = alloca %struct.Circle, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %union.Vec2, align 4
  %7 = alloca %union.Vec2, align 4
  %8 = alloca %union.Vec2, align 4
  %9 = alloca float, align 4
  %10 = alloca %union.Vec2, align 4
  %11 = alloca %union.Vec2, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca %union.Vec2, align 4
  %15 = alloca %union.Vec2, align 4
  %16 = alloca { <2 x float>, float }, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.Circle, ptr %17, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %7, ptr align 4 %18, i64 8, i1 false), !tbaa.struct !9
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.Circle, ptr %19, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %20, i64 8, i1 false), !tbaa.struct !9
  %21 = getelementptr inbounds %union.Vec2, ptr %7, i32 0, i32 0
  %22 = load <2 x float>, ptr %21, align 4
  %23 = getelementptr inbounds %union.Vec2, ptr %8, i32 0, i32 0
  %24 = load <2 x float>, ptr %23, align 4
  %25 = call <2 x float> @_Zmi4Vec2S_(<2 x float> %22, <2 x float> %24)
  %26 = getelementptr inbounds %union.Vec2, ptr %6, i32 0, i32 0
  store <2 x float> %25, ptr %26, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !9
  %27 = getelementptr inbounds %union.Vec2, ptr %10, i32 0, i32 0
  %28 = load <2 x float>, ptr %27, align 4
  %29 = getelementptr inbounds %union.Vec2, ptr %11, i32 0, i32 0
  %30 = load <2 x float>, ptr %29, align 4
  %31 = call noundef float @_Z8vec2_dot4Vec2S_(<2 x float> %28, <2 x float> %30)
  store float %31, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Circle, ptr %32, i32 0, i32 1
  %34 = load float, ptr %33, align 4, !tbaa !13
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.Circle, ptr %35, i32 0, i32 1
  %37 = load float, ptr %36, align 4, !tbaa !13
  %38 = fsub float %34, %37
  store float %38, ptr %12, align 4, !tbaa !11
  %39 = load float, ptr %12, align 4, !tbaa !11
  %40 = load float, ptr %12, align 4, !tbaa !11
  %41 = fmul float %40, %39
  store float %41, ptr %12, align 4, !tbaa !11
  %42 = load float, ptr %12, align 4, !tbaa !11
  %43 = load float, ptr %9, align 4, !tbaa !11
  %44 = fcmp oge float %42, %43
  br i1 %44, label %45, label %58

45:                                               ; preds = %2
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Circle, ptr %46, i32 0, i32 1
  %48 = load float, ptr %47, align 4, !tbaa !13
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.Circle, ptr %49, i32 0, i32 1
  %51 = load float, ptr %50, align 4, !tbaa !13
  %52 = fcmp oge float %48, %51
  br i1 %52, label %53, label %55

53:                                               ; preds = %45
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 4 %54, i64 12, i1 false), !tbaa.struct !15
  br label %57

55:                                               ; preds = %45
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %3, ptr align 4 %56, i64 12, i1 false), !tbaa.struct !15
  br label %57

57:                                               ; preds = %55, %53
  br label %95

58:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %59 = load float, ptr %9, align 4, !tbaa !11
  %60 = call float @sqrtf(float noundef %59) #6
  store float %60, ptr %13, align 4, !tbaa !11
  %61 = load float, ptr %13, align 4, !tbaa !11
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.Circle, ptr %62, i32 0, i32 1
  %64 = load float, ptr %63, align 4, !tbaa !13
  %65 = fadd float %61, %64
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.Circle, ptr %66, i32 0, i32 1
  %68 = load float, ptr %67, align 4, !tbaa !13
  %69 = fadd float %65, %68
  %70 = fmul float %69, 5.000000e-01
  %71 = getelementptr inbounds %struct.Circle, ptr %3, i32 0, i32 1
  store float %70, ptr %71, align 4, !tbaa !13
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.Circle, ptr %72, i32 0, i32 0
  %74 = getelementptr inbounds %struct.Circle, ptr %3, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %74, ptr align 4 %73, i64 8, i1 false), !tbaa.struct !9
  %75 = load float, ptr %13, align 4, !tbaa !11
  %76 = fcmp ogt float %75, 0x3E80000000000000
  br i1 %76, label %77, label %94

77:                                               ; preds = %58
  %78 = getelementptr inbounds %struct.Circle, ptr %3, i32 0, i32 1
  %79 = load float, ptr %78, align 4, !tbaa !13
  %80 = load ptr, ptr %4, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.Circle, ptr %80, i32 0, i32 1
  %82 = load float, ptr %81, align 4, !tbaa !13
  %83 = fsub float %79, %82
  %84 = load float, ptr %13, align 4, !tbaa !11
  %85 = fdiv float %83, %84
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !9
  %86 = getelementptr inbounds %union.Vec2, ptr %15, i32 0, i32 0
  %87 = load <2 x float>, ptr %86, align 4
  %88 = call <2 x float> @_Zmlf4Vec2(float noundef %85, <2 x float> %87)
  %89 = getelementptr inbounds %union.Vec2, ptr %14, i32 0, i32 0
  store <2 x float> %88, ptr %89, align 4
  %90 = getelementptr inbounds %struct.Circle, ptr %3, i32 0, i32 0
  %91 = getelementptr inbounds %union.Vec2, ptr %14, i32 0, i32 0
  %92 = load <2 x float>, ptr %91, align 4
  %93 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZpLR4Vec2S_(ptr noundef nonnull align 4 dereferenceable(8) %90, <2 x float> %92)
  br label %94

94:                                               ; preds = %77, %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  br label %95

95:                                               ; preds = %94, %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 4 %3, i64 12, i1 false)
  %96 = load { <2 x float>, float }, ptr %16, align 8
  ret { <2 x float>, float } %96
}

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


; 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.Circle = type { %union.Vec2, float }
%union.Vec2 = type { %struct.anon.1 }
%struct.anon.1 = type { float, float }

; Function Attrs: mustprogress 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) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_Z8vec2_dot4Vec2S_(<2 x float>, <2 x float>) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Zmi4Vec2S_(<2 x float>, <2 x float>) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZpLR4Vec2S_(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Zmlf4Vec2(float noundef, <2 x float>) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @_Z23enclosing_circle_circleRK6CircleS1_(ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %1) local_unnamed_addr #4 {
  %3 = alloca %struct.Circle, align 8
  %.sroa.013.0.copyload = load <2 x float>, ptr %1, align 4, !tbaa !5
  %.sroa.012.0.copyload = load <2 x float>, ptr %0, align 4, !tbaa !5
  %4 = tail call <2 x float> @_Zmi4Vec2S_(<2 x float> %.sroa.013.0.copyload, <2 x float> %.sroa.012.0.copyload)
  %5 = tail call noundef float @_Z8vec2_dot4Vec2S_(<2 x float> %4, <2 x float> %4)
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load float, ptr %6, align 4, !tbaa !8
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load float, ptr %8, align 4, !tbaa !8
  %10 = fsub float %7, %9
  %11 = fmul float %10, %10
  %12 = fcmp ult float %11, %5
  br i1 %12, label %17, label %13

13:                                               ; preds = %2
  %14 = fcmp ult float %7, %9
  br i1 %14, label %16, label %15

15:                                               ; preds = %13
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(12) %1, i64 12, i1 false), !tbaa.struct !11
  br label %32

16:                                               ; preds = %13
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(12) %3, ptr noundef nonnull align 4 dereferenceable(12) %0, i64 12, i1 false), !tbaa.struct !11
  br label %32

17:                                               ; preds = %2
  %18 = tail call float @sqrtf(float noundef %5) #5
  %19 = load float, ptr %8, align 4, !tbaa !8
  %20 = fadd float %18, %19
  %21 = load float, ptr %6, align 4, !tbaa !8
  %22 = fadd float %20, %21
  %23 = fmul float %22, 5.000000e-01
  %24 = getelementptr inbounds i8, ptr %3, i64 8
  store float %23, ptr %24, align 8, !tbaa !8
  %25 = load i64, ptr %0, align 4, !tbaa !5
  store i64 %25, ptr %3, align 8, !tbaa !5
  %26 = fcmp ogt float %18, 0x3E80000000000000
  br i1 %26, label %27, label %32

27:                                               ; preds = %17
  %28 = fsub float %23, %19
  %29 = fdiv float %28, %18
  %30 = tail call <2 x float> @_Zmlf4Vec2(float noundef %29, <2 x float> %4)
  %31 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZpLR4Vec2S_(ptr noundef nonnull align 4 dereferenceable(8) %3, <2 x float> %30)
  br label %32

32:                                               ; preds = %17, %27, %15, %16
  %.sroa.0.0.copyload = load <2 x float>, ptr %3, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %3, i64 8
  %.sroa.2.0.copyload = load float, ptr %.sroa.2.0..sroa_idx, align 8
  %.fca.0.insert = insertvalue { <2 x float>, float } poison, <2 x float> %.sroa.0.0.copyload, 0
  %.fca.1.insert = insertvalue { <2 x float>, float } %.fca.0.insert, float %.sroa.2.0.copyload, 1
  ret { <2 x float>, float } %.fca.1.insert
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { 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 = { inlinehint mustprogress 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 #4 = { mustprogress 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 8}
!9 = !{!"_ZTS6Circle", !6, i64 0, !10, i64 8}
!10 = !{!"float", !6, i64 0}
!11 = !{i64 0, i64 8, !5, i64 8, i64 4, !12}
!12 = !{!10, !10, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass