; LLVM IR from atlantis13579/Riemann :: Src/Geometry (Polygon2)

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

%"class.Maths::TVector2" = type { float, float }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN7Riemann21TriangleArea2D_SignedERKN5Maths8TVector2IfEES4_S4_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7Riemann25SegmentIntersectSegment2DERKN5Maths8TVector2IfEES4_S4_S4_PfPS2_(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, ptr noundef %4, ptr noundef %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca %"class.Maths::TVector2", align 4
  %19 = alloca %"class.Maths::TVector2", align 4
  %20 = alloca %"class.Maths::TVector2", align 4
  %21 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  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
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = call noundef float @_ZN7Riemann21TriangleArea2D_SignedERKN5Maths8TVector2IfEES4_S4_(ptr noundef nonnull align 4 dereferenceable(8) %22, ptr noundef nonnull align 4 dereferenceable(8) %23, ptr noundef nonnull align 4 dereferenceable(8) %24)
  store float %25, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = call noundef float @_ZN7Riemann21TriangleArea2D_SignedERKN5Maths8TVector2IfEES4_S4_(ptr noundef nonnull align 4 dereferenceable(8) %26, ptr noundef nonnull align 4 dereferenceable(8) %27, ptr noundef nonnull align 4 dereferenceable(8) %28)
  store float %29, ptr %15, align 4, !tbaa !9
  %30 = load float, ptr %14, align 4, !tbaa !9
  %31 = load float, ptr %15, align 4, !tbaa !9
  %32 = fmul float %30, %31
  %33 = fcmp olt float %32, 0.000000e+00
  br i1 %33, label %34, label %66

34:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = call noundef float @_ZN7Riemann21TriangleArea2D_SignedERKN5Maths8TVector2IfEES4_S4_(ptr noundef nonnull align 4 dereferenceable(8) %35, ptr noundef nonnull align 4 dereferenceable(8) %36, ptr noundef nonnull align 4 dereferenceable(8) %37)
  store float %38, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %39 = load float, ptr %16, align 4, !tbaa !9
  %40 = load float, ptr %15, align 4, !tbaa !9
  %41 = fadd float %39, %40
  %42 = load float, ptr %14, align 4, !tbaa !9
  %43 = fsub float %41, %42
  store float %43, ptr %17, align 4, !tbaa !9
  %44 = load float, ptr %16, align 4, !tbaa !9
  %45 = load float, ptr %17, align 4, !tbaa !9
  %46 = fmul float %44, %45
  %47 = fcmp olt float %46, 0.000000e+00
  br i1 %47, label %48, label %62

48:                                               ; preds = %34
  %49 = load float, ptr %16, align 4, !tbaa !9
  %50 = load float, ptr %16, align 4, !tbaa !9
  %51 = load float, ptr %17, align 4, !tbaa !9
  %52 = fsub float %50, %51
  %53 = fdiv float %49, %52
  %54 = load ptr, ptr %12, align 8, !tbaa !5
  store float %53, ptr %54, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %56 = load ptr, ptr %12, align 8, !tbaa !5
  %57 = load float, ptr %56, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZNK5Maths8TVector2IfEmiERKS1_(ptr dead_on_unwind writable sret(%"class.Maths::TVector2") align 4 %20, ptr noundef nonnull align 4 dereferenceable(8) %58, ptr noundef nonnull align 4 dereferenceable(8) %59)
  call void @_ZN5MathsmlIfEENS_8TVector2IT_EES2_RKS3_(ptr dead_on_unwind writable sret(%"class.Maths::TVector2") align 4 %19, float noundef %57, ptr noundef nonnull align 4 dereferenceable(8) %20)
  call void @_ZNK5Maths8TVector2IfEplERKS1_(ptr dead_on_unwind writable sret(%"class.Maths::TVector2") align 4 %18, ptr noundef nonnull align 4 dereferenceable(8) %55, ptr noundef nonnull align 4 dereferenceable(8) %19)
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN5Maths8TVector2IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(8) %60, ptr noundef nonnull align 4 dereferenceable(8) %18)
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  store i32 1, ptr %7, align 4
  store i32 1, ptr %21, align 4
  br label %63

62:                                               ; preds = %34
  store i32 0, ptr %21, align 4
  br label %63

63:                                               ; preds = %62, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  %64 = load i32, ptr %21, align 4
  switch i32 %64, label %67 [
    i32 0, label %65
  ]

65:                                               ; preds = %63
  br label %66

66:                                               ; preds = %65, %6
  store i32 0, ptr %7, align 4
  store i32 1, ptr %21, align 4
  br label %67

67:                                               ; preds = %66, %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  %68 = load i32, ptr %7, align 4
  ret i32 %68
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Maths8TVector2IfEplERKS1_(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector2") align 4, ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5MathsmlIfEENS_8TVector2IT_EES2_RKS3_(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector2") align 4, float noundef, ptr noundef nonnull align 4 dereferenceable(8)) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Maths8TVector2IfEmiERKS1_(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector2") align 4, ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZN5Maths8TVector2IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) #4 align 2

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

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "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 = { mustprogress uwtable "min-legal-vector-width"="0" "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 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "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 nounwind uwtable "min-legal-vector-width"="0" "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 = !{!10, !10, i64 0}
!10 = !{!"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"

%"class.Maths::TVector2" = type { float, float }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN7Riemann21TriangleArea2D_SignedERKN5Maths8TVector2IfEES4_S4_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN7Riemann25SegmentIntersectSegment2DERKN5Maths8TVector2IfEES4_S4_S4_PfPS2_(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, ptr nocapture noundef writeonly %4, ptr noundef %5) local_unnamed_addr #1 {
  %7 = alloca %"class.Maths::TVector2", align 4
  %8 = alloca %"class.Maths::TVector2", align 4
  %9 = alloca %"class.Maths::TVector2", align 4
  %10 = tail call noundef float @_ZN7Riemann21TriangleArea2D_SignedERKN5Maths8TVector2IfEES4_S4_(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %3)
  %11 = tail call noundef float @_ZN7Riemann21TriangleArea2D_SignedERKN5Maths8TVector2IfEES4_S4_(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %2)
  %12 = fmul float %10, %11
  %13 = fcmp olt float %12, 0.000000e+00
  br i1 %13, label %14, label %.critedge

14:                                               ; preds = %6
  %15 = tail call noundef float @_ZN7Riemann21TriangleArea2D_SignedERKN5Maths8TVector2IfEES4_S4_(ptr noundef nonnull align 4 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(8) %3, ptr noundef nonnull align 4 dereferenceable(8) %0)
  %16 = fadd float %11, %15
  %17 = fsub float %16, %10
  %18 = fmul float %15, %17
  %19 = fcmp uge float %18, 0.000000e+00
  br i1 %19, label %.critedge, label %20

20:                                               ; preds = %14
  %21 = fsub float %15, %17
  %22 = fdiv float %15, %21
  store float %22, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #5
  call void @_ZNK5Maths8TVector2IfEmiERKS1_(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector2") align 4 %9, ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(8) %0)
  call void @_ZN5MathsmlIfEENS_8TVector2IT_EES2_RKS3_(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector2") align 4 %8, float noundef %22, ptr noundef nonnull align 4 dereferenceable(8) %9)
  call void @_ZNK5Maths8TVector2IfEplERKS1_(ptr dead_on_unwind nonnull writable sret(%"class.Maths::TVector2") align 4 %7, ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(8) %8)
  %23 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZN5Maths8TVector2IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(8) %5, ptr noundef nonnull align 4 dereferenceable(8) %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  br label %.critedge

.critedge:                                        ; preds = %6, %14, %20
  %.1 = phi i32 [ 1, %20 ], [ 0, %14 ], [ 0, %6 ]
  ret i32 %.1
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Maths8TVector2IfEplERKS1_(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector2") align 4, ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN5MathsmlIfEENS_8TVector2IT_EES2_RKS3_(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector2") align 4, float noundef, ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Maths8TVector2IfEmiERKS1_(ptr dead_on_unwind noalias writable sret(%"class.Maths::TVector2") align 4, ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZN5Maths8TVector2IfEaSERKS1_(ptr noundef nonnull align 4 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #4 align 2

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

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "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 = { mustprogress uwtable "min-legal-vector-width"="0" "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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "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 nounwind uwtable "min-legal-vector-width"="0" "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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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