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

; 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.34 = external hidden unnamed_addr constant [24 x i8], align 1
@__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage4flipERNS_8CSurfaceE = external hidden unnamed_addr constant [41 x i8], align 1

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6nv_dds9CDDSImage4flipERNS_8CSurfaceE(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca { i64, i64 }, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %20 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %21 = call noundef zeroext i1 @_ZN6nv_dds9CDDSImage13is_compressedEv(ptr noundef nonnull align 8 dereferenceable(104) %20)
  br i1 %21, label %88, label %22

22:                                               ; preds = %2
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = call noundef i32 @_ZNK6nv_dds8CSurface9get_depthEv(ptr noundef nonnull align 8 dereferenceable(32) %23)
  %25 = icmp ugt i32 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %22
  br label %29

27:                                               ; preds = %22
  call void @__assert_fail(ptr noundef @.str.34, ptr noundef @.str.1, i32 noundef 969, ptr noundef @__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage4flipERNS_8CSurfaceE) #6
  unreachable

28:                                               ; No predecessors!
  br label %29

29:                                               ; preds = %28, %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = call noundef i32 @_ZNK6nv_dds8CSurface8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %30)
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call noundef i32 @_ZNK6nv_dds8CSurface9get_depthEv(ptr noundef nonnull align 8 dereferenceable(32) %32)
  %34 = udiv i32 %31, %33
  store i32 %34, ptr %7, align 4, !tbaa !9
  %35 = load i32, ptr %7, align 4, !tbaa !9
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = call noundef i32 @_ZNK6nv_dds8CSurface10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32) %36)
  %38 = udiv i32 %35, %37
  store i32 %38, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %84, %29
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = call noundef i32 @_ZNK6nv_dds8CSurface9get_depthEv(ptr noundef nonnull align 8 dereferenceable(32) %41)
  %43 = icmp ult i32 %40, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %39
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %87

45:                                               ; preds = %39
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = mul i32 %46, %47
  store i32 %48, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %49)
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds i8, ptr %50, i64 %52
  store ptr %53, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = load i32, ptr %7, align 4, !tbaa !9
  %56 = load i32, ptr %5, align 4, !tbaa !9
  %57 = sub i32 %55, %56
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds i8, ptr %54, i64 %58
  store ptr %59, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %80, %45
  %61 = load i32, ptr %12, align 4, !tbaa !9
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = call noundef i32 @_ZNK6nv_dds8CSurface10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32) %62)
  %64 = lshr i32 %63, 1
  %65 = icmp ult i32 %61, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %60
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %83

67:                                               ; preds = %60
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = load ptr, ptr %10, align 8, !tbaa !5
  %70 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN6nv_dds9CDDSImage4swapEPvS1_j(ptr noundef nonnull align 8 dereferenceable(104) %20, ptr noundef %68, ptr noundef %69, i32 noundef %70)
  %71 = load i32, ptr %5, align 4, !tbaa !9
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = zext i32 %71 to i64
  %74 = getelementptr inbounds i8, ptr %72, i64 %73
  store ptr %74, ptr %10, align 8, !tbaa !5
  %75 = load i32, ptr %5, align 4, !tbaa !9
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = zext i32 %75 to i64
  %78 = sub i64 0, %77
  %79 = getelementptr inbounds i8, ptr %76, i64 %78
  store ptr %79, ptr %11, align 8, !tbaa !5
  br label %80

80:                                               ; preds = %67
  %81 = load i32, ptr %12, align 4, !tbaa !9
  %82 = add i32 %81, 1
  store i32 %82, ptr %12, align 4, !tbaa !9
  br label %60, !llvm.loop !11

83:                                               ; preds = %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %84

84:                                               ; preds = %83
  %85 = load i32, ptr %8, align 4, !tbaa !9
  %86 = add i32 %85, 1
  store i32 %86, ptr %8, align 4, !tbaa !9
  br label %39, !llvm.loop !13

87:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %206

88:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = call noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %89)
  %91 = udiv i32 %90, 4
  store i32 %91, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %92 = load ptr, ptr %4, align 8, !tbaa !5
  %93 = call noundef i32 @_ZNK6nv_dds8CSurface10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32) %92)
  %94 = udiv i32 %93, 4
  store i32 %94, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %95 = getelementptr inbounds %"class.nv_dds::CDDSImage", ptr %20, i32 0, i32 0
  %96 = load i32, ptr %95, align 8, !tbaa !14
  switch i32 %96, label %100 [
    i32 33777, label %97
    i32 33778, label %98
    i32 33779, label %99
  ]

97:                                               ; preds = %88
  store i32 8, ptr %16, align 4, !tbaa !9
  store { i64, i64 } { i64 ptrtoint (ptr @_ZN6nv_dds9CDDSImage17flip_blocks_dxtc1EPNS_11DXTColBlockEj to i64), i64 0 }, ptr %13, align 8, !tbaa !24
  br label %101

98:                                               ; preds = %88
  store i32 16, ptr %16, align 4, !tbaa !9
  store { i64, i64 } { i64 ptrtoint (ptr @_ZN6nv_dds9CDDSImage17flip_blocks_dxtc3EPNS_11DXTColBlockEj to i64), i64 0 }, ptr %13, align 8, !tbaa !24
  br label %101

99:                                               ; preds = %88
  store i32 16, ptr %16, align 4, !tbaa !9
  store { i64, i64 } { i64 ptrtoint (ptr @_ZN6nv_dds9CDDSImage17flip_blocks_dxtc5EPNS_11DXTColBlockEj to i64), i64 0 }, ptr %13, align 8, !tbaa !24
  br label %101

100:                                              ; preds = %88
  store i32 1, ptr %9, align 4
  br label %203

101:                                              ; preds = %99, %98, %97
  %102 = load i32, ptr %14, align 4, !tbaa !9
  %103 = load i32, ptr %16, align 4, !tbaa !9
  %104 = mul i32 %102, %103
  store i32 %104, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %105

105:                                              ; preds = %198, %101
  %106 = load i32, ptr %17, align 4, !tbaa !9
  %107 = load i32, ptr %15, align 4, !tbaa !9
  %108 = lshr i32 %107, 1
  %109 = icmp ugt i32 %108, 1
  br i1 %109, label %110, label %113

110:                                              ; preds = %105
  %111 = load i32, ptr %15, align 4, !tbaa !9
  %112 = lshr i32 %111, 1
  br label %114

113:                                              ; preds = %105
  br label %114

114:                                              ; preds = %113, %110
  %115 = phi i32 [ %112, %110 ], [ 1, %113 ]
  %116 = icmp ult i32 %106, %115
  br i1 %116, label %118, label %117

117:                                              ; preds = %114
  store i32 9, ptr %9, align 4
  br label %201

118:                                              ; preds = %114
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %119 = load ptr, ptr %4, align 8, !tbaa !5
  %120 = call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %119)
  %121 = load i32, ptr %17, align 4, !tbaa !9
  %122 = load i32, ptr %5, align 4, !tbaa !9
  %123 = mul i32 %121, %122
  %124 = zext i32 %123 to i64
  %125 = getelementptr inbounds i8, ptr %120, i64 %124
  store ptr %125, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  %126 = load ptr, ptr %4, align 8, !tbaa !5
  %127 = call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %126)
  %128 = load i32, ptr %15, align 4, !tbaa !9
  %129 = load i32, ptr %17, align 4, !tbaa !9
  %130 = sub i32 %128, %129
  %131 = sub i32 %130, 1
  %132 = load i32, ptr %5, align 4, !tbaa !9
  %133 = mul i32 %131, %132
  %134 = zext i32 %133 to i64
  %135 = getelementptr inbounds i8, ptr %127, i64 %134
  store ptr %135, ptr %19, align 8, !tbaa !5
  %136 = load ptr, ptr %18, align 8, !tbaa !5
  %137 = load ptr, ptr %19, align 8, !tbaa !5
  %138 = icmp eq ptr %136, %137
  br i1 %138, label %139, label %157

139:                                              ; preds = %118
  %140 = load { i64, i64 }, ptr %13, align 8, !tbaa !24
  %141 = extractvalue { i64, i64 } %140, 1
  %142 = getelementptr inbounds i8, ptr %20, i64 %141
  %143 = extractvalue { i64, i64 } %140, 0
  %144 = and i64 %143, 1
  %145 = icmp ne i64 %144, 0
  br i1 %145, label %146, label %151

146:                                              ; preds = %139
  %147 = load ptr, ptr %142, align 8, !tbaa !25
  %148 = sub i64 %143, 1
  %149 = getelementptr i8, ptr %147, i64 %148, !nosanitize !27
  %150 = load ptr, ptr %149, align 8, !nosanitize !27
  br label %153

151:                                              ; preds = %139
  %152 = inttoptr i64 %143 to ptr
  br label %153

153:                                              ; preds = %151, %146
  %154 = phi ptr [ %150, %146 ], [ %152, %151 ]
  %155 = load ptr, ptr %18, align 8, !tbaa !5
  %156 = load i32, ptr %14, align 4, !tbaa !9
  call void %154(ptr noundef nonnull align 8 dereferenceable(104) %142, ptr noundef %155, i32 noundef %156)
  store i32 9, ptr %9, align 4
  br label %195

157:                                              ; preds = %118
  %158 = load { i64, i64 }, ptr %13, align 8, !tbaa !24
  %159 = extractvalue { i64, i64 } %158, 1
  %160 = getelementptr inbounds i8, ptr %20, i64 %159
  %161 = extractvalue { i64, i64 } %158, 0
  %162 = and i64 %161, 1
  %163 = icmp ne i64 %162, 0
  br i1 %163, label %164, label %169

164:                                              ; preds = %157
  %165 = load ptr, ptr %160, align 8, !tbaa !25
  %166 = sub i64 %161, 1
  %167 = getelementptr i8, ptr %165, i64 %166, !nosanitize !27
  %168 = load ptr, ptr %167, align 8, !nosanitize !27
  br label %171

169:                                              ; preds = %157
  %170 = inttoptr i64 %161 to ptr
  br label %171

171:                                              ; preds = %169, %164
  %172 = phi ptr [ %168, %164 ], [ %170, %169 ]
  %173 = load ptr, ptr %18, align 8, !tbaa !5
  %174 = load i32, ptr %14, align 4, !tbaa !9
  call void %172(ptr noundef nonnull align 8 dereferenceable(104) %160, ptr noundef %173, i32 noundef %174)
  %175 = load { i64, i64 }, ptr %13, align 8, !tbaa !24
  %176 = extractvalue { i64, i64 } %175, 1
  %177 = getelementptr inbounds i8, ptr %20, i64 %176
  %178 = extractvalue { i64, i64 } %175, 0
  %179 = and i64 %178, 1
  %180 = icmp ne i64 %179, 0
  br i1 %180, label %181, label %186

181:                                              ; preds = %171
  %182 = load ptr, ptr %177, align 8, !tbaa !25
  %183 = sub i64 %178, 1
  %184 = getelementptr i8, ptr %182, i64 %183, !nosanitize !27
  %185 = load ptr, ptr %184, align 8, !nosanitize !27
  br label %188

186:                                              ; preds = %171
  %187 = inttoptr i64 %178 to ptr
  br label %188

188:                                              ; preds = %186, %181
  %189 = phi ptr [ %185, %181 ], [ %187, %186 ]
  %190 = load ptr, ptr %19, align 8, !tbaa !5
  %191 = load i32, ptr %14, align 4, !tbaa !9
  call void %189(ptr noundef nonnull align 8 dereferenceable(104) %177, ptr noundef %190, i32 noundef %191)
  %192 = load ptr, ptr %19, align 8, !tbaa !5
  %193 = load ptr, ptr %18, align 8, !tbaa !5
  %194 = load i32, ptr %5, align 4, !tbaa !9
  call void @_ZN6nv_dds9CDDSImage4swapEPvS1_j(ptr noundef nonnull align 8 dereferenceable(104) %20, ptr noundef %192, ptr noundef %193, i32 noundef %194)
  store i32 0, ptr %9, align 4
  br label %195

195:                                              ; preds = %188, %153
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  %196 = load i32, ptr %9, align 4
  switch i32 %196, label %201 [
    i32 0, label %197
  ]

197:                                              ; preds = %195
  br label %198

198:                                              ; preds = %197
  %199 = load i32, ptr %17, align 4, !tbaa !9
  %200 = add i32 %199, 1
  store i32 %200, ptr %17, align 4, !tbaa !9
  br label %105, !llvm.loop !28

201:                                              ; preds = %195, %117
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %202

202:                                              ; preds = %201
  store i32 0, ptr %9, align 4
  br label %203

203:                                              ; preds = %202, %100
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #5
  %204 = load i32, ptr %9, align 4
  switch i32 %204, label %207 [
    i32 0, label %205
  ]

205:                                              ; preds = %203
  br label %206

206:                                              ; preds = %205, %87
  store i32 0, ptr %9, align 4
  br label %207

207:                                              ; preds = %206, %203
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  %208 = load i32, ptr %9, align 4
  switch i32 %208, label %210 [
    i32 0, label %209
    i32 1, label %209
  ]

209:                                              ; preds = %207, %207
  ret void

210:                                              ; preds = %207
  unreachable
}

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6nv_dds9CDDSImage4swapEPvS1_j(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef, ptr noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6nv_dds9CDDSImage17flip_blocks_dxtc1EPNS_11DXTColBlockEj(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6nv_dds9CDDSImage17flip_blocks_dxtc3EPNS_11DXTColBlockEj(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6nv_dds9CDDSImage17flip_blocks_dxtc5EPNS_11DXTColBlockEj(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef, i32 noundef) #3 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 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !10, i64 0}
!15 = !{!"_ZTSN6nv_dds9CDDSImageE", !10, i64 0, !10, i64 4, !10, i64 8, !16, i64 12, !17, i64 16, !18, i64 24}
!16 = !{!"_ZTSN6nv_dds11TextureTypeE", !7, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!"_ZTSSt5dequeIN6nv_dds8CTextureESaIS1_EE", !19, i64 0}
!19 = !{!"_ZTSSt11_Deque_baseIN6nv_dds8CTextureESaIS1_EE", !20, i64 0}
!20 = !{!"_ZTSNSt11_Deque_baseIN6nv_dds8CTextureESaIS1_EE11_Deque_implE", !21, i64 0}
!21 = !{!"_ZTSNSt11_Deque_baseIN6nv_dds8CTextureESaIS1_EE16_Deque_impl_dataE", !6, i64 0, !22, i64 8, !23, i64 16, !23, i64 48}
!22 = !{!"long", !7, i64 0}
!23 = !{!"_ZTSSt15_Deque_iteratorIN6nv_dds8CTextureERS1_PS1_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!24 = !{!7, !7, i64 0}
!25 = !{!26, !26, i64 0}
!26 = !{!"vtable pointer", !8, i64 0}
!27 = !{}
!28 = distinct !{!28, !12}


; 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.34 = external hidden unnamed_addr constant [24 x i8], align 1
@__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage4flipERNS_8CSurfaceE = external hidden unnamed_addr constant [41 x i8], align 1
@switch.table._ZN6nv_dds9CDDSImage4flipERNS_8CSurfaceE = private unnamed_addr constant [3 x ptr] [ptr @_ZN6nv_dds9CDDSImage17flip_blocks_dxtc1EPNS_11DXTColBlockEj, ptr @_ZN6nv_dds9CDDSImage17flip_blocks_dxtc3EPNS_11DXTColBlockEj, ptr @_ZN6nv_dds9CDDSImage17flip_blocks_dxtc5EPNS_11DXTColBlockEj], align 8
@switch.table._ZN6nv_dds9CDDSImage4flipERNS_8CSurfaceE.1 = private unnamed_addr constant [3 x i32] [i32 8, i32 16, i32 16], align 4

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

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

; 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 #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6nv_dds9CDDSImage4flipERNS_8CSurfaceE(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) local_unnamed_addr #2 align 2 {
  %3 = tail call noundef zeroext i1 @_ZN6nv_dds9CDDSImage13is_compressedEv(ptr noundef nonnull align 8 dereferenceable(104) %0)
  br i1 %3, label %35, label %4

4:                                                ; preds = %2
  %5 = tail call noundef i32 @_ZNK6nv_dds8CSurface9get_depthEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %7

6:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.34, ptr noundef nonnull @.str.1, i32 noundef 969, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN6nv_dds9CDDSImage4flipERNS_8CSurfaceE) #5
  unreachable

7:                                                ; preds = %4
  %8 = tail call noundef i32 @_ZNK6nv_dds8CSurface8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %9 = tail call noundef i32 @_ZNK6nv_dds8CSurface9get_depthEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %10 = udiv i32 %8, %9
  %11 = tail call noundef i32 @_ZNK6nv_dds8CSurface10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %12 = udiv i32 %10, %11
  %13 = tail call noundef i32 @_ZNK6nv_dds8CSurface9get_depthEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %.not94 = icmp eq i32 %13, 0
  br i1 %.not94, label %.critedge, label %.lr.ph92

.lr.ph92:                                         ; preds = %7
  %14 = sub i32 %10, %12
  %15 = zext i32 %14 to i64
  %16 = zext i32 %12 to i64
  %17 = sub nsw i64 0, %16
  br label %18

18:                                               ; preds = %.lr.ph92, %._crit_edge
  %indvars.iv = phi i64 [ 0, %.lr.ph92 ], [ %indvars.iv.next, %._crit_edge ]
  %19 = tail call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %20 = tail call noundef i32 @_ZNK6nv_dds8CSurface10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %.not95 = icmp ult i32 %20, 2
  br i1 %.not95, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %18
  %21 = trunc nuw i64 %indvars.iv to i32
  %22 = mul i32 %10, %21
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds i8, ptr %19, i64 %23
  %25 = getelementptr inbounds i8, ptr %24, i64 %15
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = tail call noundef i32 @_ZNK6nv_dds8CSurface9get_depthEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %27 = zext i32 %26 to i64
  %28 = icmp ult i64 %indvars.iv.next, %27
  br i1 %28, label %18, label %.critedge, !llvm.loop !5

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.07989 = phi ptr [ %29, %.lr.ph ], [ %24, %.lr.ph.preheader ]
  %.08088 = phi i32 [ %31, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %.08187 = phi ptr [ %30, %.lr.ph ], [ %25, %.lr.ph.preheader ]
  tail call void @_ZN6nv_dds9CDDSImage4swapEPvS1_j(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %.08187, ptr noundef %.07989, i32 noundef %12)
  %29 = getelementptr inbounds i8, ptr %.07989, i64 %16
  %30 = getelementptr inbounds i8, ptr %.08187, i64 %17
  %31 = add nuw nsw i32 %.08088, 1
  %32 = tail call noundef i32 @_ZNK6nv_dds8CSurface10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %33 = lshr i32 %32, 1
  %34 = icmp ult i32 %31, %33
  br i1 %34, label %.lr.ph, label %._crit_edge, !llvm.loop !7

35:                                               ; preds = %2
  %36 = tail call noundef i32 @_ZNK6nv_dds8CSurface9get_widthEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %37 = lshr i32 %36, 2
  %38 = tail call noundef i32 @_ZNK6nv_dds8CSurface10get_heightEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %39 = lshr i32 %38, 2
  %40 = load i32, ptr %0, align 8, !tbaa !8
  %switch.tableidx = add i32 %40, -33777
  %41 = icmp ult i32 %switch.tableidx, 3
  br i1 %41, label %switch.lookup, label %.critedge

switch.lookup:                                    ; preds = %35
  %42 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [3 x ptr], ptr @switch.table._ZN6nv_dds9CDDSImage4flipERNS_8CSurfaceE, i64 0, i64 %42
  %switch.load = load ptr, ptr %switch.gep, align 8
  %43 = zext nneg i32 %switch.tableidx to i64
  %switch.gep106 = getelementptr inbounds [3 x i32], ptr @switch.table._ZN6nv_dds9CDDSImage4flipERNS_8CSurfaceE.1, i64 0, i64 %43
  %switch.load107 = load i32, ptr %switch.gep106, align 4
  %44 = mul i32 %switch.load107, %37
  %45 = lshr i32 %38, 3
  %umax = tail call i32 @llvm.umax.i32(i32 %45, i32 1)
  %wide.trip.count = zext nneg i32 %umax to i64
  br label %46

46:                                               ; preds = %switch.lookup, %58
  %indvars.iv99 = phi i64 [ 0, %switch.lookup ], [ %indvars.iv.next100, %58 ]
  %47 = tail call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %48 = trunc nuw nsw i64 %indvars.iv99 to i32
  %49 = mul i32 %44, %48
  %50 = zext i32 %49 to i64
  %51 = getelementptr inbounds i8, ptr %47, i64 %50
  %52 = tail call noundef ptr @_ZNK6nv_dds8CSurfacecvPhEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %53 = xor i32 %48, -1
  %54 = add nsw i32 %39, %53
  %55 = mul i32 %54, %44
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds i8, ptr %52, i64 %56
  %.not85 = icmp eq ptr %51, %57
  tail call void %switch.load(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %51, i32 noundef %37)
  br i1 %.not85, label %.critedge, label %58

58:                                               ; preds = %46
  tail call void %switch.load(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %57, i32 noundef %37)
  tail call void @_ZN6nv_dds9CDDSImage4swapEPvS1_j(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %57, ptr noundef %51, i32 noundef %44)
  %indvars.iv.next100 = add nuw nsw i64 %indvars.iv99, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next100, %wide.trip.count
  br i1 %exitcond.not, label %.critedge, label %46, !llvm.loop !22

.critedge:                                        ; preds = %._crit_edge, %58, %46, %35, %7
  ret void
}

; 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 #1 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 #1 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 #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6nv_dds9CDDSImage4swapEPvS1_j(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6nv_dds9CDDSImage17flip_blocks_dxtc1EPNS_11DXTColBlockEj(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6nv_dds9CDDSImage17flip_blocks_dxtc3EPNS_11DXTColBlockEj(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6nv_dds9CDDSImage17flip_blocks_dxtc5EPNS_11DXTColBlockEj(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef, i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #4

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


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