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

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

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z18segment_vs_segment4Vec2S_S_S_PfPS_(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3, ptr noundef %4, ptr noundef %5) #4 {
  %7 = alloca i1, align 1
  %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 ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca float, align 4
  %15 = alloca %union.Vec2, align 4
  %16 = alloca %union.Vec2, align 4
  %17 = alloca %union.Vec2, align 4
  %18 = alloca float, align 4
  %19 = alloca %union.Vec2, align 4
  %20 = alloca %union.Vec2, align 4
  %21 = alloca %union.Vec2, align 4
  %22 = alloca float, align 4
  %23 = alloca %union.Vec2, align 4
  %24 = alloca %union.Vec2, align 4
  %25 = alloca %union.Vec2, align 4
  %26 = alloca float, align 4
  %27 = alloca %union.Vec2, align 4
  %28 = alloca %union.Vec2, align 4
  %29 = alloca %union.Vec2, align 4
  %30 = alloca %union.Vec2, align 4
  %31 = alloca %union.Vec2, align 4
  %32 = alloca %union.Vec2, align 4
  %33 = alloca i32, align 4
  %34 = getelementptr inbounds %union.Vec2, ptr %8, i32 0, i32 0
  store <2 x float> %0, ptr %34, align 4
  %35 = getelementptr inbounds %union.Vec2, ptr %9, i32 0, i32 0
  store <2 x float> %1, ptr %35, align 4
  %36 = getelementptr inbounds %union.Vec2, ptr %10, i32 0, i32 0
  store <2 x float> %2, ptr %36, align 4
  %37 = getelementptr inbounds %union.Vec2, ptr %11, i32 0, i32 0
  store <2 x float> %3, ptr %37, align 4
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %17, ptr align 4 %11, i64 8, i1 false), !tbaa.struct !9
  %38 = getelementptr inbounds %union.Vec2, ptr %15, i32 0, i32 0
  %39 = load <2 x float>, ptr %38, align 4
  %40 = getelementptr inbounds %union.Vec2, ptr %16, i32 0, i32 0
  %41 = load <2 x float>, ptr %40, align 4
  %42 = getelementptr inbounds %union.Vec2, ptr %17, i32 0, i32 0
  %43 = load <2 x float>, ptr %42, align 4
  %44 = call noundef float @_Z18signed_area_double4Vec2S_S_(<2 x float> %39, <2 x float> %41, <2 x float> %43)
  store float %44, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 4 %10, i64 8, i1 false), !tbaa.struct !9
  %45 = getelementptr inbounds %union.Vec2, ptr %19, i32 0, i32 0
  %46 = load <2 x float>, ptr %45, align 4
  %47 = getelementptr inbounds %union.Vec2, ptr %20, i32 0, i32 0
  %48 = load <2 x float>, ptr %47, align 4
  %49 = getelementptr inbounds %union.Vec2, ptr %21, i32 0, i32 0
  %50 = load <2 x float>, ptr %49, align 4
  %51 = call noundef float @_Z18signed_area_double4Vec2S_S_(<2 x float> %46, <2 x float> %48, <2 x float> %50)
  store float %51, ptr %18, align 4, !tbaa !11
  %52 = load float, ptr %14, align 4, !tbaa !11
  %53 = fcmp une float %52, 0.000000e+00
  br i1 %53, label %54, label %115

54:                                               ; preds = %6
  %55 = load float, ptr %18, align 4, !tbaa !11
  %56 = fcmp une float %55, 0.000000e+00
  br i1 %56, label %57, label %115

57:                                               ; preds = %54
  %58 = load float, ptr %14, align 4, !tbaa !11
  %59 = load float, ptr %18, align 4, !tbaa !11
  %60 = fmul float %58, %59
  %61 = fcmp olt float %60, 0.000000e+00
  br i1 %61, label %62, label %115

62:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %23, ptr align 4 %10, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %24, ptr align 4 %11, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %25, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !9
  %63 = getelementptr inbounds %union.Vec2, ptr %23, i32 0, i32 0
  %64 = load <2 x float>, ptr %63, align 4
  %65 = getelementptr inbounds %union.Vec2, ptr %24, i32 0, i32 0
  %66 = load <2 x float>, ptr %65, align 4
  %67 = getelementptr inbounds %union.Vec2, ptr %25, i32 0, i32 0
  %68 = load <2 x float>, ptr %67, align 4
  %69 = call noundef float @_Z18signed_area_double4Vec2S_S_(<2 x float> %64, <2 x float> %66, <2 x float> %68)
  store float %69, ptr %22, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %26) #5
  %70 = load float, ptr %22, align 4, !tbaa !11
  %71 = load float, ptr %18, align 4, !tbaa !11
  %72 = fadd float %70, %71
  %73 = load float, ptr %14, align 4, !tbaa !11
  %74 = fsub float %72, %73
  store float %74, ptr %26, align 4, !tbaa !11
  %75 = load float, ptr %22, align 4, !tbaa !11
  %76 = fcmp une float %75, 0.000000e+00
  br i1 %76, label %77, label %111

77:                                               ; preds = %62
  %78 = load float, ptr %26, align 4, !tbaa !11
  %79 = fcmp une float %78, 0.000000e+00
  br i1 %79, label %80, label %111

80:                                               ; preds = %77
  %81 = load float, ptr %22, align 4, !tbaa !11
  %82 = load float, ptr %26, align 4, !tbaa !11
  %83 = fmul float %81, %82
  %84 = fcmp olt float %83, 0.000000e+00
  br i1 %84, label %85, label %111

85:                                               ; preds = %80
  %86 = load float, ptr %22, align 4, !tbaa !11
  %87 = load float, ptr %22, align 4, !tbaa !11
  %88 = load float, ptr %26, align 4, !tbaa !11
  %89 = fsub float %87, %88
  %90 = fdiv float %86, %89
  %91 = load ptr, ptr %12, align 8, !tbaa !5
  store float %90, ptr %91, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !9
  %92 = load ptr, ptr %12, align 8, !tbaa !5
  %93 = load float, ptr %92, align 4, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %31, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %32, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !9
  %94 = getelementptr inbounds %union.Vec2, ptr %31, i32 0, i32 0
  %95 = load <2 x float>, ptr %94, align 4
  %96 = getelementptr inbounds %union.Vec2, ptr %32, i32 0, i32 0
  %97 = load <2 x float>, ptr %96, align 4
  %98 = call <2 x float> @_Zmi4Vec2S_(<2 x float> %95, <2 x float> %97)
  %99 = getelementptr inbounds %union.Vec2, ptr %30, i32 0, i32 0
  store <2 x float> %98, ptr %99, align 4
  %100 = getelementptr inbounds %union.Vec2, ptr %30, i32 0, i32 0
  %101 = load <2 x float>, ptr %100, align 4
  %102 = call <2 x float> @_Zmlf4Vec2(float noundef %93, <2 x float> %101)
  %103 = getelementptr inbounds %union.Vec2, ptr %29, i32 0, i32 0
  store <2 x float> %102, ptr %103, align 4
  %104 = getelementptr inbounds %union.Vec2, ptr %28, i32 0, i32 0
  %105 = load <2 x float>, ptr %104, align 4
  %106 = getelementptr inbounds %union.Vec2, ptr %29, i32 0, i32 0
  %107 = load <2 x float>, ptr %106, align 4
  %108 = call <2 x float> @_Zpl4Vec2S_(<2 x float> %105, <2 x float> %107)
  %109 = getelementptr inbounds %union.Vec2, ptr %27, i32 0, i32 0
  store <2 x float> %108, ptr %109, align 4
  %110 = load ptr, ptr %13, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %110, ptr align 4 %27, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #5
  store i1 true, ptr %7, align 1
  store i32 1, ptr %33, align 4
  br label %112

111:                                              ; preds = %80, %77, %62
  store i32 0, ptr %33, align 4
  br label %112

112:                                              ; preds = %111, %85
  call void @llvm.lifetime.end.p0(i64 4, ptr %26) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #5
  %113 = load i32, ptr %33, align 4
  switch i32 %113, label %116 [
    i32 0, label %114
  ]

114:                                              ; preds = %112
  br label %115

115:                                              ; preds = %114, %57, %54, %6
  store i1 false, ptr %7, align 1
  store i32 1, ptr %33, align 4
  br label %116

116:                                              ; preds = %115, %112
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  %117 = load i1, ptr %7, align 1
  ret i1 %117
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { inlinehint 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 #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: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_Zmi4Vec2S_(<2 x float>, <2 x float>) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z18segment_vs_segment4Vec2S_S_S_PfPS_(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #2 {
  %7 = tail call noundef float @_Z18signed_area_double4Vec2S_S_(<2 x float> %0, <2 x float> %1, <2 x float> %3)
  %8 = tail call noundef float @_Z18signed_area_double4Vec2S_S_(<2 x float> %0, <2 x float> %1, <2 x float> %2)
  %9 = fcmp une float %7, 0.000000e+00
  %10 = fcmp une float %8, 0.000000e+00
  %or.cond = and i1 %9, %10
  %11 = fmul float %7, %8
  %12 = fcmp olt float %11, 0.000000e+00
  %or.cond53 = and i1 %or.cond, %12
  br i1 %or.cond53, label %13, label %26

13:                                               ; preds = %6
  %14 = tail call noundef float @_Z18signed_area_double4Vec2S_S_(<2 x float> %2, <2 x float> %3, <2 x float> %0)
  %15 = fadd float %8, %14
  %16 = fsub float %15, %7
  %17 = fcmp une float %14, 0.000000e+00
  %18 = fcmp une float %16, 0.000000e+00
  %or.cond3 = and i1 %17, %18
  %19 = fmul float %14, %16
  %20 = fcmp olt float %19, 0.000000e+00
  %or.cond55 = and i1 %or.cond3, %20
  br i1 %or.cond55, label %.critedge, label %26

.critedge:                                        ; preds = %13
  %21 = fsub float %14, %16
  %22 = fdiv float %14, %21
  store float %22, ptr %4, align 4, !tbaa !5
  %23 = tail call <2 x float> @_Zmi4Vec2S_(<2 x float> %1, <2 x float> %0)
  %24 = tail call <2 x float> @_Zmlf4Vec2(float noundef %22, <2 x float> %23)
  %25 = tail call <2 x float> @_Zpl4Vec2S_(<2 x float> %0, <2 x float> %24)
  store <2 x float> %25, ptr %5, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %6, %13, %.critedge
  %.1 = phi i1 [ true, %.critedge ], [ false, %13 ], [ false, %6 ]
  ret i1 %.1
}

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


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