; LLVM IR from team-charls/charls :: samples/convert.c (main)

; 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.options_t = type { ptr, ptr, i32, i32 }
%struct.bmp_header_t = type { [2 x i8], i32, i32, i32 }
%struct.bmp_dib_header_t = type { i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [46 x i8], align 1

; 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.options_t, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca %struct.bmp_header_t, align 4
  %10 = alloca %struct.bmp_dib_header_t, align 4
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i8, align 1
  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 24, ptr %6) #6
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !9
  %18 = call zeroext i1 @parse_command_line_options(i32 noundef %16, ptr noundef %17, ptr noundef %6)
  br i1 %18, label %20, label %19

19:                                               ; preds = %2
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %147

20:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %21 = getelementptr inbounds %struct.options_t, ptr %6, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = call noalias ptr @fopen(ptr noundef %22, ptr noundef @.str)
  store ptr %23, ptr %8, align 8, !tbaa !9
  %24 = load ptr, ptr %8, align 8, !tbaa !9
  %25 = icmp ne ptr %24, null
  br i1 %25, label %32, label %26

26:                                               ; preds = %20
  %27 = getelementptr inbounds %struct.options_t, ptr %6, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = call ptr @__errno_location() #7
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, ptr noundef %28, i32 noundef %30)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %146

32:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 40, ptr %10) #6
  %33 = load ptr, ptr %8, align 8, !tbaa !9
  %34 = call zeroext i1 @bmp_read_header(ptr noundef %33, ptr noundef %9)
  br i1 %34, label %35, label %38

35:                                               ; preds = %32
  %36 = load ptr, ptr %8, align 8, !tbaa !9
  %37 = call zeroext i1 @bmp_read_dib_header(ptr noundef %36, ptr noundef %10)
  br i1 %37, label %45, label %38

38:                                               ; preds = %35, %32
  %39 = load ptr, ptr %5, align 8, !tbaa !9
  %40 = getelementptr inbounds ptr, ptr %39, i64 1
  %41 = load ptr, ptr %40, align 8, !tbaa !9
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, ptr noundef %41)
  %43 = load ptr, ptr %8, align 8, !tbaa !9
  %44 = call i32 @fclose(ptr noundef %43)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %145

45:                                               ; preds = %35
  %46 = getelementptr inbounds %struct.bmp_dib_header_t, ptr %10, i32 0, i32 5
  %47 = load i32, ptr %46, align 4, !tbaa !13
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %54, label %49

49:                                               ; preds = %45
  %50 = getelementptr inbounds %struct.bmp_dib_header_t, ptr %10, i32 0, i32 4
  %51 = load i16, ptr %50, align 2, !tbaa !16
  %52 = zext i16 %51 to i32
  %53 = icmp ne i32 %52, 24
  br i1 %53, label %54, label %58

54:                                               ; preds = %49, %45
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %56 = load ptr, ptr %8, align 8, !tbaa !9
  %57 = call i32 @fclose(ptr noundef %56)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %145

58:                                               ; preds = %49
  %59 = getelementptr inbounds %struct.bmp_dib_header_t, ptr %10, i32 0, i32 1
  %60 = load i32, ptr %59, align 4, !tbaa !17
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %66, label %62

62:                                               ; preds = %58
  %63 = getelementptr inbounds %struct.bmp_dib_header_t, ptr %10, i32 0, i32 2
  %64 = load i32, ptr %63, align 4, !tbaa !18
  %65 = icmp eq i32 %64, 0
  br i1 %65, label %66, label %70

66:                                               ; preds = %62, %58
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %68 = load ptr, ptr %8, align 8, !tbaa !9
  %69 = call i32 @fclose(ptr noundef %68)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %145

70:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %71 = load ptr, ptr %8, align 8, !tbaa !9
  %72 = getelementptr inbounds %struct.bmp_header_t, ptr %9, i32 0, i32 3
  %73 = load i32, ptr %72, align 4, !tbaa !19
  %74 = call ptr @bmp_read_pixel_data(ptr noundef %71, i32 noundef %73, ptr noundef %10, ptr noundef %11)
  store ptr %74, ptr %12, align 8, !tbaa !9
  %75 = load ptr, ptr %8, align 8, !tbaa !9
  %76 = call i32 @fclose(ptr noundef %75)
  %77 = load ptr, ptr %12, align 8, !tbaa !9
  %78 = icmp ne ptr %77, null
  br i1 %78, label %84, label %79

79:                                               ; preds = %70
  %80 = load ptr, ptr %5, align 8, !tbaa !9
  %81 = getelementptr inbounds ptr, ptr %80, i64 1
  %82 = load ptr, ptr %81, align 8, !tbaa !9
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, ptr noundef %82)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %144

84:                                               ; preds = %70
  %85 = getelementptr inbounds %struct.bmp_dib_header_t, ptr %10, i32 0, i32 2
  %86 = load i32, ptr %85, align 4, !tbaa !18
  %87 = icmp sgt i32 %86, 0
  br i1 %87, label %88, label %102

88:                                               ; preds = %84
  %89 = load ptr, ptr %12, align 8, !tbaa !9
  %90 = getelementptr inbounds %struct.bmp_dib_header_t, ptr %10, i32 0, i32 1
  %91 = load i32, ptr %90, align 4, !tbaa !17
  %92 = zext i32 %91 to i64
  %93 = getelementptr inbounds %struct.bmp_dib_header_t, ptr %10, i32 0, i32 2
  %94 = load i32, ptr %93, align 4, !tbaa !18
  %95 = sext i32 %94 to i64
  %96 = load i64, ptr %11, align 8, !tbaa !21
  %97 = call zeroext i1 @convert_bottom_up_to_top_down(ptr noundef %89, i64 noundef %92, i64 noundef %95, i64 noundef %96)
  br i1 %97, label %101, label %98

98:                                               ; preds = %88
  %99 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %100 = load ptr, ptr %12, align 8, !tbaa !9
  call void @free(ptr noundef %100) #6
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %144

101:                                              ; preds = %88
  br label %107

102:                                              ; preds = %84
  %103 = getelementptr inbounds %struct.bmp_dib_header_t, ptr %10, i32 0, i32 2
  %104 = load i32, ptr %103, align 4, !tbaa !18
  %105 = call i32 @llvm.abs.i32(i32 %104, i1 true)
  %106 = getelementptr inbounds %struct.bmp_dib_header_t, ptr %10, i32 0, i32 2
  store i32 %105, ptr %106, align 4, !tbaa !18
  br label %107

107:                                              ; preds = %102, %101
  %108 = load ptr, ptr %12, align 8, !tbaa !9
  %109 = getelementptr inbounds %struct.bmp_dib_header_t, ptr %10, i32 0, i32 1
  %110 = load i32, ptr %109, align 4, !tbaa !17
  %111 = zext i32 %110 to i64
  %112 = getelementptr inbounds %struct.bmp_dib_header_t, ptr %10, i32 0, i32 2
  %113 = load i32, ptr %112, align 4, !tbaa !18
  %114 = sext i32 %113 to i64
  %115 = load i64, ptr %11, align 8, !tbaa !21
  call void @convert_bgr_to_rgb(ptr noundef %108, i64 noundef %111, i64 noundef %114, i64 noundef %115)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %116 = load ptr, ptr %12, align 8, !tbaa !9
  %117 = load i64, ptr %11, align 8, !tbaa !21
  %118 = getelementptr inbounds %struct.options_t, ptr %6, i32 0, i32 2
  %119 = load i32, ptr %118, align 8, !tbaa !23
  %120 = getelementptr inbounds %struct.options_t, ptr %6, i32 0, i32 3
  %121 = load i32, ptr %120, align 4, !tbaa !24
  %122 = call ptr @encode_bmp_to_jpegls(ptr noundef %116, i64 noundef %117, ptr noundef %10, i32 noundef %119, i32 noundef %121, ptr noundef %13)
  store ptr %122, ptr %14, align 8, !tbaa !9
  %123 = load ptr, ptr %12, align 8, !tbaa !9
  call void @free(ptr noundef %123) #6
  %124 = load ptr, ptr %14, align 8, !tbaa !9
  %125 = icmp ne ptr %124, null
  br i1 %125, label %127, label %126

126:                                              ; preds = %107
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %143

127:                                              ; preds = %107
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #6
  %128 = getelementptr inbounds %struct.options_t, ptr %6, i32 0, i32 1
  %129 = load ptr, ptr %128, align 8, !tbaa !25
  %130 = load ptr, ptr %14, align 8, !tbaa !9
  %131 = load i64, ptr %13, align 8, !tbaa !21
  %132 = call zeroext i1 @save_jpegls_file(ptr noundef %129, ptr noundef %130, i64 noundef %131)
  %133 = zext i1 %132 to i8
  store i8 %133, ptr %15, align 1, !tbaa !26
  %134 = load ptr, ptr %14, align 8, !tbaa !9
  call void @free(ptr noundef %134) #6
  %135 = load i8, ptr %15, align 1, !tbaa !26, !range !28, !noundef !29
  %136 = trunc i8 %135 to i1
  br i1 %136, label %141, label %137

137:                                              ; preds = %127
  %138 = getelementptr inbounds %struct.options_t, ptr %6, i32 0, i32 1
  %139 = load ptr, ptr %138, align 8, !tbaa !25
  %140 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, ptr noundef %139)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %142

141:                                              ; preds = %127
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %142

142:                                              ; preds = %141, %137
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #6
  br label %143

143:                                              ; preds = %142, %126
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %144

144:                                              ; preds = %143, %98, %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %145

145:                                              ; preds = %144, %66, %54, %38
  call void @llvm.lifetime.end.p0(i64 40, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #6
  br label %146

146:                                              ; preds = %145, %26
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %147

147:                                              ; preds = %146, %19
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #6
  %148 = load i32, ptr %3, align 4
  ret i32 %148
}

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

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

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

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

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

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

declare i32 @fclose(ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @convert_bottom_up_to_top_down(ptr noundef, i64 noundef, i64 noundef, i64 noundef) #0

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #5

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

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @save_jpegls_file(ptr noundef, ptr noundef, i64 noundef) #0

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

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 willreturn memory(none) "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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }

!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 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !10, i64 8, !6, i64 16, !6, i64 20}
!13 = !{!14, !6, i64 16}
!14 = !{!"", !6, i64 0, !6, i64 4, !6, i64 8, !15, i64 12, !15, i64 14, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36}
!15 = !{!"short", !7, i64 0}
!16 = !{!14, !15, i64 14}
!17 = !{!14, !6, i64 4}
!18 = !{!14, !6, i64 8}
!19 = !{!20, !6, i64 12}
!20 = !{!"", !7, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!21 = !{!22, !22, i64 0}
!22 = !{!"long", !7, i64 0}
!23 = !{!12, !6, i64 16}
!24 = !{!12, !6, i64 20}
!25 = !{!12, !10, i64 8}
!26 = !{!27, !27, i64 0}
!27 = !{!"_Bool", !7, i64 0}
!28 = !{i8 0, i8 2}
!29 = !{}


; 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.options_t = type { ptr, ptr, i32, i32 }
%struct.bmp_header_t = type { [2 x i8], i32, i32, i32 }
%struct.bmp_dib_header_t = type { i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [46 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.options_t, align 8
  %4 = alloca %struct.bmp_header_t, align 4
  %5 = alloca %struct.bmp_dib_header_t, align 4
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #5
  %8 = call zeroext i1 @parse_command_line_options(i32 noundef %0, ptr noundef %1, ptr noundef nonnull %3)
  br i1 %8, label %9, label %91

9:                                                ; preds = %2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call noalias ptr @fopen(ptr noundef %10, ptr noundef nonnull @.str)
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %12, label %17

12:                                               ; preds = %9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = tail call ptr @__errno_location() #6
  %15 = load i32, ptr %14, align 4, !tbaa !11
  %16 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef %13, i32 noundef %15)
  br label %91

17:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #5
  %18 = call zeroext i1 @bmp_read_header(ptr noundef nonnull %11, ptr noundef nonnull %4)
  br i1 %18, label %19, label %21

19:                                               ; preds = %17
  %20 = call zeroext i1 @bmp_read_dib_header(ptr noundef nonnull %11, ptr noundef nonnull %5)
  br i1 %20, label %26, label %21

21:                                               ; preds = %19, %17
  %22 = getelementptr inbounds i8, ptr %1, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !12
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, ptr noundef %23)
  %25 = call i32 @fclose(ptr noundef nonnull %11)
  br label %90

26:                                               ; preds = %19
  %27 = getelementptr inbounds i8, ptr %5, i64 16
  %28 = load i32, ptr %27, align 4, !tbaa !13
  %29 = icmp ne i32 %28, 0
  %30 = getelementptr inbounds i8, ptr %5, i64 14
  %31 = load i16, ptr %30, align 2
  %32 = icmp ne i16 %31, 24
  %or.cond = select i1 %29, i1 true, i1 %32
  br i1 %or.cond, label %33, label %36

33:                                               ; preds = %26
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %35 = call i32 @fclose(ptr noundef nonnull %11)
  br label %90

36:                                               ; preds = %26
  %37 = getelementptr inbounds i8, ptr %5, i64 4
  %38 = load i32, ptr %37, align 4, !tbaa !16
  %39 = icmp eq i32 %38, 0
  %40 = getelementptr inbounds i8, ptr %5, i64 8
  %41 = load i32, ptr %40, align 4
  %42 = icmp eq i32 %41, 0
  %or.cond6 = select i1 %39, i1 true, i1 %42
  br i1 %or.cond6, label %43, label %46

43:                                               ; preds = %36
  %44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %45 = call i32 @fclose(ptr noundef nonnull %11)
  br label %90

46:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %47 = getelementptr inbounds i8, ptr %4, i64 12
  %48 = load i32, ptr %47, align 4, !tbaa !17
  %49 = call ptr @bmp_read_pixel_data(ptr noundef nonnull %11, i32 noundef %48, ptr noundef nonnull %5, ptr noundef nonnull %6)
  %50 = call i32 @fclose(ptr noundef nonnull %11)
  %.not33 = icmp eq ptr %49, null
  br i1 %.not33, label %51, label %55

51:                                               ; preds = %46
  %52 = getelementptr inbounds i8, ptr %1, i64 8
  %53 = load ptr, ptr %52, align 8, !tbaa !12
  %54 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef %53)
  br label %89

55:                                               ; preds = %46
  %56 = load i32, ptr %40, align 4, !tbaa !19
  %57 = icmp sgt i32 %56, 0
  br i1 %57, label %58, label %66

58:                                               ; preds = %55
  %59 = load i32, ptr %37, align 4, !tbaa !16
  %60 = zext i32 %59 to i64
  %61 = zext nneg i32 %56 to i64
  %62 = load i64, ptr %6, align 8, !tbaa !20
  %63 = call zeroext i1 @convert_bottom_up_to_top_down(ptr noundef nonnull %49, i64 noundef %60, i64 noundef %61, i64 noundef %62)
  br i1 %63, label %._crit_edge, label %64

._crit_edge:                                      ; preds = %58
  %.pre = load i32, ptr %40, align 4, !tbaa !19
  br label %68

64:                                               ; preds = %58
  %65 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  call void @free(ptr noundef nonnull %49) #5
  br label %89

66:                                               ; preds = %55
  %67 = sub nsw i32 0, %56
  store i32 %67, ptr %40, align 4, !tbaa !19
  br label %68

68:                                               ; preds = %._crit_edge, %66
  %69 = phi i32 [ %.pre, %._crit_edge ], [ %67, %66 ]
  %70 = load i32, ptr %37, align 4, !tbaa !16
  %71 = zext i32 %70 to i64
  %72 = sext i32 %69 to i64
  %73 = load i64, ptr %6, align 8, !tbaa !20
  call void @convert_bgr_to_rgb(ptr noundef nonnull %49, i64 noundef %71, i64 noundef %72, i64 noundef %73)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  %74 = load i64, ptr %6, align 8, !tbaa !20
  %75 = getelementptr inbounds i8, ptr %3, i64 16
  %76 = load i32, ptr %75, align 8, !tbaa !22
  %77 = getelementptr inbounds i8, ptr %3, i64 20
  %78 = load i32, ptr %77, align 4, !tbaa !23
  %79 = call ptr @encode_bmp_to_jpegls(ptr noundef nonnull %49, i64 noundef %74, ptr noundef nonnull %5, i32 noundef %76, i32 noundef %78, ptr noundef nonnull %7)
  call void @free(ptr noundef nonnull %49) #5
  %.not34 = icmp eq ptr %79, null
  br i1 %.not34, label %88, label %80

80:                                               ; preds = %68
  %81 = getelementptr inbounds i8, ptr %3, i64 8
  %82 = load ptr, ptr %81, align 8, !tbaa !24
  %83 = load i64, ptr %7, align 8, !tbaa !20
  %84 = call zeroext i1 @save_jpegls_file(ptr noundef %82, ptr noundef nonnull %79, i64 noundef %83)
  call void @free(ptr noundef nonnull %79) #5
  br i1 %84, label %88, label %85

85:                                               ; preds = %80
  %86 = load ptr, ptr %81, align 8, !tbaa !24
  %87 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef %86)
  br label %88

88:                                               ; preds = %85, %80, %68
  %.1 = phi i32 [ 1, %68 ], [ 1, %85 ], [ 0, %80 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  br label %89

89:                                               ; preds = %88, %64, %51
  %.2 = phi i32 [ %.1, %88 ], [ 1, %64 ], [ 1, %51 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  br label %90

90:                                               ; preds = %89, %43, %33, %21
  %.3 = phi i32 [ 1, %33 ], [ 1, %43 ], [ %.2, %89 ], [ 1, %21 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  br label %91

91:                                               ; preds = %12, %90, %2
  %.5 = phi i32 [ 1, %2 ], [ %.3, %90 ], [ 1, %12 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #5
  ret i32 %.5
}

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @parse_command_line_options(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; 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 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @bmp_read_header(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @bmp_read_dib_header(ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @convert_bottom_up_to_top_down(ptr noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden void @convert_bgr_to_rgb(ptr noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden ptr @encode_bmp_to_jpegls(ptr noundef, i64 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @save_jpegls_file(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 nofree nosync nounwind willreturn memory(none) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nounwind willreturn memory(none) }

!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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!10, !10, i64 0}
!12 = !{!7, !7, i64 0}
!13 = !{!14, !10, i64 16}
!14 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !15, i64 12, !15, i64 14, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36}
!15 = !{!"short", !8, i64 0}
!16 = !{!14, !10, i64 4}
!17 = !{!18, !10, i64 12}
!18 = !{!"", !8, i64 0, !10, i64 4, !10, i64 8, !10, i64 12}
!19 = !{!14, !10, i64 8}
!20 = !{!21, !21, i64 0}
!21 = !{!"long", !8, i64 0}
!22 = !{!6, !10, i64 16}
!23 = !{!6, !10, i64 20}
!24 = !{!6, !7, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass