; LLVM IR from chrxh/alien :: source/Base/Math.ll (ZN4Math8crossingERK12RealVector2DS2_S2_S2_)

; 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.RealVector2D = type { float, float }

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #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: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4Math8crossingERK12RealVector2DS2_S2_S2_(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(8) %3) #2 align 2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %struct.RealVector2D, align 4
  %12 = alloca ptr, align 8
  %13 = alloca %struct.RealVector2D, align 4
  %14 = alloca float, align 4
  %15 = alloca i32, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %18, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = call <2 x float> @_ZNK12RealVector2DmiERKS_(ptr noundef nonnull align 4 dereferenceable(8) %19, ptr noundef nonnull align 4 dereferenceable(8) %20)
  store <2 x float> %21, ptr %11, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %22, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = call <2 x float> @_ZNK12RealVector2DmiERKS_(ptr noundef nonnull align 4 dereferenceable(8) %23, ptr noundef nonnull align 4 dereferenceable(8) %24)
  store <2 x float> %25, ptr %13, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %26 = getelementptr inbounds %struct.RealVector2D, ptr %13, i32 0, i32 0
  %27 = load float, ptr %26, align 4, !tbaa !9
  %28 = getelementptr inbounds %struct.RealVector2D, ptr %11, i32 0, i32 1
  %29 = load float, ptr %28, align 4, !tbaa !12
  %30 = getelementptr inbounds %struct.RealVector2D, ptr %13, i32 0, i32 1
  %31 = load float, ptr %30, align 4, !tbaa !12
  %32 = getelementptr inbounds %struct.RealVector2D, ptr %11, i32 0, i32 0
  %33 = load float, ptr %32, align 4, !tbaa !9
  %34 = fmul float %31, %33
  %35 = fneg float %34
  %36 = call float @llvm.fmuladd.f32(float %27, float %29, float %35)
  store float %36, ptr %14, align 4, !tbaa !13
  %37 = load float, ptr %14, align 4, !tbaa !13
  %38 = fptosi float %37 to i32
  %39 = call i32 @llvm.abs.i32(i32 %38, i1 true)
  %40 = sitofp i32 %39 to float
  %41 = fcmp olt float %40, 0x3F1A36E2E0000000
  br i1 %41, label %42, label %43

42:                                               ; preds = %4
  store i1 false, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %129

43:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %44 = getelementptr inbounds %struct.RealVector2D, ptr %11, i32 0, i32 0
  %45 = load float, ptr %44, align 4, !tbaa !9
  %46 = load ptr, ptr %12, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.RealVector2D, ptr %46, i32 0, i32 1
  %48 = load float, ptr %47, align 4, !tbaa !12
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.RealVector2D, ptr %49, i32 0, i32 1
  %51 = load float, ptr %50, align 4, !tbaa !12
  %52 = fsub float %48, %51
  %53 = getelementptr inbounds %struct.RealVector2D, ptr %11, i32 0, i32 1
  %54 = load float, ptr %53, align 4, !tbaa !12
  %55 = load ptr, ptr %12, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.RealVector2D, ptr %55, i32 0, i32 0
  %57 = load float, ptr %56, align 4, !tbaa !9
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.RealVector2D, ptr %58, i32 0, i32 0
  %60 = load float, ptr %59, align 4, !tbaa !9
  %61 = fsub float %57, %60
  %62 = fmul float %54, %61
  %63 = fneg float %62
  %64 = call float @llvm.fmuladd.f32(float %45, float %52, float %63)
  %65 = load float, ptr %14, align 4, !tbaa !13
  %66 = fdiv float %64, %65
  store float %66, ptr %16, align 4, !tbaa !13
  %67 = load float, ptr %16, align 4, !tbaa !13
  %68 = fcmp olt float %67, 0xBF1A36E2E0000000
  br i1 %68, label %72, label %69

69:                                               ; preds = %43
  %70 = load float, ptr %16, align 4, !tbaa !13
  %71 = fcmp ogt float %70, 0x3FF00068E0000000
  br i1 %71, label %72, label %73

72:                                               ; preds = %69, %43
  store i1 false, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %128

73:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %74 = getelementptr inbounds %struct.RealVector2D, ptr %11, i32 0, i32 0
  %75 = load float, ptr %74, align 4, !tbaa !9
  %76 = fptosi float %75 to i32
  %77 = call i32 @llvm.abs.i32(i32 %76, i1 true)
  %78 = sitofp i32 %77 to float
  %79 = fcmp ogt float %78, 0x3F1A36E2E0000000
  br i1 %79, label %80, label %95

80:                                               ; preds = %73
  %81 = load ptr, ptr %12, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.RealVector2D, ptr %81, i32 0, i32 0
  %83 = load float, ptr %82, align 4, !tbaa !9
  %84 = load ptr, ptr %10, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.RealVector2D, ptr %84, i32 0, i32 0
  %86 = load float, ptr %85, align 4, !tbaa !9
  %87 = fsub float %83, %86
  %88 = load float, ptr %16, align 4, !tbaa !13
  %89 = getelementptr inbounds %struct.RealVector2D, ptr %13, i32 0, i32 0
  %90 = load float, ptr %89, align 4, !tbaa !9
  %91 = call float @llvm.fmuladd.f32(float %88, float %90, float %87)
  %92 = getelementptr inbounds %struct.RealVector2D, ptr %11, i32 0, i32 0
  %93 = load float, ptr %92, align 4, !tbaa !9
  %94 = fdiv float %91, %93
  store float %94, ptr %17, align 4, !tbaa !13
  br label %119

95:                                               ; preds = %73
  %96 = getelementptr inbounds %struct.RealVector2D, ptr %11, i32 0, i32 1
  %97 = load float, ptr %96, align 4, !tbaa !12
  %98 = fptosi float %97 to i32
  %99 = call i32 @llvm.abs.i32(i32 %98, i1 true)
  %100 = sitofp i32 %99 to float
  %101 = fcmp ogt float %100, 0x3F1A36E2E0000000
  br i1 %101, label %102, label %117

102:                                              ; preds = %95
  %103 = load ptr, ptr %12, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.RealVector2D, ptr %103, i32 0, i32 1
  %105 = load float, ptr %104, align 4, !tbaa !12
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.RealVector2D, ptr %106, i32 0, i32 1
  %108 = load float, ptr %107, align 4, !tbaa !12
  %109 = fsub float %105, %108
  %110 = load float, ptr %16, align 4, !tbaa !13
  %111 = getelementptr inbounds %struct.RealVector2D, ptr %13, i32 0, i32 1
  %112 = load float, ptr %111, align 4, !tbaa !12
  %113 = call float @llvm.fmuladd.f32(float %110, float %112, float %109)
  %114 = getelementptr inbounds %struct.RealVector2D, ptr %11, i32 0, i32 1
  %115 = load float, ptr %114, align 4, !tbaa !12
  %116 = fdiv float %113, %115
  store float %116, ptr %17, align 4, !tbaa !13
  br label %118

117:                                              ; preds = %95
  store i1 false, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %127

118:                                              ; preds = %102
  br label %119

119:                                              ; preds = %118, %80
  %120 = load float, ptr %17, align 4, !tbaa !13
  %121 = fcmp oge float %120, 0x3F1A36E2E0000000
  br i1 %121, label %122, label %125

122:                                              ; preds = %119
  %123 = load float, ptr %17, align 4, !tbaa !13
  %124 = fcmp ole float %123, 0x3FEFFF2E40000000
  br label %125

125:                                              ; preds = %122, %119
  %126 = phi i1 [ false, %119 ], [ %124, %122 ]
  store i1 %126, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %127

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

128:                                              ; preds = %127, %72
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %129

129:                                              ; preds = %128, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %130 = load i1, ptr %5, align 1
  ret i1 %130
}

declare <2 x float> @_ZNK12RealVector2DmiERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #0

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { "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 = { 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 = !{!10, !11, i64 0}
!10 = !{!"_ZTS12RealVector2D", !11, i64 0, !11, i64 4}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!11, !11, 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: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4Math8crossingERK12RealVector2DS2_S2_S2_(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(8) %3) local_unnamed_addr #1 align 2 {
  %5 = tail call <2 x float> @_ZNK12RealVector2DmiERKS_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %0)
  %6 = tail call <2 x float> @_ZNK12RealVector2DmiERKS_(ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) %2)
  %.sroa.0.0.vec.extract = extractelement <2 x float> %6, i64 0
  %.sroa.017.4.vec.extract = extractelement <2 x float> %5, i64 1
  %.sroa.0.4.vec.extract = extractelement <2 x float> %6, i64 1
  %.sroa.017.0.vec.extract = extractelement <2 x float> %5, i64 0
  %7 = fneg float %.sroa.0.4.vec.extract
  %8 = fmul float %.sroa.017.0.vec.extract, %7
  %9 = tail call float @llvm.fmuladd.f32(float %.sroa.0.0.vec.extract, float %.sroa.017.4.vec.extract, float %8)
  %10 = fptosi float %9 to i32
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %41, label %12

12:                                               ; preds = %4
  %13 = getelementptr inbounds i8, ptr %2, i64 4
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 4
  %16 = load float, ptr %15, align 4, !tbaa !5
  %17 = fsub float %14, %16
  %18 = load float, ptr %2, align 4, !tbaa !10
  %19 = load float, ptr %0, align 4, !tbaa !10
  %20 = fsub float %18, %19
  %21 = fneg float %.sroa.017.4.vec.extract
  %22 = fmul float %20, %21
  %23 = tail call float @llvm.fmuladd.f32(float %.sroa.017.0.vec.extract, float %17, float %22)
  %24 = fdiv float %23, %9
  %25 = fcmp olt float %24, 0xBF1A36E2E0000000
  %26 = fcmp ogt float %24, 0x3FF00068E0000000
  %or.cond = or i1 %25, %26
  br i1 %or.cond, label %41, label %27

27:                                               ; preds = %12
  %28 = fptosi float %.sroa.017.0.vec.extract to i32
  %.not = icmp eq i32 %28, 0
  br i1 %.not, label %32, label %29

29:                                               ; preds = %27
  %30 = tail call float @llvm.fmuladd.f32(float %24, float %.sroa.0.0.vec.extract, float %20)
  %31 = fdiv float %30, %.sroa.017.0.vec.extract
  br label %37

32:                                               ; preds = %27
  %33 = fptosi float %.sroa.017.4.vec.extract to i32
  %.not43 = icmp eq i32 %33, 0
  br i1 %.not43, label %41, label %34

34:                                               ; preds = %32
  %35 = tail call float @llvm.fmuladd.f32(float %24, float %.sroa.0.4.vec.extract, float %17)
  %36 = fdiv float %35, %.sroa.017.4.vec.extract
  br label %37

37:                                               ; preds = %34, %29
  %.0 = phi float [ %31, %29 ], [ %36, %34 ]
  %38 = fcmp oge float %.0, 0x3F1A36E2E0000000
  %39 = fcmp ole float %.0, 0x3FEFFF2E40000000
  %40 = and i1 %38, %39
  br label %41

41:                                               ; preds = %12, %32, %37, %4
  %.2 = phi i1 [ false, %4 ], [ false, %12 ], [ %40, %37 ], [ false, %32 ]
  ret i1 %.2
}

declare <2 x float> @_ZNK12RealVector2DmiERKS_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 = { "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, !7, i64 4}
!6 = !{!"_ZTS12RealVector2D", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}


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