; LLVM IR from Razakhel/RaZ :: extern/fastgltf/src (fastgltf)

; 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.fastgltf::Expected.501" = type { i64, %"struct.fastgltf::ExportResult.502" }
%"struct.fastgltf::ExportResult.502" = type { %"class.std::vector.503", %"class.std::vector.461", %"class.std::vector.461" }
%"class.std::vector.503" = type { %"struct.std::_Vector_base.504" }
%"struct.std::_Vector_base.504" = type { %"struct.std::_Vector_base<std::byte, std::allocator<std::byte>>::_Vector_impl" }
%"struct.std::_Vector_base<std::byte, std::allocator<std::byte>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::byte, std::allocator<std::byte>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::byte, std::allocator<std::byte>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.461" = type { %"struct.std::_Vector_base.462" }
%"struct.std::_Vector_base.462" = type { %"struct.std::_Vector_base<std::optional<std::filesystem::__cxx11::path>, std::allocator<std::optional<std::filesystem::__cxx11::path>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::optional<std::filesystem::__cxx11::path>, std::allocator<std::optional<std::filesystem::__cxx11::path>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::optional<std::filesystem::__cxx11::path>, std::allocator<std::optional<std::filesystem::__cxx11::path>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::optional<std::filesystem::__cxx11::path>, std::allocator<std::optional<std::filesystem::__cxx11::path>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::filesystem::__cxx11::path" = type { %"class.std::__cxx11::basic_string", %"struct.std::filesystem::__cxx11::path::_List" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon.30 }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon.30 = type { i64, [8 x i8] }
%"struct.std::filesystem::__cxx11::path::_List" = type { %"class.std::unique_ptr.31" }
%"class.std::unique_ptr.31" = type { %"struct.std::__uniq_ptr_data.32" }
%"struct.std::__uniq_ptr_data.32" = type { %"class.std::__uniq_ptr_impl.33" }
%"class.std::__uniq_ptr_impl.33" = type { %"class.std::tuple.34" }
%"class.std::tuple.34" = type { %"struct.std::_Tuple_impl.35" }
%"struct.std::_Tuple_impl.35" = type { %"struct.std::_Head_base.38" }
%"struct.std::_Head_base.38" = type { ptr }
%"class.std::error_code" = type { i32, ptr }
%"class.std::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon.523 }
%union.anon.523 = type { i32 }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10filesystem7__cxx114pathD2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8fastgltf8Exporter15writeGltfBinaryERKNS_5AssetENS_13ExportOptionsE(ptr dead_on_unwind noalias writable sret(%"class.fastgltf::Expected.501") align 8, ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(580), i64 noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNSt6vectorISt4byteSaIS0_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNSt10filesystem6existsERKNS_7__cxx114pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(16)) #3

declare void @_ZNKSt10filesystem7__cxx114path11parent_pathEv(ptr dead_on_unwind writable sret(%"class.std::filesystem::__cxx11::path") align 8, ptr noundef nonnull align 8 dereferenceable(40)) #4

; Function Attrs: nounwind
declare noundef zeroext i1 @_ZNSt10filesystem16create_directoryERKNS_7__cxx114pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(16)) #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1INSt10filesystem7__cxx114pathES6_EERKT_St13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248), ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef zeroext i1 @_ZNSt14basic_ofstreamIcSt11char_traitsIcEE7is_openEv(ptr noundef nonnull align 8 dereferenceable(248)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN8fastgltf12FileExporter15writeGltfBinaryERKNS_5AssetENSt10filesystem7__cxx114pathENS_13ExportOptionsE(ptr noundef nonnull align 8 dereferenceable(168) %0, ptr noundef nonnull align 8 dereferenceable(580) %1, ptr noundef %2, i64 noundef %3) #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca %"class.std::error_code", align 8
  %11 = alloca %"class.std::filesystem::__cxx11::path", align 8
  %12 = alloca %"class.std::filesystem::__cxx11::path", align 8
  %13 = alloca i32, align 4
  %14 = alloca %"class.fastgltf::Expected.501", align 8
  %15 = alloca ptr, align 8
  %16 = alloca %"class.std::basic_ofstream", align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca %"class.std::filesystem::__cxx11::path", align 8
  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 i64 %3, ptr %9, align 8, !tbaa !9
  %20 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #6
  call void @_ZNSt10error_codeC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %10) #6
  call void @llvm.lifetime.start.p0(i64 40, ptr %11) #6
  call void @_ZNKSt10filesystem7__cxx114path11parent_pathEv(ptr dead_on_unwind writable sret(%"class.std::filesystem::__cxx11::path") align 8 %11, ptr noundef nonnull align 8 dereferenceable(40) %2)
  %21 = call noundef zeroext i1 @_ZNSt10filesystem6existsERKNS_7__cxx114pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(40) %11, ptr noundef nonnull align 8 dereferenceable(16) %10) #6
  br i1 %21, label %22, label %24

22:                                               ; preds = %4
  %23 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %10) #6
  br label %24

24:                                               ; preds = %22, %4
  %25 = phi i1 [ true, %4 ], [ %23, %22 ]
  call void @_ZNSt10filesystem7__cxx114pathD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %11) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %11) #6
  br i1 %25, label %26, label %31

26:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 40, ptr %12) #6
  call void @_ZNKSt10filesystem7__cxx114path11parent_pathEv(ptr dead_on_unwind writable sret(%"class.std::filesystem::__cxx11::path") align 8 %12, ptr noundef nonnull align 8 dereferenceable(40) %2)
  %27 = call noundef zeroext i1 @_ZNSt10filesystem16create_directoryERKNS_7__cxx114pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(40) %12, ptr noundef nonnull align 8 dereferenceable(16) %10) #6
  call void @_ZNSt10filesystem7__cxx114pathD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %12) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr %12) #6
  %28 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %10) #6
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  store i64 1, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %32

30:                                               ; preds = %26
  br label %31

31:                                               ; preds = %30, %24
  store i32 0, ptr %13, align 4
  br label %32

32:                                               ; preds = %31, %29
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #6
  %33 = load i32, ptr %13, align 4
  switch i32 %33, label %88 [
    i32 0, label %34
    i32 1, label %81
  ]

34:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 80, ptr %14) #6
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load i64, ptr %9, align 8, !tbaa !9
  call void @_ZN8fastgltf8Exporter15writeGltfBinaryERKNS_5AssetENS_13ExportOptionsE(ptr dead_on_unwind writable sret(%"class.fastgltf::Expected.501") align 8 %14, ptr noundef nonnull align 8 dereferenceable(168) %20, ptr noundef nonnull align 8 dereferenceable(580) %35, i64 noundef %36)
  %37 = call noundef zeroext i1 @_ZNK8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEEcvbEv(ptr noundef nonnull align 8 dereferenceable(80) %14) #6
  br i1 %37, label %40, label %38

38:                                               ; preds = %34
  %39 = call noundef i64 @_ZNK8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEE5errorEv(ptr noundef nonnull align 8 dereferenceable(80) %14) #6
  store i64 %39, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %80

40:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %41 = call noundef nonnull align 8 dereferenceable(72) ptr @_ZN8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEE3getEv(ptr noundef nonnull align 8 dereferenceable(80) %14) #6
  store ptr %41, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 512, ptr %16) #6
  %42 = invoke noundef i32 @_ZStorSt13_Ios_OpenmodeS_(i32 noundef 16, i32 noundef 4)
          to label %43 unwind label %48

43:                                               ; preds = %40
  invoke void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1INSt10filesystem7__cxx114pathES6_EERKT_St13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248) %16, ptr noundef nonnull align 8 dereferenceable(40) %2, i32 noundef %42)
          to label %44 unwind label %48

44:                                               ; preds = %43
  %45 = invoke noundef zeroext i1 @_ZNSt14basic_ofstreamIcSt11char_traitsIcEE7is_openEv(ptr noundef nonnull align 8 dereferenceable(248) %16)
          to label %46 unwind label %52

46:                                               ; preds = %44
  br i1 %45, label %56, label %47

47:                                               ; preds = %46
  store i64 1, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %77

48:                                               ; preds = %43, %40
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %17, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %18, align 4
  br label %79

52:                                               ; preds = %64, %56, %44
  %53 = landingpad { ptr, i32 }
          cleanup
  %54 = extractvalue { ptr, i32 } %53, 0
  store ptr %54, ptr %17, align 8
  %55 = extractvalue { ptr, i32 } %53, 1
  store i32 %55, ptr %18, align 4
  br label %78

56:                                               ; preds = %46
  %57 = load ptr, ptr %15, align 8, !tbaa !5
  %58 = getelementptr inbounds %"struct.fastgltf::ExportResult.502", ptr %57, i32 0, i32 0
  %59 = call noundef ptr @_ZNSt6vectorISt4byteSaIS0_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %58) #6
  %60 = load ptr, ptr %15, align 8, !tbaa !5
  %61 = getelementptr inbounds %"struct.fastgltf::ExportResult.502", ptr %60, i32 0, i32 0
  %62 = call noundef i64 @_ZNKSt6vectorISt4byteSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %61) #6
  %63 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef %59, i64 noundef %62)
          to label %64 unwind label %52

64:                                               ; preds = %56
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = load ptr, ptr %15, align 8, !tbaa !5
  invoke void @_ZNKSt10filesystem7__cxx114path11parent_pathEv(ptr dead_on_unwind writable sret(%"class.std::filesystem::__cxx11::path") align 8 %19, ptr noundef nonnull align 8 dereferenceable(40) %2)
          to label %67 unwind label %52

67:                                               ; preds = %64
  %68 = invoke noundef zeroext i1 @_ZN8fastgltf10writeFilesISt6vectorISt4byteSaIS2_EEEEbRKNS_5AssetERNS_12ExportResultIT_EENSt10filesystem7__cxx114pathE(ptr noundef nonnull align 8 dereferenceable(580) %65, ptr noundef nonnull align 8 dereferenceable(72) %66, ptr noundef %19)
          to label %69 unwind label %72

69:                                               ; preds = %67
  %70 = xor i1 %68, true
  call void @_ZNSt10filesystem7__cxx114pathD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %19) #6
  br i1 %70, label %71, label %76

71:                                               ; preds = %69
  store i64 13, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %77

72:                                               ; preds = %67
  %73 = landingpad { ptr, i32 }
          cleanup
  %74 = extractvalue { ptr, i32 } %73, 0
  store ptr %74, ptr %17, align 8
  %75 = extractvalue { ptr, i32 } %73, 1
  store i32 %75, ptr %18, align 4
  call void @_ZNSt10filesystem7__cxx114pathD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %19) #6
  br label %78

76:                                               ; preds = %69
  store i64 0, ptr %5, align 8
  store i32 1, ptr %13, align 4
  br label %77

77:                                               ; preds = %76, %71, %47
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %16) #6
  call void @llvm.lifetime.end.p0(i64 512, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  br label %80

78:                                               ; preds = %72, %52
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %16) #6
  br label %79

79:                                               ; preds = %78, %48
  call void @llvm.lifetime.end.p0(i64 512, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @_ZN8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %14) #6
  call void @llvm.lifetime.end.p0(i64 80, ptr %14) #6
  br label %83

80:                                               ; preds = %77, %38
  call void @_ZN8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %14) #6
  call void @llvm.lifetime.end.p0(i64 80, ptr %14) #6
  br label %81

81:                                               ; preds = %80, %32
  %82 = load i64, ptr %5, align 8
  ret i64 %82

83:                                               ; preds = %79
  %84 = load ptr, ptr %17, align 8
  %85 = load i32, ptr %18, align 4
  %86 = insertvalue { ptr, i32 } poison, ptr %84, 0
  %87 = insertvalue { ptr, i32 } %86, i32 %85, 1
  resume { ptr, i32 } %87

88:                                               ; preds = %32
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEEcvbEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEE5errorEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(72) ptr @_ZN8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEE3getEv(ptr noundef nonnull align 8 dereferenceable(80)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZStorSt13_Ios_OpenmodeS_(i32 noundef, i32 noundef) #3

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, i64 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorISt4byteSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN8fastgltf10writeFilesISt6vectorISt4byteSaIS2_EEEEbRKNS_5AssetERNS_12ExportResultIT_EENSt10filesystem7__cxx114pathE(ptr noundef nonnull align 8 dereferenceable(580), ptr noundef nonnull align 8 dereferenceable(72), ptr noundef) #2

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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 "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, !10, i64 0}
!10 = !{!"_ZTSN8fastgltf13ExportOptionsE", !7, i64 0}


; 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.fastgltf::Expected.501" = type { i64, %"struct.fastgltf::ExportResult.502" }
%"struct.fastgltf::ExportResult.502" = type { %"class.std::vector.503", %"class.std::vector.461", %"class.std::vector.461" }
%"class.std::vector.503" = type { %"struct.std::_Vector_base.504" }
%"struct.std::_Vector_base.504" = type { %"struct.std::_Vector_base<std::byte, std::allocator<std::byte>>::_Vector_impl" }
%"struct.std::_Vector_base<std::byte, std::allocator<std::byte>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::byte, std::allocator<std::byte>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::byte, std::allocator<std::byte>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.461" = type { %"struct.std::_Vector_base.462" }
%"struct.std::_Vector_base.462" = type { %"struct.std::_Vector_base<std::optional<std::filesystem::__cxx11::path>, std::allocator<std::optional<std::filesystem::__cxx11::path>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::optional<std::filesystem::__cxx11::path>, std::allocator<std::optional<std::filesystem::__cxx11::path>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::optional<std::filesystem::__cxx11::path>, std::allocator<std::optional<std::filesystem::__cxx11::path>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::optional<std::filesystem::__cxx11::path>, std::allocator<std::optional<std::filesystem::__cxx11::path>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::filesystem::__cxx11::path" = type { %"class.std::__cxx11::basic_string", %"struct.std::filesystem::__cxx11::path::_List" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon.30 }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon.30 = type { i64, [8 x i8] }
%"struct.std::filesystem::__cxx11::path::_List" = type { %"class.std::unique_ptr.31" }
%"class.std::unique_ptr.31" = type { %"struct.std::__uniq_ptr_data.32" }
%"struct.std::__uniq_ptr_data.32" = type { %"class.std::__uniq_ptr_impl.33" }
%"class.std::__uniq_ptr_impl.33" = type { %"class.std::tuple.34" }
%"class.std::tuple.34" = type { %"struct.std::_Tuple_impl.35" }
%"struct.std::_Tuple_impl.35" = type { %"struct.std::_Head_base.38" }
%"struct.std::_Head_base.38" = type { ptr }
%"class.std::error_code" = type { i32, ptr }
%"class.std::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon.523 }
%union.anon.523 = type { i32 }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }

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

declare i32 @__gxx_personality_v0(...)

; 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 nounwind uwtable
declare dso_local void @_ZNSt10filesystem7__cxx114pathD2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8fastgltf8Exporter15writeGltfBinaryERKNS_5AssetENS_13ExportOptionsE(ptr dead_on_unwind noalias writable sret(%"class.fastgltf::Expected.501") align 8, ptr noundef nonnull align 8 dereferenceable(168), ptr noundef nonnull align 8 dereferenceable(580), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNSt6vectorISt4byteSaIS0_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNSt10filesystem6existsERKNS_7__cxx114pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #3

declare void @_ZNKSt10filesystem7__cxx114path11parent_pathEv(ptr dead_on_unwind writable sret(%"class.std::filesystem::__cxx11::path") align 8, ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #4

; Function Attrs: nounwind
declare noundef zeroext i1 @_ZNSt10filesystem16create_directoryERKNS_7__cxx114pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1INSt10filesystem7__cxx114pathES6_EERKT_St13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248), ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef zeroext i1 @_ZNSt14basic_ofstreamIcSt11char_traitsIcEE7is_openEv(ptr noundef nonnull align 8 dereferenceable(248)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248)) unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_ZN8fastgltf12FileExporter15writeGltfBinaryERKNS_5AssetENSt10filesystem7__cxx114pathENS_13ExportOptionsE(ptr noundef nonnull align 8 dereferenceable(168) %0, ptr noundef nonnull align 8 dereferenceable(580) %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.std::error_code", align 8
  %6 = alloca %"class.std::filesystem::__cxx11::path", align 8
  %7 = alloca %"class.std::filesystem::__cxx11::path", align 8
  %8 = alloca %"class.fastgltf::Expected.501", align 8
  %9 = alloca %"class.std::basic_ofstream", align 8
  %10 = alloca %"class.std::filesystem::__cxx11::path", align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #6
  call void @_ZNSt10error_codeC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #6
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %6) #6
  call void @_ZNKSt10filesystem7__cxx114path11parent_pathEv(ptr dead_on_unwind nonnull writable sret(%"class.std::filesystem::__cxx11::path") align 8 %6, ptr noundef nonnull align 8 dereferenceable(40) %2)
  %11 = call noundef zeroext i1 @_ZNSt10filesystem6existsERKNS_7__cxx114pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(40) %6, ptr noundef nonnull align 8 dereferenceable(16) %5) #6
  br i1 %11, label %12, label %.critedge

12:                                               ; preds = %4
  %13 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %5) #6
  call void @_ZNSt10filesystem7__cxx114pathD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %6) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #6
  br i1 %13, label %14, label %18

.critedge:                                        ; preds = %4
  call void @_ZNSt10filesystem7__cxx114pathD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %6) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %6) #6
  br label %14

14:                                               ; preds = %.critedge, %12
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %7) #6
  call void @_ZNKSt10filesystem7__cxx114path11parent_pathEv(ptr dead_on_unwind nonnull writable sret(%"class.std::filesystem::__cxx11::path") align 8 %7, ptr noundef nonnull align 8 dereferenceable(40) %2)
  %15 = call noundef zeroext i1 @_ZNSt10filesystem16create_directoryERKNS_7__cxx114pathERSt10error_code(ptr noundef nonnull align 8 dereferenceable(40) %7, ptr noundef nonnull align 8 dereferenceable(16) %5) #6
  call void @_ZNSt10filesystem7__cxx114pathD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %7) #6
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %7) #6
  %16 = call noundef zeroext i1 @_ZNKSt10error_codecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %5) #6
  br i1 %16, label %17, label %18

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  br label %45

18:                                               ; preds = %12, %14
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %8) #6
  call void @_ZN8fastgltf8Exporter15writeGltfBinaryERKNS_5AssetENS_13ExportOptionsE(ptr dead_on_unwind nonnull writable sret(%"class.fastgltf::Expected.501") align 8 %8, ptr noundef nonnull align 8 dereferenceable(168) %0, ptr noundef nonnull align 8 dereferenceable(580) %1, i64 noundef %3)
  %19 = call noundef zeroext i1 @_ZNK8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEEcvbEv(ptr noundef nonnull align 8 dereferenceable(80) %8) #6
  br i1 %19, label %22, label %20

20:                                               ; preds = %18
  %21 = call noundef i64 @_ZNK8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEE5errorEv(ptr noundef nonnull align 8 dereferenceable(80) %8) #6
  br label %44

22:                                               ; preds = %18
  %23 = call noundef nonnull align 8 dereferenceable(72) ptr @_ZN8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEE3getEv(ptr noundef nonnull align 8 dereferenceable(80) %8) #6
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %9) #6
  %24 = call noundef i32 @_ZStorSt13_Ios_OpenmodeS_(i32 noundef 16, i32 noundef 4)
  invoke void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1INSt10filesystem7__cxx114pathES6_EERKT_St13_Ios_Openmode(ptr noundef nonnull align 8 dereferenceable(248) %9, ptr noundef nonnull align 8 dereferenceable(40) %2, i32 noundef %24)
          to label %25 unwind label %27

25:                                               ; preds = %22
  %26 = call noundef zeroext i1 @_ZNSt14basic_ofstreamIcSt11char_traitsIcEE7is_openEv(ptr noundef nonnull align 8 dereferenceable(248) %9)
  br i1 %26, label %31, label %41

27:                                               ; preds = %22
  %28 = landingpad { ptr, i32 }
          cleanup
  br label %43

29:                                               ; preds = %35, %31
  %30 = landingpad { ptr, i32 }
          cleanup
  br label %42

31:                                               ; preds = %25
  %32 = call noundef ptr @_ZNSt6vectorISt4byteSaIS0_EE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %23) #6
  %33 = call noundef i64 @_ZNKSt6vectorISt4byteSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %23) #6
  %34 = invoke noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef %32, i64 noundef %33)
          to label %35 unwind label %29

35:                                               ; preds = %31
  invoke void @_ZNKSt10filesystem7__cxx114path11parent_pathEv(ptr dead_on_unwind nonnull writable sret(%"class.std::filesystem::__cxx11::path") align 8 %10, ptr noundef nonnull align 8 dereferenceable(40) %2)
          to label %36 unwind label %29

36:                                               ; preds = %35
  %37 = invoke noundef zeroext i1 @_ZN8fastgltf10writeFilesISt6vectorISt4byteSaIS2_EEEEbRKNS_5AssetERNS_12ExportResultIT_EENSt10filesystem7__cxx114pathE(ptr noundef nonnull align 8 dereferenceable(580) %1, ptr noundef nonnull align 8 dereferenceable(72) %23, ptr noundef nonnull %10)
          to label %38 unwind label %39

38:                                               ; preds = %36
  call void @_ZNSt10filesystem7__cxx114pathD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %10) #6
  %. = select i1 %37, i64 0, i64 13
  br label %41

39:                                               ; preds = %36
  %40 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt10filesystem7__cxx114pathD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %10) #6
  br label %42

41:                                               ; preds = %38, %25
  %.113 = phi i64 [ 1, %25 ], [ %., %38 ]
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %9) #6
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %9) #6
  br label %44

42:                                               ; preds = %39, %29
  %.pn = phi { ptr, i32 } [ %40, %39 ], [ %30, %29 ]
  call void @_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(248) %9) #6
  br label %43

43:                                               ; preds = %42, %27
  %.pn.pn = phi { ptr, i32 } [ %.pn, %42 ], [ %28, %27 ]
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %9) #6
  call void @_ZN8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %8) #6
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %8) #6
  resume { ptr, i32 } %.pn.pn

44:                                               ; preds = %41, %20
  %.2 = phi i64 [ %.113, %41 ], [ %21, %20 ]
  call void @_ZN8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %8) #6
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %8) #6
  br label %45

45:                                               ; preds = %17, %44
  %.3 = phi i64 [ 1, %17 ], [ %.2, %44 ]
  ret i64 %.3
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEEcvbEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEE5errorEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(72) ptr @_ZN8fastgltf8ExpectedINS_12ExportResultISt6vectorISt4byteSaIS3_EEEEE3getEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZStorSt13_Ios_OpenmodeS_(i32 noundef, i32 noundef) local_unnamed_addr #3

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSo5writeEPKcl(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorISt4byteSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN8fastgltf10writeFilesISt6vectorISt4byteSaIS2_EEEEbRKNS_5AssetERNS_12ExportResultIT_EENSt10filesystem7__cxx114pathE(ptr noundef nonnull align 8 dereferenceable(580), ptr noundef nonnull align 8 dereferenceable(72), ptr noundef) local_unnamed_addr #2

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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 "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)"}


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