; LLVM IR from filipwasil/fillwave :: ext/nv_helpers_gl/nv_dds.ll (ZN6nv_dds9CDDSImage16upload_texture1DEv)

; 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.nv_dds::CDDSImage" = type { i32, i32, i32, i32, i8, %"class.std::deque" }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<nv_dds::CTexture, std::allocator<nv_dds::CTexture>>::_Deque_impl" }
%"struct.std::_Deque_base<nv_dds::CTexture, std::allocator<nv_dds::CTexture>>::_Deque_impl" = type { %"struct.std::_Deque_base<nv_dds::CTexture, std::allocator<nv_dds::CTexture>>::_Deque_impl_data" }
%"struct.std::_Deque_base<nv_dds::CTexture, std::allocator<nv_dds::CTexture>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage16upload_texture1DEv = external hidden unnamed_addr constant [43 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [26 x i8], align 1
@glad_glCompressedTexImage1D = external global ptr, align 8
@glad_glGetIntegerv = external global ptr, align 8
@glad_glPixelStorei = external global ptr, align 8
@glad_glTexImage1D = external global ptr, align 8

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6nv_dds9CDDSImage13is_compressedEv(ptr noundef nonnull align 8 dereferenceable(104)) #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(112) ptr @_ZNSt5dequeIN6nv_dds8CTextureESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(80), i64 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6nv_dds8CTexture15get_num_mipmapsEv(ptr noundef nonnull align 8 dereferenceable(112)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6nv_dds8CSurface8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK6nv_dds8CTexture10get_mipmapEj(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6nv_dds9CDDSImage16upload_texture1DEv(ptr noundef nonnull align 8 dereferenceable(104) %0) #4 align 2 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  %12 = getelementptr inbounds %"class.nv_dds::CDDSImage", ptr %11, i32 0, i32 4
  %13 = load i8, ptr %12, align 8, !tbaa !9, !range !20, !noundef !21
  %14 = trunc i8 %13 to i1
  br i1 %14, label %15, label %16

15:                                               ; preds = %1
  br label %18

16:                                               ; preds = %1
  call void @__assert_fail(ptr noundef @.str.18, ptr noundef @.str.1, i32 noundef 686, ptr noundef @__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage16upload_texture1DEv) #6
  unreachable

17:                                               ; No predecessors!
  br label %18

18:                                               ; preds = %17, %15
  %19 = getelementptr inbounds %"class.nv_dds::CDDSImage", ptr %11, i32 0, i32 5
  %20 = call noundef zeroext i1 @_ZNKSt5dequeIN6nv_dds8CTextureESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %19) #7
  %21 = xor i1 %20, true
  br i1 %21, label %22, label %23

22:                                               ; preds = %18
  br label %25

23:                                               ; preds = %18
  call void @__assert_fail(ptr noundef @.str.22, ptr noundef @.str.1, i32 noundef 687, ptr noundef @__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage16upload_texture1DEv) #6
  unreachable

24:                                               ; No predecessors!
  br label %25

25:                                               ; preds = %24, %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  %26 = getelementptr inbounds %"class.nv_dds::CDDSImage", ptr %11, i32 0, i32 5
  %27 = call noundef nonnull align 8 dereferenceable(112) ptr @_ZNSt5dequeIN6nv_dds8CTextureESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(80) %26, i64 noundef 0) #7
  store ptr %27, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call noundef i32 @_ZNK6nv_dds8CSurface10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32) %28)
  %30 = icmp eq i32 %29, 1
  br i1 %30, label %31, label %32

31:                                               ; preds = %25
  br label %34

32:                                               ; preds = %25
  call void @__assert_fail(ptr noundef @.str.23, ptr noundef @.str.1, i32 noundef 691, ptr noundef @__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage16upload_texture1DEv) #6
  unreachable

33:                                               ; No predecessors!
  br label %34

34:                                               ; preds = %33, %31
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = call noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %35)
  %37 = icmp ugt i32 %36, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %34
  br label %41

39:                                               ; preds = %34
  call void @__assert_fail(ptr noundef @.str.24, ptr noundef @.str.1, i32 noundef 692, ptr noundef @__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage16upload_texture1DEv) #6
  unreachable

40:                                               ; No predecessors!
  br label %41

41:                                               ; preds = %40, %38
  %42 = call noundef zeroext i1 @_ZN6nv_dds9CDDSImage13is_compressedEv(ptr noundef nonnull align 8 dereferenceable(104) %11)
  br i1 %42, label %43, label %82

43:                                               ; preds = %41
  %44 = load ptr, ptr @glad_glCompressedTexImage1D, align 8, !tbaa !5
  %45 = icmp eq ptr %44, null
  br i1 %45, label %46, label %47

46:                                               ; preds = %43
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %129

47:                                               ; preds = %43
  %48 = load ptr, ptr @glad_glCompressedTexImage1D, align 8, !tbaa !5
  %49 = getelementptr inbounds %"class.nv_dds::CDDSImage", ptr %11, i32 0, i32 0
  %50 = load i32, ptr %49, align 8, !tbaa !22
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = call noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %51)
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = call noundef i32 @_ZNK6nv_dds8CSurface8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %53)
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %55)
  call void %48(i32 noundef 3552, i32 noundef 0, i32 noundef %50, i32 noundef %52, i32 noundef 0, i32 noundef %54, ptr noundef %56)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 0, ptr %6, align 4, !tbaa !23
  br label %57

57:                                               ; preds = %78, %47
  %58 = load i32, ptr %6, align 4, !tbaa !23
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = call noundef i32 @_ZNK6nv_dds8CTexture15get_num_mipmapsEv(ptr noundef nonnull align 8 dereferenceable(112) %59)
  %61 = icmp ult i32 %58, %60
  br i1 %61, label %63, label %62

62:                                               ; preds = %57
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %81

63:                                               ; preds = %57
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = load i32, ptr %6, align 4, !tbaa !23
  %66 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK6nv_dds8CTexture10get_mipmapEj(ptr noundef nonnull align 8 dereferenceable(112) %64, i32 noundef %65)
  store ptr %66, ptr %7, align 8, !tbaa !5
  %67 = load ptr, ptr @glad_glCompressedTexImage1D, align 8, !tbaa !5
  %68 = load i32, ptr %6, align 4, !tbaa !23
  %69 = add i32 %68, 1
  %70 = getelementptr inbounds %"class.nv_dds::CDDSImage", ptr %11, i32 0, i32 0
  %71 = load i32, ptr %70, align 8, !tbaa !22
  %72 = load ptr, ptr %7, align 8, !tbaa !5
  %73 = call noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %72)
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = call noundef i32 @_ZNK6nv_dds8CSurface8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %74)
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %76)
  call void %67(i32 noundef 3552, i32 noundef %69, i32 noundef %71, i32 noundef %73, i32 noundef 0, i32 noundef %75, ptr noundef %77)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %78

78:                                               ; preds = %63
  %79 = load i32, ptr %6, align 4, !tbaa !23
  %80 = add i32 %79, 1
  store i32 %80, ptr %6, align 4, !tbaa !23
  br label %57, !llvm.loop !24

81:                                               ; preds = %62
  br label %128

82:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 -1, ptr %8, align 4, !tbaa !23
  %83 = call noundef zeroext i1 @_ZN6nv_dds9CDDSImage16is_dword_alignedEv(ptr noundef nonnull align 8 dereferenceable(104) %11)
  br i1 %83, label %87, label %84

84:                                               ; preds = %82
  %85 = load ptr, ptr @glad_glGetIntegerv, align 8, !tbaa !5
  call void %85(i32 noundef 3317, ptr noundef %8)
  %86 = load ptr, ptr @glad_glPixelStorei, align 8, !tbaa !5
  call void %86(i32 noundef 3317, i32 noundef 1)
  br label %87

87:                                               ; preds = %84, %82
  %88 = load ptr, ptr @glad_glTexImage1D, align 8, !tbaa !5
  %89 = getelementptr inbounds %"class.nv_dds::CDDSImage", ptr %11, i32 0, i32 1
  %90 = load i32, ptr %89, align 4, !tbaa !26
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = call noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %91)
  %93 = getelementptr inbounds %"class.nv_dds::CDDSImage", ptr %11, i32 0, i32 0
  %94 = load i32, ptr %93, align 8, !tbaa !22
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  %96 = call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %95)
  call void %88(i32 noundef 3552, i32 noundef 0, i32 noundef %90, i32 noundef %92, i32 noundef 0, i32 noundef %94, i32 noundef 5121, ptr noundef %96)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !23
  br label %97

97:                                               ; preds = %118, %87
  %98 = load i32, ptr %9, align 4, !tbaa !23
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = call noundef i32 @_ZNK6nv_dds8CTexture15get_num_mipmapsEv(ptr noundef nonnull align 8 dereferenceable(112) %99)
  %101 = icmp ult i32 %98, %100
  br i1 %101, label %103, label %102

102:                                              ; preds = %97
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %121

103:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  %104 = load ptr, ptr %4, align 8, !tbaa !5
  %105 = load i32, ptr %9, align 4, !tbaa !23
  %106 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK6nv_dds8CTexture10get_mipmapEj(ptr noundef nonnull align 8 dereferenceable(112) %104, i32 noundef %105)
  store ptr %106, ptr %10, align 8, !tbaa !5
  %107 = load ptr, ptr @glad_glTexImage1D, align 8, !tbaa !5
  %108 = load i32, ptr %9, align 4, !tbaa !23
  %109 = add i32 %108, 1
  %110 = getelementptr inbounds %"class.nv_dds::CDDSImage", ptr %11, i32 0, i32 1
  %111 = load i32, ptr %110, align 4, !tbaa !26
  %112 = load ptr, ptr %10, align 8, !tbaa !5
  %113 = call noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %112)
  %114 = getelementptr inbounds %"class.nv_dds::CDDSImage", ptr %11, i32 0, i32 0
  %115 = load i32, ptr %114, align 8, !tbaa !22
  %116 = load ptr, ptr %10, align 8, !tbaa !5
  %117 = call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %116)
  call void %107(i32 noundef 3552, i32 noundef %109, i32 noundef %111, i32 noundef %113, i32 noundef 0, i32 noundef %115, i32 noundef 5121, ptr noundef %117)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %118

118:                                              ; preds = %103
  %119 = load i32, ptr %9, align 4, !tbaa !23
  %120 = add i32 %119, 1
  store i32 %120, ptr %9, align 4, !tbaa !23
  br label %97, !llvm.loop !27

121:                                              ; preds = %102
  %122 = load i32, ptr %8, align 4, !tbaa !23
  %123 = icmp ne i32 %122, -1
  br i1 %123, label %124, label %127

124:                                              ; preds = %121
  %125 = load ptr, ptr @glad_glPixelStorei, align 8, !tbaa !5
  %126 = load i32, ptr %8, align 4, !tbaa !23
  call void %125(i32 noundef 3317, i32 noundef %126)
  br label %127

127:                                              ; preds = %124, %121
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %128

128:                                              ; preds = %127, %81
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %129

129:                                              ; preds = %128, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  %130 = load i1, ptr %2, align 1
  ret i1 %130
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6nv_dds8CSurface10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN6nv_dds9CDDSImage16is_dword_alignedEv(ptr noundef nonnull align 8 dereferenceable(104)) #5 align 2

attributes #0 = { noreturn 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 = { 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 = { 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 #6 = { noreturn nounwind }
attributes #7 = { 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, !13, i64 16}
!10 = !{!"_ZTSN6nv_dds9CDDSImageE", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 12, !13, i64 16, !14, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSN6nv_dds11TextureTypeE", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSSt5dequeIN6nv_dds8CTextureESaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSSt11_Deque_baseIN6nv_dds8CTextureESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSNSt11_Deque_baseIN6nv_dds8CTextureESaIS1_EE11_Deque_implE", !17, i64 0}
!17 = !{!"_ZTSNSt11_Deque_baseIN6nv_dds8CTextureESaIS1_EE16_Deque_impl_dataE", !6, i64 0, !18, i64 8, !19, i64 16, !19, i64 48}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTSSt15_Deque_iteratorIN6nv_dds8CTextureERS1_PS1_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!10, !11, i64 0}
!23 = !{!11, !11, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!10, !11, i64 4}
!27 = distinct !{!27, !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"

@.str.1 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [8 x i8], align 1
@__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage16upload_texture1DEv = external hidden unnamed_addr constant [43 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [26 x i8], align 1
@glad_glCompressedTexImage1D = external local_unnamed_addr global ptr, align 8
@glad_glGetIntegerv = external local_unnamed_addr global ptr, align 8
@glad_glPixelStorei = external local_unnamed_addr global ptr, align 8
@glad_glTexImage1D = external local_unnamed_addr global ptr, align 8

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN6nv_dds9CDDSImage13is_compressedEv(ptr noundef nonnull align 8 dereferenceable(104)) 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) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(112) ptr @_ZNSt5dequeIN6nv_dds8CTextureESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(80), i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6nv_dds8CTexture15get_num_mipmapsEv(ptr noundef nonnull align 8 dereferenceable(112)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6nv_dds8CSurface8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK6nv_dds8CTexture10get_mipmapEj(ptr noundef nonnull align 8 dereferenceable(112), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6nv_dds9CDDSImage16upload_texture1DEv(ptr noundef nonnull align 8 dereferenceable(104) %0) local_unnamed_addr #4 align 2 {
  %2 = alloca i32, align 4
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  %4 = load i8, ptr %3, align 8, !tbaa !5, !range !19, !noundef !20
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %7, label %6

6:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.1, i32 noundef 686, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage16upload_texture1DEv) #6
  unreachable

7:                                                ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = tail call noundef zeroext i1 @_ZNKSt5dequeIN6nv_dds8CTextureESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(80) %8) #7
  br i1 %9, label %10, label %11

10:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.22, ptr noundef nonnull @.str.1, i32 noundef 687, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage16upload_texture1DEv) #6
  unreachable

11:                                               ; preds = %7
  %12 = tail call noundef nonnull align 8 dereferenceable(112) ptr @_ZNSt5dequeIN6nv_dds8CTextureESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(80) %8, i64 noundef 0) #7
  %13 = tail call noundef i32 @_ZNK6nv_dds8CSurface10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32) %12)
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.23, ptr noundef nonnull @.str.1, i32 noundef 691, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage16upload_texture1DEv) #6
  unreachable

16:                                               ; preds = %11
  %17 = tail call noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %12)
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %18, label %19

18:                                               ; preds = %16
  tail call void @__assert_fail(ptr noundef nonnull @.str.24, ptr noundef nonnull @.str.1, i32 noundef 692, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage16upload_texture1DEv) #6
  unreachable

19:                                               ; preds = %16
  %20 = tail call noundef zeroext i1 @_ZN6nv_dds9CDDSImage13is_compressedEv(ptr noundef nonnull align 8 dereferenceable(104) %0)
  br i1 %20, label %21, label %39

21:                                               ; preds = %19
  %22 = load ptr, ptr @glad_glCompressedTexImage1D, align 8, !tbaa !21
  %23 = icmp eq ptr %22, null
  br i1 %23, label %.loopexit, label %24

24:                                               ; preds = %21
  %25 = load i32, ptr %0, align 8, !tbaa !22
  %26 = tail call noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %12)
  %27 = tail call noundef i32 @_ZNK6nv_dds8CSurface8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %12)
  %28 = tail call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %12)
  tail call void %22(i32 noundef 3552, i32 noundef 0, i32 noundef %25, i32 noundef %26, i32 noundef 0, i32 noundef %27, ptr noundef %28)
  %29 = tail call noundef i32 @_ZNK6nv_dds8CTexture15get_num_mipmapsEv(ptr noundef nonnull align 8 dereferenceable(112) %12)
  %.not35 = icmp eq i32 %29, 0
  br i1 %.not35, label %.loopexit, label %.lr.ph33

.lr.ph33:                                         ; preds = %24, %.lr.ph33
  %.02631 = phi i32 [ %32, %.lr.ph33 ], [ 0, %24 ]
  %30 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK6nv_dds8CTexture10get_mipmapEj(ptr noundef nonnull align 8 dereferenceable(112) %12, i32 noundef %.02631)
  %31 = load ptr, ptr @glad_glCompressedTexImage1D, align 8, !tbaa !21
  %32 = add nuw i32 %.02631, 1
  %33 = load i32, ptr %0, align 8, !tbaa !22
  %34 = tail call noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %30)
  %35 = tail call noundef i32 @_ZNK6nv_dds8CSurface8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %30)
  %36 = tail call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %30)
  tail call void %31(i32 noundef 3552, i32 noundef %32, i32 noundef %33, i32 noundef %34, i32 noundef 0, i32 noundef %35, ptr noundef %36)
  %37 = tail call noundef i32 @_ZNK6nv_dds8CTexture15get_num_mipmapsEv(ptr noundef nonnull align 8 dereferenceable(112) %12)
  %38 = icmp ult i32 %32, %37
  br i1 %38, label %.lr.ph33, label %.loopexit, !llvm.loop !23

39:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  store i32 -1, ptr %2, align 4, !tbaa !25
  %40 = tail call noundef zeroext i1 @_ZN6nv_dds9CDDSImage16is_dword_alignedEv(ptr noundef nonnull align 8 dereferenceable(104) %0)
  br i1 %40, label %44, label %41

41:                                               ; preds = %39
  %42 = load ptr, ptr @glad_glGetIntegerv, align 8, !tbaa !21
  call void %42(i32 noundef 3317, ptr noundef nonnull %2)
  %43 = load ptr, ptr @glad_glPixelStorei, align 8, !tbaa !21
  call void %43(i32 noundef 3317, i32 noundef 1)
  br label %44

44:                                               ; preds = %41, %39
  %45 = load ptr, ptr @glad_glTexImage1D, align 8, !tbaa !21
  %46 = getelementptr inbounds i8, ptr %0, i64 4
  %47 = load i32, ptr %46, align 4, !tbaa !26
  %48 = call noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %12)
  %49 = load i32, ptr %0, align 8, !tbaa !22
  %50 = call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %12)
  call void %45(i32 noundef 3552, i32 noundef 0, i32 noundef %47, i32 noundef %48, i32 noundef 0, i32 noundef %49, i32 noundef 5121, ptr noundef %50)
  %51 = call noundef i32 @_ZNK6nv_dds8CTexture15get_num_mipmapsEv(ptr noundef nonnull align 8 dereferenceable(112) %12)
  %.not34 = icmp eq i32 %51, 0
  br i1 %.not34, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %44
  %52 = load i32, ptr %2, align 4, !tbaa !25
  %.not29 = icmp eq i32 %52, -1
  br i1 %.not29, label %64, label %62

.lr.ph:                                           ; preds = %44, %.lr.ph
  %.02530 = phi i32 [ %55, %.lr.ph ], [ 0, %44 ]
  %53 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK6nv_dds8CTexture10get_mipmapEj(ptr noundef nonnull align 8 dereferenceable(112) %12, i32 noundef %.02530)
  %54 = load ptr, ptr @glad_glTexImage1D, align 8, !tbaa !21
  %55 = add nuw i32 %.02530, 1
  %56 = load i32, ptr %46, align 4, !tbaa !26
  %57 = call noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %53)
  %58 = load i32, ptr %0, align 8, !tbaa !22
  %59 = call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %53)
  call void %54(i32 noundef 3552, i32 noundef %55, i32 noundef %56, i32 noundef %57, i32 noundef 0, i32 noundef %58, i32 noundef 5121, ptr noundef %59)
  %60 = call noundef i32 @_ZNK6nv_dds8CTexture15get_num_mipmapsEv(ptr noundef nonnull align 8 dereferenceable(112) %12)
  %61 = icmp ult i32 %55, %60
  br i1 %61, label %.lr.ph, label %._crit_edge, !llvm.loop !27

62:                                               ; preds = %._crit_edge
  %63 = load ptr, ptr @glad_glPixelStorei, align 8, !tbaa !21
  call void %63(i32 noundef 3317, i32 noundef %52)
  br label %64

64:                                               ; preds = %62, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph33, %24, %64, %21
  %.0 = phi i1 [ false, %21 ], [ true, %64 ], [ true, %24 ], [ true, %.lr.ph33 ]
  ret i1 %.0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6nv_dds8CSurface10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN6nv_dds9CDDSImage16is_dword_alignedEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #5 align 2

attributes #0 = { noreturn 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 = { 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 = { 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 #6 = { noreturn nounwind }
attributes #7 = { 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, !11, i64 16}
!6 = !{!"_ZTSN6nv_dds9CDDSImageE", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !11, i64 16, !12, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN6nv_dds11TextureTypeE", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"_ZTSSt5dequeIN6nv_dds8CTextureESaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSSt11_Deque_baseIN6nv_dds8CTextureESaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSNSt11_Deque_baseIN6nv_dds8CTextureESaIS1_EE11_Deque_implE", !15, i64 0}
!15 = !{!"_ZTSNSt11_Deque_baseIN6nv_dds8CTextureESaIS1_EE16_Deque_impl_dataE", !16, i64 0, !17, i64 8, !18, i64 16, !18, i64 48}
!16 = !{!"any pointer", !8, i64 0}
!17 = !{!"long", !8, i64 0}
!18 = !{!"_ZTSSt15_Deque_iteratorIN6nv_dds8CTextureERS1_PS1_E", !16, i64 0, !16, i64 8, !16, i64 16, !16, i64 24}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!16, !16, i64 0}
!22 = !{!6, !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!7, !7, i64 0}
!26 = !{!6, !7, i64 4}
!27 = distinct !{!27, !24}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass