; LLVM IR from drohmer/cgp :: library/third_party/src/jpeg (jpgd)

; 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.jpgd::jpeg_decoder" = type <{ [1 x %struct.__jmp_buf_tag], ptr, i32, i32, ptr, i32, [8 x i8], [4 x i8], [8 x ptr], [8 x ptr], [4 x ptr], i32, i32, [4 x i32], [4 x i32], [4 x i32], [4 x i32], [4 x i32], [4 x i32], i32, [4 x i32], [4 x i32], [4 x i32], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [10 x i32], i32, i32, i32, i32, i32, [8 x ptr], [4 x ptr], [4 x ptr], i32, [4 x i32], [4 x i8], ptr, i32, i32, i8, [128 x i8], [8320 x i8], [128 x i8], [3 x i8], i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8, [3 x i8], i32, [4 x i32], [4 x i8], ptr, [10 x i32], ptr, [256 x i32], [256 x i32], [256 x i32], [256 x i32], ptr, ptr, i32, i8, [3 x i8], i32, [4 x i8] }>
%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t }
%struct.__sigset_t = type { [16 x i64] }

@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@_ZN4jpgdL5g_ZAGE = external hidden global [64 x i32], align 16
@.str.12 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__._ZN4jpgd12jpeg_decoder22decode_block_ac_refineEPS0_iii = external hidden unnamed_addr constant [86 x i8], align 1

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress noreturn uwtable
declare dso_local void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652), i32 noundef) #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN4jpgd12jpeg_decoder19get_bits_no_markersEi(ptr noundef nonnull align 8 dereferenceable(13652), i32 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4jpgd12jpeg_decoder14coeff_buf_getpEPNS0_9coeff_bufEii(ptr noundef nonnull align 8 dereferenceable(13652), ptr noundef, i32 noundef, i32 noundef) #4 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN4jpgd12jpeg_decoder11huff_decodeEPNS0_11huff_tablesE(ptr noundef nonnull align 8 dereferenceable(13652), ptr noundef) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4jpgd12jpeg_decoder22decode_block_ac_refineEPS0_iii(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #5 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %18, i32 0, i32 25
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = shl i32 1, %20
  store i32 %21, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %22, i32 0, i32 25
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = shl i32 -1, %24
  store i32 %25, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %27, i32 0, i32 41
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [4 x ptr], ptr %28, i64 0, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = call noundef ptr @_ZN4jpgd12jpeg_decoder14coeff_buf_getpEPNS0_9coeff_bufEii(ptr noundef nonnull align 8 dereferenceable(13652) %26, ptr noundef %32, i32 noundef %33, i32 noundef %34)
  store ptr %35, ptr %14, align 8, !tbaa !5
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %36, i32 0, i32 24
  %38 = load i32, ptr %37, align 8, !tbaa !15
  %39 = icmp sle i32 %38, 63
  br i1 %39, label %40, label %41

40:                                               ; preds = %4
  br label %43

41:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.12, ptr noundef @.str.1, i32 noundef 2692, ptr noundef @__PRETTY_FUNCTION__._ZN4jpgd12jpeg_decoder22decode_block_ac_refineEPS0_iii) #7
  unreachable

42:                                               ; No predecessors!
  br label %43

43:                                               ; preds = %42, %40
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %44, i32 0, i32 23
  %46 = load i32, ptr %45, align 4, !tbaa !16
  store i32 %46, ptr %10, align 4, !tbaa !9
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %47, i32 0, i32 42
  %49 = load i32, ptr %48, align 8, !tbaa !17
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %51, label %200

51:                                               ; preds = %43
  br label %52

52:                                               ; preds = %196, %51
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %54, i32 0, i32 24
  %56 = load i32, ptr %55, align 8, !tbaa !15
  %57 = icmp sle i32 %53, %56
  br i1 %57, label %58, label %199

58:                                               ; preds = %52
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = load ptr, ptr %5, align 8, !tbaa !5
  %61 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %60, i32 0, i32 39
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %62, i32 0, i32 22
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [4 x i32], ptr %63, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [8 x ptr], ptr %61, i64 0, i64 %68
  %70 = load ptr, ptr %69, align 8, !tbaa !5
  %71 = call noundef i32 @_ZN4jpgd12jpeg_decoder11huff_decodeEPNS0_11huff_tablesE(ptr noundef nonnull align 8 dereferenceable(13652) %59, ptr noundef %70)
  store i32 %71, ptr %9, align 4, !tbaa !9
  %72 = load i32, ptr %9, align 4, !tbaa !9
  %73 = ashr i32 %72, 4
  store i32 %73, ptr %11, align 4, !tbaa !9
  %74 = load i32, ptr %9, align 4, !tbaa !9
  %75 = and i32 %74, 15
  store i32 %75, ptr %9, align 4, !tbaa !9
  %76 = load i32, ptr %9, align 4, !tbaa !9
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %92

78:                                               ; preds = %58
  %79 = load i32, ptr %9, align 4, !tbaa !9
  %80 = icmp ne i32 %79, 1
  br i1 %80, label %81, label %83

81:                                               ; preds = %78
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652) %82, i32 noundef -230) #8
  unreachable

83:                                               ; preds = %78
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = call noundef i32 @_ZN4jpgd12jpeg_decoder19get_bits_no_markersEi(ptr noundef nonnull align 8 dereferenceable(13652) %84, i32 noundef 1)
  %86 = icmp ne i32 %85, 0
  br i1 %86, label %87, label %89

87:                                               ; preds = %83
  %88 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %88, ptr %9, align 4, !tbaa !9
  br label %91

89:                                               ; preds = %83
  %90 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %90, ptr %9, align 4, !tbaa !9
  br label %91

91:                                               ; preds = %89, %87
  br label %112

92:                                               ; preds = %58
  %93 = load i32, ptr %11, align 4, !tbaa !9
  %94 = icmp ne i32 %93, 15
  br i1 %94, label %95, label %111

95:                                               ; preds = %92
  %96 = load i32, ptr %11, align 4, !tbaa !9
  %97 = shl i32 1, %96
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %98, i32 0, i32 42
  store i32 %97, ptr %99, align 8, !tbaa !17
  %100 = load i32, ptr %11, align 4, !tbaa !9
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %102, label %110

102:                                              ; preds = %95
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = load i32, ptr %11, align 4, !tbaa !9
  %105 = call noundef i32 @_ZN4jpgd12jpeg_decoder19get_bits_no_markersEi(ptr noundef nonnull align 8 dereferenceable(13652) %103, i32 noundef %104)
  %106 = load ptr, ptr %5, align 8, !tbaa !5
  %107 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %106, i32 0, i32 42
  %108 = load i32, ptr %107, align 8, !tbaa !17
  %109 = add i32 %108, %105
  store i32 %109, ptr %107, align 8, !tbaa !17
  br label %110

110:                                              ; preds = %102, %95
  br label %199

111:                                              ; preds = %92
  br label %112

112:                                              ; preds = %111, %91
  br label %113

113:                                              ; preds = %173, %112
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %114 = load ptr, ptr %14, align 8, !tbaa !5
  %115 = load i32, ptr %10, align 4, !tbaa !9
  %116 = and i32 %115, 63
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [64 x i32], ptr @_ZN4jpgdL5g_ZAGE, i64 0, i64 %117
  %119 = load i32, ptr %118, align 4, !tbaa !9
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds i16, ptr %114, i64 %120
  store ptr %121, ptr %15, align 8, !tbaa !5
  %122 = load ptr, ptr %15, align 8, !tbaa !5
  %123 = load i16, ptr %122, align 2, !tbaa !18
  %124 = sext i16 %123 to i32
  %125 = icmp ne i32 %124, 0
  br i1 %125, label %126, label %161

126:                                              ; preds = %113
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  %128 = call noundef i32 @_ZN4jpgd12jpeg_decoder19get_bits_no_markersEi(ptr noundef nonnull align 8 dereferenceable(13652) %127, i32 noundef 1)
  %129 = icmp ne i32 %128, 0
  br i1 %129, label %130, label %160

130:                                              ; preds = %126
  %131 = load ptr, ptr %15, align 8, !tbaa !5
  %132 = load i16, ptr %131, align 2, !tbaa !18
  %133 = sext i16 %132 to i32
  %134 = load i32, ptr %12, align 4, !tbaa !9
  %135 = and i32 %133, %134
  %136 = icmp eq i32 %135, 0
  br i1 %136, label %137, label %159

137:                                              ; preds = %130
  %138 = load ptr, ptr %15, align 8, !tbaa !5
  %139 = load i16, ptr %138, align 2, !tbaa !18
  %140 = sext i16 %139 to i32
  %141 = icmp sge i32 %140, 0
  br i1 %141, label %142, label %150

142:                                              ; preds = %137
  %143 = load ptr, ptr %15, align 8, !tbaa !5
  %144 = load i16, ptr %143, align 2, !tbaa !18
  %145 = sext i16 %144 to i32
  %146 = load i32, ptr %12, align 4, !tbaa !9
  %147 = add nsw i32 %145, %146
  %148 = trunc i32 %147 to i16
  %149 = load ptr, ptr %15, align 8, !tbaa !5
  store i16 %148, ptr %149, align 2, !tbaa !18
  br label %158

150:                                              ; preds = %137
  %151 = load ptr, ptr %15, align 8, !tbaa !5
  %152 = load i16, ptr %151, align 2, !tbaa !18
  %153 = sext i16 %152 to i32
  %154 = load i32, ptr %13, align 4, !tbaa !9
  %155 = add nsw i32 %153, %154
  %156 = trunc i32 %155 to i16
  %157 = load ptr, ptr %15, align 8, !tbaa !5
  store i16 %156, ptr %157, align 2, !tbaa !18
  br label %158

158:                                              ; preds = %150, %142
  br label %159

159:                                              ; preds = %158, %130
  br label %160

160:                                              ; preds = %159, %126
  br label %167

161:                                              ; preds = %113
  %162 = load i32, ptr %11, align 4, !tbaa !9
  %163 = add nsw i32 %162, -1
  store i32 %163, ptr %11, align 4, !tbaa !9
  %164 = icmp slt i32 %163, 0
  br i1 %164, label %165, label %166

165:                                              ; preds = %161
  store i32 5, ptr %16, align 4
  br label %170

166:                                              ; preds = %161
  br label %167

167:                                              ; preds = %166, %160
  %168 = load i32, ptr %10, align 4, !tbaa !9
  %169 = add nsw i32 %168, 1
  store i32 %169, ptr %10, align 4, !tbaa !9
  store i32 0, ptr %16, align 4
  br label %170

170:                                              ; preds = %167, %165
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  %171 = load i32, ptr %16, align 4
  switch i32 %171, label %270 [
    i32 0, label %172
    i32 5, label %179
  ]

172:                                              ; preds = %170
  br label %173

173:                                              ; preds = %172
  %174 = load i32, ptr %10, align 4, !tbaa !9
  %175 = load ptr, ptr %5, align 8, !tbaa !5
  %176 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %175, i32 0, i32 24
  %177 = load i32, ptr %176, align 8, !tbaa !15
  %178 = icmp sle i32 %174, %177
  br i1 %178, label %113, label %179, !llvm.loop !20

179:                                              ; preds = %173, %170
  %180 = load i32, ptr %9, align 4, !tbaa !9
  %181 = icmp ne i32 %180, 0
  br i1 %181, label %182, label %195

182:                                              ; preds = %179
  %183 = load i32, ptr %10, align 4, !tbaa !9
  %184 = icmp slt i32 %183, 64
  br i1 %184, label %185, label %195

185:                                              ; preds = %182
  %186 = load i32, ptr %9, align 4, !tbaa !9
  %187 = trunc i32 %186 to i16
  %188 = load ptr, ptr %14, align 8, !tbaa !5
  %189 = load i32, ptr %10, align 4, !tbaa !9
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [64 x i32], ptr @_ZN4jpgdL5g_ZAGE, i64 0, i64 %190
  %192 = load i32, ptr %191, align 4, !tbaa !9
  %193 = sext i32 %192 to i64
  %194 = getelementptr inbounds i16, ptr %188, i64 %193
  store i16 %187, ptr %194, align 2, !tbaa !18
  br label %195

195:                                              ; preds = %185, %182, %179
  br label %196

196:                                              ; preds = %195
  %197 = load i32, ptr %10, align 4, !tbaa !9
  %198 = add nsw i32 %197, 1
  store i32 %198, ptr %10, align 4, !tbaa !9
  br label %52, !llvm.loop !22

199:                                              ; preds = %110, %52
  br label %200

200:                                              ; preds = %199, %43
  %201 = load ptr, ptr %5, align 8, !tbaa !5
  %202 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %201, i32 0, i32 42
  %203 = load i32, ptr %202, align 8, !tbaa !17
  %204 = icmp sgt i32 %203, 0
  br i1 %204, label %205, label %269

205:                                              ; preds = %200
  br label %206

206:                                              ; preds = %261, %205
  %207 = load i32, ptr %10, align 4, !tbaa !9
  %208 = load ptr, ptr %5, align 8, !tbaa !5
  %209 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %208, i32 0, i32 24
  %210 = load i32, ptr %209, align 8, !tbaa !15
  %211 = icmp sle i32 %207, %210
  br i1 %211, label %212, label %264

212:                                              ; preds = %206
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %213 = load ptr, ptr %14, align 8, !tbaa !5
  %214 = load i32, ptr %10, align 4, !tbaa !9
  %215 = and i32 %214, 63
  %216 = sext i32 %215 to i64
  %217 = getelementptr inbounds [64 x i32], ptr @_ZN4jpgdL5g_ZAGE, i64 0, i64 %216
  %218 = load i32, ptr %217, align 4, !tbaa !9
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds i16, ptr %213, i64 %219
  store ptr %220, ptr %17, align 8, !tbaa !5
  %221 = load ptr, ptr %17, align 8, !tbaa !5
  %222 = load i16, ptr %221, align 2, !tbaa !18
  %223 = sext i16 %222 to i32
  %224 = icmp ne i32 %223, 0
  br i1 %224, label %225, label %260

225:                                              ; preds = %212
  %226 = load ptr, ptr %5, align 8, !tbaa !5
  %227 = call noundef i32 @_ZN4jpgd12jpeg_decoder19get_bits_no_markersEi(ptr noundef nonnull align 8 dereferenceable(13652) %226, i32 noundef 1)
  %228 = icmp ne i32 %227, 0
  br i1 %228, label %229, label %259

229:                                              ; preds = %225
  %230 = load ptr, ptr %17, align 8, !tbaa !5
  %231 = load i16, ptr %230, align 2, !tbaa !18
  %232 = sext i16 %231 to i32
  %233 = load i32, ptr %12, align 4, !tbaa !9
  %234 = and i32 %232, %233
  %235 = icmp eq i32 %234, 0
  br i1 %235, label %236, label %258

236:                                              ; preds = %229
  %237 = load ptr, ptr %17, align 8, !tbaa !5
  %238 = load i16, ptr %237, align 2, !tbaa !18
  %239 = sext i16 %238 to i32
  %240 = icmp sge i32 %239, 0
  br i1 %240, label %241, label %249

241:                                              ; preds = %236
  %242 = load ptr, ptr %17, align 8, !tbaa !5
  %243 = load i16, ptr %242, align 2, !tbaa !18
  %244 = sext i16 %243 to i32
  %245 = load i32, ptr %12, align 4, !tbaa !9
  %246 = add nsw i32 %244, %245
  %247 = trunc i32 %246 to i16
  %248 = load ptr, ptr %17, align 8, !tbaa !5
  store i16 %247, ptr %248, align 2, !tbaa !18
  br label %257

249:                                              ; preds = %236
  %250 = load ptr, ptr %17, align 8, !tbaa !5
  %251 = load i16, ptr %250, align 2, !tbaa !18
  %252 = sext i16 %251 to i32
  %253 = load i32, ptr %13, align 4, !tbaa !9
  %254 = add nsw i32 %252, %253
  %255 = trunc i32 %254 to i16
  %256 = load ptr, ptr %17, align 8, !tbaa !5
  store i16 %255, ptr %256, align 2, !tbaa !18
  br label %257

257:                                              ; preds = %249, %241
  br label %258

258:                                              ; preds = %257, %229
  br label %259

259:                                              ; preds = %258, %225
  br label %260

260:                                              ; preds = %259, %212
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  br label %261

261:                                              ; preds = %260
  %262 = load i32, ptr %10, align 4, !tbaa !9
  %263 = add nsw i32 %262, 1
  store i32 %263, ptr %10, align 4, !tbaa !9
  br label %206, !llvm.loop !23

264:                                              ; preds = %206
  %265 = load ptr, ptr %5, align 8, !tbaa !5
  %266 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %265, i32 0, i32 42
  %267 = load i32, ptr %266, align 8, !tbaa !17
  %268 = add nsw i32 %267, -1
  store i32 %268, ptr %266, align 8, !tbaa !17
  br label %269

269:                                              ; preds = %264, %200
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  ret void

270:                                              ; preds = %170
  unreachable
}

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 = { mustprogress noreturn 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 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 = { 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 #5 = { 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 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { noreturn }

!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 = !{!12, !10, i64 564}
!12 = !{!"_ZTSN4jpgd12jpeg_decoderE", !7, i64 0, !6, i64 200, !10, i64 208, !10, i64 212, !6, i64 216, !10, i64 224, !7, i64 228, !7, i64 240, !7, i64 304, !7, i64 368, !10, i64 400, !10, i64 404, !7, i64 408, !7, i64 424, !7, i64 440, !7, i64 456, !7, i64 472, !7, i64 488, !10, i64 504, !7, i64 508, !7, i64 524, !7, i64 540, !10, i64 556, !10, i64 560, !10, i64 564, !10, i64 568, !10, i64 572, !10, i64 576, !10, i64 580, !10, i64 584, !10, i64 588, !10, i64 592, !7, i64 596, !10, i64 636, !10, i64 640, !10, i64 644, !10, i64 648, !10, i64 652, !7, i64 656, !7, i64 720, !7, i64 752, !10, i64 784, !7, i64 788, !6, i64 808, !10, i64 816, !10, i64 820, !13, i64 824, !7, i64 825, !7, i64 953, !7, i64 9273, !10, i64 9404, !10, i64 9408, !10, i64 9412, !10, i64 9416, !10, i64 9420, !10, i64 9424, !10, i64 9428, !10, i64 9432, !10, i64 9436, !10, i64 9440, !13, i64 9444, !10, i64 9448, !7, i64 9452, !6, i64 9472, !7, i64 9480, !6, i64 9520, !7, i64 9528, !7, i64 10552, !7, i64 11576, !7, i64 12600, !6, i64 13624, !6, i64 13632, !14, i64 13640, !13, i64 13644, !10, i64 13648}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN4jpgd11jpgd_statusE", !7, i64 0}
!15 = !{!12, !10, i64 560}
!16 = !{!12, !10, i64 556}
!17 = !{!12, !10, i64 784}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = distinct !{!23, !21}


; 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 [83 x i8], align 1
@_ZN4jpgdL5g_ZAGE = external hidden local_unnamed_addr global [64 x i32], align 16
@.str.12 = external hidden unnamed_addr constant [25 x i8], align 1
@__PRETTY_FUNCTION__._ZN4jpgd12jpeg_decoder22decode_block_ac_refineEPS0_iii = external hidden unnamed_addr constant [86 x i8], align 1

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

; Function Attrs: mustprogress noreturn uwtable
declare dso_local void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN4jpgd12jpeg_decoder19get_bits_no_markersEi(ptr noundef nonnull align 8 dereferenceable(13652), i32 noundef) local_unnamed_addr #2 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN4jpgd12jpeg_decoder11huff_decodeEPNS0_11huff_tablesE(ptr noundef nonnull align 8 dereferenceable(13652), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4jpgd12jpeg_decoder22decode_block_ac_refineEPS0_iii(ptr noundef nonnull %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #4 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 564
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = shl nuw i32 1, %6
  %8 = shl nsw i32 -1, %6
  %9 = getelementptr inbounds i8, ptr %0, i64 752
  %10 = sext i32 %1 to i64
  %11 = getelementptr inbounds [4 x ptr], ptr %9, i64 0, i64 %10
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = tail call noundef ptr @_ZN4jpgd12jpeg_decoder14coeff_buf_getpEPNS0_9coeff_bufEii(ptr noundef nonnull align 8 dereferenceable(13652) %0, ptr noundef %12, i32 noundef %2, i32 noundef %3)
  %14 = getelementptr inbounds i8, ptr %0, i64 560
  %15 = load i32, ptr %14, align 8, !tbaa !14
  %16 = icmp slt i32 %15, 64
  br i1 %16, label %18, label %17

17:                                               ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.1, i32 noundef 2692, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN4jpgd12jpeg_decoder22decode_block_ac_refineEPS0_iii) #5
  unreachable

18:                                               ; preds = %4
  %19 = getelementptr inbounds i8, ptr %0, i64 556
  %20 = load i32, ptr %19, align 4, !tbaa !15
  %21 = getelementptr inbounds i8, ptr %0, i64 784
  %22 = load i32, ptr %21, align 8, !tbaa !16
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %.preheader105, label %thread-pre-split

.preheader105:                                    ; preds = %18
  %.not111 = icmp sgt i32 %20, %15
  br i1 %.not111, label %thread-pre-split.thread, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader105
  %24 = getelementptr inbounds i8, ptr %0, i64 656
  %25 = getelementptr inbounds i8, ptr %0, i64 540
  %26 = getelementptr inbounds [4 x i32], ptr %25, i64 0, i64 %10
  br label %27

27:                                               ; preds = %.lr.ph, %79
  %.074112 = phi i32 [ %20, %.lr.ph ], [ %80, %79 ]
  %28 = load i32, ptr %26, align 4, !tbaa !17
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [8 x ptr], ptr %24, i64 0, i64 %29
  %31 = load ptr, ptr %30, align 8, !tbaa !13
  %32 = tail call noundef i32 @_ZN4jpgd12jpeg_decoder11huff_decodeEPNS0_11huff_tablesE(ptr noundef nonnull align 8 dereferenceable(13652) %0, ptr noundef %31)
  %33 = ashr i32 %32, 4
  %34 = and i32 %32, 15
  switch i32 %34, label %35 [
    i32 0, label %38
    i32 1, label %36
  ]

35:                                               ; preds = %27
  tail call void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef -230) #6
  unreachable

36:                                               ; preds = %27
  %37 = tail call noundef i32 @_ZN4jpgd12jpeg_decoder19get_bits_no_markersEi(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef 1)
  %.not94 = icmp eq i32 %37, 0
  %. = select i1 %.not94, i32 %8, i32 %7
  br label %45

38:                                               ; preds = %27
  %.not88 = icmp eq i32 %33, 15
  br i1 %.not88, label %45, label %39

39:                                               ; preds = %38
  %40 = shl nuw i32 1, %33
  store i32 %40, ptr %21, align 8, !tbaa !16
  %.not89 = icmp ult i32 %32, 16
  br i1 %.not89, label %thread-pre-split, label %41

41:                                               ; preds = %39
  %42 = tail call noundef i32 @_ZN4jpgd12jpeg_decoder19get_bits_no_markersEi(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef %33)
  %43 = load i32, ptr %21, align 8, !tbaa !16
  %44 = add i32 %43, %42
  store i32 %44, ptr %21, align 8, !tbaa !16
  br label %thread-pre-split

45:                                               ; preds = %36, %38
  %.0 = phi i32 [ 0, %38 ], [ %., %36 ]
  br label %46

46:                                               ; preds = %66, %45
  %.075 = phi i32 [ %33, %45 ], [ %.176, %66 ]
  %.1 = phi i32 [ %.074112, %45 ], [ %67, %66 ]
  %47 = and i32 %.1, 63
  %48 = zext nneg i32 %47 to i64
  %49 = getelementptr inbounds [64 x i32], ptr @_ZN4jpgdL5g_ZAGE, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !17
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds i16, ptr %13, i64 %51
  %53 = load i16, ptr %52, align 2, !tbaa !18
  %.not95 = icmp eq i16 %53, 0
  br i1 %.not95, label %63, label %54

54:                                               ; preds = %46
  %55 = tail call noundef i32 @_ZN4jpgd12jpeg_decoder19get_bits_no_markersEi(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef 1)
  %.not96 = icmp eq i32 %55, 0
  br i1 %.not96, label %66, label %56

56:                                               ; preds = %54
  %57 = load i16, ptr %52, align 2, !tbaa !18
  %58 = sext i16 %57 to i32
  %59 = and i32 %7, %58
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %.sink.split, label %66

.sink.split:                                      ; preds = %56
  %61 = icmp slt i16 %57, 0
  %.137.v = select i1 %61, i32 %8, i32 %7
  %.137 = trunc i32 %.137.v to i16
  %62 = add i16 %57, %.137
  store i16 %62, ptr %52, align 2, !tbaa !18
  br label %66

63:                                               ; preds = %46
  %64 = add nsw i32 %.075, -1
  %65 = icmp slt i32 %.075, 1
  br i1 %65, label %69, label %66

66:                                               ; preds = %.sink.split, %56, %54, %63
  %.176 = phi i32 [ %.075, %56 ], [ %.075, %54 ], [ %64, %63 ], [ %.075, %.sink.split ]
  %67 = add nsw i32 %.1, 1
  %68 = load i32, ptr %14, align 8, !tbaa !14
  %.not97.not = icmp slt i32 %.1, %68
  br i1 %.not97.not, label %46, label %69, !llvm.loop !20

69:                                               ; preds = %63, %66
  %.2103 = phi i32 [ %67, %66 ], [ %.1, %63 ]
  %70 = icmp ne i32 %.0, 0
  %71 = icmp slt i32 %.2103, 64
  %or.cond = select i1 %70, i1 %71, i1 false
  br i1 %or.cond, label %72, label %79

72:                                               ; preds = %69
  %73 = trunc i32 %.0 to i16
  %74 = sext i32 %.2103 to i64
  %75 = getelementptr inbounds [64 x i32], ptr @_ZN4jpgdL5g_ZAGE, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !17
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds i16, ptr %13, i64 %77
  store i16 %73, ptr %78, align 2, !tbaa !18
  br label %79

79:                                               ; preds = %69, %72
  %80 = add nsw i32 %.2103, 1
  %81 = load i32, ptr %14, align 8, !tbaa !14
  %.not.not = icmp slt i32 %.2103, %81
  br i1 %.not.not, label %27, label %thread-pre-split.loopexit, !llvm.loop !22

thread-pre-split.loopexit:                        ; preds = %79
  %.pr.pre = load i32, ptr %21, align 8, !tbaa !16
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %thread-pre-split.loopexit, %41, %39, %18
  %82 = phi i32 [ %44, %41 ], [ %40, %39 ], [ %22, %18 ], [ %.pr.pre, %thread-pre-split.loopexit ]
  %.3 = phi i32 [ %.074112, %41 ], [ %.074112, %39 ], [ %20, %18 ], [ %80, %thread-pre-split.loopexit ]
  %83 = icmp sgt i32 %82, 0
  br i1 %83, label %.preheader, label %thread-pre-split.thread

.preheader:                                       ; preds = %thread-pre-split
  %84 = load i32, ptr %14, align 8, !tbaa !14
  %.not90113 = icmp sgt i32 %.3, %84
  br i1 %.not90113, label %._crit_edge, label %.lr.ph115

.lr.ph115:                                        ; preds = %.preheader, %101
  %.4114 = phi i32 [ %102, %101 ], [ %.3, %.preheader ]
  %85 = and i32 %.4114, 63
  %86 = zext nneg i32 %85 to i64
  %87 = getelementptr inbounds [64 x i32], ptr @_ZN4jpgdL5g_ZAGE, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !17
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds i16, ptr %13, i64 %89
  %91 = load i16, ptr %90, align 2, !tbaa !18
  %.not91 = icmp eq i16 %91, 0
  br i1 %.not91, label %101, label %92

92:                                               ; preds = %.lr.ph115
  %93 = tail call noundef i32 @_ZN4jpgd12jpeg_decoder19get_bits_no_markersEi(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef 1)
  %.not92 = icmp eq i32 %93, 0
  br i1 %.not92, label %101, label %94

94:                                               ; preds = %92
  %95 = load i16, ptr %90, align 2, !tbaa !18
  %96 = sext i16 %95 to i32
  %97 = and i32 %7, %96
  %98 = icmp eq i32 %97, 0
  br i1 %98, label %.sink.split135, label %101

.sink.split135:                                   ; preds = %94
  %99 = icmp slt i16 %95, 0
  %.138.v = select i1 %99, i32 %8, i32 %7
  %.138 = trunc i32 %.138.v to i16
  %100 = add i16 %95, %.138
  store i16 %100, ptr %90, align 2, !tbaa !18
  br label %101

101:                                              ; preds = %.sink.split135, %92, %94, %.lr.ph115
  %102 = add nsw i32 %.4114, 1
  %103 = load i32, ptr %14, align 8, !tbaa !14
  %.not90.not = icmp slt i32 %.4114, %103
  br i1 %.not90.not, label %.lr.ph115, label %._crit_edge.loopexit, !llvm.loop !23

._crit_edge.loopexit:                             ; preds = %101
  %.pre = load i32, ptr %21, align 8, !tbaa !16
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %104 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %82, %.preheader ]
  %105 = add nsw i32 %104, -1
  store i32 %105, ptr %21, align 8, !tbaa !16
  br label %thread-pre-split.thread

thread-pre-split.thread:                          ; preds = %.preheader105, %._crit_edge, %thread-pre-split
  ret void
}

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 noreturn 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 = { 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 #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 = { 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 = { noreturn nounwind }
attributes #6 = { noreturn }

!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, !10, i64 564}
!6 = !{!"_ZTSN4jpgd12jpeg_decoderE", !7, i64 0, !9, i64 200, !10, i64 208, !10, i64 212, !9, i64 216, !10, i64 224, !7, i64 228, !7, i64 240, !7, i64 304, !7, i64 368, !10, i64 400, !10, i64 404, !7, i64 408, !7, i64 424, !7, i64 440, !7, i64 456, !7, i64 472, !7, i64 488, !10, i64 504, !7, i64 508, !7, i64 524, !7, i64 540, !10, i64 556, !10, i64 560, !10, i64 564, !10, i64 568, !10, i64 572, !10, i64 576, !10, i64 580, !10, i64 584, !10, i64 588, !10, i64 592, !7, i64 596, !10, i64 636, !10, i64 640, !10, i64 644, !10, i64 648, !10, i64 652, !7, i64 656, !7, i64 720, !7, i64 752, !10, i64 784, !7, i64 788, !9, i64 808, !10, i64 816, !10, i64 820, !11, i64 824, !7, i64 825, !7, i64 953, !7, i64 9273, !10, i64 9404, !10, i64 9408, !10, i64 9412, !10, i64 9416, !10, i64 9420, !10, i64 9424, !10, i64 9428, !10, i64 9432, !10, i64 9436, !10, i64 9440, !11, i64 9444, !10, i64 9448, !7, i64 9452, !9, i64 9472, !7, i64 9480, !9, i64 9520, !7, i64 9528, !7, i64 10552, !7, i64 11576, !7, i64 12600, !9, i64 13624, !9, i64 13632, !12, i64 13640, !11, i64 13644, !10, i64 13648}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"_ZTSN4jpgd11jpgd_statusE", !7, i64 0}
!13 = !{!9, !9, i64 0}
!14 = !{!6, !10, i64 560}
!15 = !{!6, !10, i64 556}
!16 = !{!6, !10, i64 784}
!17 = !{!10, !10, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = distinct !{!23, !21}


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