; LLVM IR from fwip/fastqz :: libzpaq.ll (ZN7libzpaq10decompressEPNS_6ReaderEPNS_6WriterE)

; 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.libzpaq::Decompresser" = type { %"class.libzpaq::ZPAQL", %"class.libzpaq::Decoder", %"class.libzpaq::PostProcessor", i32, i32 }
%"class.libzpaq::ZPAQL" = type { ptr, ptr, %"class.libzpaq::Array.0", i32, i32, i32, [4 x i8], %"class.libzpaq::Array.0", %"class.libzpaq::Array", %"class.libzpaq::Array", %"class.libzpaq::Array.4", i32, i32, i32, i32, i32, i32, i32, i32, ptr }
%"class.libzpaq::Array.0" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libzpaq::Array" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libzpaq::Array.4" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libzpaq::Decoder" = type { ptr, i32, i32, i32, [4 x i8], %"class.libzpaq::Predictor", %"class.libzpaq::Array.4" }
%"class.libzpaq::Predictor" = type <{ i32, i32, [256 x i32], [256 x i32], ptr, [256 x %"struct.libzpaq::Component"], [256 x i32], [1024 x i32], [4096 x i16], [32768 x i16], %"class.libzpaq::StateTable", ptr, i32, [4 x i8] }>
%"struct.libzpaq::Component" = type { i64, i64, i64, i64, i64, %"class.libzpaq::Array", %"class.libzpaq::Array.0", %"class.libzpaq::Array.2" }
%"class.libzpaq::Array.2" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libzpaq::StateTable" = type { [1024 x i8] }
%"class.libzpaq::PostProcessor" = type { i32, i32, i32, i32, %"class.libzpaq::ZPAQL" }

; 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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7libzpaq10decompressEPNS_6ReaderEPNS_6WriterE(ptr noundef %0, ptr noundef %1) #1 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.libzpaq::Decompresser", align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 111080, ptr %5) #4
  call void @_ZN7libzpaq12DecompresserC2Ev(ptr noundef nonnull align 8 dereferenceable(111080) %5)
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  invoke void @_ZN7libzpaq12Decompresser8setInputEPNS_6ReaderE(ptr noundef nonnull align 8 dereferenceable(111080) %5, ptr noundef %8)
          to label %9 unwind label %24

9:                                                ; preds = %2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN7libzpaq12Decompresser9setOutputEPNS_6WriterE(ptr noundef nonnull align 8 dereferenceable(111080) %5, ptr noundef %10)
          to label %11 unwind label %24

11:                                               ; preds = %9
  br label %12

12:                                               ; preds = %28, %11
  %13 = invoke noundef zeroext i1 @_ZN7libzpaq12Decompresser9findBlockEPd(ptr noundef nonnull align 8 dereferenceable(111080) %5, ptr noundef null)
          to label %14 unwind label %24

14:                                               ; preds = %12
  br i1 %13, label %15, label %29

15:                                               ; preds = %14
  br label %16

16:                                               ; preds = %23, %15
  %17 = invoke noundef zeroext i1 @_ZN7libzpaq12Decompresser12findFilenameEPNS_6WriterE(ptr noundef nonnull align 8 dereferenceable(111080) %5, ptr noundef null)
          to label %18 unwind label %24

18:                                               ; preds = %16
  br i1 %17, label %19, label %28

19:                                               ; preds = %18
  invoke void @_ZN7libzpaq12Decompresser11readCommentEPNS_6WriterE(ptr noundef nonnull align 8 dereferenceable(111080) %5, ptr noundef null)
          to label %20 unwind label %24

20:                                               ; preds = %19
  %21 = invoke noundef zeroext i1 @_ZN7libzpaq12Decompresser10decompressEi(ptr noundef nonnull align 8 dereferenceable(111080) %5, i32 noundef -1)
          to label %22 unwind label %24

22:                                               ; preds = %20
  invoke void @_ZN7libzpaq12Decompresser14readSegmentEndEPc(ptr noundef nonnull align 8 dereferenceable(111080) %5, ptr noundef null)
          to label %23 unwind label %24

23:                                               ; preds = %22
  br label %16, !llvm.loop !9

24:                                               ; preds = %22, %20, %19, %16, %12, %9, %2
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %6, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %7, align 4
  call void @_ZN7libzpaq12DecompresserD2Ev(ptr noundef nonnull align 8 dereferenceable(111080) %5) #4
  call void @llvm.lifetime.end.p0(i64 111080, ptr %5) #4
  br label %30

28:                                               ; preds = %18
  br label %12, !llvm.loop !11

29:                                               ; preds = %14
  call void @_ZN7libzpaq12DecompresserD2Ev(ptr noundef nonnull align 8 dereferenceable(111080) %5) #4
  call void @llvm.lifetime.end.p0(i64 111080, ptr %5) #4
  ret void

30:                                               ; preds = %24
  %31 = load ptr, ptr %6, align 8
  %32 = load i32, ptr %7, align 4
  %33 = insertvalue { ptr, i32 } poison, ptr %31, 0
  %34 = insertvalue { ptr, i32 } %33, i32 %32, 1
  resume { ptr, i32 } %34
}

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

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

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

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

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 = { 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 #4 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


; 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.libzpaq::Decompresser" = type { %"class.libzpaq::ZPAQL", %"class.libzpaq::Decoder", %"class.libzpaq::PostProcessor", i32, i32 }
%"class.libzpaq::ZPAQL" = type { ptr, ptr, %"class.libzpaq::Array.0", i32, i32, i32, [4 x i8], %"class.libzpaq::Array.0", %"class.libzpaq::Array", %"class.libzpaq::Array", %"class.libzpaq::Array.4", i32, i32, i32, i32, i32, i32, i32, i32, ptr }
%"class.libzpaq::Array.0" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libzpaq::Array" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libzpaq::Array.4" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libzpaq::Decoder" = type { ptr, i32, i32, i32, [4 x i8], %"class.libzpaq::Predictor", %"class.libzpaq::Array.4" }
%"class.libzpaq::Predictor" = type <{ i32, i32, [256 x i32], [256 x i32], ptr, [256 x %"struct.libzpaq::Component"], [256 x i32], [1024 x i32], [4096 x i16], [32768 x i16], %"class.libzpaq::StateTable", ptr, i32, [4 x i8] }>
%"struct.libzpaq::Component" = type { i64, i64, i64, i64, i64, %"class.libzpaq::Array", %"class.libzpaq::Array.0", %"class.libzpaq::Array.2" }
%"class.libzpaq::Array.2" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libzpaq::StateTable" = type { [1024 x i8] }
%"class.libzpaq::PostProcessor" = type { i32, i32, i32, i32, %"class.libzpaq::ZPAQL" }

; 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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7libzpaq10decompressEPNS_6ReaderEPNS_6WriterE(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.libzpaq::Decompresser", align 8
  call void @llvm.lifetime.start.p0(i64 111080, ptr nonnull %3) #4
  call void @_ZN7libzpaq12DecompresserC2Ev(ptr noundef nonnull align 8 dereferenceable(111080) %3)
  call void @_ZN7libzpaq12Decompresser8setInputEPNS_6ReaderE(ptr noundef nonnull align 8 dereferenceable(111080) %3, ptr noundef %0)
  invoke void @_ZN7libzpaq12Decompresser9setOutputEPNS_6WriterE(ptr noundef nonnull align 8 dereferenceable(111080) %3, ptr noundef %1)
          to label %.preheader4 unwind label %.loopexit.split-lp.loopexit.split-lp

.preheader4:                                      ; preds = %7, %2
  %4 = invoke noundef zeroext i1 @_ZN7libzpaq12Decompresser9findBlockEPd(ptr noundef nonnull align 8 dereferenceable(111080) %3, ptr noundef null)
          to label %5 unwind label %.loopexit.split-lp.loopexit

5:                                                ; preds = %.preheader4
  br i1 %4, label %.preheader, label %12

.preheader:                                       ; preds = %5, %11
  %6 = invoke noundef zeroext i1 @_ZN7libzpaq12Decompresser12findFilenameEPNS_6WriterE(ptr noundef nonnull align 8 dereferenceable(111080) %3, ptr noundef null)
          to label %7 unwind label %.loopexit

7:                                                ; preds = %.preheader
  br i1 %6, label %8, label %.preheader4, !llvm.loop !5

8:                                                ; preds = %7
  invoke void @_ZN7libzpaq12Decompresser11readCommentEPNS_6WriterE(ptr noundef nonnull align 8 dereferenceable(111080) %3, ptr noundef null)
          to label %9 unwind label %.loopexit

9:                                                ; preds = %8
  %10 = invoke noundef zeroext i1 @_ZN7libzpaq12Decompresser10decompressEi(ptr noundef nonnull align 8 dereferenceable(111080) %3, i32 noundef -1)
          to label %11 unwind label %.loopexit

11:                                               ; preds = %9
  invoke void @_ZN7libzpaq12Decompresser14readSegmentEndEPc(ptr noundef nonnull align 8 dereferenceable(111080) %3, ptr noundef null)
          to label %.preheader unwind label %.loopexit, !llvm.loop !7

.loopexit:                                        ; preds = %.preheader, %8, %9, %11
  %lpad.loopexit = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit:                      ; preds = %.preheader4
  %lpad.loopexit5 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp.loopexit.split-lp:             ; preds = %2
  %lpad.loopexit.split-lp6 = landingpad { ptr, i32 }
          cleanup
  br label %.loopexit.split-lp

.loopexit.split-lp:                               ; preds = %.loopexit.split-lp.loopexit, %.loopexit.split-lp.loopexit.split-lp, %.loopexit
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit5, %.loopexit.split-lp.loopexit ], [ %lpad.loopexit.split-lp6, %.loopexit.split-lp.loopexit.split-lp ]
  call void @_ZN7libzpaq12DecompresserD2Ev(ptr noundef nonnull align 8 dereferenceable(111080) %3) #4
  call void @llvm.lifetime.end.p0(i64 111080, ptr nonnull %3) #4
  resume { ptr, i32 } %lpad.phi

12:                                               ; preds = %5
  call void @_ZN7libzpaq12DecompresserD2Ev(ptr noundef nonnull align 8 dereferenceable(111080) %3) #4
  call void @llvm.lifetime.end.p0(i64 111080, ptr nonnull %3) #4
  ret void
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7libzpaq12Decompresser8setInputEPNS_6ReaderE(ptr noundef nonnull align 8 dereferenceable(111080), ptr noundef) local_unnamed_addr #2 align 2

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

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

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 = { 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 #4 = { 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: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass