; LLVM IR from doyubkim/fluid-engine-dev :: src/jet/plane2.ll (ZNK3jet6Plane224closestIntersectionLocalERKNS_3RayIdLm2EEE)

; 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.jet::Vector" = type { double, double }
%"struct.jet::SurfaceRayIntersection2" = type { i8, double, %"class.jet::Vector", %"class.jet::Vector" }
%"class.jet::Ray" = type { %"class.jet::Vector", %"class.jet::Vector" }
%"class.jet::Plane2" = type { %"class.jet::Surface2.base", %"class.jet::Vector", %"class.jet::Vector" }
%"class.jet::Surface2.base" = type <{ ptr, %"class.jet::Transform2", i8 }>
%"class.jet::Transform2" = type { %"class.jet::Vector", double, double, double }

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3jetmiIdEENS_6VectorIT_Lm2EEERKS3_S5_(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3jet6VectorIdLm2EE3dotERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3jet6Plane224closestIntersectionLocalERKNS_3RayIdLm2EEE(ptr dead_on_unwind noalias writable sret(%"struct.jet::SurfaceRayIntersection2") align 8 %0, ptr noundef nonnull align 8 dereferenceable(88) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca %"class.jet::Vector", align 8
  %10 = alloca %"class.jet::Vector", align 8
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  call void @_ZN3jet23SurfaceRayIntersection2C2Ev(ptr noundef nonnull align 8 dereferenceable(48) %0)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = getelementptr inbounds %"class.jet::Ray", ptr %12, i32 0, i32 1
  %14 = getelementptr inbounds %"class.jet::Plane2", ptr %11, i32 0, i32 1
  %15 = call noundef double @_ZNK3jet6VectorIdLm2EE3dotERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(16) %14)
  store double %15, ptr %7, align 8, !tbaa !9
  %16 = load double, ptr %7, align 8, !tbaa !9
  %17 = call double @llvm.fabs.f64(double %16)
  %18 = fcmp ogt double %17, 0.000000e+00
  br i1 %18, label %19, label %41

19:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %20 = getelementptr inbounds %"class.jet::Plane2", ptr %11, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #5
  %21 = getelementptr inbounds %"class.jet::Plane2", ptr %11, i32 0, i32 2
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.jet::Ray", ptr %22, i32 0, i32 0
  call void @_ZN3jetmiIdEENS_6VectorIT_Lm2EEERKS3_S5_(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %9, ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 8 dereferenceable(16) %23)
  %24 = call noundef double @_ZNK3jet6VectorIdLm2EE3dotERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %20, ptr noundef nonnull align 8 dereferenceable(16) %9)
  %25 = load double, ptr %7, align 8, !tbaa !9
  %26 = fdiv double %24, %25
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #5
  store double %26, ptr %8, align 8, !tbaa !9
  %27 = load double, ptr %8, align 8, !tbaa !9
  %28 = fcmp oge double %27, 0.000000e+00
  br i1 %28, label %29, label %40

29:                                               ; preds = %19
  %30 = getelementptr inbounds %"struct.jet::SurfaceRayIntersection2", ptr %0, i32 0, i32 0
  store i8 1, ptr %30, align 8, !tbaa !11
  %31 = load double, ptr %8, align 8, !tbaa !9
  %32 = getelementptr inbounds %"struct.jet::SurfaceRayIntersection2", ptr %0, i32 0, i32 1
  store double %31, ptr %32, align 8, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #5
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load double, ptr %8, align 8, !tbaa !9
  call void @_ZNK3jet3RayIdLm2EE7pointAtEd(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %10, ptr noundef nonnull align 8 dereferenceable(32) %33, double noundef %34)
  %35 = getelementptr inbounds %"struct.jet::SurfaceRayIntersection2", ptr %0, i32 0, i32 2
  %36 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3jet6VectorIdLm2EEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %35, ptr noundef nonnull align 8 dereferenceable(16) %10)
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #5
  %37 = getelementptr inbounds %"class.jet::Plane2", ptr %11, i32 0, i32 1
  %38 = getelementptr inbounds %"struct.jet::SurfaceRayIntersection2", ptr %0, i32 0, i32 3
  %39 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3jet6VectorIdLm2EEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %38, ptr noundef nonnull align 8 dereferenceable(16) %37)
  br label %40

40:                                               ; preds = %29, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %41

41:                                               ; preds = %40, %3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3jet23SurfaceRayIntersection2C2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3jet3RayIdLm2EE7pointAtEd(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, ptr noundef nonnull align 8 dereferenceable(32), double noundef) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN3jet6VectorIdLm2EEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #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 = !{!"double", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN3jet23SurfaceRayIntersection2E", !13, i64 0, !10, i64 8, !14, i64 16, !14, i64 32}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN3jet6VectorIdLm2EEE", !10, i64 0, !10, i64 8}
!15 = !{!12, !10, 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.jet::Vector" = type { double, double }
%"struct.jet::SurfaceRayIntersection2" = type { i8, double, %"class.jet::Vector", %"class.jet::Vector" }

; 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 uwtable
declare dso_local void @_ZN3jetmiIdEENS_6VectorIT_Lm2EEERKS3_S5_(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3jet6VectorIdLm2EE3dotERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_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) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3jet6Plane224closestIntersectionLocalERKNS_3RayIdLm2EEE(ptr dead_on_unwind noalias nonnull writable sret(%"struct.jet::SurfaceRayIntersection2") align 8 %0, ptr noundef nonnull align 8 dereferenceable(88) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) unnamed_addr #1 align 2 {
  %4 = alloca %"class.jet::Vector", align 8
  %5 = alloca %"class.jet::Vector", align 8
  tail call void @_ZN3jet23SurfaceRayIntersection2C2Ev(ptr noundef nonnull align 8 dereferenceable(48) %0)
  %6 = getelementptr inbounds i8, ptr %2, i64 16
  %7 = getelementptr inbounds i8, ptr %1, i64 56
  %8 = tail call noundef double @_ZNK3jet6VectorIdLm2EE3dotERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(16) %7)
  %9 = fcmp ueq double %8, 0.000000e+00
  br i1 %9, label %21, label %10

10:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  %11 = getelementptr inbounds i8, ptr %1, i64 72
  call void @_ZN3jetmiIdEENS_6VectorIT_Lm2EEERKS3_S5_(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %4, ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(16) %2)
  %12 = call noundef double @_ZNK3jet6VectorIdLm2EE3dotERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 8 dereferenceable(16) %4)
  %13 = fdiv double %12, %8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  %14 = fcmp ult double %13, 0.000000e+00
  br i1 %14, label %21, label %15

15:                                               ; preds = %10
  store i8 1, ptr %0, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  store double %13, ptr %16, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @_ZNK3jet3RayIdLm2EE7pointAtEd(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %5, ptr noundef nonnull align 8 dereferenceable(32) %2, double noundef %13)
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  %18 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3jet6VectorIdLm2EEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 8 dereferenceable(16) %5)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  %19 = getelementptr inbounds i8, ptr %0, i64 32
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3jet6VectorIdLm2EEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %19, ptr noundef nonnull align 8 dereferenceable(16) %7)
  br label %21

21:                                               ; preds = %10, %15, %3
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN3jet23SurfaceRayIntersection2C2Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3jet3RayIdLm2EE7pointAtEd(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, ptr noundef nonnull align 8 dereferenceable(32), double noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZN3jet6VectorIdLm2EEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

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 = { 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, !7, i64 0}
!6 = !{!"_ZTSN3jet23SurfaceRayIntersection2E", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 32}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"_ZTSN3jet6VectorIdLm2EEE", !10, i64 0, !10, i64 8}
!12 = !{!6, !10, i64 8}


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