; LLVM IR from corentinartaud/graphics :: ThirdParty/FreeImage-3170/Source/LibJPEG (cjpeg)

; 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_compress_struct = type { ptr, ptr, ptr, ptr, i8, i32, ptr, i32, i32, i32, i32, double, i32, i32, i32, i32, i32, i32, i32, ptr, [4 x ptr], [4 x i32], [4 x ptr], [4 x ptr], [16 x i8], [16 x i8], [16 x i8], i32, ptr, i8, i8, i8, i8, i8, i32, i32, i32, i32, i8, i8, i8, i8, i16, i16, i8, i32, i32, i8, i32, i32, i32, i32, i32, i32, [4 x ptr], i32, i32, i32, [10 x i32], i32, i32, i32, i32, i32, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32 }
%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] }
%struct.cjpeg_source_struct = type { ptr, ptr, ptr, ptr, ptr, i32 }

@progname = external hidden global ptr, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@cdjpeg_message_table = external hidden constant [45 x ptr], align 16
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@outfilename = external hidden global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@stdin = external global ptr, align 8
@stdout = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %struct.jpeg_compress_struct, align 8
  %7 = alloca %struct.jpeg_error_mgr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 568, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 168, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  %14 = getelementptr inbounds ptr, ptr %13, i64 0
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  store ptr %15, ptr @progname, align 8, !tbaa !9
  %16 = load ptr, ptr @progname, align 8, !tbaa !9
  %17 = icmp eq ptr %16, null
  br i1 %17, label %24, label %18

18:                                               ; preds = %2
  %19 = load ptr, ptr @progname, align 8, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %19, i64 0
  %21 = load i8, ptr %20, align 1, !tbaa !11
  %22 = sext i8 %21 to i32
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %18, %2
  store ptr @.str, ptr @progname, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %24, %18
  %26 = call ptr @jpeg_std_error(ptr noundef %7)
  %27 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %6, i32 0, i32 0
  store ptr %26, ptr %27, align 8, !tbaa !12
  call void @jpeg_CreateCompress(ptr noundef %6, i32 noundef 90, i64 noundef 568)
  %28 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %7, i32 0, i32 11
  store ptr @cdjpeg_message_table, ptr %28, align 8, !tbaa !16
  %29 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %7, i32 0, i32 12
  store i32 1000, ptr %29, align 8, !tbaa !19
  %30 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %7, i32 0, i32 13
  store i32 1044, ptr %30, align 4, !tbaa !20
  %31 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %6, i32 0, i32 10
  store i32 2, ptr %31, align 4, !tbaa !21
  call void @jpeg_set_defaults(ptr noundef %6)
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = load ptr, ptr %5, align 8, !tbaa !9
  %34 = call i32 @parse_switches(ptr noundef %6, i32 noundef %32, ptr noundef %33, i32 noundef 0, i8 noundef zeroext 0)
  store i32 %34, ptr %8, align 4, !tbaa !5
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = sub nsw i32 %36, 1
  %38 = icmp slt i32 %35, %37
  br i1 %38, label %39, label %43

39:                                               ; preds = %25
  %40 = load ptr, ptr @stderr, align 8, !tbaa !9
  %41 = load ptr, ptr @progname, align 8, !tbaa !9
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.1, ptr noundef %41) #5
  call void @usage()
  br label %43

43:                                               ; preds = %39, %25
  %44 = load i32, ptr %8, align 4, !tbaa !5
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %47, label %65

47:                                               ; preds = %43
  %48 = load ptr, ptr %5, align 8, !tbaa !9
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds ptr, ptr %48, i64 %50
  %52 = load ptr, ptr %51, align 8, !tbaa !9
  %53 = call noalias ptr @fopen(ptr noundef %52, ptr noundef @.str.2)
  store ptr %53, ptr %10, align 8, !tbaa !9
  %54 = icmp eq ptr %53, null
  br i1 %54, label %55, label %64

55:                                               ; preds = %47
  %56 = load ptr, ptr @stderr, align 8, !tbaa !9
  %57 = load ptr, ptr @progname, align 8, !tbaa !9
  %58 = load ptr, ptr %5, align 8, !tbaa !9
  %59 = load i32, ptr %8, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds ptr, ptr %58, i64 %60
  %62 = load ptr, ptr %61, align 8, !tbaa !9
  %63 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str.3, ptr noundef %57, ptr noundef %62) #5
  call void @exit(i32 noundef 1) #6
  unreachable

64:                                               ; preds = %47
  br label %67

65:                                               ; preds = %43
  %66 = call ptr @read_stdin()
  store ptr %66, ptr %10, align 8, !tbaa !9
  br label %67

67:                                               ; preds = %65, %64
  %68 = load ptr, ptr @outfilename, align 8, !tbaa !9
  %69 = icmp ne ptr %68, null
  br i1 %69, label %70, label %80

70:                                               ; preds = %67
  %71 = load ptr, ptr @outfilename, align 8, !tbaa !9
  %72 = call noalias ptr @fopen(ptr noundef %71, ptr noundef @.str.4)
  store ptr %72, ptr %11, align 8, !tbaa !9
  %73 = icmp eq ptr %72, null
  br i1 %73, label %74, label %79

74:                                               ; preds = %70
  %75 = load ptr, ptr @stderr, align 8, !tbaa !9
  %76 = load ptr, ptr @progname, align 8, !tbaa !9
  %77 = load ptr, ptr @outfilename, align 8, !tbaa !9
  %78 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %75, ptr noundef @.str.3, ptr noundef %76, ptr noundef %77) #5
  call void @exit(i32 noundef 1) #6
  unreachable

79:                                               ; preds = %70
  br label %82

80:                                               ; preds = %67
  %81 = call ptr @write_stdout()
  store ptr %81, ptr %11, align 8, !tbaa !9
  br label %82

82:                                               ; preds = %80, %79
  %83 = load ptr, ptr %10, align 8, !tbaa !9
  %84 = call ptr @select_file_type(ptr noundef %6, ptr noundef %83)
  store ptr %84, ptr %9, align 8, !tbaa !9
  %85 = load ptr, ptr %10, align 8, !tbaa !9
  %86 = load ptr, ptr %9, align 8, !tbaa !9
  %87 = getelementptr inbounds %struct.cjpeg_source_struct, ptr %86, i32 0, i32 3
  store ptr %85, ptr %87, align 8, !tbaa !22
  %88 = load ptr, ptr %9, align 8, !tbaa !9
  %89 = getelementptr inbounds %struct.cjpeg_source_struct, ptr %88, i32 0, i32 0
  %90 = load ptr, ptr %89, align 8, !tbaa !24
  %91 = load ptr, ptr %9, align 8, !tbaa !9
  call void %90(ptr noundef %6, ptr noundef %91)
  call void @jpeg_default_colorspace(ptr noundef %6)
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = load ptr, ptr %5, align 8, !tbaa !9
  %94 = call i32 @parse_switches(ptr noundef %6, i32 noundef %92, ptr noundef %93, i32 noundef 0, i8 noundef zeroext 1)
  store i32 %94, ptr %8, align 4, !tbaa !5
  %95 = load ptr, ptr %11, align 8, !tbaa !9
  call void @jpeg_stdio_dest(ptr noundef %6, ptr noundef %95)
  call void @jpeg_start_compress(ptr noundef %6, i8 noundef zeroext 1)
  br label %96

96:                                               ; preds = %102, %82
  %97 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %6, i32 0, i32 46
  %98 = load i32, ptr %97, align 8, !tbaa !25
  %99 = getelementptr inbounds %struct.jpeg_compress_struct, ptr %6, i32 0, i32 8
  %100 = load i32, ptr %99, align 4, !tbaa !26
  %101 = icmp ult i32 %98, %100
  br i1 %101, label %102, label %113

102:                                              ; preds = %96
  %103 = load ptr, ptr %9, align 8, !tbaa !9
  %104 = getelementptr inbounds %struct.cjpeg_source_struct, ptr %103, i32 0, i32 1
  %105 = load ptr, ptr %104, align 8, !tbaa !27
  %106 = load ptr, ptr %9, align 8, !tbaa !9
  %107 = call i32 %105(ptr noundef %6, ptr noundef %106)
  store i32 %107, ptr %12, align 4, !tbaa !5
  %108 = load ptr, ptr %9, align 8, !tbaa !9
  %109 = getelementptr inbounds %struct.cjpeg_source_struct, ptr %108, i32 0, i32 4
  %110 = load ptr, ptr %109, align 8, !tbaa !28
  %111 = load i32, ptr %12, align 4, !tbaa !5
  %112 = call i32 @jpeg_write_scanlines(ptr noundef %6, ptr noundef %110, i32 noundef %111)
  br label %96, !llvm.loop !29

113:                                              ; preds = %96
  %114 = load ptr, ptr %9, align 8, !tbaa !9
  %115 = getelementptr inbounds %struct.cjpeg_source_struct, ptr %114, i32 0, i32 2
  %116 = load ptr, ptr %115, align 8, !tbaa !31
  %117 = load ptr, ptr %9, align 8, !tbaa !9
  call void %116(ptr noundef %6, ptr noundef %117)
  call void @jpeg_finish_compress(ptr noundef %6)
  call void @jpeg_destroy_compress(ptr noundef %6)
  %118 = load ptr, ptr %10, align 8, !tbaa !9
  %119 = load ptr, ptr @stdin, align 8, !tbaa !9
  %120 = icmp ne ptr %118, %119
  br i1 %120, label %121, label %124

121:                                              ; preds = %113
  %122 = load ptr, ptr %10, align 8, !tbaa !9
  %123 = call i32 @fclose(ptr noundef %122)
  br label %124

124:                                              ; preds = %121, %113
  %125 = load ptr, ptr %11, align 8, !tbaa !9
  %126 = load ptr, ptr @stdout, align 8, !tbaa !9
  %127 = icmp ne ptr %125, %126
  br i1 %127, label %128, label %131

128:                                              ; preds = %124
  %129 = load ptr, ptr %11, align 8, !tbaa !9
  %130 = call i32 @fclose(ptr noundef %129)
  br label %131

131:                                              ; preds = %128, %124
  %132 = getelementptr inbounds %struct.jpeg_error_mgr, ptr %7, i32 0, i32 8
  %133 = load i64, ptr %132, align 8, !tbaa !32
  %134 = icmp ne i64 %133, 0
  %135 = zext i1 %134 to i64
  %136 = select i1 %134, i32 2, i32 0
  call void @exit(i32 noundef %136) #6
  unreachable
}

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

declare ptr @jpeg_std_error(ptr noundef) #2

declare void @jpeg_CreateCompress(ptr noundef, i32 noundef, i64 noundef) #2

declare void @jpeg_set_defaults(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @parse_switches(ptr noundef, i32 noundef, ptr noundef, i32 noundef, i8 noundef zeroext) #0

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

; Function Attrs: nounwind uwtable
declare hidden void @usage() #0

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

declare ptr @read_stdin() #2

declare ptr @write_stdout() #2

; Function Attrs: nounwind uwtable
declare hidden ptr @select_file_type(ptr noundef, ptr noundef) #0

declare void @jpeg_default_colorspace(ptr noundef) #2

declare void @jpeg_stdio_dest(ptr noundef, ptr noundef) #2

declare void @jpeg_start_compress(ptr noundef, i8 noundef zeroext) #2

declare i32 @jpeg_write_scanlines(ptr noundef, ptr noundef, i32 noundef) #2

declare void @jpeg_finish_compress(ptr noundef) #2

declare void @jpeg_destroy_compress(ptr noundef) #2

declare i32 @fclose(ptr noundef) #2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 #4 = { 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 #5 = { nounwind }
attributes #6 = { noreturn nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !10, i64 0}
!13 = !{!"jpeg_compress_struct", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !7, i64 32, !6, i64 36, !10, i64 40, !6, i64 48, !6, i64 52, !6, i64 56, !6, i64 60, !14, i64 64, !6, i64 72, !6, i64 76, !6, i64 80, !6, i64 84, !6, i64 88, !6, i64 92, !6, i64 96, !10, i64 104, !7, i64 112, !7, i64 144, !7, i64 160, !7, i64 192, !7, i64 224, !7, i64 240, !7, i64 256, !6, i64 272, !10, i64 280, !7, i64 288, !7, i64 289, !7, i64 290, !7, i64 291, !7, i64 292, !6, i64 296, !6, i64 300, !6, i64 304, !6, i64 308, !7, i64 312, !7, i64 313, !7, i64 314, !7, i64 315, !15, i64 316, !15, i64 318, !7, i64 320, !6, i64 324, !6, i64 328, !7, i64 332, !6, i64 336, !6, i64 340, !6, i64 344, !6, i64 348, !6, i64 352, !6, i64 356, !7, i64 360, !6, i64 392, !6, i64 396, !6, i64 400, !7, i64 404, !6, i64 444, !6, i64 448, !6, i64 452, !6, i64 456, !6, i64 460, !10, i64 464, !6, i64 472, !10, i64 480, !10, i64 488, !10, i64 496, !10, i64 504, !10, i64 512, !10, i64 520, !10, i64 528, !10, i64 536, !10, i64 544, !10, i64 552, !6, i64 560}
!14 = !{!"double", !7, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!17, !10, i64 152}
!17 = !{!"jpeg_error_mgr", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !6, i64 40, !7, i64 44, !6, i64 124, !18, i64 128, !10, i64 136, !6, i64 144, !10, i64 152, !6, i64 160, !6, i64 164}
!18 = !{!"long", !7, i64 0}
!19 = !{!17, !6, i64 160}
!20 = !{!17, !6, i64 164}
!21 = !{!13, !6, i64 60}
!22 = !{!23, !10, i64 24}
!23 = !{!"cjpeg_source_struct", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !6, i64 40}
!24 = !{!23, !10, i64 0}
!25 = !{!13, !6, i64 328}
!26 = !{!13, !6, i64 52}
!27 = !{!23, !10, i64 8}
!28 = !{!23, !10, i64 32}
!29 = distinct !{!29, !30}
!30 = !{!"llvm.loop.mustprogress"}
!31 = !{!23, !10, i64 16}
!32 = !{!17, !18, i64 128}


; 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_compress_struct = type { ptr, ptr, ptr, ptr, i8, i32, ptr, i32, i32, i32, i32, double, i32, i32, i32, i32, i32, i32, i32, ptr, [4 x ptr], [4 x i32], [4 x ptr], [4 x ptr], [16 x i8], [16 x i8], [16 x i8], i32, ptr, i8, i8, i8, i8, i8, i32, i32, i32, i32, i8, i8, i8, i8, i16, i16, i8, i32, i32, i8, i32, i32, i32, i32, i32, i32, [4 x ptr], i32, i32, i32, [10 x i32], i32, i32, i32, i32, i32, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32 }
%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] }

@progname = external hidden local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [6 x i8], align 1
@cdjpeg_message_table = external hidden constant [45 x ptr], align 16
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@outfilename = external hidden local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@stdout = external local_unnamed_addr global ptr, align 8

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.jpeg_compress_struct, align 8
  %4 = alloca %struct.jpeg_error_mgr, align 8
  call void @llvm.lifetime.start.p0(i64 568, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 168, ptr nonnull %4) #6
  %5 = load ptr, ptr %1, align 8, !tbaa !5
  store ptr %5, ptr @progname, align 8, !tbaa !5
  %6 = icmp eq ptr %5, null
  br i1 %6, label %10, label %7

7:                                                ; preds = %2
  %8 = load i8, ptr %5, align 1, !tbaa !9
  %9 = icmp eq i8 %8, 0
  br i1 %9, label %10, label %11

10:                                               ; preds = %7, %2
  store ptr @.str, ptr @progname, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %10, %7
  %12 = call ptr @jpeg_std_error(ptr noundef nonnull %4) #6
  store ptr %12, ptr %3, align 8, !tbaa !10
  call void @jpeg_CreateCompress(ptr noundef nonnull %3, i32 noundef 90, i64 noundef 568) #6
  %13 = getelementptr inbounds i8, ptr %4, i64 152
  store ptr @cdjpeg_message_table, ptr %13, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %4, i64 160
  store i32 1000, ptr %14, align 8, !tbaa !18
  %15 = getelementptr inbounds i8, ptr %4, i64 164
  store i32 1044, ptr %15, align 4, !tbaa !19
  %16 = getelementptr inbounds i8, ptr %3, i64 60
  store i32 2, ptr %16, align 4, !tbaa !20
  call void @jpeg_set_defaults(ptr noundef nonnull %3) #6
  %17 = call i32 @parse_switches(ptr noundef nonnull %3, i32 noundef %0, ptr noundef nonnull %1, i32 noundef 0, i8 noundef zeroext 0)
  %18 = add nsw i32 %0, -1
  %19 = icmp slt i32 %17, %18
  br i1 %19, label %20, label %24

20:                                               ; preds = %11
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = load ptr, ptr @progname, align 8, !tbaa !5
  %23 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.1, ptr noundef %22) #7
  call void @usage()
  br label %24

24:                                               ; preds = %20, %11
  %25 = icmp slt i32 %17, %0
  br i1 %25, label %26, label %37

26:                                               ; preds = %24
  %27 = sext i32 %17 to i64
  %28 = getelementptr inbounds ptr, ptr %1, i64 %27
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = call noalias ptr @fopen(ptr noundef %29, ptr noundef nonnull @.str.2)
  %31 = icmp eq ptr %30, null
  br i1 %31, label %32, label %39

32:                                               ; preds = %26
  %33 = load ptr, ptr @stderr, align 8, !tbaa !5
  %34 = load ptr, ptr @progname, align 8, !tbaa !5
  %35 = load ptr, ptr %28, align 8, !tbaa !5
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef nonnull @.str.3, ptr noundef %34, ptr noundef %35) #7
  call void @exit(i32 noundef 1) #8
  unreachable

37:                                               ; preds = %24
  %38 = call ptr @read_stdin() #6
  br label %39

39:                                               ; preds = %26, %37
  %.028 = phi ptr [ %30, %26 ], [ %38, %37 ]
  %40 = load ptr, ptr @outfilename, align 8, !tbaa !5
  %.not = icmp eq ptr %40, null
  br i1 %.not, label %49, label %41

41:                                               ; preds = %39
  %42 = call noalias ptr @fopen(ptr noundef nonnull %40, ptr noundef nonnull @.str.4)
  %43 = icmp eq ptr %42, null
  br i1 %43, label %44, label %51

44:                                               ; preds = %41
  %45 = load ptr, ptr @stderr, align 8, !tbaa !5
  %46 = load ptr, ptr @progname, align 8, !tbaa !5
  %47 = load ptr, ptr @outfilename, align 8, !tbaa !5
  %48 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef nonnull @.str.3, ptr noundef %46, ptr noundef %47) #7
  call void @exit(i32 noundef 1) #8
  unreachable

49:                                               ; preds = %39
  %50 = call ptr @write_stdout() #6
  br label %51

51:                                               ; preds = %41, %49
  %.0 = phi ptr [ %42, %41 ], [ %50, %49 ]
  %52 = call ptr @select_file_type(ptr noundef nonnull %3, ptr noundef %.028)
  %53 = getelementptr inbounds i8, ptr %52, i64 24
  store ptr %.028, ptr %53, align 8, !tbaa !21
  %54 = load ptr, ptr %52, align 8, !tbaa !23
  call void %54(ptr noundef nonnull %3, ptr noundef nonnull %52) #6
  call void @jpeg_default_colorspace(ptr noundef nonnull %3) #6
  %55 = call i32 @parse_switches(ptr noundef nonnull %3, i32 noundef %0, ptr noundef nonnull %1, i32 noundef 0, i8 noundef zeroext 1)
  call void @jpeg_stdio_dest(ptr noundef nonnull %3, ptr noundef %.0) #6
  call void @jpeg_start_compress(ptr noundef nonnull %3, i8 noundef zeroext 1) #6
  %56 = getelementptr inbounds i8, ptr %3, i64 328
  %57 = getelementptr inbounds i8, ptr %3, i64 52
  %58 = load i32, ptr %56, align 8, !tbaa !24
  %59 = load i32, ptr %57, align 4, !tbaa !25
  %60 = icmp ult i32 %58, %59
  br i1 %60, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %51
  %61 = getelementptr inbounds i8, ptr %52, i64 8
  %62 = getelementptr inbounds i8, ptr %52, i64 32
  br label %63

63:                                               ; preds = %.lr.ph, %63
  %64 = load ptr, ptr %61, align 8, !tbaa !26
  %65 = call i32 %64(ptr noundef nonnull %3, ptr noundef nonnull %52) #6
  %66 = load ptr, ptr %62, align 8, !tbaa !27
  %67 = call i32 @jpeg_write_scanlines(ptr noundef nonnull %3, ptr noundef %66, i32 noundef %65) #6
  %68 = load i32, ptr %56, align 8, !tbaa !24
  %69 = load i32, ptr %57, align 4, !tbaa !25
  %70 = icmp ult i32 %68, %69
  br i1 %70, label %63, label %._crit_edge, !llvm.loop !28

._crit_edge:                                      ; preds = %63, %51
  %71 = getelementptr inbounds i8, ptr %52, i64 16
  %72 = load ptr, ptr %71, align 8, !tbaa !30
  call void %72(ptr noundef nonnull %3, ptr noundef nonnull %52) #6
  call void @jpeg_finish_compress(ptr noundef nonnull %3) #6
  call void @jpeg_destroy_compress(ptr noundef nonnull %3) #6
  %73 = load ptr, ptr @stdin, align 8, !tbaa !5
  %.not34 = icmp eq ptr %.028, %73
  br i1 %.not34, label %76, label %74

74:                                               ; preds = %._crit_edge
  %75 = call i32 @fclose(ptr noundef %.028)
  br label %76

76:                                               ; preds = %74, %._crit_edge
  %77 = load ptr, ptr @stdout, align 8, !tbaa !5
  %.not35 = icmp eq ptr %.0, %77
  br i1 %.not35, label %80, label %78

78:                                               ; preds = %76
  %79 = call i32 @fclose(ptr noundef %.0)
  br label %80

80:                                               ; preds = %78, %76
  %81 = getelementptr inbounds i8, ptr %4, i64 128
  %82 = load i64, ptr %81, align 8, !tbaa !31
  %.not36 = icmp eq i64 %82, 0
  %83 = select i1 %.not36, i32 0, i32 2
  call void @exit(i32 noundef %83) #8
  unreachable
}

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

declare ptr @jpeg_std_error(ptr noundef) local_unnamed_addr #2

declare void @jpeg_CreateCompress(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #2

declare void @jpeg_set_defaults(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @parse_switches(ptr noundef, i32 noundef, ptr noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare hidden void @usage() local_unnamed_addr #3

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #5

declare ptr @read_stdin() local_unnamed_addr #2

declare ptr @write_stdout() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden ptr @select_file_type(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @jpeg_default_colorspace(ptr noundef) local_unnamed_addr #2

declare void @jpeg_stdio_dest(ptr noundef, ptr noundef) local_unnamed_addr #2

declare void @jpeg_start_compress(ptr noundef, i8 noundef zeroext) local_unnamed_addr #2

declare i32 @jpeg_write_scanlines(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @jpeg_finish_compress(ptr noundef) local_unnamed_addr #2

declare void @jpeg_destroy_compress(ptr noundef) local_unnamed_addr #2

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

attributes #0 = { noreturn 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { 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 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { cold nounwind }
attributes #8 = { noreturn nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !6, i64 0}
!11 = !{!"jpeg_compress_struct", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32, !12, i64 36, !6, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !12, i64 60, !13, i64 64, !12, i64 72, !12, i64 76, !12, i64 80, !12, i64 84, !12, i64 88, !12, i64 92, !12, i64 96, !6, i64 104, !7, i64 112, !7, i64 144, !7, i64 160, !7, i64 192, !7, i64 224, !7, i64 240, !7, i64 256, !12, i64 272, !6, i64 280, !7, i64 288, !7, i64 289, !7, i64 290, !7, i64 291, !7, i64 292, !12, i64 296, !12, i64 300, !12, i64 304, !12, i64 308, !7, i64 312, !7, i64 313, !7, i64 314, !7, i64 315, !14, i64 316, !14, i64 318, !7, i64 320, !12, i64 324, !12, i64 328, !7, i64 332, !12, i64 336, !12, i64 340, !12, i64 344, !12, i64 348, !12, i64 352, !12, i64 356, !7, i64 360, !12, i64 392, !12, i64 396, !12, i64 400, !7, i64 404, !12, i64 444, !12, i64 448, !12, i64 452, !12, i64 456, !12, i64 460, !6, i64 464, !12, i64 472, !6, i64 480, !6, i64 488, !6, i64 496, !6, i64 504, !6, i64 512, !6, i64 520, !6, i64 528, !6, i64 536, !6, i64 544, !6, i64 552, !12, i64 560}
!12 = !{!"int", !7, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!16, !6, i64 152}
!16 = !{!"jpeg_error_mgr", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !7, i64 44, !12, i64 124, !17, i64 128, !6, i64 136, !12, i64 144, !6, i64 152, !12, i64 160, !12, i64 164}
!17 = !{!"long", !7, i64 0}
!18 = !{!16, !12, i64 160}
!19 = !{!16, !12, i64 164}
!20 = !{!11, !12, i64 60}
!21 = !{!22, !6, i64 24}
!22 = !{!"cjpeg_source_struct", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40}
!23 = !{!22, !6, i64 0}
!24 = !{!11, !12, i64 328}
!25 = !{!11, !12, i64 52}
!26 = !{!22, !6, i64 8}
!27 = !{!22, !6, i64 32}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = !{!22, !6, i64 16}
!31 = !{!16, !17, i64 128}


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