; LLVM IR from mncoppola/rpef :: utilities_src/squashfs2.1/lzma/C/7zip/Compress/LZMA (LZMAEncoder)

; 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.NPat2::CPatricia" = type { %struct.IMatchFinder, %struct.IMatchFinderSetCallback, %class.CMyUnknownImp, %class.CLZInWindow, i32, i32, ptr, ptr, i32, i32, i32, i32, i8, i32, ptr, %class.CMyComPtr }
%struct.IMatchFinder = type { %struct.IInWindowStream }
%struct.IInWindowStream = type { %struct.IUnknown }
%struct.IUnknown = type { ptr }
%struct.IMatchFinderSetCallback = type { %struct.IUnknown }
%class.CMyUnknownImp = type { i32 }
%class.CLZInWindow = type { ptr, ptr, ptr, i32, i8, ptr, ptr, i32, i32, i32, i32, i32, i32 }
%class.CMyComPtr = type { ptr }

@_ZTVN5NPat29CPatriciaE = external dso_local unnamed_addr constant { [20 x ptr], [6 x ptr], [7 x ptr] }, align 8

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

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

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

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

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5NPat29CPatriciaC2Ev(ptr noundef nonnull align 8 dereferenceable(160) %0) unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @_ZN12IMatchFinderC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  %6 = getelementptr inbounds i8, ptr %5, i64 8
  call void @_ZN23IMatchFinderSetCallbackC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #3
  %7 = getelementptr inbounds i8, ptr %5, i64 16
  call void @_ZN13CMyUnknownImpC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %7)
  %8 = getelementptr inbounds i8, ptr %5, i64 24
  call void @_ZN11CLZInWindowC2Ev(ptr noundef nonnull align 8 dereferenceable(72) %8)
  store ptr getelementptr inbounds inrange(-16, 144) ({ [20 x ptr], [6 x ptr], [7 x ptr] }, ptr @_ZTVN5NPat29CPatriciaE, i32 0, i32 0, i32 2), ptr %5, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr getelementptr inbounds inrange(-16, 32) ({ [20 x ptr], [6 x ptr], [7 x ptr] }, ptr @_ZTVN5NPat29CPatriciaE, i32 0, i32 1, i32 2), ptr %9, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %5, i64 24
  store ptr getelementptr inbounds inrange(-16, 40) ({ [20 x ptr], [6 x ptr], [7 x ptr] }, ptr @_ZTVN5NPat29CPatriciaE, i32 0, i32 2, i32 2), ptr %10, align 8, !tbaa !9
  %11 = getelementptr inbounds %"class.NPat2::CPatricia", ptr %5, i32 0, i32 6
  store ptr null, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds %"class.NPat2::CPatricia", ptr %5, i32 0, i32 7
  store ptr null, ptr %12, align 8, !tbaa !22
  %13 = getelementptr inbounds %"class.NPat2::CPatricia", ptr %5, i32 0, i32 14
  store ptr null, ptr %13, align 8, !tbaa !23
  %14 = getelementptr inbounds %"class.NPat2::CPatricia", ptr %5, i32 0, i32 15
  invoke void @_ZN9CMyComPtrI20IMatchFinderCallbackEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %14)
          to label %15 unwind label %16

15:                                               ; preds = %1
  ret void

16:                                               ; preds = %1
  %17 = landingpad { ptr, i32 }
          cleanup
  %18 = extractvalue { ptr, i32 } %17, 0
  store ptr %18, ptr %3, align 8
  %19 = extractvalue { ptr, i32 } %17, 1
  store i32 %19, ptr %4, align 4
  %20 = getelementptr inbounds i8, ptr %5, i64 24
  call void @_ZN11CLZInWindowD2Ev(ptr noundef nonnull align 8 dereferenceable(72) %20) #3
  br label %21

21:                                               ; preds = %16
  %22 = load ptr, ptr %3, align 8
  %23 = load i32, ptr %4, align 4
  %24 = insertvalue { ptr, i32 } poison, ptr %22, 0
  %25 = insertvalue { ptr, i32 } %24, i32 %23, 1
  resume { ptr, i32 } %25
}

attributes #0 = { 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 #1 = { 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 #2 = { 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 #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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !6, i64 104}
!12 = !{!"_ZTSN5NPat29CPatriciaE", !13, i64 0, !16, i64 8, !17, i64 16, !19, i64 24, !18, i64 96, !18, i64 100, !6, i64 104, !6, i64 112, !18, i64 120, !18, i64 124, !18, i64 128, !18, i64 132, !20, i64 136, !18, i64 140, !6, i64 144, !21, i64 152}
!13 = !{!"_ZTS12IMatchFinder", !14, i64 0}
!14 = !{!"_ZTS15IInWindowStream", !15, i64 0}
!15 = !{!"_ZTS8IUnknown"}
!16 = !{!"_ZTS23IMatchFinderSetCallback", !15, i64 0}
!17 = !{!"_ZTS13CMyUnknownImp", !18, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!"_ZTS11CLZInWindow", !6, i64 8, !6, i64 16, !18, i64 24, !20, i64 28, !6, i64 32, !6, i64 40, !18, i64 48, !18, i64 52, !18, i64 56, !18, i64 60, !18, i64 64, !18, i64 68}
!20 = !{!"bool", !7, i64 0}
!21 = !{!"_ZTS9CMyComPtrI20IMatchFinderCallbackE", !6, i64 0}
!22 = !{!12, !6, i64 112}
!23 = !{!12, !6, i64 144}


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

@_ZTVN5NPat29CPatriciaE = external dso_local unnamed_addr constant { [20 x ptr], [6 x ptr], [7 x ptr] }, align 8

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

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

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5NPat29CPatriciaC2Ev(ptr noundef nonnull align 8 dereferenceable(160) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN12IMatchFinderC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #3
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN23IMatchFinderSetCallbackC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %2) #3
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @_ZN13CMyUnknownImpC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %3)
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @_ZN11CLZInWindowC2Ev(ptr noundef nonnull align 8 dereferenceable(72) %4)
  store ptr getelementptr inbounds inrange(-16, 144) (i8, ptr @_ZTVN5NPat29CPatriciaE, i64 16), ptr %0, align 8, !tbaa !5
  store ptr getelementptr inbounds inrange(-16, 32) (i8, ptr @_ZTVN5NPat29CPatriciaE, i64 176), ptr %2, align 8, !tbaa !5
  store ptr getelementptr inbounds inrange(-16, 40) (i8, ptr @_ZTVN5NPat29CPatriciaE, i64 224), ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 104
  %6 = getelementptr inbounds i8, ptr %0, i64 144
  store ptr null, ptr %6, align 8, !tbaa !8
  %7 = getelementptr inbounds i8, ptr %0, i64 152
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  tail call void @_ZN9CMyComPtrI20IMatchFinderCallbackEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { 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 #1 = { 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !18, i64 144}
!9 = !{!"_ZTSN5NPat29CPatriciaE", !10, i64 0, !13, i64 8, !14, i64 16, !17, i64 24, !15, i64 96, !15, i64 100, !18, i64 104, !18, i64 112, !15, i64 120, !15, i64 124, !15, i64 128, !15, i64 132, !19, i64 136, !15, i64 140, !18, i64 144, !20, i64 152}
!10 = !{!"_ZTS12IMatchFinder", !11, i64 0}
!11 = !{!"_ZTS15IInWindowStream", !12, i64 0}
!12 = !{!"_ZTS8IUnknown"}
!13 = !{!"_ZTS23IMatchFinderSetCallback", !12, i64 0}
!14 = !{!"_ZTS13CMyUnknownImp", !15, i64 0}
!15 = !{!"int", !16, i64 0}
!16 = !{!"omnipotent char", !7, i64 0}
!17 = !{!"_ZTS11CLZInWindow", !18, i64 8, !18, i64 16, !15, i64 24, !19, i64 28, !18, i64 32, !18, i64 40, !15, i64 48, !15, i64 52, !15, i64 56, !15, i64 60, !15, i64 64, !15, i64 68}
!18 = !{!"any pointer", !16, i64 0}
!19 = !{!"bool", !16, i64 0}
!20 = !{!"_ZTS9CMyComPtrI20IMatchFinderCallbackE", !18, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass