; LLVM IR from ThePhysicsGuys/Physics3D :: graphics/resource (textureResource)

; 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.P3D::Graphics::Texture" = type { %"class.P3D::Graphics::Bindable.base", i32, i32, i32, i32, i32, i32, i32, i32, [4 x i8] }
%"class.P3D::Graphics::Bindable.base" = type <{ ptr, i32 }>

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN3P3D8Graphics16TextureAllocator4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %"class.P3D::Graphics::Texture", align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr %8) #6
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN3P3D8Graphics7Texture4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr dead_on_unwind writable sret(%"class.P3D::Graphics::Texture") align 8 %8, ptr noundef nonnull align 8 dereferenceable(32) %13)
  %14 = invoke noundef i32 @_ZNK3P3D8Graphics8Bindable5getIDEv(ptr noundef nonnull align 8 dereferenceable(12) %8)
          to label %15 unwind label %23

15:                                               ; preds = %3
  %16 = icmp ne i32 %14, 0
  br i1 %16, label %17, label %31

17:                                               ; preds = %15
  %18 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 120) #7
          to label %19 unwind label %23

19:                                               ; preds = %17
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  invoke void @_ZN3P3D8Graphics15TextureResourceC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_ONS0_7TextureE(ptr noundef nonnull align 8 dereferenceable(116) %18, ptr noundef nonnull align 8 dereferenceable(32) %20, ptr noundef nonnull align 8 dereferenceable(32) %21, ptr noundef nonnull align 8 dereferenceable(44) %8)
          to label %22 unwind label %27

22:                                               ; preds = %19
  store ptr %18, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %32

23:                                               ; preds = %17, %3
  %24 = landingpad { ptr, i32 }
          cleanup
  %25 = extractvalue { ptr, i32 } %24, 0
  store ptr %25, ptr %9, align 8
  %26 = extractvalue { ptr, i32 } %24, 1
  store i32 %26, ptr %10, align 4
  br label %34

27:                                               ; preds = %19
  %28 = landingpad { ptr, i32 }
          cleanup
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %9, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %10, align 4
  call void @_ZdlPvm(ptr noundef %18, i64 noundef 120) #8
  br label %34

31:                                               ; preds = %15
  store ptr null, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %32

32:                                               ; preds = %31, %22
  call void @_ZN3P3D8Graphics7TextureD1Ev(ptr noundef nonnull align 8 dereferenceable(44) %8) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr %8) #6
  %33 = load ptr, ptr %4, align 8
  ret ptr %33

34:                                               ; preds = %27, %23
  call void @_ZN3P3D8Graphics7TextureD1Ev(ptr noundef nonnull align 8 dereferenceable(44) %8) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr %8) #6
  br label %35

35:                                               ; preds = %34
  %36 = load ptr, ptr %9, align 8
  %37 = load i32, ptr %10, align 4
  %38 = insertvalue { ptr, i32 } poison, ptr %36, 0
  %39 = insertvalue { ptr, i32 } %38, i32 %37, 1
  resume { ptr, i32 } %39
}

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

declare void @_ZN3P3D8Graphics7Texture4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr dead_on_unwind writable sret(%"class.P3D::Graphics::Texture") align 8, ptr noundef nonnull align 8 dereferenceable(32)) #2

declare noundef i32 @_ZNK3P3D8Graphics8Bindable5getIDEv(ptr noundef nonnull align 8 dereferenceable(12)) #2

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: nounwind
declare void @_ZN3P3D8Graphics7TextureD1Ev(ptr noundef nonnull align 8 dereferenceable(44)) unnamed_addr #5

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 #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 }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { 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"}


; 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.P3D::Graphics::Texture" = type { %"class.P3D::Graphics::Bindable.base", i32, i32, i32, i32, i32, i32, i32, i32, [4 x i8] }
%"class.P3D::Graphics::Bindable.base" = type <{ ptr, i32 }>

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN3P3D8Graphics16TextureAllocator4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_(ptr nocapture noundef nonnull readnone align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.P3D::Graphics::Texture", align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %4) #6
  call void @_ZN3P3D8Graphics7Texture4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr dead_on_unwind nonnull writable sret(%"class.P3D::Graphics::Texture") align 8 %4, ptr noundef nonnull align 8 dereferenceable(32) %2)
  %5 = invoke noundef i32 @_ZNK3P3D8Graphics8Bindable5getIDEv(ptr noundef nonnull align 8 dereferenceable(12) %4)
          to label %6 unwind label %10

6:                                                ; preds = %3
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %14, label %7

7:                                                ; preds = %6
  %8 = invoke noalias noundef nonnull dereferenceable(120) ptr @_Znwm(i64 noundef 120) #7
          to label %9 unwind label %10

9:                                                ; preds = %7
  invoke void @_ZN3P3D8Graphics15TextureResourceC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_ONS0_7TextureE(ptr noundef nonnull align 8 dereferenceable(116) %8, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 8 dereferenceable(44) %4)
          to label %14 unwind label %12

10:                                               ; preds = %7, %3
  %11 = landingpad { ptr, i32 }
          cleanup
  br label %15

12:                                               ; preds = %9
  %13 = landingpad { ptr, i32 }
          cleanup
  call void @_ZdlPvm(ptr noundef nonnull %8, i64 noundef 120) #8
  br label %15

14:                                               ; preds = %6, %9
  %.07 = phi ptr [ %8, %9 ], [ null, %6 ]
  call void @_ZN3P3D8Graphics7TextureD1Ev(ptr noundef nonnull align 8 dereferenceable(44) %4) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %4) #6
  ret ptr %.07

15:                                               ; preds = %12, %10
  %.pn = phi { ptr, i32 } [ %13, %12 ], [ %11, %10 ]
  call void @_ZN3P3D8Graphics7TextureD1Ev(ptr noundef nonnull align 8 dereferenceable(44) %4) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %4) #6
  resume { ptr, i32 } %.pn
}

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

declare void @_ZN3P3D8Graphics7Texture4loadERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr dead_on_unwind writable sret(%"class.P3D::Graphics::Texture") align 8, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2

declare noundef i32 @_ZNK3P3D8Graphics8Bindable5getIDEv(ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: nounwind
declare void @_ZN3P3D8Graphics7TextureD1Ev(ptr noundef nonnull align 8 dereferenceable(44)) unnamed_addr #5

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

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 #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 }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { 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)"}


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