; LLVM IR from doyubkim/fluid-engine-dev :: src/jet (custom_implicit_surface2)

; 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::BoundingBoxRayIntersection2" = type { i8, double, double }
%"struct.jet::SurfaceRayIntersection2" = type { i8, double, %"class.jet::Vector", %"class.jet::Vector" }
%"class.jet::CustomImplicitSurface2" = type <{ %"class.jet::ImplicitSurface2.base", [7 x i8], %"class.std::function", %"class.jet::BoundingBox", double, double, i32, [4 x i8] }>
%"class.jet::ImplicitSurface2.base" = type { %"class.jet::Surface2.base" }
%"class.jet::Surface2.base" = type <{ ptr, %"class.jet::Transform2", i8 }>
%"class.jet::Transform2" = type { %"class.jet::Vector", double, double, double }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%"class.jet::BoundingBox" = type { %"class.jet::Vector", %"class.jet::Vector" }

; 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 speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3jet22CustomImplicitSurface213gradientLocalERKNS_6VectorIdLm2EEE(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, ptr noundef nonnull align 8 dereferenceable(144), ptr noundef nonnull align 8 dereferenceable(16)) #2 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)) #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: mustprogress uwtable
declare dso_local void @_ZNK3jet11BoundingBoxIdLm2EE19closestIntersectionERKNS_3RayIdLm2EEE(ptr dead_on_unwind noalias writable sret(%"struct.jet::BoundingBoxRayIntersection2") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #2 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) #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3jet22CustomImplicitSurface224closestIntersectionLocalERKNS_3RayIdLm2EEE(ptr dead_on_unwind noalias writable sret(%"struct.jet::SurfaceRayIntersection2") align 8 %0, ptr noundef nonnull align 8 dereferenceable(144) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) unnamed_addr #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.jet::BoundingBoxRayIntersection2", align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca %"class.jet::Vector", align 8
  %13 = alloca double, align 8
  %14 = alloca %"class.jet::Vector", align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  %19 = alloca %"class.jet::Vector", align 8
  %20 = alloca %"class.jet::Vector", align 8
  %21 = alloca i32, align 4
  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
  %22 = load ptr, ptr %5, align 8
  call void @_ZN3jet23SurfaceRayIntersection2C2Ev(ptr noundef nonnull align 8 dereferenceable(48) %0)
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #6
  %23 = getelementptr inbounds %"class.jet::CustomImplicitSurface2", ptr %22, i32 0, i32 3
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZNK3jet11BoundingBoxIdLm2EE19closestIntersectionERKNS_3RayIdLm2EEE(ptr dead_on_unwind writable sret(%"struct.jet::BoundingBoxRayIntersection2") align 8 %7, ptr noundef nonnull align 8 dereferenceable(32) %23, ptr noundef nonnull align 8 dereferenceable(32) %24)
  %25 = getelementptr inbounds %"struct.jet::BoundingBoxRayIntersection2", ptr %7, i32 0, i32 0
  %26 = load i8, ptr %25, align 8, !tbaa !9, !range !13, !noundef !14
  %27 = trunc i8 %26 to i1
  br i1 %27, label %28, label %105

28:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %29 = getelementptr inbounds %"struct.jet::BoundingBoxRayIntersection2", ptr %7, i32 0, i32 2
  %30 = load double, ptr %29, align 8, !tbaa !15
  %31 = fcmp oeq double %30, 0x7FEFFFFFFFFFFFFF
  br i1 %31, label %32, label %35

32:                                               ; preds = %28
  store double 0.000000e+00, ptr %8, align 8, !tbaa !16
  %33 = getelementptr inbounds %"struct.jet::BoundingBoxRayIntersection2", ptr %7, i32 0, i32 1
  %34 = load double, ptr %33, align 8, !tbaa !17
  store double %34, ptr %9, align 8, !tbaa !16
  br label %40

35:                                               ; preds = %28
  %36 = getelementptr inbounds %"struct.jet::BoundingBoxRayIntersection2", ptr %7, i32 0, i32 1
  %37 = load double, ptr %36, align 8, !tbaa !17
  store double %37, ptr %8, align 8, !tbaa !16
  %38 = getelementptr inbounds %"struct.jet::BoundingBoxRayIntersection2", ptr %7, i32 0, i32 2
  %39 = load double, ptr %38, align 8, !tbaa !15
  store double %39, ptr %9, align 8, !tbaa !16
  br label %40

40:                                               ; preds = %35, %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %41 = load double, ptr %8, align 8, !tbaa !16
  store double %41, ptr %10, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %42 = load double, ptr %10, align 8, !tbaa !16
  store double %42, ptr %11, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #6
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load double, ptr %10, align 8, !tbaa !16
  call void @_ZNK3jet3RayIdLm2EE7pointAtEd(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %12, ptr noundef nonnull align 8 dereferenceable(32) %43, double noundef %44)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %45 = getelementptr inbounds %"class.jet::CustomImplicitSurface2", ptr %22, i32 0, i32 2
  %46 = call noundef double @_ZNKSt8functionIFdRKN3jet6VectorIdLm2EEEEEclES4_(ptr noundef nonnull align 8 dereferenceable(32) %45, ptr noundef nonnull align 8 dereferenceable(16) %12)
  store double %46, ptr %13, align 8, !tbaa !16
  br label %47

47:                                               ; preds = %100, %40
  %48 = load double, ptr %10, align 8, !tbaa !16
  %49 = load double, ptr %9, align 8, !tbaa !16
  %50 = fcmp ole double %48, %49
  br i1 %50, label %51, label %101

51:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #6
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = load double, ptr %10, align 8, !tbaa !16
  call void @_ZNK3jet3RayIdLm2EE7pointAtEd(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %14, ptr noundef nonnull align 8 dereferenceable(32) %52, double noundef %53)
  %54 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3jet6VectorIdLm2EEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 8 dereferenceable(16) %14)
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %55 = getelementptr inbounds %"class.jet::CustomImplicitSurface2", ptr %22, i32 0, i32 2
  %56 = call noundef double @_ZNKSt8functionIFdRKN3jet6VectorIdLm2EEEEEclES4_(ptr noundef nonnull align 8 dereferenceable(32) %55, ptr noundef nonnull align 8 dereferenceable(16) %12)
  store double %56, ptr %15, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %57 = load double, ptr %15, align 8, !tbaa !16
  %58 = call double @llvm.fabs.f64(double %57)
  store double %58, ptr %16, align 8, !tbaa !16
  %59 = load double, ptr %15, align 8, !tbaa !16
  %60 = load double, ptr %13, align 8, !tbaa !16
  %61 = fmul double %59, %60
  %62 = fcmp olt double %61, 0.000000e+00
  br i1 %62, label %63, label %90

63:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %64 = load double, ptr %13, align 8, !tbaa !16
  %65 = load double, ptr %13, align 8, !tbaa !16
  %66 = load double, ptr %15, align 8, !tbaa !16
  %67 = fsub double %65, %66
  %68 = fdiv double %64, %67
  store double %68, ptr %17, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %69 = load double, ptr %11, align 8, !tbaa !16
  %70 = getelementptr inbounds %"class.jet::CustomImplicitSurface2", ptr %22, i32 0, i32 5
  %71 = load double, ptr %70, align 8, !tbaa !18
  %72 = load double, ptr %17, align 8, !tbaa !16
  %73 = call double @llvm.fmuladd.f64(double %71, double %72, double %69)
  store double %73, ptr %18, align 8, !tbaa !16
  %74 = getelementptr inbounds %"struct.jet::SurfaceRayIntersection2", ptr %0, i32 0, i32 0
  store i8 1, ptr %74, align 8, !tbaa !28
  %75 = load double, ptr %18, align 8, !tbaa !16
  %76 = getelementptr inbounds %"struct.jet::SurfaceRayIntersection2", ptr %0, i32 0, i32 1
  store double %75, ptr %76, align 8, !tbaa !30
  call void @llvm.lifetime.start.p0(i64 16, ptr %19) #6
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = load double, ptr %18, align 8, !tbaa !16
  call void @_ZNK3jet3RayIdLm2EE7pointAtEd(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %19, ptr noundef nonnull align 8 dereferenceable(32) %77, double noundef %78)
  %79 = getelementptr inbounds %"struct.jet::SurfaceRayIntersection2", ptr %0, i32 0, i32 2
  %80 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3jet6VectorIdLm2EEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %79, ptr noundef nonnull align 8 dereferenceable(16) %19)
  call void @llvm.lifetime.end.p0(i64 16, ptr %19) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %20) #6
  %81 = getelementptr inbounds %"struct.jet::SurfaceRayIntersection2", ptr %0, i32 0, i32 2
  call void @_ZNK3jet22CustomImplicitSurface213gradientLocalERKNS_6VectorIdLm2EEE(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %20, ptr noundef nonnull align 8 dereferenceable(144) %22, ptr noundef nonnull align 8 dereferenceable(16) %81)
  %82 = getelementptr inbounds %"struct.jet::SurfaceRayIntersection2", ptr %0, i32 0, i32 3
  %83 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3jet6VectorIdLm2EEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %82, ptr noundef nonnull align 8 dereferenceable(16) %20)
  call void @llvm.lifetime.end.p0(i64 16, ptr %20) #6
  %84 = getelementptr inbounds %"struct.jet::SurfaceRayIntersection2", ptr %0, i32 0, i32 3
  %85 = call noundef double @_ZNK3jet6VectorIdLm2EE6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %84)
  %86 = fcmp ogt double %85, 0.000000e+00
  br i1 %86, label %87, label %89

87:                                               ; preds = %63
  %88 = getelementptr inbounds %"struct.jet::SurfaceRayIntersection2", ptr %0, i32 0, i32 3
  call void @_ZN3jet6VectorIdLm2EE9normalizeEv(ptr noundef nonnull align 8 dereferenceable(16) %88)
  br label %89

89:                                               ; preds = %87, %63
  store i32 1, ptr %21, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  br label %98

90:                                               ; preds = %51
  %91 = load double, ptr %10, align 8, !tbaa !16
  store double %91, ptr %11, align 8, !tbaa !16
  %92 = getelementptr inbounds %"class.jet::CustomImplicitSurface2", ptr %22, i32 0, i32 5
  %93 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef nonnull align 8 dereferenceable(8) %92)
  %94 = load double, ptr %93, align 8, !tbaa !16
  %95 = load double, ptr %10, align 8, !tbaa !16
  %96 = fadd double %95, %94
  store double %96, ptr %10, align 8, !tbaa !16
  %97 = load double, ptr %15, align 8, !tbaa !16
  store double %97, ptr %13, align 8, !tbaa !16
  store i32 0, ptr %21, align 4
  br label %98

98:                                               ; preds = %90, %89
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  %99 = load i32, ptr %21, align 4
  switch i32 %99, label %102 [
    i32 0, label %100
  ]

100:                                              ; preds = %98
  br label %47, !llvm.loop !31

101:                                              ; preds = %47
  store i32 0, ptr %21, align 4
  br label %102

102:                                              ; preds = %101, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  %103 = load i32, ptr %21, align 4
  switch i32 %103, label %106 [
    i32 0, label %104
  ]

104:                                              ; preds = %102
  br label %105

105:                                              ; preds = %104, %3
  store i32 1, ptr %21, align 4
  br label %106

106:                                              ; preds = %105, %102
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #6
  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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3jet6VectorIdLm2EE9normalizeEv(ptr noundef nonnull align 8 dereferenceable(16)) #5 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { 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 #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 = { 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 #6 = { 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 = !{!"_ZTSN3jet27BoundingBoxRayIntersection2IdEE", !11, i64 0, !12, i64 8, !12, i64 16}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!10, !12, i64 16}
!16 = !{!12, !12, i64 0}
!17 = !{!10, !12, i64 8}
!18 = !{!19, !12, i64 128}
!19 = !{!"_ZTSN3jet22CustomImplicitSurface2E", !20, i64 0, !24, i64 56, !26, i64 88, !12, i64 120, !12, i64 128, !27, i64 136}
!20 = !{!"_ZTSN3jet16ImplicitSurface2E", !21, i64 0}
!21 = !{!"_ZTSN3jet8Surface2E", !22, i64 8, !11, i64 48}
!22 = !{!"_ZTSN3jet10Transform2E", !23, i64 0, !12, i64 16, !12, i64 24, !12, i64 32}
!23 = !{!"_ZTSN3jet6VectorIdLm2EEE", !12, i64 0, !12, i64 8}
!24 = !{!"_ZTSSt8functionIFdRKN3jet6VectorIdLm2EEEEE", !25, i64 0, !6, i64 24}
!25 = !{!"_ZTSSt14_Function_base", !7, i64 0, !6, i64 16}
!26 = !{!"_ZTSN3jet11BoundingBoxIdLm2EEE", !23, i64 0, !23, i64 16}
!27 = !{!"int", !7, i64 0}
!28 = !{!29, !11, i64 0}
!29 = !{!"_ZTSN3jet23SurfaceRayIntersection2E", !11, i64 0, !12, i64 8, !23, i64 16, !23, i64 32}
!30 = !{!29, !12, i64 8}
!31 = distinct !{!31, !32}
!32 = !{!"llvm.loop.mustprogress"}


; 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::BoundingBoxRayIntersection2" = type { i8, 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3jet22CustomImplicitSurface213gradientLocalERKNS_6VectorIdLm2EEE(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, ptr noundef nonnull align 8 dereferenceable(144), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 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 #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
declare dso_local void @_ZNK3jet11BoundingBoxIdLm2EE19closestIntersectionERKNS_3RayIdLm2EEE(ptr dead_on_unwind noalias writable sret(%"struct.jet::BoundingBoxRayIntersection2") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 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 #2 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3jet22CustomImplicitSurface224closestIntersectionLocalERKNS_3RayIdLm2EEE(ptr dead_on_unwind noalias nonnull writable sret(%"struct.jet::SurfaceRayIntersection2") align 8 %0, ptr noundef nonnull align 8 dereferenceable(144) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) unnamed_addr #2 align 2 {
  %4 = alloca %"struct.jet::BoundingBoxRayIntersection2", align 8
  %5 = alloca %"class.jet::Vector", align 8
  %6 = alloca %"class.jet::Vector", align 8
  %7 = alloca double, align 8
  %8 = alloca %"class.jet::Vector", align 8
  %9 = alloca %"class.jet::Vector", align 8
  tail call void @_ZN3jet23SurfaceRayIntersection2C2Ev(ptr noundef nonnull align 8 dereferenceable(48) %0)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #6
  %10 = getelementptr inbounds i8, ptr %1, i64 88
  call void @_ZNK3jet11BoundingBoxIdLm2EE19closestIntersectionERKNS_3RayIdLm2EEE(ptr dead_on_unwind nonnull writable sret(%"struct.jet::BoundingBoxRayIntersection2") align 8 %4, ptr noundef nonnull align 8 dereferenceable(32) %10, ptr noundef nonnull align 8 dereferenceable(32) %2)
  %11 = load i8, ptr %4, align 8, !tbaa !5, !range !11, !noundef !12
  %12 = trunc nuw i8 %11 to i1
  br i1 %12, label %13, label %52

13:                                               ; preds = %3
  %14 = getelementptr inbounds i8, ptr %4, i64 16
  %15 = load double, ptr %14, align 8, !tbaa !13
  %16 = fcmp oeq double %15, 0x7FEFFFFFFFFFFFFF
  %17 = getelementptr inbounds i8, ptr %4, i64 8
  %18 = load double, ptr %17, align 8
  %.027 = select i1 %16, double %18, double %15
  %.026 = select i1 %16, double 0.000000e+00, double %18
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #6
  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 %.026)
  %19 = getelementptr inbounds i8, ptr %1, i64 56
  %20 = call noundef double @_ZNKSt8functionIFdRKN3jet6VectorIdLm2EEEEEclES4_(ptr noundef nonnull align 8 dereferenceable(32) %19, ptr noundef nonnull align 8 dereferenceable(16) %5)
  %21 = fcmp ugt double %.026, %.027
  br i1 %21, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %13
  %22 = getelementptr inbounds i8, ptr %1, i64 128
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #6
  call void @_ZNK3jet3RayIdLm2EE7pointAtEd(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %6, ptr noundef nonnull align 8 dereferenceable(32) %2, double noundef %.026)
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3jet6VectorIdLm2EEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %6)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #6
  %24 = call noundef double @_ZNKSt8functionIFdRKN3jet6VectorIdLm2EEEEEclES4_(ptr noundef nonnull align 8 dereferenceable(32) %19, ptr noundef nonnull align 8 dereferenceable(16) %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  %25 = call double @llvm.fabs.f64(double %24)
  store double %25, ptr %7, align 8, !tbaa !14
  %26 = fmul double %20, %24
  %27 = fcmp uge double %26, 0.000000e+00
  br i1 %27, label %.lr.ph53, label %._crit_edge

28:                                               ; preds = %.lr.ph53
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #6
  call void @_ZNK3jet3RayIdLm2EE7pointAtEd(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %6, ptr noundef nonnull align 8 dereferenceable(32) %2, double noundef %49)
  %29 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3jet6VectorIdLm2EEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %6)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #6
  %30 = call noundef double @_ZNKSt8functionIFdRKN3jet6VectorIdLm2EEEEEclES4_(ptr noundef nonnull align 8 dereferenceable(32) %19, ptr noundef nonnull align 8 dereferenceable(16) %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #6
  %31 = call double @llvm.fabs.f64(double %30)
  store double %31, ptr %7, align 8, !tbaa !14
  %32 = fmul double %46, %30
  %33 = fcmp uge double %32, 0.000000e+00
  br i1 %33, label %.lr.ph53, label %._crit_edge

._crit_edge:                                      ; preds = %28, %.lr.ph
  %.03041.lcssa = phi double [ %20, %.lr.ph ], [ %46, %28 ]
  %.03240.lcssa = phi double [ %.026, %.lr.ph ], [ %.0284252, %28 ]
  %.lcssa = phi double [ %24, %.lr.ph ], [ %30, %28 ]
  %34 = fsub double %.03041.lcssa, %.lcssa
  %35 = fdiv double %.03041.lcssa, %34
  %36 = load double, ptr %22, align 8, !tbaa !15
  %37 = call double @llvm.fmuladd.f64(double %36, double %35, double %.03240.lcssa)
  store i8 1, ptr %0, align 8, !tbaa !26
  %38 = getelementptr inbounds i8, ptr %0, i64 8
  store double %37, ptr %38, align 8, !tbaa !28
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #6
  call void @_ZNK3jet3RayIdLm2EE7pointAtEd(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %8, ptr noundef nonnull align 8 dereferenceable(32) %2, double noundef %37)
  %39 = getelementptr inbounds i8, ptr %0, i64 16
  %40 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3jet6VectorIdLm2EEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %39, ptr noundef nonnull align 8 dereferenceable(16) %8)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %9) #6
  call void @_ZNK3jet22CustomImplicitSurface213gradientLocalERKNS_6VectorIdLm2EEE(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %9, ptr noundef nonnull align 8 dereferenceable(144) %1, ptr noundef nonnull align 8 dereferenceable(16) %39)
  %41 = getelementptr inbounds i8, ptr %0, i64 32
  %42 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZN3jet6VectorIdLm2EEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %41, ptr noundef nonnull align 8 dereferenceable(16) %9)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %9) #6
  %43 = call noundef double @_ZNK3jet6VectorIdLm2EE6lengthEv(ptr noundef nonnull align 8 dereferenceable(16) %41)
  %44 = fcmp ogt double %43, 0.000000e+00
  br i1 %44, label %45, label %51

45:                                               ; preds = %._crit_edge
  call void @_ZN3jet6VectorIdLm2EE9normalizeEv(ptr noundef nonnull align 8 dereferenceable(16) %41)
  br label %51

.lr.ph53:                                         ; preds = %.lr.ph, %28
  %46 = phi double [ %30, %28 ], [ %24, %.lr.ph ]
  %.0284252 = phi double [ %49, %28 ], [ %.026, %.lr.ph ]
  %47 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %22)
  %48 = load double, ptr %47, align 8, !tbaa !14
  %49 = fadd double %.0284252, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  %50 = fcmp ugt double %49, %.027
  br i1 %50, label %.critedge, label %28

51:                                               ; preds = %._crit_edge, %45
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  br label %52

.critedge:                                        ; preds = %.lr.ph53, %13
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  br label %52

52:                                               ; preds = %51, %3, %.critedge
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3jet6VectorIdLm2EE9normalizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #5 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { 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 #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 = { 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 #6 = { 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 = !{!"_ZTSN3jet27BoundingBoxRayIntersection2IdEE", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!6, !10, i64 16}
!14 = !{!10, !10, i64 0}
!15 = !{!16, !10, i64 128}
!16 = !{!"_ZTSN3jet22CustomImplicitSurface2E", !17, i64 0, !21, i64 56, !24, i64 88, !10, i64 120, !10, i64 128, !25, i64 136}
!17 = !{!"_ZTSN3jet16ImplicitSurface2E", !18, i64 0}
!18 = !{!"_ZTSN3jet8Surface2E", !19, i64 8, !7, i64 48}
!19 = !{!"_ZTSN3jet10Transform2E", !20, i64 0, !10, i64 16, !10, i64 24, !10, i64 32}
!20 = !{!"_ZTSN3jet6VectorIdLm2EEE", !10, i64 0, !10, i64 8}
!21 = !{!"_ZTSSt8functionIFdRKN3jet6VectorIdLm2EEEEE", !22, i64 0, !23, i64 24}
!22 = !{!"_ZTSSt14_Function_base", !8, i64 0, !23, i64 16}
!23 = !{!"any pointer", !8, i64 0}
!24 = !{!"_ZTSN3jet11BoundingBoxIdLm2EEE", !20, i64 0, !20, i64 16}
!25 = !{!"int", !8, i64 0}
!26 = !{!27, !7, i64 0}
!27 = !{!"_ZTSN3jet23SurfaceRayIntersection2E", !7, i64 0, !10, i64 8, !20, i64 16, !20, i64 32}
!28 = !{!27, !10, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass