; LLVM IR from yangfengzzz/Arche-webgpu :: vox.geometry (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.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"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.anon = type { i8 }
%"class.vox::CustomImplicitSurface2::Builder" = type <{ %"class.vox::SurfaceBuilderBase2", %"class.std::function", %"struct.vox::BoundingBox", double, double, i32, [4 x i8] }>
%"class.vox::SurfaceBuilderBase2" = type { i8, %"class.vox::Transform2" }
%"class.vox::Transform2" = type { %"struct.vox::Vector", double, double, double }
%"struct.vox::Vector" = type { double, double }
%"struct.vox::BoundingBox" = type { %"struct.vox::Point", %"struct.vox::Point" }
%"struct.vox::Point" = type { double, double }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt8functionIFdRKN3vox5PointIdLm2EEEEEC2ERKS6_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3vox22CustomImplicitSurface27Builder10makeSharedEv(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr") align 8 %0, ptr noundef nonnull align 8 dereferenceable(136) %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.std::function", align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i1, align 1
  %9 = alloca %class.anon, align 1
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %4, align 8
  %11 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 144) #4
  store i1 true, ptr %8, align 1
  %12 = getelementptr inbounds %"class.vox::CustomImplicitSurface2::Builder", ptr %10, i32 0, i32 1
  invoke void @_ZNSt8functionIFdRKN3vox5PointIdLm2EEEEEC2ERKS6_(ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef nonnull align 8 dereferenceable(32) %12)
          to label %13 unwind label %27

13:                                               ; preds = %2
  %14 = getelementptr inbounds %"class.vox::CustomImplicitSurface2::Builder", ptr %10, i32 0, i32 2
  %15 = getelementptr inbounds %"class.vox::CustomImplicitSurface2::Builder", ptr %10, i32 0, i32 3
  %16 = load double, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %"class.vox::CustomImplicitSurface2::Builder", ptr %10, i32 0, i32 4
  %18 = load double, ptr %17, align 8, !tbaa !21
  %19 = getelementptr inbounds %"class.vox::CustomImplicitSurface2::Builder", ptr %10, i32 0, i32 5
  %20 = load i32, ptr %19, align 8, !tbaa !22
  %21 = getelementptr inbounds %"class.vox::SurfaceBuilderBase2", ptr %10, i32 0, i32 1
  %22 = getelementptr inbounds %"class.vox::SurfaceBuilderBase2", ptr %10, i32 0, i32 0
  %23 = load i8, ptr %22, align 8, !tbaa !23, !range !24, !noundef !25
  %24 = trunc i8 %23 to i1
  invoke void @_ZN3vox22CustomImplicitSurface2C1ESt8functionIFdRKNS_5PointIdLm2EEEEERKNS_11BoundingBoxIdLm2EEEddjRKNS_10Transform2IdEEb(ptr noundef nonnull align 8 dereferenceable(144) %11, ptr noundef %5, ptr noundef nonnull align 8 dereferenceable(32) %14, double noundef %16, double noundef %18, i32 noundef %20, ptr noundef nonnull align 8 dereferenceable(40) %21, i1 noundef zeroext %24)
          to label %25 unwind label %31

25:                                               ; preds = %13
  store i1 false, ptr %8, align 1
  invoke void @"_ZNSt10shared_ptrIN3vox22CustomImplicitSurface2EEC2IS1_ZNKS1_7Builder10makeSharedEvE3$_0vEEPT_T0_"(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %11)
          to label %26 unwind label %31

26:                                               ; preds = %25
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #5
  ret void

27:                                               ; preds = %2
  %28 = landingpad { ptr, i32 }
          cleanup
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %6, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %7, align 4
  br label %35

31:                                               ; preds = %25, %13
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %6, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %7, align 4
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #5
  br label %35

35:                                               ; preds = %31, %27
  %36 = load i1, ptr %8, align 1
  br i1 %36, label %37, label %38

37:                                               ; preds = %35
  call void @_ZdlPvm(ptr noundef %11, i64 noundef 144) #6
  br label %38

38:                                               ; preds = %37, %35
  br label %39

39:                                               ; preds = %38
  %40 = load ptr, ptr %6, align 8
  %41 = load i32, ptr %7, align 4
  %42 = insertvalue { ptr, i32 } poison, ptr %40, 0
  %43 = insertvalue { ptr, i32 } %42, i32 %41, 1
  resume { ptr, i32 } %43
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #3

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZNSt10shared_ptrIN3vox22CustomImplicitSurface2EEC2IS1_ZNKS1_7Builder10makeSharedEvE3$_0vEEPT_T0_"(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #2 align 2

declare void @_ZN3vox22CustomImplicitSurface2C1ESt8functionIFdRKNS_5PointIdLm2EEEEERKNS_11BoundingBoxIdLm2EEEddjRKNS_10Transform2IdEEb(ptr, ptr, ptr, double, double, i32, ptr, i1)

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 = { nobuiltin nounwind "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 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 = { nobuiltin allocsize(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 = { builtin allocsize(0) }
attributes #5 = { nounwind }
attributes #6 = { builtin 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, !15, i64 112}
!10 = !{!"_ZTSN3vox22CustomImplicitSurface27BuilderE", !11, i64 0, !16, i64 48, !18, i64 80, !15, i64 112, !15, i64 120, !20, i64 128}
!11 = !{!"_ZTSN3vox19SurfaceBuilderBase2INS_22CustomImplicitSurface27BuilderEEE", !12, i64 0, !13, i64 8}
!12 = !{!"bool", !7, i64 0}
!13 = !{!"_ZTSN3vox10Transform2IdEE", !14, i64 0, !15, i64 16, !15, i64 24, !15, i64 32}
!14 = !{!"_ZTSN3vox6VectorIdLm2EEE", !15, i64 0, !15, i64 8}
!15 = !{!"double", !7, i64 0}
!16 = !{!"_ZTSSt8functionIFdRKN3vox5PointIdLm2EEEEE", !17, i64 0, !6, i64 24}
!17 = !{!"_ZTSSt14_Function_base", !7, i64 0, !6, i64 16}
!18 = !{!"_ZTSN3vox11BoundingBoxIdLm2EEE", !19, i64 0, !19, i64 16}
!19 = !{!"_ZTSN3vox5PointIdLm2EEE", !15, i64 0, !15, i64 8}
!20 = !{!"int", !7, i64 0}
!21 = !{!10, !15, i64 120}
!22 = !{!10, !20, i64 128}
!23 = !{!11, !12, i64 0}
!24 = !{i8 0, i8 2}
!25 = !{}


; 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.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"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 } }

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #0 align 2

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt8functionIFdRKN3vox5PointIdLm2EEEEEC2ERKS6_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3vox22CustomImplicitSurface27Builder10makeSharedEv(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr") align 8 %0, ptr noundef nonnull align 8 dereferenceable(136) %1) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.std::function", align 8
  %4 = tail call noalias noundef nonnull dereferenceable(144) ptr @_Znwm(i64 noundef 144) #4
  %5 = getelementptr inbounds i8, ptr %1, i64 48
  invoke void @_ZNSt8functionIFdRKN3vox5PointIdLm2EEEEEC2ERKS6_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 8 dereferenceable(32) %5)
          to label %6 unwind label %.thread

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %1, i64 80
  %8 = getelementptr inbounds i8, ptr %1, i64 112
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 120
  %11 = load double, ptr %10, align 8, !tbaa !20
  %12 = getelementptr inbounds i8, ptr %1, i64 128
  %13 = load i32, ptr %12, align 8, !tbaa !21
  %14 = getelementptr inbounds i8, ptr %1, i64 8
  %15 = load i8, ptr %1, align 8, !tbaa !22, !range !23, !noundef !24
  %16 = trunc nuw i8 %15 to i1
  invoke void @_ZN3vox22CustomImplicitSurface2C1ESt8functionIFdRKNS_5PointIdLm2EEEEERKNS_11BoundingBoxIdLm2EEEddjRKNS_10Transform2IdEEb(ptr noundef nonnull align 8 dereferenceable(144) %4, ptr noundef nonnull %3, ptr noundef nonnull align 8 dereferenceable(32) %7, double noundef %9, double noundef %11, i32 noundef %13, ptr noundef nonnull align 8 dereferenceable(40) %14, i1 noundef zeroext %16)
          to label %18 unwind label %.thread10

.thread10:                                        ; preds = %6
  %17 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  br label %23

18:                                               ; preds = %6
  invoke void @"_ZNSt10shared_ptrIN3vox22CustomImplicitSurface2EEC2IS1_ZNKS1_7Builder10makeSharedEvE3$_0vEEPT_T0_"(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %4)
          to label %19 unwind label %21

19:                                               ; preds = %18
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  ret void

.thread:                                          ; preds = %2
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %23

21:                                               ; preds = %18
  %22 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  br label %24

23:                                               ; preds = %.thread10, %.thread
  %.pn9 = phi { ptr, i32 } [ %20, %.thread ], [ %17, %.thread10 ]
  call void @_ZdlPvm(ptr noundef nonnull %4, i64 noundef 144) #6
  br label %24

24:                                               ; preds = %21, %23
  %.pn8 = phi { ptr, i32 } [ %22, %21 ], [ %.pn9, %23 ]
  resume { ptr, i32 } %.pn8
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZNSt10shared_ptrIN3vox22CustomImplicitSurface2EEC2IS1_ZNKS1_7Builder10makeSharedEvE3$_0vEEPT_T0_"(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #2 align 2

declare void @_ZN3vox22CustomImplicitSurface2C1ESt8functionIFdRKNS_5PointIdLm2EEEEERKNS_11BoundingBoxIdLm2EEEddjRKNS_10Transform2IdEEb(ptr, ptr, ptr, double, double, i32, ptr, i1) local_unnamed_addr

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 = { nobuiltin nounwind "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 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 = { nobuiltin allocsize(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 = { builtin allocsize(0) }
attributes #5 = { nounwind }
attributes #6 = { builtin 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, !13, i64 112}
!6 = !{!"_ZTSN3vox22CustomImplicitSurface27BuilderE", !7, i64 0, !14, i64 48, !17, i64 80, !13, i64 112, !13, i64 120, !19, i64 128}
!7 = !{!"_ZTSN3vox19SurfaceBuilderBase2INS_22CustomImplicitSurface27BuilderEEE", !8, i64 0, !11, i64 8}
!8 = !{!"bool", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN3vox10Transform2IdEE", !12, i64 0, !13, i64 16, !13, i64 24, !13, i64 32}
!12 = !{!"_ZTSN3vox6VectorIdLm2EEE", !13, i64 0, !13, i64 8}
!13 = !{!"double", !9, i64 0}
!14 = !{!"_ZTSSt8functionIFdRKN3vox5PointIdLm2EEEEE", !15, i64 0, !16, i64 24}
!15 = !{!"_ZTSSt14_Function_base", !9, i64 0, !16, i64 16}
!16 = !{!"any pointer", !9, i64 0}
!17 = !{!"_ZTSN3vox11BoundingBoxIdLm2EEE", !18, i64 0, !18, i64 16}
!18 = !{!"_ZTSN3vox5PointIdLm2EEE", !13, i64 0, !13, i64 8}
!19 = !{!"int", !9, i64 0}
!20 = !{!6, !13, i64 120}
!21 = !{!6, !19, i64 128}
!22 = !{!7, !8, i64 0}
!23 = !{i8 0, i8 2}
!24 = !{}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass