; LLVM IR from team-charls/charls :: samples/convert.cpp (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.(anonymous namespace)::options" = type { ptr, ptr, i32, i32 }
%class.bmp_image = type { %"struct.bmp_image::bmp_header", %"struct.bmp_image::bmp_dib_header", i32, %"class.std::vector" }
%"struct.bmp_image::bmp_header" = type { i16, i32, i32, i32 }
%"struct.bmp_image::bmp_dib_header" = type { i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZTISt9exception = external constant ptr
@.str = external hidden unnamed_addr constant [23 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [81 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca %"struct.(anonymous namespace)::options", align 8
  %9 = alloca %class.bmp_image, align 8
  %10 = alloca %"class.std::vector", align 8
  %11 = alloca ptr, align 8
  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
  %12 = invoke noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
          to label %13 unwind label %39

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #9
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !9
  invoke void @_ZN12_GLOBAL__N_17optionsC2EiPPc(ptr noundef nonnull align 8 dereferenceable(24) %8, i32 noundef %14, ptr noundef %15)
          to label %16 unwind label %43

16:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 88, ptr %9) #9
  %17 = getelementptr inbounds %"struct.(anonymous namespace)::options", ptr %8, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  invoke void @_ZN9bmp_imageC2EPKc(ptr noundef nonnull align 8 dereferenceable(88) %9, ptr noundef %18)
          to label %19 unwind label %47

19:                                               ; preds = %16
  %20 = getelementptr inbounds %class.bmp_image, ptr %9, i32 0, i32 1
  %21 = getelementptr inbounds %"struct.bmp_image::bmp_dib_header", ptr %20, i32 0, i32 2
  %22 = load i32, ptr %21, align 8, !tbaa !14
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %24, label %55

24:                                               ; preds = %19
  %25 = getelementptr inbounds %class.bmp_image, ptr %9, i32 0, i32 3
  %26 = call noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %25) #9
  %27 = getelementptr inbounds %class.bmp_image, ptr %9, i32 0, i32 1
  %28 = getelementptr inbounds %"struct.bmp_image::bmp_dib_header", ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !23
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds %class.bmp_image, ptr %9, i32 0, i32 1
  %32 = getelementptr inbounds %"struct.bmp_image::bmp_dib_header", ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 8, !tbaa !14
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %class.bmp_image, ptr %9, i32 0, i32 2
  %36 = load i32, ptr %35, align 8, !tbaa !24
  %37 = zext i32 %36 to i64
  invoke void @_ZN12_GLOBAL__N_129convert_bottom_up_to_top_downEPhmmm(ptr noundef %26, i64 noundef %30, i64 noundef %34, i64 noundef %37)
          to label %38 unwind label %51

38:                                               ; preds = %24
  br label %62

39:                                               ; preds = %2
  %40 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %6, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %7, align 4
  br label %97

43:                                               ; preds = %13
  %44 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  %45 = extractvalue { ptr, i32 } %44, 0
  store ptr %45, ptr %6, align 8
  %46 = extractvalue { ptr, i32 } %44, 1
  store i32 %46, ptr %7, align 4
  br label %96

47:                                               ; preds = %16
  %48 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %6, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %7, align 4
  br label %95

51:                                               ; preds = %24
  %52 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  %53 = extractvalue { ptr, i32 } %52, 0
  store ptr %53, ptr %6, align 8
  %54 = extractvalue { ptr, i32 } %52, 1
  store i32 %54, ptr %7, align 4
  br label %94

55:                                               ; preds = %19
  %56 = getelementptr inbounds %class.bmp_image, ptr %9, i32 0, i32 1
  %57 = getelementptr inbounds %"struct.bmp_image::bmp_dib_header", ptr %56, i32 0, i32 2
  %58 = load i32, ptr %57, align 8, !tbaa !14
  %59 = call i32 @llvm.abs.i32(i32 %58, i1 true)
  %60 = getelementptr inbounds %class.bmp_image, ptr %9, i32 0, i32 1
  %61 = getelementptr inbounds %"struct.bmp_image::bmp_dib_header", ptr %60, i32 0, i32 2
  store i32 %59, ptr %61, align 8, !tbaa !14
  br label %62

62:                                               ; preds = %55, %38
  %63 = getelementptr inbounds %class.bmp_image, ptr %9, i32 0, i32 3
  %64 = getelementptr inbounds %class.bmp_image, ptr %9, i32 0, i32 1
  %65 = getelementptr inbounds %"struct.bmp_image::bmp_dib_header", ptr %64, i32 0, i32 1
  %66 = load i32, ptr %65, align 4, !tbaa !23
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds %class.bmp_image, ptr %9, i32 0, i32 1
  %69 = getelementptr inbounds %"struct.bmp_image::bmp_dib_header", ptr %68, i32 0, i32 2
  %70 = load i32, ptr %69, align 8, !tbaa !14
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds %class.bmp_image, ptr %9, i32 0, i32 2
  %73 = load i32, ptr %72, align 8, !tbaa !24
  %74 = zext i32 %73 to i64
  call void @_ZN12_GLOBAL__N_118convert_bgr_to_rgbERSt6vectorIhSaIhEEmmm(ptr noundef nonnull align 8 dereferenceable(24) %63, i64 noundef %67, i64 noundef %71, i64 noundef %74) #9
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #9
  %75 = getelementptr inbounds %"struct.(anonymous namespace)::options", ptr %8, i32 0, i32 2
  %76 = load i32, ptr %75, align 8, !tbaa !25
  %77 = getelementptr inbounds %"struct.(anonymous namespace)::options", ptr %8, i32 0, i32 3
  %78 = load i32, ptr %77, align 4, !tbaa !26
  invoke void @_ZN12_GLOBAL__N_126encode_bmp_image_to_jpeglsERK9bmp_imageN6charls15interleave_modeEi(ptr dead_on_unwind writable sret(%"class.std::vector") align 8 %10, ptr noundef nonnull align 8 dereferenceable(88) %9, i32 noundef %76, i32 noundef %78)
          to label %79 unwind label %85

79:                                               ; preds = %62
  %80 = call noundef ptr @_ZNKSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %10) #9
  %81 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %10) #9
  %82 = getelementptr inbounds %"struct.(anonymous namespace)::options", ptr %8, i32 0, i32 1
  %83 = load ptr, ptr %82, align 8, !tbaa !27
  invoke void @_ZN12_GLOBAL__N_119save_buffer_to_fileEPKvmPKc(ptr noundef %80, i64 noundef %81, ptr noundef %83)
          to label %84 unwind label %89

84:                                               ; preds = %79
  store i32 0, ptr %3, align 4
  call void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %10) #9
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #9
  call void @_ZN9bmp_imageD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %9) #9
  call void @llvm.lifetime.end.p0(i64 88, ptr %9) #9
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #9
  br label %113

85:                                               ; preds = %62
  %86 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  %87 = extractvalue { ptr, i32 } %86, 0
  store ptr %87, ptr %6, align 8
  %88 = extractvalue { ptr, i32 } %86, 1
  store i32 %88, ptr %7, align 4
  br label %93

89:                                               ; preds = %79
  %90 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  %91 = extractvalue { ptr, i32 } %90, 0
  store ptr %91, ptr %6, align 8
  %92 = extractvalue { ptr, i32 } %90, 1
  store i32 %92, ptr %7, align 4
  call void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %10) #9
  br label %93

93:                                               ; preds = %89, %85
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #9
  br label %94

94:                                               ; preds = %93, %51
  call void @_ZN9bmp_imageD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %9) #9
  br label %95

95:                                               ; preds = %94, %47
  call void @llvm.lifetime.end.p0(i64 88, ptr %9) #9
  br label %96

96:                                               ; preds = %95, %43
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #9
  br label %97

97:                                               ; preds = %96, %39
  %98 = load i32, ptr %7, align 4
  %99 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTISt9exception) #9
  %100 = icmp eq i32 %98, %99
  br i1 %100, label %101, label %110

101:                                              ; preds = %97
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #9
  %102 = load ptr, ptr %6, align 8
  %103 = call ptr @__cxa_begin_catch(ptr %102) #9
  store ptr %103, ptr %11, align 8
  %104 = load ptr, ptr %11, align 8, !tbaa !9
  %105 = load ptr, ptr %104, align 8, !tbaa !28
  %106 = getelementptr inbounds ptr, ptr %105, i64 2
  %107 = load ptr, ptr %106, align 8
  %108 = call noundef ptr %107(ptr noundef nonnull align 8 dereferenceable(8) %104) #9
  call void @_ZN12_GLOBAL__N_111log_failureEPKc(ptr noundef %108) #9
  call void @__cxa_end_catch()
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #9
  br label %109

109:                                              ; preds = %101
  store i32 1, ptr %3, align 4
  br label %113

110:                                              ; preds = %97
  %111 = load ptr, ptr %6, align 8
  %112 = call ptr @__cxa_begin_catch(ptr %111) #9
  call void @_ZN12_GLOBAL__N_111log_failureEPKc(ptr noundef @.str) #9
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 238, ptr noundef @__PRETTY_FUNCTION__.main) #10
  unreachable

113:                                              ; preds = %109, %84
  %114 = load i32, ptr %3, align 4
  ret i32 %114
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #1

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_17optionsC2EiPPc(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, ptr noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9bmp_imageC2EPKc(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_129convert_bottom_up_to_top_downEPhmmm(ptr noundef, i64 noundef, i64 noundef, i64 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN12_GLOBAL__N_118convert_bgr_to_rgbERSt6vectorIhSaIhEEmmm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, i64 noundef, i64 noundef) #4

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_126encode_bmp_image_to_jpeglsERK9bmp_imageN6charls15interleave_modeEi(ptr dead_on_unwind noalias writable sret(%"class.std::vector") align 8, ptr noundef nonnull align 8 dereferenceable(88), i32 noundef, i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_119save_buffer_to_fileEPKvmPKc(ptr noundef, i64 noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN9bmp_imageD2Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #6 align 2

; Function Attrs: nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #7

declare ptr @__cxa_begin_catch(ptr)

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN12_GLOBAL__N_111log_failureEPKc(ptr noundef) #4

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

declare void @__cxa_end_catch()

attributes #0 = { mustprogress norecurse 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #7 = { nounwind memory(none) }
attributes #8 = { 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 #9 = { nounwind }
attributes #10 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN12_GLOBAL__N_17optionsE", !10, i64 0, !10, i64 8, !13, i64 16, !6, i64 20}
!13 = !{!"_ZTSN6charls15interleave_modeE", !7, i64 0}
!14 = !{!15, !6, i64 24}
!15 = !{!"_ZTS9bmp_image", !16, i64 0, !18, i64 16, !6, i64 56, !19, i64 64}
!16 = !{!"_ZTSN9bmp_image10bmp_headerE", !17, i64 0, !6, i64 4, !6, i64 8, !6, i64 12}
!17 = !{!"short", !7, i64 0}
!18 = !{!"_ZTSN9bmp_image14bmp_dib_headerE", !6, i64 0, !6, i64 4, !6, i64 8, !17, i64 12, !17, i64 14, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !6, i64 36}
!19 = !{!"_ZTSSt6vectorIhSaIhEE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !10, i64 0, !10, i64 8, !10, i64 16}
!23 = !{!15, !6, i64 20}
!24 = !{!15, !6, i64 56}
!25 = !{!12, !13, i64 16}
!26 = !{!12, !6, i64 20}
!27 = !{!12, !10, i64 8}
!28 = !{!29, !29, i64 0}
!29 = !{!"vtable pointer", !8, i64 0}


; 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.(anonymous namespace)::options" = type { ptr, ptr, i32, i32 }
%class.bmp_image = type { %"struct.bmp_image::bmp_header", %"struct.bmp_image::bmp_dib_header", i32, %"class.std::vector" }
%"struct.bmp_image::bmp_header" = type { i16, i32, i32, i32 }
%"struct.bmp_image::bmp_dib_header" = type { i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZTISt9exception = external constant ptr
@.str = external hidden unnamed_addr constant [23 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [81 x i8], align 1
@__PRETTY_FUNCTION__.main = external hidden unnamed_addr constant [29 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef range(i32 0, 2) i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"struct.(anonymous namespace)::options", align 8
  %4 = alloca %class.bmp_image, align 8
  %5 = alloca %"class.std::vector", align 8
  %6 = invoke noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
          to label %7 unwind label %25

7:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #8
  invoke void @_ZN12_GLOBAL__N_17optionsC2EiPPc(ptr noundef nonnull align 8 dereferenceable(24) %3, i32 noundef %0, ptr noundef %1)
          to label %8 unwind label %27

8:                                                ; preds = %7
  call void @llvm.lifetime.start.p0(i64 88, ptr nonnull %4) #8
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  invoke void @_ZN9bmp_imageC2EPKc(ptr noundef nonnull align 8 dereferenceable(88) %4, ptr noundef %9)
          to label %10 unwind label %29

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %4, i64 24
  %12 = load i32, ptr %11, align 8, !tbaa !12
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %14, label %33

14:                                               ; preds = %10
  %15 = getelementptr inbounds i8, ptr %4, i64 64
  %16 = call noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #8
  %17 = getelementptr inbounds i8, ptr %4, i64 20
  %18 = load i32, ptr %17, align 4, !tbaa !21
  %19 = zext i32 %18 to i64
  %20 = load i32, ptr %11, align 8, !tbaa !12
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i8, ptr %4, i64 56
  %23 = load i32, ptr %22, align 8, !tbaa !22
  %24 = zext i32 %23 to i64
  invoke void @_ZN12_GLOBAL__N_129convert_bottom_up_to_top_downEPhmmm(ptr noundef %16, i64 noundef %19, i64 noundef %21, i64 noundef %24)
          to label %._crit_edge unwind label %31

._crit_edge:                                      ; preds = %14
  %.pre = load i32, ptr %11, align 8, !tbaa !12
  br label %35

25:                                               ; preds = %2
  %26 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  br label %63

27:                                               ; preds = %7
  %28 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  br label %62

29:                                               ; preds = %8
  %30 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  br label %61

31:                                               ; preds = %14
  %32 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  br label %60

33:                                               ; preds = %10
  %34 = sub nsw i32 0, %12
  store i32 %34, ptr %11, align 8, !tbaa !12
  br label %35

35:                                               ; preds = %._crit_edge, %33
  %36 = phi i32 [ %.pre, %._crit_edge ], [ %34, %33 ]
  %37 = getelementptr inbounds i8, ptr %4, i64 64
  %38 = getelementptr inbounds i8, ptr %4, i64 20
  %39 = load i32, ptr %38, align 4, !tbaa !21
  %40 = zext i32 %39 to i64
  %41 = sext i32 %36 to i64
  %42 = getelementptr inbounds i8, ptr %4, i64 56
  %43 = load i32, ptr %42, align 8, !tbaa !22
  %44 = zext i32 %43 to i64
  call void @_ZN12_GLOBAL__N_118convert_bgr_to_rgbERSt6vectorIhSaIhEEmmm(ptr noundef nonnull align 8 dereferenceable(24) %37, i64 noundef %40, i64 noundef %41, i64 noundef %44) #8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #8
  %45 = getelementptr inbounds i8, ptr %3, i64 16
  %46 = load i32, ptr %45, align 8, !tbaa !23
  %47 = getelementptr inbounds i8, ptr %3, i64 20
  %48 = load i32, ptr %47, align 4, !tbaa !24
  invoke void @_ZN12_GLOBAL__N_126encode_bmp_image_to_jpeglsERK9bmp_imageN6charls15interleave_modeEi(ptr dead_on_unwind nonnull writable sret(%"class.std::vector") align 8 %5, ptr noundef nonnull align 8 dereferenceable(88) %4, i32 noundef %46, i32 noundef %48)
          to label %49 unwind label %55

49:                                               ; preds = %35
  %50 = call noundef ptr @_ZNKSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  %51 = call noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  %52 = getelementptr inbounds i8, ptr %3, i64 8
  %53 = load ptr, ptr %52, align 8, !tbaa !25
  invoke void @_ZN12_GLOBAL__N_119save_buffer_to_fileEPKvmPKc(ptr noundef %50, i64 noundef %51, ptr noundef %53)
          to label %54 unwind label %57

54:                                               ; preds = %49
  call void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #8
  call void @_ZN9bmp_imageD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %4) #8
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #8
  br label %73

55:                                               ; preds = %35
  %56 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  br label %59

57:                                               ; preds = %49
  %58 = landingpad { ptr, i32 }
          catch ptr @_ZTISt9exception
          catch ptr null
  call void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5) #8
  br label %59

59:                                               ; preds = %57, %55
  %.pn = phi { ptr, i32 } [ %58, %57 ], [ %56, %55 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #8
  br label %60

60:                                               ; preds = %59, %31
  %.pn.pn = phi { ptr, i32 } [ %.pn, %59 ], [ %32, %31 ]
  call void @_ZN9bmp_imageD2Ev(ptr noundef nonnull align 8 dereferenceable(88) %4) #8
  br label %61

61:                                               ; preds = %60, %29
  %.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn, %60 ], [ %30, %29 ]
  call void @llvm.lifetime.end.p0(i64 88, ptr nonnull %4) #8
  br label %62

62:                                               ; preds = %61, %27
  %.pn.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn.pn, %61 ], [ %28, %27 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #8
  br label %63

63:                                               ; preds = %62, %25
  %.pn.pn.pn.pn.pn = phi { ptr, i32 } [ %.pn.pn.pn.pn, %62 ], [ %26, %25 ]
  %.4 = extractvalue { ptr, i32 } %.pn.pn.pn.pn.pn, 1
  %.411 = extractvalue { ptr, i32 } %.pn.pn.pn.pn.pn, 0
  %64 = call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTISt9exception) #8
  %65 = icmp eq i32 %.4, %64
  %66 = call ptr @__cxa_begin_catch(ptr %.411) #8
  br i1 %65, label %67, label %72

67:                                               ; preds = %63
  %68 = load ptr, ptr %66, align 8, !tbaa !26
  %69 = getelementptr inbounds i8, ptr %68, i64 16
  %70 = load ptr, ptr %69, align 8
  %71 = call noundef ptr %70(ptr noundef nonnull align 8 dereferenceable(8) %66) #8
  call void @_ZN12_GLOBAL__N_111log_failureEPKc(ptr noundef %71) #8
  call void @__cxa_end_catch()
  br label %73

72:                                               ; preds = %63
  call void @_ZN12_GLOBAL__N_111log_failureEPKc(ptr noundef nonnull @.str) #8
  call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 238, ptr noundef nonnull @__PRETTY_FUNCTION__.main) #9
  unreachable

73:                                               ; preds = %67, %54
  %.0 = phi i32 [ 0, %54 ], [ 1, %67 ]
  ret i32 %.0
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_17optionsC2EiPPc(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, ptr noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9bmp_imageC2EPKc(ptr noundef nonnull align 8 dereferenceable(88), ptr noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_129convert_bottom_up_to_top_downEPhmmm(ptr noundef, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN12_GLOBAL__N_118convert_bgr_to_rgbERSt6vectorIhSaIhEEmmm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_126encode_bmp_image_to_jpeglsERK9bmp_imageN6charls15interleave_modeEi(ptr dead_on_unwind noalias writable sret(%"class.std::vector") align 8, ptr noundef nonnull align 8 dereferenceable(88), i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN12_GLOBAL__N_119save_buffer_to_fileEPKvmPKc(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt6vectorIhSaIhEE4dataEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIhSaIhEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIhSaIhEED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #4 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN9bmp_imageD2Ev(ptr noundef nonnull align 8 dereferenceable(88)) unnamed_addr #5 align 2

; Function Attrs: nofree nosync nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #6

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZN12_GLOBAL__N_111log_failureEPKc(ptr noundef) local_unnamed_addr #4

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

declare void @__cxa_end_catch() local_unnamed_addr

attributes #0 = { mustprogress norecurse 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 = { "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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nofree nosync nounwind memory(none) }
attributes #7 = { 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 #8 = { nounwind }
attributes #9 = { 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, !7, i64 0}
!6 = !{!"_ZTSN12_GLOBAL__N_17optionsE", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 20}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN6charls15interleave_modeE", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !11, i64 24}
!13 = !{!"_ZTS9bmp_image", !14, i64 0, !16, i64 16, !11, i64 56, !17, i64 64}
!14 = !{!"_ZTSN9bmp_image10bmp_headerE", !15, i64 0, !11, i64 4, !11, i64 8, !11, i64 12}
!15 = !{!"short", !8, i64 0}
!16 = !{!"_ZTSN9bmp_image14bmp_dib_headerE", !11, i64 0, !11, i64 4, !11, i64 8, !15, i64 12, !15, i64 14, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36}
!17 = !{!"_ZTSSt6vectorIhSaIhEE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!21 = !{!13, !11, i64 20}
!22 = !{!13, !11, i64 56}
!23 = !{!6, !10, i64 16}
!24 = !{!6, !11, i64 20}
!25 = !{!6, !7, i64 8}
!26 = !{!27, !27, i64 0}
!27 = !{!"vtable pointer", !9, i64 0}


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