; LLVM IR from niessner/Matterport :: code/gaps/pkgs/R2Shapes/R2Image.ll (ZN7R2Image8ReadJPEGEPKc)

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

%struct.jpeg_decompress_struct = type { ptr, ptr, ptr, ptr, i32, i32, ptr, i32, i32, i32, i32, i32, i32, i32, double, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i32, i32, i32, i32, i32, ptr, [4 x ptr], [4 x ptr], [4 x ptr], i32, ptr, i32, i32, [16 x i8], [16 x i8], [16 x i8], i32, i32, i8, i8, i8, i16, i16, i32, i8, i32, ptr, i32, i32, i32, i32, ptr, i32, [4 x ptr], i32, i32, i32, [10 x i32], i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.jpeg_error_mgr = type { ptr, ptr, ptr, ptr, ptr, i32, %union.anon, i32, i64, ptr, i32, ptr, i32, i32 }
%union.anon = type { [8 x i32], [48 x i8] }
%class.R2Image = type { i32, i32, i32, i32, ptr }

@stderr = external global ptr, align 8
@.str.25 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.73 = external hidden unnamed_addr constant [40 x i8], align 1

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

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7R2Image8ReadJPEGEPKc(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) #3 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %struct.jpeg_decompress_struct, align 8
  %9 = alloca %struct.jpeg_error_mgr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = call noalias ptr @fopen(ptr noundef %14, ptr noundef @.str.25)
  store ptr %15, ptr %6, align 8, !tbaa !5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %22, label %18

18:                                               ; preds = %2
  %19 = load ptr, ptr @stderr, align 8, !tbaa !5
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str.26, ptr noundef %20) #5
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %100

22:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 632, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 168, ptr %9) #5
  %23 = call ptr @jpeg_std_error(ptr noundef %9)
  %24 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %8, i32 0, i32 0
  store ptr %23, ptr %24, align 8, !tbaa !9
  call void @jpeg_CreateDecompress(ptr noundef %8, i32 noundef 62, i64 noundef 632)
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  call void @jpeg_stdio_src(ptr noundef %8, ptr noundef %25)
  %26 = call i32 @jpeg_read_header(ptr noundef %8, i32 noundef 1)
  %27 = call i32 @jpeg_start_decompress(ptr noundef %8)
  %28 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %8, i32 0, i32 27
  %29 = load i32, ptr %28, align 8, !tbaa !17
  %30 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 0
  store i32 %29, ptr %30, align 8, !tbaa !18
  %31 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %8, i32 0, i32 28
  %32 = load i32, ptr %31, align 4, !tbaa !20
  %33 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 1
  store i32 %32, ptr %33, align 4, !tbaa !21
  %34 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %8, i32 0, i32 30
  %35 = load i32, ptr %34, align 4, !tbaa !22
  %36 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 2
  store i32 %35, ptr %36, align 8, !tbaa !23
  %37 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 2
  %38 = load i32, ptr %37, align 8, !tbaa !23
  %39 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !18
  %41 = mul nsw i32 %38, %40
  %42 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 3
  store i32 %41, ptr %42, align 4, !tbaa !24
  %43 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 3
  %44 = load i32, ptr %43, align 4, !tbaa !24
  %45 = srem i32 %44, 4
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %54

47:                                               ; preds = %22
  %48 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 3
  %49 = load i32, ptr %48, align 4, !tbaa !24
  %50 = sdiv i32 %49, 4
  %51 = add nsw i32 %50, 1
  %52 = mul nsw i32 %51, 4
  %53 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 3
  store i32 %52, ptr %53, align 4, !tbaa !24
  br label %54

54:                                               ; preds = %47, %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %55 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 3
  %56 = load i32, ptr %55, align 4, !tbaa !24
  %57 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 1
  %58 = load i32, ptr %57, align 4, !tbaa !21
  %59 = mul nsw i32 %56, %58
  store i32 %59, ptr %10, align 4, !tbaa !25
  %60 = load i32, ptr %10, align 4, !tbaa !25
  %61 = sext i32 %60 to i64
  %62 = call noalias noundef nonnull ptr @_Znam(i64 noundef %61) #6
  %63 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 4
  store ptr %62, ptr %63, align 8, !tbaa !26
  %64 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 4
  %65 = load ptr, ptr %64, align 8, !tbaa !26
  %66 = icmp ne ptr %65, null
  br i1 %66, label %72, label %67

67:                                               ; preds = %54
  %68 = load ptr, ptr @stderr, align 8, !tbaa !5
  %69 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %68, ptr noundef @.str.73) #5
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = call i32 @fclose(ptr noundef %70)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %99

72:                                               ; preds = %54
  br label %73

73:                                               ; preds = %79, %72
  %74 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %8, i32 0, i32 34
  %75 = load i32, ptr %74, align 8, !tbaa !27
  %76 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %8, i32 0, i32 28
  %77 = load i32, ptr %76, align 4, !tbaa !20
  %78 = icmp ult i32 %75, %77
  br i1 %78, label %79, label %95

79:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %80 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %8, i32 0, i32 28
  %81 = load i32, ptr %80, align 4, !tbaa !20
  %82 = getelementptr inbounds %struct.jpeg_decompress_struct, ptr %8, i32 0, i32 34
  %83 = load i32, ptr %82, align 8, !tbaa !27
  %84 = sub i32 %81, %83
  %85 = sub i32 %84, 1
  store i32 %85, ptr %11, align 4, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %86 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 4
  %87 = load ptr, ptr %86, align 8, !tbaa !26
  %88 = load i32, ptr %11, align 4, !tbaa !25
  %89 = getelementptr inbounds %class.R2Image, ptr %13, i32 0, i32 3
  %90 = load i32, ptr %89, align 4, !tbaa !24
  %91 = mul nsw i32 %88, %90
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds i8, ptr %87, i64 %92
  store ptr %93, ptr %12, align 8, !tbaa !5
  %94 = call i32 @jpeg_read_scanlines(ptr noundef %8, ptr noundef %12, i32 noundef 1)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %73, !llvm.loop !28

95:                                               ; preds = %73
  %96 = call i32 @jpeg_finish_decompress(ptr noundef %8)
  call void @jpeg_destroy_decompress(ptr noundef %8)
  %97 = load ptr, ptr %6, align 8, !tbaa !5
  %98 = call i32 @fclose(ptr noundef %97)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %99

99:                                               ; preds = %95, %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 168, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 632, ptr %8) #5
  br label %100

100:                                              ; preds = %99, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %101 = load i32, ptr %3, align 4
  ret i32 %101
}

declare noalias ptr @fopen(ptr noundef, ptr noundef) #4

declare i32 @fclose(ptr noundef) #4

declare ptr @jpeg_std_error(ptr noundef) #4

declare void @jpeg_CreateDecompress(ptr noundef, i32 noundef, i64 noundef) #4

declare void @jpeg_stdio_src(ptr noundef, ptr noundef) #4

declare i32 @jpeg_read_header(ptr noundef, i32 noundef) #4

declare i32 @jpeg_start_decompress(ptr noundef) #4

declare i32 @jpeg_read_scanlines(ptr noundef, ptr noundef, i32 noundef) #4

declare i32 @jpeg_finish_decompress(ptr noundef) #4

declare void @jpeg_destroy_decompress(ptr noundef) #4

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

!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, !6, i64 0}
!10 = !{!"_ZTS22jpeg_decompress_struct", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !6, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !12, i64 60, !12, i64 64, !11, i64 68, !11, i64 72, !13, i64 80, !11, i64 88, !11, i64 92, !14, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !15, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !11, i64 148, !11, i64 152, !11, i64 156, !6, i64 160, !11, i64 168, !11, i64 172, !11, i64 176, !11, i64 180, !11, i64 184, !6, i64 192, !7, i64 200, !7, i64 232, !7, i64 264, !11, i64 296, !6, i64 304, !11, i64 312, !11, i64 316, !7, i64 320, !7, i64 336, !7, i64 352, !11, i64 368, !11, i64 372, !7, i64 376, !7, i64 377, !7, i64 378, !16, i64 380, !16, i64 382, !11, i64 384, !7, i64 388, !11, i64 392, !6, i64 400, !11, i64 408, !11, i64 412, !11, i64 416, !11, i64 420, !6, i64 424, !11, i64 432, !7, i64 440, !11, i64 472, !11, i64 476, !11, i64 480, !7, i64 484, !11, i64 524, !11, i64 528, !11, i64 532, !11, i64 536, !11, i64 540, !6, i64 544, !6, i64 552, !6, i64 560, !6, i64 568, !6, i64 576, !6, i64 584, !6, i64 592, !6, i64 600, !6, i64 608, !6, i64 616, !6, i64 624}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS13J_COLOR_SPACE", !7, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!"_ZTS12J_DCT_METHOD", !7, i64 0}
!15 = !{!"_ZTS13J_DITHER_MODE", !7, i64 0}
!16 = !{!"short", !7, i64 0}
!17 = !{!10, !11, i64 136}
!18 = !{!19, !11, i64 0}
!19 = !{!"_ZTS7R2Image", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16}
!20 = !{!10, !11, i64 140}
!21 = !{!19, !11, i64 4}
!22 = !{!10, !11, i64 148}
!23 = !{!19, !11, i64 8}
!24 = !{!19, !11, i64 12}
!25 = !{!11, !11, i64 0}
!26 = !{!19, !6, i64 16}
!27 = !{!10, !11, i64 168}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


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

%struct.jpeg_decompress_struct = type { ptr, ptr, ptr, ptr, i32, i32, ptr, i32, i32, i32, i32, i32, i32, i32, double, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, ptr, i32, i32, i32, i32, i32, ptr, [4 x ptr], [4 x ptr], [4 x ptr], i32, ptr, i32, i32, [16 x i8], [16 x i8], [16 x i8], i32, i32, i8, i8, i8, i16, i16, i32, i8, i32, ptr, i32, i32, i32, i32, ptr, i32, [4 x ptr], i32, i32, i32, [10 x i32], i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.jpeg_error_mgr = type { ptr, ptr, ptr, ptr, ptr, i32, %union.anon, i32, i64, ptr, i32, ptr, i32, i32 }
%union.anon = type { [8 x i32], [48 x i8] }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.25 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [30 x i8], align 1

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

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN7R2Image8ReadJPEGEPKc(ptr nocapture noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) local_unnamed_addr #3 align 2 {
  %3 = alloca %struct.jpeg_decompress_struct, align 8
  %4 = alloca %struct.jpeg_error_mgr, align 8
  %5 = alloca ptr, align 8
  %6 = tail call noalias ptr @fopen(ptr noundef %1, ptr noundef nonnull @.str.25)
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %7, label %10

7:                                                ; preds = %2
  %8 = load ptr, ptr @stderr, align 8, !tbaa !5
  %9 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %8, ptr noundef nonnull @.str.26, ptr noundef %1) #5
  br label %52

10:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 632, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 168, ptr nonnull %4) #6
  %11 = call ptr @jpeg_std_error(ptr noundef nonnull %4)
  store ptr %11, ptr %3, align 8, !tbaa !9
  call void @jpeg_CreateDecompress(ptr noundef nonnull %3, i32 noundef 62, i64 noundef 632)
  call void @jpeg_stdio_src(ptr noundef nonnull %3, ptr noundef nonnull %6)
  %12 = call i32 @jpeg_read_header(ptr noundef nonnull %3, i32 noundef 1)
  %13 = call i32 @jpeg_start_decompress(ptr noundef nonnull %3)
  %14 = getelementptr inbounds i8, ptr %3, i64 136
  %15 = load i32, ptr %14, align 8, !tbaa !17
  store i32 %15, ptr %0, align 8, !tbaa !18
  %16 = getelementptr inbounds i8, ptr %3, i64 140
  %17 = load i32, ptr %16, align 4, !tbaa !20
  %18 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %17, ptr %18, align 4, !tbaa !21
  %19 = getelementptr inbounds i8, ptr %3, i64 148
  %20 = load i32, ptr %19, align 4, !tbaa !22
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %20, ptr %21, align 8, !tbaa !23
  %22 = mul nsw i32 %20, %15
  %23 = getelementptr inbounds i8, ptr %0, i64 12
  %24 = and i32 %22, 3
  %.not12 = icmp eq i32 %24, 0
  br i1 %.not12, label %29, label %25

25:                                               ; preds = %10
  %26 = sdiv i32 %22, 4
  %27 = shl nsw i32 %26, 2
  %28 = add i32 %27, 4
  br label %29

29:                                               ; preds = %25, %10
  %storemerge = phi i32 [ %28, %25 ], [ %22, %10 ]
  store i32 %storemerge, ptr %23, align 4, !tbaa !24
  %30 = mul nsw i32 %storemerge, %17
  %31 = sext i32 %30 to i64
  %32 = call noalias noundef nonnull ptr @_Znam(i64 noundef %31) #7
  %33 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %32, ptr %33, align 8, !tbaa !25
  %34 = getelementptr inbounds i8, ptr %3, i64 168
  %35 = load i32, ptr %34, align 8, !tbaa !26
  %36 = icmp ult i32 %35, %17
  br i1 %36, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %29, %.lr.ph
  %37 = phi i32 [ %48, %.lr.ph ], [ %17, %29 ]
  %38 = phi i32 [ %47, %.lr.ph ], [ %35, %29 ]
  %39 = xor i32 %38, -1
  %40 = add i32 %37, %39
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #6
  %41 = load ptr, ptr %33, align 8, !tbaa !25
  %42 = load i32, ptr %23, align 4, !tbaa !24
  %43 = mul nsw i32 %42, %40
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i8, ptr %41, i64 %44
  store ptr %45, ptr %5, align 8, !tbaa !5
  %46 = call i32 @jpeg_read_scanlines(ptr noundef nonnull %3, ptr noundef nonnull %5, i32 noundef 1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #6
  %47 = load i32, ptr %34, align 8, !tbaa !26
  %48 = load i32, ptr %16, align 4, !tbaa !20
  %49 = icmp ult i32 %47, %48
  br i1 %49, label %.lr.ph, label %._crit_edge, !llvm.loop !27

._crit_edge:                                      ; preds = %.lr.ph, %29
  %50 = call i32 @jpeg_finish_decompress(ptr noundef nonnull %3)
  call void @jpeg_destroy_decompress(ptr noundef nonnull %3)
  %51 = call i32 @fclose(ptr noundef nonnull %6)
  call void @llvm.lifetime.end.p0(i64 168, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 632, ptr nonnull %3) #6
  br label %52

52:                                               ; preds = %._crit_edge, %7
  %.1 = phi i32 [ 1, %._crit_edge ], [ 0, %7 ]
  ret i32 %.1
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

declare ptr @jpeg_std_error(ptr noundef) local_unnamed_addr #4

declare void @jpeg_CreateDecompress(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #4

declare void @jpeg_stdio_src(ptr noundef, ptr noundef) local_unnamed_addr #4

declare i32 @jpeg_read_header(ptr noundef, i32 noundef) local_unnamed_addr #4

declare i32 @jpeg_start_decompress(ptr noundef) local_unnamed_addr #4

declare i32 @jpeg_read_scanlines(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

declare i32 @jpeg_finish_decompress(ptr noundef) local_unnamed_addr #4

declare void @jpeg_destroy_decompress(ptr noundef) local_unnamed_addr #4

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

!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, !6, i64 0}
!10 = !{!"_ZTS22jpeg_decompress_struct", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !6, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !12, i64 60, !12, i64 64, !11, i64 68, !11, i64 72, !13, i64 80, !11, i64 88, !11, i64 92, !14, i64 96, !11, i64 100, !11, i64 104, !11, i64 108, !15, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !11, i64 136, !11, i64 140, !11, i64 144, !11, i64 148, !11, i64 152, !11, i64 156, !6, i64 160, !11, i64 168, !11, i64 172, !11, i64 176, !11, i64 180, !11, i64 184, !6, i64 192, !7, i64 200, !7, i64 232, !7, i64 264, !11, i64 296, !6, i64 304, !11, i64 312, !11, i64 316, !7, i64 320, !7, i64 336, !7, i64 352, !11, i64 368, !11, i64 372, !7, i64 376, !7, i64 377, !7, i64 378, !16, i64 380, !16, i64 382, !11, i64 384, !7, i64 388, !11, i64 392, !6, i64 400, !11, i64 408, !11, i64 412, !11, i64 416, !11, i64 420, !6, i64 424, !11, i64 432, !7, i64 440, !11, i64 472, !11, i64 476, !11, i64 480, !7, i64 484, !11, i64 524, !11, i64 528, !11, i64 532, !11, i64 536, !11, i64 540, !6, i64 544, !6, i64 552, !6, i64 560, !6, i64 568, !6, i64 576, !6, i64 584, !6, i64 592, !6, i64 600, !6, i64 608, !6, i64 616, !6, i64 624}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTS13J_COLOR_SPACE", !7, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!"_ZTS12J_DCT_METHOD", !7, i64 0}
!15 = !{!"_ZTS13J_DITHER_MODE", !7, i64 0}
!16 = !{!"short", !7, i64 0}
!17 = !{!10, !11, i64 136}
!18 = !{!19, !11, i64 0}
!19 = !{!"_ZTS7R2Image", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !6, i64 16}
!20 = !{!10, !11, i64 140}
!21 = !{!19, !11, i64 4}
!22 = !{!10, !11, i64 148}
!23 = !{!19, !11, i64 8}
!24 = !{!19, !11, i64 12}
!25 = !{!19, !6, i64 16}
!26 = !{!10, !11, i64 168}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}


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