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

; 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] }

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4jpgd12jpeg_decoder21decode_block_dc_firstEPS0_iii(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4jpgd12jpeg_decoder22decode_block_dc_refineEPS0_iii(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4jpgd12jpeg_decoder21decode_block_ac_firstEPS0_iii(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4jpgd12jpeg_decoder22decode_block_ac_refineEPS0_iii(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #4 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4jpgd12jpeg_decoder16init_progressiveEv(ptr noundef nonnull align 8 dereferenceable(13652) %0) #4 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %9 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 12
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %11 = icmp eq i32 %10, 4
  br i1 %11, label %12, label %13

12:                                               ; preds = %1
  call void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652) %8, i32 noundef -232) #6
  unreachable

13:                                               ; preds = %1
  store i32 0, ptr %3, align 4, !tbaa !14
  br label %14

14:                                               ; preds = %62, %13
  %15 = load i32, ptr %3, align 4, !tbaa !14
  %16 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 12
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = icmp slt i32 %15, %17
  br i1 %18, label %19, label %65

19:                                               ; preds = %14
  %20 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 58
  %21 = load i32, ptr %20, align 8, !tbaa !15
  %22 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 13
  %23 = load i32, ptr %3, align 4, !tbaa !14
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [4 x i32], ptr %22, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !14
  %27 = mul nsw i32 %21, %26
  %28 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 65
  %29 = load i32, ptr %28, align 8, !tbaa !16
  %30 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 14
  %31 = load i32, ptr %3, align 4, !tbaa !14
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [4 x i32], ptr %30, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !14
  %35 = mul nsw i32 %29, %34
  %36 = call noundef ptr @_ZN4jpgd12jpeg_decoder14coeff_buf_openEiiii(ptr noundef nonnull align 8 dereferenceable(13652) %8, i32 noundef %27, i32 noundef %35, i32 noundef 1, i32 noundef 1)
  %37 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 40
  %38 = load i32, ptr %3, align 4, !tbaa !14
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [4 x ptr], ptr %37, i64 0, i64 %39
  store ptr %36, ptr %40, align 8, !tbaa !5
  %41 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 58
  %42 = load i32, ptr %41, align 8, !tbaa !15
  %43 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 13
  %44 = load i32, ptr %3, align 4, !tbaa !14
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [4 x i32], ptr %43, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !14
  %48 = mul nsw i32 %42, %47
  %49 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 65
  %50 = load i32, ptr %49, align 8, !tbaa !16
  %51 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 14
  %52 = load i32, ptr %3, align 4, !tbaa !14
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [4 x i32], ptr %51, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !14
  %56 = mul nsw i32 %50, %55
  %57 = call noundef ptr @_ZN4jpgd12jpeg_decoder14coeff_buf_openEiiii(ptr noundef nonnull align 8 dereferenceable(13652) %8, i32 noundef %48, i32 noundef %56, i32 noundef 8, i32 noundef 8)
  %58 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 41
  %59 = load i32, ptr %3, align 4, !tbaa !14
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [4 x ptr], ptr %58, i64 0, i64 %60
  store ptr %57, ptr %61, align 8, !tbaa !5
  br label %62

62:                                               ; preds = %19
  %63 = load i32, ptr %3, align 4, !tbaa !14
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %3, align 4, !tbaa !14
  br label %14, !llvm.loop !17

65:                                               ; preds = %14
  br label %66

66:                                               ; preds = %137, %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %67 = call noundef i32 @_ZN4jpgd12jpeg_decoder9init_scanEv(ptr noundef nonnull align 8 dereferenceable(13652) %8)
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %70, label %69

69:                                               ; preds = %66
  store i32 5, ptr %7, align 4
  br label %135

70:                                               ; preds = %66
  %71 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 23
  %72 = load i32, ptr %71, align 4, !tbaa !19
  %73 = icmp eq i32 %72, 0
  %74 = zext i1 %73 to i32
  store i32 %74, ptr %4, align 4, !tbaa !14
  %75 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 26
  %76 = load i32, ptr %75, align 8, !tbaa !20
  %77 = icmp ne i32 %76, 0
  %78 = zext i1 %77 to i32
  store i32 %78, ptr %5, align 4, !tbaa !14
  %79 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 23
  %80 = load i32, ptr %79, align 4, !tbaa !19
  %81 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 24
  %82 = load i32, ptr %81, align 8, !tbaa !21
  %83 = icmp sgt i32 %80, %82
  br i1 %83, label %88, label %84

84:                                               ; preds = %70
  %85 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 24
  %86 = load i32, ptr %85, align 8, !tbaa !21
  %87 = icmp sgt i32 %86, 63
  br i1 %87, label %88, label %89

88:                                               ; preds = %84, %70
  call void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652) %8, i32 noundef -227) #6
  unreachable

89:                                               ; preds = %84
  %90 = load i32, ptr %4, align 4, !tbaa !14
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %92, label %98

92:                                               ; preds = %89
  %93 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 24
  %94 = load i32, ptr %93, align 8, !tbaa !21
  %95 = icmp ne i32 %94, 0
  br i1 %95, label %96, label %97

96:                                               ; preds = %92
  call void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652) %8, i32 noundef -227) #6
  unreachable

97:                                               ; preds = %92
  br label %104

98:                                               ; preds = %89
  %99 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 19
  %100 = load i32, ptr %99, align 8, !tbaa !22
  %101 = icmp ne i32 %100, 1
  br i1 %101, label %102, label %103

102:                                              ; preds = %98
  call void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652) %8, i32 noundef -227) #6
  unreachable

103:                                              ; preds = %98
  br label %104

104:                                              ; preds = %103, %97
  %105 = load i32, ptr %5, align 4, !tbaa !14
  %106 = icmp ne i32 %105, 0
  br i1 %106, label %107, label %115

107:                                              ; preds = %104
  %108 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 25
  %109 = load i32, ptr %108, align 4, !tbaa !23
  %110 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 26
  %111 = load i32, ptr %110, align 8, !tbaa !20
  %112 = sub nsw i32 %111, 1
  %113 = icmp ne i32 %109, %112
  br i1 %113, label %114, label %115

114:                                              ; preds = %107
  call void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652) %8, i32 noundef -226) #6
  unreachable

115:                                              ; preds = %107, %104
  %116 = load i32, ptr %4, align 4, !tbaa !14
  %117 = icmp ne i32 %116, 0
  br i1 %117, label %118, label %124

118:                                              ; preds = %115
  %119 = load i32, ptr %5, align 4, !tbaa !14
  %120 = icmp ne i32 %119, 0
  br i1 %120, label %121, label %122

121:                                              ; preds = %118
  store ptr @_ZN4jpgd12jpeg_decoder22decode_block_dc_refineEPS0_iii, ptr %6, align 8, !tbaa !5
  br label %123

122:                                              ; preds = %118
  store ptr @_ZN4jpgd12jpeg_decoder21decode_block_dc_firstEPS0_iii, ptr %6, align 8, !tbaa !5
  br label %123

123:                                              ; preds = %122, %121
  br label %130

124:                                              ; preds = %115
  %125 = load i32, ptr %5, align 4, !tbaa !14
  %126 = icmp ne i32 %125, 0
  br i1 %126, label %127, label %128

127:                                              ; preds = %124
  store ptr @_ZN4jpgd12jpeg_decoder22decode_block_ac_refineEPS0_iii, ptr %6, align 8, !tbaa !5
  br label %129

128:                                              ; preds = %124
  store ptr @_ZN4jpgd12jpeg_decoder21decode_block_ac_firstEPS0_iii, ptr %6, align 8, !tbaa !5
  br label %129

129:                                              ; preds = %128, %127
  br label %130

130:                                              ; preds = %129, %123
  %131 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN4jpgd12jpeg_decoder11decode_scanEPFvPS0_iiiE(ptr noundef nonnull align 8 dereferenceable(13652) %8, ptr noundef %131)
  %132 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 53
  store i32 16, ptr %132, align 4, !tbaa !24
  %133 = call noundef i32 @_ZN4jpgd12jpeg_decoder8get_bitsEi(ptr noundef nonnull align 8 dereferenceable(13652) %8, i32 noundef 16)
  %134 = call noundef i32 @_ZN4jpgd12jpeg_decoder8get_bitsEi(ptr noundef nonnull align 8 dereferenceable(13652) %8, i32 noundef 16)
  store i32 0, ptr %7, align 4
  br label %135

135:                                              ; preds = %130, %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %136 = load i32, ptr %7, align 4
  switch i32 %136, label %157 [
    i32 0, label %137
    i32 5, label %138
  ]

137:                                              ; preds = %135
  br label %66, !llvm.loop !25

138:                                              ; preds = %135
  %139 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 12
  %140 = load i32, ptr %139, align 4, !tbaa !9
  %141 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 19
  store i32 %140, ptr %141, align 8, !tbaa !22
  store i32 0, ptr %3, align 4, !tbaa !14
  br label %142

142:                                              ; preds = %153, %138
  %143 = load i32, ptr %3, align 4, !tbaa !14
  %144 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 12
  %145 = load i32, ptr %144, align 4, !tbaa !9
  %146 = icmp slt i32 %143, %145
  br i1 %146, label %147, label %156

147:                                              ; preds = %142
  %148 = load i32, ptr %3, align 4, !tbaa !14
  %149 = getelementptr inbounds %"class.jpgd::jpeg_decoder", ptr %8, i32 0, i32 20
  %150 = load i32, ptr %3, align 4, !tbaa !14
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [4 x i32], ptr %149, i64 0, i64 %151
  store i32 %148, ptr %152, align 4, !tbaa !14
  br label %153

153:                                              ; preds = %147
  %154 = load i32, ptr %3, align 4, !tbaa !14
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %3, align 4, !tbaa !14
  br label %142, !llvm.loop !26

156:                                              ; preds = %142
  call void @_ZN4jpgd12jpeg_decoder20calc_mcu_block_orderEv(ptr noundef nonnull align 8 dereferenceable(13652) %8)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret void

157:                                              ; preds = %135
  unreachable
}

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


; 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"

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4jpgd12jpeg_decoder20calc_mcu_block_orderEv(ptr noundef nonnull align 8 dereferenceable(13652)) local_unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4jpgd12jpeg_decoder21decode_block_dc_firstEPS0_iii(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4jpgd12jpeg_decoder22decode_block_dc_refineEPS0_iii(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4jpgd12jpeg_decoder21decode_block_ac_firstEPS0_iii(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4jpgd12jpeg_decoder22decode_block_ac_refineEPS0_iii(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4jpgd12jpeg_decoder11decode_scanEPFvPS0_iiiE(ptr noundef nonnull align 8 dereferenceable(13652), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4jpgd12jpeg_decoder16init_progressiveEv(ptr noundef nonnull align 8 dereferenceable(13652) %0) local_unnamed_addr #3 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 404
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = icmp eq i32 %3, 4
  br i1 %4, label %12, label %.preheader28

.preheader28:                                     ; preds = %1
  %5 = icmp sgt i32 %3, 0
  br i1 %5, label %.lr.ph, label %.preheader

.lr.ph:                                           ; preds = %.preheader28
  %6 = getelementptr inbounds i8, ptr %0, i64 9424
  %7 = getelementptr inbounds i8, ptr %0, i64 408
  %8 = getelementptr inbounds i8, ptr %0, i64 9448
  %9 = getelementptr inbounds i8, ptr %0, i64 424
  %10 = getelementptr inbounds i8, ptr %0, i64 720
  %11 = getelementptr inbounds i8, ptr %0, i64 752
  br label %20

12:                                               ; preds = %1
  tail call void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef -232) #4
  unreachable

.preheader:                                       ; preds = %20, %.preheader28
  %13 = tail call noundef i32 @_ZN4jpgd12jpeg_decoder9init_scanEv(ptr noundef nonnull align 8 dereferenceable(13652) %0)
  %.not30 = icmp eq i32 %13, 0
  br i1 %.not30, label %._crit_edge, label %.lr.ph31

.lr.ph31:                                         ; preds = %.preheader
  %14 = getelementptr inbounds i8, ptr %0, i64 556
  %15 = getelementptr inbounds i8, ptr %0, i64 568
  %16 = getelementptr inbounds i8, ptr %0, i64 560
  %17 = getelementptr inbounds i8, ptr %0, i64 504
  %18 = getelementptr inbounds i8, ptr %0, i64 564
  %19 = getelementptr inbounds i8, ptr %0, i64 9404
  br label %42

20:                                               ; preds = %.lr.ph, %20
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %20 ]
  %21 = load i32, ptr %6, align 8, !tbaa !13
  %22 = getelementptr inbounds [4 x i32], ptr %7, i64 0, i64 %indvars.iv
  %23 = load i32, ptr %22, align 4, !tbaa !14
  %24 = mul nsw i32 %23, %21
  %25 = load i32, ptr %8, align 8, !tbaa !15
  %26 = getelementptr inbounds [4 x i32], ptr %9, i64 0, i64 %indvars.iv
  %27 = load i32, ptr %26, align 4, !tbaa !14
  %28 = mul nsw i32 %27, %25
  %29 = tail call noundef ptr @_ZN4jpgd12jpeg_decoder14coeff_buf_openEiiii(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef %24, i32 noundef %28, i32 noundef 1, i32 noundef 1)
  %30 = getelementptr inbounds [4 x ptr], ptr %10, i64 0, i64 %indvars.iv
  store ptr %29, ptr %30, align 8, !tbaa !16
  %31 = load i32, ptr %6, align 8, !tbaa !13
  %32 = load i32, ptr %22, align 4, !tbaa !14
  %33 = mul nsw i32 %32, %31
  %34 = load i32, ptr %8, align 8, !tbaa !15
  %35 = load i32, ptr %26, align 4, !tbaa !14
  %36 = mul nsw i32 %35, %34
  %37 = tail call noundef ptr @_ZN4jpgd12jpeg_decoder14coeff_buf_openEiiii(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef %33, i32 noundef %36, i32 noundef 8, i32 noundef 8)
  %38 = getelementptr inbounds [4 x ptr], ptr %11, i64 0, i64 %indvars.iv
  store ptr %37, ptr %38, align 8, !tbaa !16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = icmp slt i64 %indvars.iv.next, %40
  br i1 %41, label %20, label %.preheader, !llvm.loop !17

42:                                               ; preds = %.lr.ph31, %61
  %43 = load i32, ptr %14, align 4, !tbaa !19
  %44 = icmp eq i32 %43, 0
  %45 = load i32, ptr %15, align 8, !tbaa !20
  %.not22 = icmp eq i32 %45, 0
  %46 = load i32, ptr %16, align 8, !tbaa !21
  %47 = icmp sgt i32 %43, %46
  %48 = icmp sgt i32 %46, 63
  %or.cond = or i1 %47, %48
  br i1 %or.cond, label %49, label %50

49:                                               ; preds = %42
  tail call void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef -227) #4
  unreachable

50:                                               ; preds = %42
  br i1 %44, label %51, label %53

51:                                               ; preds = %50
  %.not24 = icmp eq i32 %46, 0
  br i1 %.not24, label %56, label %52

52:                                               ; preds = %51
  tail call void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef -227) #4
  unreachable

53:                                               ; preds = %50
  %54 = load i32, ptr %17, align 8, !tbaa !22
  %.not23 = icmp eq i32 %54, 1
  br i1 %.not23, label %56, label %55

55:                                               ; preds = %53
  tail call void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef -227) #4
  unreachable

56:                                               ; preds = %53, %51
  br i1 %.not22, label %61, label %57

57:                                               ; preds = %56
  %58 = load i32, ptr %18, align 4, !tbaa !23
  %59 = add nsw i32 %45, -1
  %.not25 = icmp eq i32 %58, %59
  br i1 %.not25, label %61, label %60

60:                                               ; preds = %57
  tail call void @_ZN4jpgd12jpeg_decoder13stop_decodingENS_11jpgd_statusE(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef -226) #4
  unreachable

61:                                               ; preds = %56, %57
  %_ZN4jpgd12jpeg_decoder21decode_block_ac_firstEPS0_iii._ZN4jpgd12jpeg_decoder22decode_block_ac_refineEPS0_iii = phi ptr [ @_ZN4jpgd12jpeg_decoder21decode_block_ac_firstEPS0_iii, %56 ], [ @_ZN4jpgd12jpeg_decoder22decode_block_ac_refineEPS0_iii, %57 ]
  %_ZN4jpgd12jpeg_decoder21decode_block_dc_firstEPS0_iii._ZN4jpgd12jpeg_decoder22decode_block_dc_refineEPS0_iii = phi ptr [ @_ZN4jpgd12jpeg_decoder21decode_block_dc_firstEPS0_iii, %56 ], [ @_ZN4jpgd12jpeg_decoder22decode_block_dc_refineEPS0_iii, %57 ]
  %.019 = select i1 %44, ptr %_ZN4jpgd12jpeg_decoder21decode_block_dc_firstEPS0_iii._ZN4jpgd12jpeg_decoder22decode_block_dc_refineEPS0_iii, ptr %_ZN4jpgd12jpeg_decoder21decode_block_ac_firstEPS0_iii._ZN4jpgd12jpeg_decoder22decode_block_ac_refineEPS0_iii
  tail call void @_ZN4jpgd12jpeg_decoder11decode_scanEPFvPS0_iiiE(ptr noundef nonnull align 8 dereferenceable(13652) %0, ptr noundef nonnull %.019)
  store i32 16, ptr %19, align 4, !tbaa !24
  %62 = tail call noundef i32 @_ZN4jpgd12jpeg_decoder8get_bitsEi(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef 16)
  %63 = tail call noundef i32 @_ZN4jpgd12jpeg_decoder8get_bitsEi(ptr noundef nonnull align 8 dereferenceable(13652) %0, i32 noundef 16)
  %64 = tail call noundef i32 @_ZN4jpgd12jpeg_decoder9init_scanEv(ptr noundef nonnull align 8 dereferenceable(13652) %0)
  %.not = icmp eq i32 %64, 0
  br i1 %.not, label %._crit_edge, label %42

._crit_edge:                                      ; preds = %61, %.preheader
  %65 = load i32, ptr %2, align 4, !tbaa !5
  %66 = getelementptr inbounds i8, ptr %0, i64 504
  store i32 %65, ptr %66, align 8, !tbaa !22
  %67 = icmp sgt i32 %65, 0
  br i1 %67, label %.lr.ph34, label %._crit_edge35

.lr.ph34:                                         ; preds = %._crit_edge
  %68 = getelementptr inbounds i8, ptr %0, i64 508
  %wide.trip.count = zext nneg i32 %65 to i64
  %min.iters.check = icmp ult i32 %65, 8
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.lr.ph34
  %n.vec = and i64 %wide.trip.count, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %69 = getelementptr inbounds [4 x i32], ptr %68, i64 0, i64 %index
  %70 = getelementptr inbounds i8, ptr %69, i64 16
  store <4 x i32> %vec.ind, ptr %69, align 4, !tbaa !14
  store <4 x i32> %step.add, ptr %70, align 4, !tbaa !14
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %71 = icmp eq i64 %index.next, %n.vec
  br i1 %71, label %middle.block, label %vector.body, !llvm.loop !25

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge35, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph34
  %indvars.iv37.ph = phi i64 [ 0, %.lr.ph34 ], [ %n.vec, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv37 = phi i64 [ %indvars.iv.next38, %scalar.ph ], [ %indvars.iv37.ph, %scalar.ph.preheader ]
  %72 = getelementptr inbounds [4 x i32], ptr %68, i64 0, i64 %indvars.iv37
  %73 = trunc nuw nsw i64 %indvars.iv37 to i32
  store i32 %73, ptr %72, align 4, !tbaa !14
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next38, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge35, label %scalar.ph, !llvm.loop !28

._crit_edge35:                                    ; preds = %scalar.ph, %middle.block, %._crit_edge
  tail call void @_ZN4jpgd12jpeg_decoder20calc_mcu_block_orderEv(ptr noundef nonnull align 8 dereferenceable(13652) %0)
  ret void
}

attributes #0 = { 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 #1 = { 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 #2 = { 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 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 = { 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 404}
!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 = !{!6, !10, i64 9424}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !10, i64 9448}
!16 = !{!9, !9, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !10, i64 556}
!20 = !{!6, !10, i64 568}
!21 = !{!6, !10, i64 560}
!22 = !{!6, !10, i64 504}
!23 = !{!6, !10, i64 564}
!24 = !{!6, !10, i64 9404}
!25 = distinct !{!25, !18, !26, !27}
!26 = !{!"llvm.loop.isvectorized", i32 1}
!27 = !{!"llvm.loop.unroll.runtime.disable"}
!28 = distinct !{!28, !18, !27, !26}


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