; 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::cfile_stream" = type <{ %"class.jpge::output_stream", ptr, i8, [7 x i8] }>
%"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 uwtable
define dso_local noundef zeroext i1 @_ZN4jpge27compress_image_to_jpeg_fileEPKciiiPKhRKNS_6paramsE(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef nonnull align 4 dereferenceable(10) %5) #1 personality ptr @__gxx_personality_v0 {
  %7 = alloca i1, align 1
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca %"class.jpge::cfile_stream", align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca %"class.jpge::jpeg_encoder", align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #3
  call void @_ZN4jpge12cfile_streamC2Ev(ptr noundef nonnull align 8 dereferenceable(17) %14)
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = invoke noundef zeroext i1 @_ZN4jpge12cfile_stream4openEPKc(ptr noundef nonnull align 8 dereferenceable(17) %14, ptr noundef %22)
          to label %24 unwind label %26

24:                                               ; preds = %6
  br i1 %23, label %30, label %25

25:                                               ; preds = %24
  store i1 false, ptr %7, align 1
  store i32 1, ptr %17, align 4
  br label %108

26:                                               ; preds = %6
  %27 = landingpad { ptr, i32 }
          cleanup
  %28 = extractvalue { ptr, i32 } %27, 0
  store ptr %28, ptr %15, align 8
  %29 = extractvalue { ptr, i32 } %27, 1
  store i32 %29, ptr %16, align 4
  br label %110

30:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 13496, ptr %18) #3
  invoke void @_ZN4jpge12jpeg_encoderC1Ev(ptr noundef nonnull align 8 dereferenceable(13494) %18)
          to label %31 unwind label %39

31:                                               ; preds = %30
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = load i32, ptr %11, align 4, !tbaa !9
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = invoke noundef zeroext i1 @_ZN4jpge12jpeg_encoder4initEPNS_13output_streamEiiiRKNS_6paramsE(ptr noundef nonnull align 8 dereferenceable(13494) %18, ptr noundef %14, i32 noundef %32, i32 noundef %33, i32 noundef %34, ptr noundef nonnull align 4 dereferenceable(10) %35)
          to label %37 unwind label %43

37:                                               ; preds = %31
  br i1 %36, label %47, label %38

38:                                               ; preds = %37
  store i1 false, ptr %7, align 1
  store i32 1, ptr %17, align 4
  br label %105

39:                                               ; preds = %30
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %15, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %16, align 4
  br label %107

43:                                               ; preds = %102, %101, %31
  %44 = landingpad { ptr, i32 }
          cleanup
  %45 = extractvalue { ptr, i32 } %44, 0
  store ptr %45, ptr %15, align 8
  %46 = extractvalue { ptr, i32 } %44, 1
  store i32 %46, ptr %16, align 4
  br label %106

47:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %95, %47
  %49 = load i32, ptr %19, align 4, !tbaa !9
  %50 = invoke noundef i32 @_ZNK4jpge12jpeg_encoder16get_total_passesEv(ptr noundef nonnull align 8 dereferenceable(13494) %18)
          to label %51 unwind label %54

51:                                               ; preds = %48
  %52 = icmp ult i32 %49, %50
  br i1 %52, label %58, label %53

53:                                               ; preds = %51
  store i32 2, ptr %17, align 4
  br label %98

54:                                               ; preds = %90, %48
  %55 = landingpad { ptr, i32 }
          cleanup
  %56 = extractvalue { ptr, i32 } %55, 0
  store ptr %56, ptr %15, align 8
  %57 = extractvalue { ptr, i32 } %55, 1
  store i32 %57, ptr %16, align 4
  br label %100

58:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  store i32 0, ptr %20, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %85, %58
  %60 = load i32, ptr %20, align 4, !tbaa !9
  %61 = load i32, ptr %10, align 4, !tbaa !9
  %62 = icmp slt i32 %60, %61
  br i1 %62, label %64, label %63

63:                                               ; preds = %59
  store i32 5, ptr %17, align 4
  br label %88

64:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = load i32, ptr %20, align 4, !tbaa !9
  %67 = load i32, ptr %9, align 4, !tbaa !9
  %68 = mul nsw i32 %66, %67
  %69 = load i32, ptr %11, align 4, !tbaa !9
  %70 = mul nsw i32 %68, %69
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds i8, ptr %65, i64 %71
  store ptr %72, ptr %21, align 8, !tbaa !5
  %73 = load ptr, ptr %21, align 8, !tbaa !5
  %74 = invoke noundef zeroext i1 @_ZN4jpge12jpeg_encoder16process_scanlineEPKv(ptr noundef nonnull align 8 dereferenceable(13494) %18, ptr noundef %73)
          to label %75 unwind label %77

75:                                               ; preds = %64
  br i1 %74, label %81, label %76

76:                                               ; preds = %75
  store i1 false, ptr %7, align 1
  store i32 1, ptr %17, align 4
  br label %82

77:                                               ; preds = %64
  %78 = landingpad { ptr, i32 }
          cleanup
  %79 = extractvalue { ptr, i32 } %78, 0
  store ptr %79, ptr %15, align 8
  %80 = extractvalue { ptr, i32 } %78, 1
  store i32 %80, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  br label %100

81:                                               ; preds = %75
  store i32 0, ptr %17, align 4
  br label %82

82:                                               ; preds = %81, %76
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  %83 = load i32, ptr %17, align 4
  switch i32 %83, label %88 [
    i32 0, label %84
  ]

84:                                               ; preds = %82
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %20, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %20, align 4, !tbaa !9
  br label %59, !llvm.loop !11

88:                                               ; preds = %82, %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  %89 = load i32, ptr %17, align 4
  switch i32 %89, label %98 [
    i32 5, label %90
  ]

90:                                               ; preds = %88
  %91 = invoke noundef zeroext i1 @_ZN4jpge12jpeg_encoder16process_scanlineEPKv(ptr noundef nonnull align 8 dereferenceable(13494) %18, ptr noundef null)
          to label %92 unwind label %54

92:                                               ; preds = %90
  br i1 %91, label %94, label %93

93:                                               ; preds = %92
  store i1 false, ptr %7, align 1
  store i32 1, ptr %17, align 4
  br label %98

94:                                               ; preds = %92
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %19, align 4, !tbaa !9
  %97 = add i32 %96, 1
  store i32 %97, ptr %19, align 4, !tbaa !9
  br label %48, !llvm.loop !13

98:                                               ; preds = %93, %88, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  %99 = load i32, ptr %17, align 4
  switch i32 %99, label %105 [
    i32 2, label %101
  ]

100:                                              ; preds = %77, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  br label %106

101:                                              ; preds = %98
  invoke void @_ZN4jpge12jpeg_encoder6deinitEv(ptr noundef nonnull align 8 dereferenceable(13494) %18)
          to label %102 unwind label %43

102:                                              ; preds = %101
  %103 = invoke noundef zeroext i1 @_ZN4jpge12cfile_stream5closeEv(ptr noundef nonnull align 8 dereferenceable(17) %14)
          to label %104 unwind label %43

104:                                              ; preds = %102
  store i1 %103, ptr %7, align 1
  store i32 1, ptr %17, align 4
  br label %105

105:                                              ; preds = %104, %98, %38
  call void @_ZN4jpge12jpeg_encoderD1Ev(ptr noundef nonnull align 8 dereferenceable(13494) %18) #3
  call void @llvm.lifetime.end.p0(i64 13496, ptr %18) #3
  br label %108

106:                                              ; preds = %100, %43
  call void @_ZN4jpge12jpeg_encoderD1Ev(ptr noundef nonnull align 8 dereferenceable(13494) %18) #3
  br label %107

107:                                              ; preds = %106, %39
  call void @llvm.lifetime.end.p0(i64 13496, ptr %18) #3
  br label %110

108:                                              ; preds = %105, %25
  call void @_ZN4jpge12cfile_streamD2Ev(ptr noundef nonnull align 8 dereferenceable(17) %14) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #3
  %109 = load i1, ptr %7, align 1
  ret i1 %109

110:                                              ; preds = %107, %26
  call void @_ZN4jpge12cfile_streamD2Ev(ptr noundef nonnull align 8 dereferenceable(17) %14) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #3
  br label %111

111:                                              ; preds = %110
  %112 = load ptr, ptr %15, align 8
  %113 = load i32, ptr %16, align 4
  %114 = insertvalue { ptr, i32 } poison, ptr %112, 0
  %115 = insertvalue { ptr, i32 } %114, i32 %113, 1
  resume { ptr, i32 } %115
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4jpge12cfile_stream4openEPKc(ptr noundef nonnull align 8 dereferenceable(17), 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
declare dso_local noundef zeroext i1 @_ZN4jpge12cfile_stream5closeEv(ptr noundef nonnull align 8 dereferenceable(17)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4jpge12cfile_streamD2Ev(ptr noundef nonnull align 8 dereferenceable(17)) 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::cfile_stream" = type <{ %"class.jpge::output_stream", ptr, i8, [7 x i8] }>
%"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 uwtable
define dso_local noundef zeroext i1 @_ZN4jpge27compress_image_to_jpeg_fileEPKciiiPKhRKNS_6paramsE(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef nonnull align 4 dereferenceable(10) %5) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %7 = alloca %"class.jpge::cfile_stream", align 8
  %8 = alloca %"class.jpge::jpeg_encoder", align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #3
  call void @_ZN4jpge12cfile_streamC2Ev(ptr noundef nonnull align 8 dereferenceable(17) %7)
  %9 = invoke noundef zeroext i1 @_ZN4jpge12cfile_stream4openEPKc(ptr noundef nonnull align 8 dereferenceable(17) %7, ptr noundef %0)
          to label %10 unwind label %11

10:                                               ; preds = %6
  br i1 %9, label %13, label %48

11:                                               ; preds = %6
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %49

13:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 13496, ptr nonnull %8) #3
  invoke void @_ZN4jpge12jpeg_encoderC1Ev(ptr noundef nonnull align 8 dereferenceable(13494) %8)
          to label %14 unwind label %34

14:                                               ; preds = %13
  %15 = invoke noundef zeroext i1 @_ZN4jpge12jpeg_encoder4initEPNS_13output_streamEiiiRKNS_6paramsE(ptr noundef nonnull align 8 dereferenceable(13494) %8, ptr noundef nonnull %7, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef nonnull align 4 dereferenceable(10) %5)
          to label %16 unwind label %36

16:                                               ; preds = %14
  br i1 %15, label %.preheader43, label %.loopexit

.preheader43:                                     ; preds = %16
  %17 = call noundef i32 @_ZNK4jpge12jpeg_encoder16get_total_passesEv(ptr noundef nonnull align 8 dereferenceable(13494) %8)
  %.not3647.not = icmp eq i32 %17, 0
  br i1 %.not3647.not, label %.critedge42, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %.preheader43
  %.not45 = icmp sgt i32 %2, 0
  %18 = mul i32 %3, %1
  br i1 %.not45, label %.preheader.us.preheader, label %.preheader

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

.preheader.us:                                    ; preds = %.preheader.us.preheader, %28
  %.02348.us = phi i32 [ %29, %28 ], [ 0, %.preheader.us.preheader ]
  br label %21

19:                                               ; preds = %27
  %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 %21, !llvm.loop !5

20:                                               ; preds = %..critedge_crit_edge.us
  br i1 %31, label %28, label %.loopexit

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

27:                                               ; preds = %21
  br i1 %26, label %19, label %.loopexit

28:                                               ; preds = %20
  %29 = add nuw i32 %.02348.us, 1
  %30 = call noundef i32 @_ZNK4jpge12jpeg_encoder16get_total_passesEv(ptr noundef nonnull align 8 dereferenceable(13494) %8)
  %.not36.us = icmp ult i32 %29, %30
  br i1 %.not36.us, label %.preheader.us, label %.critedge42, !llvm.loop !7

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

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

.split50.us:                                      ; preds = %21
  %33 = landingpad { ptr, i32 }
          cleanup
  br label %46

34:                                               ; preds = %13
  %35 = landingpad { ptr, i32 }
          cleanup
  br label %47

36:                                               ; preds = %44, %.critedge42, %14
  %37 = landingpad { ptr, i32 }
          cleanup
  br label %46

38:                                               ; preds = %43
  %39 = add nuw i32 %.02348, 1
  %40 = call noundef i32 @_ZNK4jpge12jpeg_encoder16get_total_passesEv(ptr noundef nonnull align 8 dereferenceable(13494) %8)
  %.not36 = icmp ult i32 %39, %40
  br i1 %.not36, label %.preheader, label %.critedge42, !llvm.loop !7

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

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

43:                                               ; preds = %.preheader
  br i1 %41, label %38, label %.loopexit

.critedge42:                                      ; preds = %38, %28, %.preheader43
  invoke void @_ZN4jpge12jpeg_encoder6deinitEv(ptr noundef nonnull align 8 dereferenceable(13494) %8)
          to label %44 unwind label %36

44:                                               ; preds = %.critedge42
  %45 = invoke noundef zeroext i1 @_ZN4jpge12cfile_stream5closeEv(ptr noundef nonnull align 8 dereferenceable(17) %7)
          to label %.loopexit unwind label %36

.loopexit:                                        ; preds = %43, %20, %27, %44, %16
  %.5 = phi i1 [ false, %16 ], [ %45, %44 ], [ false, %27 ], [ false, %20 ], [ false, %43 ]
  call void @_ZN4jpge12jpeg_encoderD1Ev(ptr noundef nonnull align 8 dereferenceable(13494) %8) #3
  call void @llvm.lifetime.end.p0(i64 13496, ptr nonnull %8) #3
  br label %48

46:                                               ; preds = %.split, %.split.us, %.split50.us, %36
  %.pn37 = phi { ptr, i32 } [ %37, %36 ], [ %33, %.split50.us ], [ %42, %.split ], [ %32, %.split.us ]
  call void @_ZN4jpge12jpeg_encoderD1Ev(ptr noundef nonnull align 8 dereferenceable(13494) %8) #3
  br label %47

47:                                               ; preds = %46, %34
  %.pn37.pn = phi { ptr, i32 } [ %.pn37, %46 ], [ %35, %34 ]
  call void @llvm.lifetime.end.p0(i64 13496, ptr nonnull %8) #3
  br label %49

48:                                               ; preds = %10, %.loopexit
  %.6 = phi i1 [ %.5, %.loopexit ], [ false, %10 ]
  call void @_ZN4jpge12cfile_streamD2Ev(ptr noundef nonnull align 8 dereferenceable(17) %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  ret i1 %.6

49:                                               ; preds = %47, %11
  %.pn37.pn.pn = phi { ptr, i32 } [ %.pn37.pn, %47 ], [ %12, %11 ]
  call void @_ZN4jpge12cfile_streamD2Ev(ptr noundef nonnull align 8 dereferenceable(17) %7) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #3
  resume { ptr, i32 } %.pn37.pn.pn
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4jpge12cfile_stream4openEPKc(ptr noundef nonnull align 8 dereferenceable(17), 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
declare dso_local noundef zeroext i1 @_ZN4jpge12cfile_stream5closeEv(ptr noundef nonnull align 8 dereferenceable(17)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4jpge12cfile_streamD2Ev(ptr noundef nonnull align 8 dereferenceable(17)) 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


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