; LLVM IR from thuhcsi/Crystal.TTVS :: Xface/XFace/src/XEngine (Geometry)

; 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.XMath::Vector3" = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7XEngine8Geometry17computeFaceNormalERKN5XMath7Vector3ES4_S4_(ptr dead_on_unwind noalias writable sret(%"class.XMath::Vector3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(12) %1, ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(12) %3) #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %"class.XMath::Vector3", align 4
  %10 = alloca %"class.XMath::Vector3", align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i1, align 1
  store ptr %0, ptr %5, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %9) #4
  call void @_ZN5XMath7Vector3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %9)
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #4
  invoke void @_ZN5XMath7Vector3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %10)
          to label %14 unwind label %65

14:                                               ; preds = %4
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %"class.XMath::Vector3", ptr %15, i32 0, i32 0
  %17 = load float, ptr %16, align 4, !tbaa !9
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.XMath::Vector3", ptr %18, i32 0, i32 0
  %20 = load float, ptr %19, align 4, !tbaa !9
  %21 = fsub float %17, %20
  %22 = getelementptr inbounds %"class.XMath::Vector3", ptr %9, i32 0, i32 0
  store float %21, ptr %22, align 4, !tbaa !9
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.XMath::Vector3", ptr %23, i32 0, i32 1
  %25 = load float, ptr %24, align 4, !tbaa !12
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %"class.XMath::Vector3", ptr %26, i32 0, i32 1
  %28 = load float, ptr %27, align 4, !tbaa !12
  %29 = fsub float %25, %28
  %30 = getelementptr inbounds %"class.XMath::Vector3", ptr %9, i32 0, i32 1
  store float %29, ptr %30, align 4, !tbaa !12
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %"class.XMath::Vector3", ptr %31, i32 0, i32 2
  %33 = load float, ptr %32, align 4, !tbaa !13
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.XMath::Vector3", ptr %34, i32 0, i32 2
  %36 = load float, ptr %35, align 4, !tbaa !13
  %37 = fsub float %33, %36
  %38 = getelementptr inbounds %"class.XMath::Vector3", ptr %9, i32 0, i32 2
  store float %37, ptr %38, align 4, !tbaa !13
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.XMath::Vector3", ptr %39, i32 0, i32 0
  %41 = load float, ptr %40, align 4, !tbaa !9
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %"class.XMath::Vector3", ptr %42, i32 0, i32 0
  %44 = load float, ptr %43, align 4, !tbaa !9
  %45 = fsub float %41, %44
  %46 = getelementptr inbounds %"class.XMath::Vector3", ptr %10, i32 0, i32 0
  store float %45, ptr %46, align 4, !tbaa !9
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %"class.XMath::Vector3", ptr %47, i32 0, i32 1
  %49 = load float, ptr %48, align 4, !tbaa !12
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %"class.XMath::Vector3", ptr %50, i32 0, i32 1
  %52 = load float, ptr %51, align 4, !tbaa !12
  %53 = fsub float %49, %52
  %54 = getelementptr inbounds %"class.XMath::Vector3", ptr %10, i32 0, i32 1
  store float %53, ptr %54, align 4, !tbaa !12
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %"class.XMath::Vector3", ptr %55, i32 0, i32 2
  %57 = load float, ptr %56, align 4, !tbaa !13
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds %"class.XMath::Vector3", ptr %58, i32 0, i32 2
  %60 = load float, ptr %59, align 4, !tbaa !13
  %61 = fsub float %57, %60
  %62 = getelementptr inbounds %"class.XMath::Vector3", ptr %10, i32 0, i32 2
  store float %61, ptr %62, align 4, !tbaa !13
  store i1 false, ptr %13, align 1
  invoke void @_ZNK5XMath7Vector39unitCrossERKS0_(ptr dead_on_unwind writable sret(%"class.XMath::Vector3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(12) %9, ptr noundef nonnull align 4 dereferenceable(12) %10)
          to label %63 unwind label %69

63:                                               ; preds = %14
  store i1 true, ptr %13, align 1
  %64 = load i1, ptr %13, align 1
  br i1 %64, label %74, label %73

65:                                               ; preds = %4
  %66 = landingpad { ptr, i32 }
          cleanup
  %67 = extractvalue { ptr, i32 } %66, 0
  store ptr %67, ptr %11, align 8
  %68 = extractvalue { ptr, i32 } %66, 1
  store i32 %68, ptr %12, align 4
  br label %75

69:                                               ; preds = %14
  %70 = landingpad { ptr, i32 }
          cleanup
  %71 = extractvalue { ptr, i32 } %70, 0
  store ptr %71, ptr %11, align 8
  %72 = extractvalue { ptr, i32 } %70, 1
  store i32 %72, ptr %12, align 4
  call void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12) %10) #4
  br label %75

73:                                               ; preds = %63
  call void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12) %0) #4
  br label %74

74:                                               ; preds = %73, %63
  call void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12) %10) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #4
  call void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12) %9) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #4
  ret void

75:                                               ; preds = %69, %65
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #4
  call void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12) %9) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %9) #4
  br label %76

76:                                               ; preds = %75
  %77 = load ptr, ptr %11, align 8
  %78 = load i32, ptr %12, align 4
  %79 = insertvalue { ptr, i32 } poison, ptr %77, 0
  %80 = insertvalue { ptr, i32 } %79, i32 %78, 1
  resume { ptr, i32 } %80
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5XMath7Vector3C2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5XMath7Vector39unitCrossERKS0_(ptr dead_on_unwind noalias writable sret(%"class.XMath::Vector3") align 4, ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #2 align 2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 = !{!"_ZTSN5XMath7Vector3E", !11, i64 0, !11, i64 4, !11, i64 8}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!10, !11, i64 8}


; 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.XMath::Vector3" = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7XEngine8Geometry17computeFaceNormalERKN5XMath7Vector3ES4_S4_(ptr dead_on_unwind noalias writable sret(%"class.XMath::Vector3") align 4 %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %1, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %2, ptr nocapture noundef nonnull readonly align 4 dereferenceable(12) %3) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.XMath::Vector3", align 8
  %6 = alloca %"class.XMath::Vector3", align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5) #4
  call void @_ZN5XMath7Vector3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %5)
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #4
  call void @_ZN5XMath7Vector3C2Ev(ptr noundef nonnull align 4 dereferenceable(12) %6)
  %7 = load <2 x float>, ptr %2, align 4, !tbaa !5
  %8 = load <2 x float>, ptr %1, align 4, !tbaa !5
  %9 = fsub <2 x float> %7, %8
  store <2 x float> %9, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %2, i64 8
  %11 = load float, ptr %10, align 4, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load float, ptr %12, align 4, !tbaa !9
  %14 = fsub float %11, %13
  %15 = getelementptr inbounds i8, ptr %5, i64 8
  store float %14, ptr %15, align 8, !tbaa !9
  %16 = load <2 x float>, ptr %3, align 4, !tbaa !5
  %17 = fsub <2 x float> %16, %8
  store <2 x float> %17, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %3, i64 8
  %19 = load float, ptr %18, align 4, !tbaa !9
  %20 = fsub float %19, %13
  %21 = getelementptr inbounds i8, ptr %6, i64 8
  store float %20, ptr %21, align 8, !tbaa !9
  invoke void @_ZNK5XMath7Vector39unitCrossERKS0_(ptr dead_on_unwind writable sret(%"class.XMath::Vector3") align 4 %0, ptr noundef nonnull align 4 dereferenceable(12) %5, ptr noundef nonnull align 4 dereferenceable(12) %6)
          to label %24 unwind label %22

22:                                               ; preds = %4
  %23 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12) %6) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #4
  call void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12) %5) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #4
  resume { ptr, i32 } %23

24:                                               ; preds = %4
  call void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12) %6) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #4
  call void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12) %5) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5) #4
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5XMath7Vector3C2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #2 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5XMath7Vector3D2Ev(ptr noundef nonnull align 4 dereferenceable(12)) unnamed_addr #2 align 2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTSN5XMath7Vector3E", !6, i64 0, !6, i64 4, !6, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass