; LLVM IR from drohmer/cgp :: library/third_party/src/jpeg (jpge)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.jpge::memory_stream" = type { %"class.jpge::output_stream", ptr, i32, i32 }
%"class.jpge::output_stream" = type { ptr }
%"class.jpge::jpeg_encoder" = type <{ ptr, %"struct.jpge::params", i8, [3 x i8], [3 x i8], i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [16 x ptr], i8, [3 x i8], [64 x i32], [64 x i16], [2 x [64 x i32]], [4 x [256 x i32]], [4 x [256 x i8]], [4 x [17 x i8]], [4 x [256 x i8]], [4 x [256 x i32]], [3 x i32], [2048 x i8], [4 x i8], ptr, i32, i32, i32, i8, i8, [2 x i8] }>
%"struct.jpge::params" = type <{ i32, i32, i8, i8, [2 x i8] }>

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4jpge12jpeg_encoder6deinitEv(ptr noundef nonnull align 8 dereferenceable(13494)) #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4jpge12jpeg_encoder4initEPNS_13output_streamEiiiRKNS_6paramsE(ptr noundef nonnull align 8 dereferenceable(13494), ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(10)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4jpge12jpeg_encoder16process_scanlineEPKv(ptr noundef nonnull align 8 dereferenceable(13494), ptr noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4jpge12jpeg_encoder16get_total_passesEv(ptr noundef nonnull align 8 dereferenceable(13494)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4jpge37compress_image_to_jpeg_file_in_memoryEPvRiiiiPKhRKNS_6paramsE(ptr noundef %0, ptr noundef nonnull align 4 dereferenceable(4) %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5, ptr noundef nonnull align 4 dereferenceable(10) %6) #1 personality ptr @__gxx_personality_v0 {
  %8 = alloca i1, align 1
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca %"class.jpge::memory_stream", align 8
  %17 = alloca %"class.jpge::jpeg_encoder", align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca ptr, align 8
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i32 %2, ptr %11, align 4, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !9
  store i32 %4, ptr %13, align 4, !tbaa !9
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %30

26:                                               ; preds = %7
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = load i32, ptr %27, align 4, !tbaa !9
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %31, label %30

30:                                               ; preds = %26, %7
  store i1 false, ptr %8, align 1
  br label %114

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #3
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = load i32, ptr %33, align 4, !tbaa !9
  call void @_ZN4jpge13memory_streamC2EPvj(ptr noundef nonnull align 8 dereferenceable(24) %16, ptr noundef %32, i32 noundef %34)
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 0, ptr %35, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 13496, ptr %17) #3
  invoke void @_ZN4jpge12jpeg_encoderC1Ev(ptr noundef nonnull align 8 dereferenceable(13494) %17)
          to label %36 unwind label %44

36:                                               ; preds = %31
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = load i32, ptr %12, align 4, !tbaa !9
  %39 = load i32, ptr %13, align 4, !tbaa !9
  %40 = load ptr, ptr %15, align 8, !tbaa !5
  %41 = invoke noundef zeroext i1 @_ZN4jpge12jpeg_encoder4initEPNS_13output_streamEiiiRKNS_6paramsE(ptr noundef nonnull align 8 dereferenceable(13494) %17, ptr noundef %16, i32 noundef %37, i32 noundef %38, i32 noundef %39, ptr noundef nonnull align 4 dereferenceable(10) %40)
          to label %42 unwind label %48

42:                                               ; preds = %36
  br i1 %41, label %52, label %43

43:                                               ; preds = %42
  store i1 false, ptr %8, align 1
  store i32 1, ptr %20, align 4
  br label %111

44:                                               ; preds = %31
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %18, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %19, align 4
  br label %113

48:                                               ; preds = %107, %106, %36
  %49 = landingpad { ptr, i32 }
          cleanup
  %50 = extractvalue { ptr, i32 } %49, 0
  store ptr %50, ptr %18, align 8
  %51 = extractvalue { ptr, i32 } %49, 1
  store i32 %51, ptr %19, align 4
  br label %112

52:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  store i32 0, ptr %21, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %100, %52
  %54 = load i32, ptr %21, align 4, !tbaa !9
  %55 = invoke noundef i32 @_ZNK4jpge12jpeg_encoder16get_total_passesEv(ptr noundef nonnull align 8 dereferenceable(13494) %17)
          to label %56 unwind label %59

56:                                               ; preds = %53
  %57 = icmp ult i32 %54, %55
  br i1 %57, label %63, label %58

58:                                               ; preds = %56
  store i32 2, ptr %20, align 4
  br label %103

59:                                               ; preds = %95, %53
  %60 = landingpad { ptr, i32 }
          cleanup
  %61 = extractvalue { ptr, i32 } %60, 0
  store ptr %61, ptr %18, align 8
  %62 = extractvalue { ptr, i32 } %60, 1
  store i32 %62, ptr %19, align 4
  br label %105

63:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  store i32 0, ptr %22, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %90, %63
  %65 = load i32, ptr %22, align 4, !tbaa !9
  %66 = load i32, ptr %12, align 4, !tbaa !9
  %67 = icmp slt i32 %65, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  store i32 5, ptr %20, align 4
  br label %93

69:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #3
  %70 = load ptr, ptr %14, align 8, !tbaa !5
  %71 = load i32, ptr %22, align 4, !tbaa !9
  %72 = load i32, ptr %11, align 4, !tbaa !9
  %73 = mul nsw i32 %71, %72
  %74 = load i32, ptr %13, align 4, !tbaa !9
  %75 = mul nsw i32 %73, %74
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds i8, ptr %70, i64 %76
  store ptr %77, ptr %23, align 8, !tbaa !5
  %78 = load ptr, ptr %23, align 8, !tbaa !5
  %79 = invoke noundef zeroext i1 @_ZN4jpge12jpeg_encoder16process_scanlineEPKv(ptr noundef nonnull align 8 dereferenceable(13494) %17, ptr noundef %78)
          to label %80 unwind label %82

80:                                               ; preds = %69
  br i1 %79, label %86, label %81

81:                                               ; preds = %80
  store i1 false, ptr %8, align 1
  store i32 1, ptr %20, align 4
  br label %87

82:                                               ; preds = %69
  %83 = landingpad { ptr, i32 }
          cleanup
  %84 = extractvalue { ptr, i32 } %83, 0
  store ptr %84, ptr %18, align 8
  %85 = extractvalue { ptr, i32 } %83, 1
  store i32 %85, ptr %19, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  br label %105

86:                                               ; preds = %80
  store i32 0, ptr %20, align 4
  br label %87

87:                                               ; preds = %86, %81
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #3
  %88 = load i32, ptr %20, align 4
  switch i32 %88, label %93 [
    i32 0, label %89
  ]

89:                                               ; preds = %87
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %22, align 4, !tbaa !9
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %22, align 4, !tbaa !9
  br label %64, !llvm.loop !11

93:                                               ; preds = %87, %68
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  %94 = load i32, ptr %20, align 4
  switch i32 %94, label %103 [
    i32 5, label %95
  ]

95:                                               ; preds = %93
  %96 = invoke noundef zeroext i1 @_ZN4jpge12jpeg_encoder16process_scanlineEPKv(ptr noundef nonnull align 8 dereferenceable(13494) %17, ptr noundef null)
          to label %97 unwind label %59

97:                                               ; preds = %95
  br i1 %96, label %99, label %98

98:                                               ; preds = %97
  store i1 false, ptr %8, align 1
  store i32 1, ptr %20, align 4
  br label %103

99:                                               ; preds = %97
  br label %100

100:                                              ; preds = %99
  %101 = load i32, ptr %21, align 4, !tbaa !9
  %102 = add i32 %101, 1
  store i32 %102, ptr %21, align 4, !tbaa !9
  br label %53, !llvm.loop !13

103:                                              ; preds = %98, %93, %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  %104 = load i32, ptr %20, align 4
  switch i32 %104, label %111 [
    i32 2, label %106
  ]

105:                                              ; preds = %82, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  br label %112

106:                                              ; preds = %103
  invoke void @_ZN4jpge12jpeg_encoder6deinitEv(ptr noundef nonnull align 8 dereferenceable(13494) %17)
          to label %107 unwind label %48

107:                                              ; preds = %106
  %108 = invoke noundef i32 @_ZNK4jpge13memory_stream8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16)
          to label %109 unwind label %48

109:                                              ; preds = %107
  %110 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %108, ptr %110, align 4, !tbaa !9
  store i1 true, ptr %8, align 1
  store i32 1, ptr %20, align 4
  br label %111

111:                                              ; preds = %109, %103, %43
  call void @_ZN4jpge12jpeg_encoderD1Ev(ptr noundef nonnull align 8 dereferenceable(13494) %17) #3
  call void @llvm.lifetime.end.p0(i64 13496, ptr %17) #3
  call void @_ZN4jpge13output_streamD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %16) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #3
  br label %114

112:                                              ; preds = %105, %48
  call void @_ZN4jpge12jpeg_encoderD1Ev(ptr noundef nonnull align 8 dereferenceable(13494) %17) #3
  br label %113

113:                                              ; preds = %112, %44
  call void @llvm.lifetime.end.p0(i64 13496, ptr %17) #3
  call void @_ZN4jpge13output_streamD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %16) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #3
  br label %116

114:                                              ; preds = %111, %30
  %115 = load i1, ptr %8, align 1
  ret i1 %115

116:                                              ; preds = %113
  %117 = load ptr, ptr %18, align 8
  %118 = load i32, ptr %19, align 4
  %119 = insertvalue { ptr, i32 } poison, ptr %117, 0
  %120 = insertvalue { ptr, i32 } %119, i32 %118, 1
  resume { ptr, i32 } %120
}

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

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

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

declare void @_ZN4jpge12jpeg_encoderC1Ev(ptr)

declare void @_ZN4jpge12jpeg_encoderD1Ev(ptr)

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

%"class.jpge::memory_stream" = type { %"class.jpge::output_stream", ptr, i32, i32 }
%"class.jpge::output_stream" = type { ptr }
%"class.jpge::jpeg_encoder" = type <{ ptr, %"struct.jpge::params", i8, [3 x i8], [3 x i8], i8, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [16 x ptr], i8, [3 x i8], [64 x i32], [64 x i16], [2 x [64 x i32]], [4 x [256 x i32]], [4 x [256 x i8]], [4 x [17 x i8]], [4 x [256 x i8]], [4 x [256 x i32]], [3 x i32], [2048 x i8], [4 x i8], ptr, i32, i32, i32, i8, i8, [2 x i8] }>
%"struct.jpge::params" = type <{ i32, i32, i8, i8, [2 x i8] }>

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4jpge12jpeg_encoder6deinitEv(ptr noundef nonnull align 8 dereferenceable(13494)) local_unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4jpge12jpeg_encoder4initEPNS_13output_streamEiiiRKNS_6paramsE(ptr noundef nonnull align 8 dereferenceable(13494), ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef nonnull align 4 dereferenceable(10)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4jpge12jpeg_encoder16process_scanlineEPKv(ptr noundef nonnull align 8 dereferenceable(13494), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4jpge12jpeg_encoder16get_total_passesEv(ptr noundef nonnull align 8 dereferenceable(13494)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4jpge37compress_image_to_jpeg_file_in_memoryEPvRiiiiPKhRKNS_6paramsE(ptr noundef %0, ptr nocapture noundef nonnull align 4 dereferenceable(4) %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5, ptr noundef nonnull align 4 dereferenceable(10) %6) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %8 = alloca %"class.jpge::memory_stream", align 8
  %9 = alloca %"class.jpge::jpeg_encoder", align 8
  %.not = icmp eq ptr %0, null
  %10 = load i32, ptr %1, align 4
  %.not39 = icmp eq i32 %10, 0
  %or.cond = select i1 %.not, i1 true, i1 %.not39
  br i1 %or.cond, label %46, label %11

11:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #3
  call void @_ZN4jpge13memory_streamC2EPvj(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef nonnull %0, i32 noundef %10)
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 13496, ptr nonnull %9) #3
  invoke void @_ZN4jpge12jpeg_encoderC1Ev(ptr noundef nonnull align 8 dereferenceable(13494) %9)
          to label %12 unwind label %32

12:                                               ; preds = %11
  %13 = invoke noundef zeroext i1 @_ZN4jpge12jpeg_encoder4initEPNS_13output_streamEiiiRKNS_6paramsE(ptr noundef nonnull align 8 dereferenceable(13494) %9, ptr noundef nonnull %8, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef nonnull align 4 dereferenceable(10) %6)
          to label %14 unwind label %34

14:                                               ; preds = %12
  br i1 %13, label %.preheader48, label %.loopexit

.preheader48:                                     ; preds = %14
  %15 = call noundef i32 @_ZNK4jpge12jpeg_encoder16get_total_passesEv(ptr noundef nonnull align 8 dereferenceable(13494) %9)
  %.not4252.not = icmp eq i32 %15, 0
  br i1 %.not4252.not, label %.critedge47, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %.preheader48
  %.not4050 = icmp sgt i32 %3, 0
  %16 = mul i32 %4, %2
  br i1 %.not4050, label %.preheader.us.preheader, label %.preheader

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %wide.trip.count = zext nneg i32 %3 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %26
  %.02853.us = phi i32 [ %27, %26 ], [ 0, %.preheader.us.preheader ]
  br label %19

17:                                               ; preds = %25
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %..critedge_crit_edge.us, label %19, !llvm.loop !9

18:                                               ; preds = %..critedge_crit_edge.us
  br i1 %29, label %26, label %.loopexit

19:                                               ; preds = %.preheader.us, %17
  %indvars.iv = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next, %17 ]
  %20 = trunc nuw nsw i64 %indvars.iv to i32
  %21 = mul i32 %16, %20
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr %5, i64 %22
  %24 = invoke noundef zeroext i1 @_ZN4jpge12jpeg_encoder16process_scanlineEPKv(ptr noundef nonnull align 8 dereferenceable(13494) %9, ptr noundef %23)
          to label %25 unwind label %.split55.us

25:                                               ; preds = %19
  br i1 %24, label %17, label %.loopexit

26:                                               ; preds = %18
  %27 = add nuw i32 %.02853.us, 1
  %28 = call noundef i32 @_ZNK4jpge12jpeg_encoder16get_total_passesEv(ptr noundef nonnull align 8 dereferenceable(13494) %9)
  %.not42.us = icmp ult i32 %27, %28
  br i1 %.not42.us, label %.preheader.us, label %.critedge47, !llvm.loop !11

..critedge_crit_edge.us:                          ; preds = %17
  %29 = invoke noundef zeroext i1 @_ZN4jpge12jpeg_encoder16process_scanlineEPKv(ptr noundef nonnull align 8 dereferenceable(13494) %9, ptr noundef null)
          to label %18 unwind label %.split.us

.split.us:                                        ; preds = %..critedge_crit_edge.us
  %30 = landingpad { ptr, i32 }
          cleanup
  br label %44

.split55.us:                                      ; preds = %19
  %31 = landingpad { ptr, i32 }
          cleanup
  br label %44

32:                                               ; preds = %11
  %33 = landingpad { ptr, i32 }
          cleanup
  br label %45

34:                                               ; preds = %.critedge47, %12
  %35 = landingpad { ptr, i32 }
          cleanup
  br label %44

36:                                               ; preds = %41
  %37 = add nuw i32 %.02853, 1
  %38 = call noundef i32 @_ZNK4jpge12jpeg_encoder16get_total_passesEv(ptr noundef nonnull align 8 dereferenceable(13494) %9)
  %.not42 = icmp ult i32 %37, %38
  br i1 %.not42, label %.preheader, label %.critedge47, !llvm.loop !11

.preheader:                                       ; preds = %.preheader.lr.ph, %36
  %.02853 = phi i32 [ %37, %36 ], [ 0, %.preheader.lr.ph ]
  %39 = invoke noundef zeroext i1 @_ZN4jpge12jpeg_encoder16process_scanlineEPKv(ptr noundef nonnull align 8 dereferenceable(13494) %9, ptr noundef null)
          to label %41 unwind label %.split

.split:                                           ; preds = %.preheader
  %40 = landingpad { ptr, i32 }
          cleanup
  br label %44

41:                                               ; preds = %.preheader
  br i1 %39, label %36, label %.loopexit

.critedge47:                                      ; preds = %36, %26, %.preheader48
  invoke void @_ZN4jpge12jpeg_encoder6deinitEv(ptr noundef nonnull align 8 dereferenceable(13494) %9)
          to label %42 unwind label %34

42:                                               ; preds = %.critedge47
  %43 = call noundef i32 @_ZNK4jpge13memory_stream8get_sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  store i32 %43, ptr %1, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %41, %18, %25, %14, %42
  %.5 = phi i1 [ true, %42 ], [ false, %14 ], [ false, %25 ], [ false, %18 ], [ false, %41 ]
  call void @_ZN4jpge12jpeg_encoderD1Ev(ptr noundef nonnull align 8 dereferenceable(13494) %9) #3
  call void @llvm.lifetime.end.p0(i64 13496, ptr nonnull %9) #3
  call void @_ZN4jpge13output_streamD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #3
  br label %46

44:                                               ; preds = %.split, %.split.us, %.split55.us, %34
  %.pn43 = phi { ptr, i32 } [ %35, %34 ], [ %31, %.split55.us ], [ %40, %.split ], [ %30, %.split.us ]
  call void @_ZN4jpge12jpeg_encoderD1Ev(ptr noundef nonnull align 8 dereferenceable(13494) %9) #3
  br label %45

45:                                               ; preds = %44, %32
  %.pn43.pn = phi { ptr, i32 } [ %.pn43, %44 ], [ %33, %32 ]
  call void @llvm.lifetime.end.p0(i64 13496, ptr nonnull %9) #3
  call void @_ZN4jpge13output_streamD2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #3
  resume { ptr, i32 } %.pn43.pn

46:                                               ; preds = %7, %.loopexit
  %.6 = phi i1 [ %.5, %.loopexit ], [ false, %7 ]
  ret i1 %.6
}

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

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

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

declare void @_ZN4jpge12jpeg_encoderC1Ev(ptr) local_unnamed_addr

declare void @_ZN4jpge12jpeg_encoderD1Ev(ptr) local_unnamed_addr

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; Effective O3 passes: ConstraintEliminationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass