; LLVM IR from atlantis13579/Riemann :: Src/CollisionPrimitive (Triangle3)

; 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.Riemann::Plane3" = type { %"class.Maths::TVector3", float }
%"class.Maths::TVector3" = type { float, float, float }
%"class.Riemann::Triangle3" = type { %"class.Maths::TVector3", %"class.Maths::TVector3", %"class.Maths::TVector3" }
%"struct.Riemann::Triangle3::Segment3IntersectionResult" = type <{ i32, [2 x %"class.Maths::TVector3"], i8, [3 x i8] }>

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Riemann6Plane3C2ERKN5Maths8TVector3IfEES5_S5_(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7Riemann6Plane325CalculateRelationsToPointERKN5Maths8TVector3IfEE(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK7Riemann9Triangle318IntersectSegmentExERKN5Maths8TVector3IfEES5_RNS0_26Segment3IntersectionResultE(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(29) %3) #1 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 %"class.Riemann::Plane3", align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, 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
  %14 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #2
  %15 = getelementptr inbounds %"class.Riemann::Triangle3", ptr %14, i32 0, i32 0
  %16 = getelementptr inbounds %"class.Riemann::Triangle3", ptr %14, i32 0, i32 1
  %17 = getelementptr inbounds %"class.Riemann::Triangle3", ptr %14, i32 0, i32 2
  call void @_ZN7Riemann6Plane3C2ERKN5Maths8TVector3IfEES5_S5_(ptr noundef nonnull align 4 dereferenceable(16) %10, ptr noundef nonnull align 4 dereferenceable(12) %15, ptr noundef nonnull align 4 dereferenceable(12) %16, ptr noundef nonnull align 4 dereferenceable(12) %17)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = call noundef i32 @_ZNK7Riemann6Plane325CalculateRelationsToPointERKN5Maths8TVector3IfEE(ptr noundef nonnull align 4 dereferenceable(16) %10, ptr noundef nonnull align 4 dereferenceable(12) %18)
  store i32 %19, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = call noundef i32 @_ZNK7Riemann6Plane325CalculateRelationsToPointERKN5Maths8TVector3IfEE(ptr noundef nonnull align 4 dereferenceable(16) %10, ptr noundef nonnull align 4 dereferenceable(12) %20)
  store i32 %21, ptr %12, align 4, !tbaa !9
  %22 = load i32, ptr %11, align 4, !tbaa !9
  %23 = load i32, ptr %12, align 4, !tbaa !9
  %24 = mul nsw i32 %22, %23
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %26, label %31

26:                                               ; preds = %4
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.Riemann::Triangle3::Segment3IntersectionResult", ptr %27, i32 0, i32 0
  store i32 0, ptr %28, align 4, !tbaa !11
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.Riemann::Triangle3::Segment3IntersectionResult", ptr %29, i32 0, i32 2
  store i8 0, ptr %30, align 4, !tbaa !14
  store i1 false, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %59

31:                                               ; preds = %4
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.Riemann::Triangle3::Segment3IntersectionResult", ptr %34, i32 0, i32 1
  %36 = getelementptr inbounds [2 x %"class.Maths::TVector3"], ptr %35, i64 0, i64 0
  %37 = call noundef i32 @_ZN7RiemannL25IntersectSegment_CoplanarERKNS_9Triangle3ERKNS_6Plane3ERKN5Maths8TVector3IfEESA_PS8_(ptr noundef nonnull align 4 dereferenceable(36) %14, ptr noundef nonnull align 4 dereferenceable(16) %10, ptr noundef nonnull align 4 dereferenceable(12) %32, ptr noundef nonnull align 4 dereferenceable(12) %33, ptr noundef %36)
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.Riemann::Triangle3::Segment3IntersectionResult", ptr %38, i32 0, i32 0
  store i32 %37, ptr %39, align 4, !tbaa !11
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.Riemann::Triangle3::Segment3IntersectionResult", ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 4, !tbaa !11
  %43 = icmp eq i32 %42, 2
  br i1 %43, label %44, label %47

44:                                               ; preds = %31
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds %"struct.Riemann::Triangle3::Segment3IntersectionResult", ptr %45, i32 0, i32 2
  store i8 2, ptr %46, align 4, !tbaa !14
  store i1 true, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %59

47:                                               ; preds = %31
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.Riemann::Triangle3::Segment3IntersectionResult", ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 4, !tbaa !11
  %51 = icmp eq i32 %50, 1
  br i1 %51, label %52, label %55

52:                                               ; preds = %47
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.Riemann::Triangle3::Segment3IntersectionResult", ptr %53, i32 0, i32 2
  store i8 1, ptr %54, align 4, !tbaa !14
  store i1 true, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %59

55:                                               ; preds = %47
  br label %56

56:                                               ; preds = %55
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = getelementptr inbounds %"struct.Riemann::Triangle3::Segment3IntersectionResult", ptr %57, i32 0, i32 2
  store i8 0, ptr %58, align 4, !tbaa !14
  store i1 true, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %59

59:                                               ; preds = %56, %52, %44, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #2
  %60 = load i1, ptr %5, align 1
  ret i1 %60
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN7RiemannL25IntersectSegment_CoplanarERKNS_9Triangle3ERKNS_6Plane3ERKN5Maths8TVector3IfEESA_PS8_(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN7Riemann9Triangle326Segment3IntersectionResultE", !10, i64 0, !7, i64 4, !13, i64 28}
!13 = !{!"_ZTSN7Riemann16IntersectionTypeE", !7, i64 0}
!14 = !{!12, !13, i64 28}


; 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.Riemann::Plane3" = type { %"class.Maths::TVector3", float }
%"class.Maths::TVector3" = type { float, float, float }

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7Riemann6Plane3C2ERKN5Maths8TVector3IfEES5_S5_(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK7Riemann6Plane325CalculateRelationsToPointERKN5Maths8TVector3IfEE(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK7Riemann9Triangle318IntersectSegmentExERKN5Maths8TVector3IfEES5_RNS0_26Segment3IntersectionResultE(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(29) %3) local_unnamed_addr #1 align 2 {
  %5 = alloca %"class.Riemann::Plane3", align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #2
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  call void @_ZN7Riemann6Plane3C2ERKN5Maths8TVector3IfEES5_S5_(ptr noundef nonnull align 4 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %6, ptr noundef nonnull align 4 dereferenceable(12) %7)
  %8 = call noundef i32 @_ZNK7Riemann6Plane325CalculateRelationsToPointERKN5Maths8TVector3IfEE(ptr noundef nonnull align 4 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(12) %1)
  %9 = call noundef i32 @_ZNK7Riemann6Plane325CalculateRelationsToPointERKN5Maths8TVector3IfEE(ptr noundef nonnull align 4 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(12) %2)
  %10 = mul nsw i32 %9, %8
  %11 = icmp slt i32 %10, 1
  br i1 %11, label %14, label %12

12:                                               ; preds = %4
  store i32 0, ptr %3, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %3, i64 28
  store i8 0, ptr %13, align 4, !tbaa !11
  br label %21

14:                                               ; preds = %4
  %15 = getelementptr inbounds i8, ptr %3, i64 4
  %16 = call noundef i32 @_ZN7RiemannL25IntersectSegment_CoplanarERKNS_9Triangle3ERKNS_6Plane3ERKN5Maths8TVector3IfEESA_PS8_(ptr noundef nonnull align 4 dereferenceable(36) %0, ptr noundef nonnull align 4 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull %15)
  store i32 %16, ptr %3, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %3, i64 28
  switch i32 %16, label %20 [
    i32 2, label %18
    i32 1, label %19
  ]

18:                                               ; preds = %14
  store i8 2, ptr %17, align 4, !tbaa !11
  br label %21

19:                                               ; preds = %14
  store i8 1, ptr %17, align 4, !tbaa !11
  br label %21

20:                                               ; preds = %14
  store i8 0, ptr %17, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %20, %19, %18, %12
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #2
  ret i1 %11
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZN7RiemannL25IntersectSegment_CoplanarERKNS_9Triangle3ERKNS_6Plane3ERKN5Maths8TVector3IfEESA_PS8_(ptr noundef nonnull align 4 dereferenceable(36), ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12), ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !7, i64 0}
!6 = !{!"_ZTSN7Riemann9Triangle326Segment3IntersectionResultE", !7, i64 0, !8, i64 4, !10, i64 28}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN7Riemann16IntersectionTypeE", !8, i64 0}
!11 = !{!6, !10, i64 28}


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