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

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

%union.Vec2 = type { %struct.anon.1 }
%struct.anon.1 = type { float, float }
%struct.Mm_Rect = type { %union.Vec2, %union.Vec2 }

; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, 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: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Zmi4Vec2S_(<2 x float>, <2 x float>) #3

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z23test_segment_vs_mm_rect4Vec2S_RK7Mm_Rect(<2 x float> %0, <2 x float> %1, ptr noundef nonnull align 4 dereferenceable(16) %2) #4 {
  %4 = alloca i1, align 1
  %5 = alloca %union.Vec2, align 4
  %6 = alloca %union.Vec2, align 4
  %7 = alloca ptr, align 8
  %8 = alloca %union.Vec2, align 4
  %9 = alloca %union.Vec2, align 4
  %10 = alloca %union.Vec2, align 4
  %11 = alloca %union.Vec2, align 4
  %12 = alloca %union.Vec2, align 4
  %13 = alloca %union.Vec2, align 4
  %14 = alloca %union.Vec2, align 4
  %15 = alloca %union.Vec2, align 4
  %16 = alloca %union.Vec2, align 4
  %17 = alloca %union.Vec2, align 4
  %18 = alloca %union.Vec2, align 4
  %19 = alloca %union.Vec2, align 4
  %20 = alloca %union.Vec2, align 4
  %21 = alloca %union.Vec2, align 4
  %22 = alloca %union.Vec2, align 4
  %23 = alloca %union.Vec2, align 4
  %24 = alloca %union.Vec2, align 4
  %25 = alloca float, align 4
  %26 = alloca i32, align 4
  %27 = alloca float, align 4
  %28 = getelementptr inbounds %union.Vec2, ptr %5, i32 0, i32 0
  store <2 x float> %0, ptr %28, align 4
  %29 = getelementptr inbounds %union.Vec2, ptr %6, i32 0, i32 0
  store <2 x float> %1, ptr %29, align 4
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Mm_Rect, ptr %30, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %31, i64 8, i1 false), !tbaa.struct !9
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Mm_Rect, ptr %32, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %33, i64 8, i1 false), !tbaa.struct !9
  %34 = getelementptr inbounds %union.Vec2, ptr %10, i32 0, i32 0
  %35 = load <2 x float>, ptr %34, align 4
  %36 = getelementptr inbounds %union.Vec2, ptr %11, i32 0, i32 0
  %37 = load <2 x float>, ptr %36, align 4
  %38 = call <2 x float> @_Zpl4Vec2S_(<2 x float> %35, <2 x float> %37)
  %39 = getelementptr inbounds %union.Vec2, ptr %9, i32 0, i32 0
  store <2 x float> %38, ptr %39, align 4
  %40 = getelementptr inbounds %union.Vec2, ptr %9, i32 0, i32 0
  %41 = load <2 x float>, ptr %40, align 4
  %42 = call <2 x float> @_Zml4Vec2f(<2 x float> %41, float noundef 5.000000e-01)
  %43 = getelementptr inbounds %union.Vec2, ptr %8, i32 0, i32 0
  store <2 x float> %42, ptr %43, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Mm_Rect, ptr %44, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %45, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !9
  %46 = getelementptr inbounds %union.Vec2, ptr %13, i32 0, i32 0
  %47 = load <2 x float>, ptr %46, align 4
  %48 = getelementptr inbounds %union.Vec2, ptr %14, i32 0, i32 0
  %49 = load <2 x float>, ptr %48, align 4
  %50 = call <2 x float> @_Zmi4Vec2S_(<2 x float> %47, <2 x float> %49)
  %51 = getelementptr inbounds %union.Vec2, ptr %12, i32 0, i32 0
  store <2 x float> %50, ptr %51, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 4 %5, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !9
  %52 = getelementptr inbounds %union.Vec2, ptr %17, i32 0, i32 0
  %53 = load <2 x float>, ptr %52, align 4
  %54 = getelementptr inbounds %union.Vec2, ptr %18, i32 0, i32 0
  %55 = load <2 x float>, ptr %54, align 4
  %56 = call <2 x float> @_Zpl4Vec2S_(<2 x float> %53, <2 x float> %55)
  %57 = getelementptr inbounds %union.Vec2, ptr %16, i32 0, i32 0
  store <2 x float> %56, ptr %57, align 4
  %58 = getelementptr inbounds %union.Vec2, ptr %16, i32 0, i32 0
  %59 = load <2 x float>, ptr %58, align 4
  %60 = call <2 x float> @_Zml4Vec2f(<2 x float> %59, float noundef 5.000000e-01)
  %61 = getelementptr inbounds %union.Vec2, ptr %15, i32 0, i32 0
  store <2 x float> %60, ptr %61, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 4 %15, i64 8, i1 false), !tbaa.struct !9
  %62 = getelementptr inbounds %union.Vec2, ptr %20, i32 0, i32 0
  %63 = load <2 x float>, ptr %62, align 4
  %64 = getelementptr inbounds %union.Vec2, ptr %21, i32 0, i32 0
  %65 = load <2 x float>, ptr %64, align 4
  %66 = call <2 x float> @_Zmi4Vec2S_(<2 x float> %63, <2 x float> %65)
  %67 = getelementptr inbounds %union.Vec2, ptr %19, i32 0, i32 0
  store <2 x float> %66, ptr %67, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %23, ptr align 4 %15, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %24, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !9
  %68 = getelementptr inbounds %union.Vec2, ptr %23, i32 0, i32 0
  %69 = load <2 x float>, ptr %68, align 4
  %70 = getelementptr inbounds %union.Vec2, ptr %24, i32 0, i32 0
  %71 = load <2 x float>, ptr %70, align 4
  %72 = call <2 x float> @_Zmi4Vec2S_(<2 x float> %69, <2 x float> %71)
  %73 = getelementptr inbounds %union.Vec2, ptr %22, i32 0, i32 0
  store <2 x float> %72, ptr %73, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %22, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #5
  %74 = getelementptr inbounds %struct.anon.1, ptr %19, i32 0, i32 0
  %75 = load float, ptr %74, align 4, !tbaa !10
  %76 = call float @llvm.fabs.f32(float %75)
  store float %76, ptr %25, align 4, !tbaa !11
  %77 = getelementptr inbounds %struct.anon.1, ptr %15, i32 0, i32 0
  %78 = load float, ptr %77, align 4, !tbaa !10
  %79 = call float @llvm.fabs.f32(float %78)
  %80 = getelementptr inbounds %struct.anon.1, ptr %12, i32 0, i32 0
  %81 = load float, ptr %80, align 4, !tbaa !10
  %82 = load float, ptr %25, align 4, !tbaa !11
  %83 = fadd float %81, %82
  %84 = fcmp ogt float %79, %83
  br i1 %84, label %85, label %86

85:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  store i32 1, ptr %26, align 4
  br label %128

86:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %27) #5
  %87 = getelementptr inbounds %struct.anon.1, ptr %19, i32 0, i32 1
  %88 = load float, ptr %87, align 4, !tbaa !10
  %89 = call float @llvm.fabs.f32(float %88)
  store float %89, ptr %27, align 4, !tbaa !11
  %90 = getelementptr inbounds %struct.anon.1, ptr %15, i32 0, i32 1
  %91 = load float, ptr %90, align 4, !tbaa !10
  %92 = call float @llvm.fabs.f32(float %91)
  %93 = getelementptr inbounds %struct.anon.1, ptr %12, i32 0, i32 1
  %94 = load float, ptr %93, align 4, !tbaa !10
  %95 = load float, ptr %27, align 4, !tbaa !11
  %96 = fadd float %94, %95
  %97 = fcmp ogt float %92, %96
  br i1 %97, label %98, label %99

98:                                               ; preds = %86
  store i1 false, ptr %4, align 1
  store i32 1, ptr %26, align 4
  br label %127

99:                                               ; preds = %86
  %100 = load float, ptr %25, align 4, !tbaa !11
  %101 = fadd float %100, 0x3E80000000000000
  store float %101, ptr %25, align 4, !tbaa !11
  %102 = load float, ptr %27, align 4, !tbaa !11
  %103 = fadd float %102, 0x3E80000000000000
  store float %103, ptr %27, align 4, !tbaa !11
  %104 = getelementptr inbounds %struct.anon.1, ptr %15, i32 0, i32 0
  %105 = load float, ptr %104, align 4, !tbaa !10
  %106 = getelementptr inbounds %struct.anon.1, ptr %19, i32 0, i32 1
  %107 = load float, ptr %106, align 4, !tbaa !10
  %108 = getelementptr inbounds %struct.anon.1, ptr %15, i32 0, i32 1
  %109 = load float, ptr %108, align 4, !tbaa !10
  %110 = getelementptr inbounds %struct.anon.1, ptr %19, i32 0, i32 0
  %111 = load float, ptr %110, align 4, !tbaa !10
  %112 = fmul float %109, %111
  %113 = fneg float %112
  %114 = call float @llvm.fmuladd.f32(float %105, float %107, float %113)
  %115 = call float @llvm.fabs.f32(float %114)
  %116 = getelementptr inbounds %struct.anon.1, ptr %12, i32 0, i32 0
  %117 = load float, ptr %116, align 4, !tbaa !10
  %118 = load float, ptr %27, align 4, !tbaa !11
  %119 = getelementptr inbounds %struct.anon.1, ptr %12, i32 0, i32 1
  %120 = load float, ptr %119, align 4, !tbaa !10
  %121 = load float, ptr %25, align 4, !tbaa !11
  %122 = fmul float %120, %121
  %123 = call float @llvm.fmuladd.f32(float %117, float %118, float %122)
  %124 = fcmp ogt float %115, %123
  br i1 %124, label %125, label %126

125:                                              ; preds = %99
  store i1 false, ptr %4, align 1
  store i32 1, ptr %26, align 4
  br label %127

126:                                              ; preds = %99
  store i1 true, ptr %4, align 1
  store i32 1, ptr %26, align 4
  br label %127

127:                                              ; preds = %126, %125, %98
  call void @llvm.lifetime.end.p0(i64 4, ptr %27) #5
  br label %128

128:                                              ; preds = %127, %85
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %129 = load i1, ptr %4, align 1
  ret i1 %129
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z23test_segment_vs_mm_rect4Vec2S_RK7Mm_Rect(<2 x float> %0, <2 x float> %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(16) %2) local_unnamed_addr #2 {
  %.sroa.033.0.copyload = load <2 x float>, ptr %2, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %2, i64 8
  %.sroa.032.0.copyload = load <2 x float>, ptr %4, align 4, !tbaa !5
  %5 = tail call <2 x float> @_Zpl4Vec2S_(<2 x float> %.sroa.033.0.copyload, <2 x float> %.sroa.032.0.copyload)
  %6 = tail call <2 x float> @_Zml4Vec2f(<2 x float> %5, float noundef 5.000000e-01)
  %.sroa.026.0.copyload = load <2 x float>, ptr %4, align 4, !tbaa !5
  %7 = tail call <2 x float> @_Zmi4Vec2S_(<2 x float> %.sroa.026.0.copyload, <2 x float> %6)
  %8 = tail call <2 x float> @_Zpl4Vec2S_(<2 x float> %0, <2 x float> %1)
  %9 = tail call <2 x float> @_Zml4Vec2f(<2 x float> %8, float noundef 5.000000e-01)
  %10 = tail call <2 x float> @_Zmi4Vec2S_(<2 x float> %1, <2 x float> %9)
  %11 = tail call <2 x float> @_Zmi4Vec2S_(<2 x float> %9, <2 x float> %6)
  %.sroa.010.0.vec.extract = extractelement <2 x float> %10, i64 0
  %12 = tail call float @llvm.fabs.f32(float %.sroa.010.0.vec.extract)
  %.sroa.018.0.vec.extract = extractelement <2 x float> %11, i64 0
  %13 = tail call float @llvm.fabs.f32(float %.sroa.018.0.vec.extract)
  %.sroa.027.0.vec.extract = extractelement <2 x float> %7, i64 0
  %14 = fadd float %.sroa.027.0.vec.extract, %12
  %15 = fcmp ogt float %13, %14
  br i1 %15, label %31, label %16

16:                                               ; preds = %3
  %.sroa.010.4.vec.extract = extractelement <2 x float> %10, i64 1
  %17 = tail call float @llvm.fabs.f32(float %.sroa.010.4.vec.extract)
  %.sroa.018.4.vec.extract = extractelement <2 x float> %11, i64 1
  %18 = tail call float @llvm.fabs.f32(float %.sroa.018.4.vec.extract)
  %.sroa.027.4.vec.extract = extractelement <2 x float> %7, i64 1
  %19 = fadd float %.sroa.027.4.vec.extract, %17
  %20 = fcmp ogt float %18, %19
  br i1 %20, label %31, label %21

21:                                               ; preds = %16
  %22 = fadd float %12, 0x3E80000000000000
  %23 = fadd float %17, 0x3E80000000000000
  %24 = fneg float %.sroa.018.4.vec.extract
  %25 = fmul float %.sroa.010.0.vec.extract, %24
  %26 = tail call float @llvm.fmuladd.f32(float %.sroa.018.0.vec.extract, float %.sroa.010.4.vec.extract, float %25)
  %27 = tail call float @llvm.fabs.f32(float %26)
  %28 = fmul float %.sroa.027.4.vec.extract, %22
  %29 = tail call float @llvm.fmuladd.f32(float %.sroa.027.0.vec.extract, float %23, float %28)
  %30 = fcmp ule float %27, %29
  br label %31

31:                                               ; preds = %16, %21, %3
  %.1 = phi i1 [ false, %3 ], [ false, %16 ], [ %30, %21 ]
  ret i1 %.1
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #2 = { 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" }

!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"}


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