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

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4NHC34HashEPKhRj(ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4NHC314CMatchFinderHC17DummyLongestMatchEv(ptr noundef nonnull align 8 dereferenceable(128) %0) unnamed_addr #2 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  %7 = getelementptr inbounds i8, ptr %6, i64 16
  %8 = getelementptr inbounds %class.CLZInWindow, ptr %7, i32 0, i32 12
  %9 = load i32, ptr %8, align 4, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %6, i64 16
  %11 = getelementptr inbounds %class.CLZInWindow, ptr %10, i32 0, i32 8
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %13 = sub i32 %9, %12
  %14 = icmp ult i32 %13, 3
  br i1 %14, label %15, label %16

15:                                               ; preds = %1
  br label %57

16:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %17 = getelementptr inbounds i8, ptr %6, i64 16
  %18 = getelementptr inbounds %class.CLZInWindow, ptr %17, i32 0, i32 6
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = getelementptr inbounds i8, ptr %6, i64 16
  %21 = getelementptr inbounds %class.CLZInWindow, ptr %20, i32 0, i32 8
  %22 = load i32, ptr %21, align 4, !tbaa !13
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds i8, ptr %19, i64 %23
  store ptr %24, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = call noundef i32 @_ZN4NHC34HashEPKhRj(ptr noundef %25, ptr noundef nonnull align 4 dereferenceable(4) %4)
  store i32 %26, ptr %5, align 4, !tbaa !15
  %27 = getelementptr inbounds i8, ptr %6, i64 16
  %28 = getelementptr inbounds %class.CLZInWindow, ptr %27, i32 0, i32 8
  %29 = load i32, ptr %28, align 4, !tbaa !13
  %30 = getelementptr inbounds %"class.NHC3::CMatchFinderHC", ptr %6, i32 0, i32 7
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %32 = load i32, ptr %4, align 4, !tbaa !15
  %33 = add i32 65536, %32
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds i32, ptr %31, i64 %34
  store i32 %29, ptr %35, align 4, !tbaa !15
  %36 = getelementptr inbounds %"class.NHC3::CMatchFinderHC", ptr %6, i32 0, i32 7
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  %38 = load i32, ptr %5, align 4, !tbaa !15
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds i32, ptr %37, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !15
  %42 = getelementptr inbounds %"class.NHC3::CMatchFinderHC", ptr %6, i32 0, i32 7
  %43 = load ptr, ptr %42, align 8, !tbaa !16
  %44 = getelementptr inbounds %"class.NHC3::CMatchFinderHC", ptr %6, i32 0, i32 4
  %45 = load i32, ptr %44, align 4, !tbaa !24
  %46 = add i32 66560, %45
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr %43, i64 %47
  store i32 %41, ptr %48, align 4, !tbaa !15
  %49 = getelementptr inbounds i8, ptr %6, i64 16
  %50 = getelementptr inbounds %class.CLZInWindow, ptr %49, i32 0, i32 8
  %51 = load i32, ptr %50, align 4, !tbaa !13
  %52 = getelementptr inbounds %"class.NHC3::CMatchFinderHC", ptr %6, i32 0, i32 7
  %53 = load ptr, ptr %52, align 8, !tbaa !16
  %54 = load i32, ptr %5, align 4, !tbaa !15
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr %53, i64 %55
  store i32 %51, ptr %56, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %57

57:                                               ; preds = %16, %15
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !11, i64 68}
!10 = !{!"_ZTS11CLZInWindow", !6, i64 8, !6, i64 16, !11, i64 24, !12, i64 28, !6, i64 32, !6, i64 40, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68}
!11 = !{!"int", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!10, !11, i64 52}
!14 = !{!10, !6, i64 40}
!15 = !{!11, !11, i64 0}
!16 = !{!17, !6, i64 104}
!17 = !{!"_ZTSN4NHC314CMatchFinderHCE", !18, i64 0, !21, i64 8, !10, i64 16, !22, i64 88, !11, i64 92, !11, i64 96, !11, i64 100, !6, i64 104, !11, i64 112, !23, i64 120}
!18 = !{!"_ZTS12IMatchFinder", !19, i64 0}
!19 = !{!"_ZTS15IInWindowStream", !20, i64 0}
!20 = !{!"_ZTS8IUnknown"}
!21 = !{!"_ZTS23IMatchFinderSetCallback", !20, i64 0}
!22 = !{!"_ZTS13CMyUnknownImp", !11, i64 0}
!23 = !{!"_ZTS9CMyComPtrI20IMatchFinderCallbackE", !6, i64 0}
!24 = !{!17, !11, i64 92}


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

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4NHC34HashEPKhRj(ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4NHC314CMatchFinderHC17DummyLongestMatchEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(128) %0) unnamed_addr #2 align 2 {
  %2 = alloca i32, align 4
  %3 = getelementptr inbounds i8, ptr %0, i64 84
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 68
  %6 = load i32, ptr %5, align 4, !tbaa !12
  %7 = sub i32 %4, %6
  %8 = icmp ult i32 %7, 3
  br i1 %8, label %31, label %9

9:                                                ; preds = %1
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = zext i32 %6 to i64
  %13 = getelementptr inbounds i8, ptr %11, i64 %12
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #3
  %14 = call noundef i32 @_ZN4NHC34HashEPKhRj(ptr noundef %13, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %15 = load i32, ptr %5, align 4, !tbaa !12
  %16 = getelementptr inbounds i8, ptr %0, i64 104
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = load i32, ptr %2, align 4, !tbaa !22
  %19 = add i32 %18, 65536
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds i32, ptr %17, i64 %20
  store i32 %15, ptr %21, align 4, !tbaa !22
  %22 = zext i32 %14 to i64
  %23 = getelementptr inbounds i32, ptr %17, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !22
  %25 = getelementptr inbounds i8, ptr %0, i64 92
  %26 = load i32, ptr %25, align 4, !tbaa !23
  %27 = add i32 %26, 66560
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr %17, i64 %28
  store i32 %24, ptr %29, align 4, !tbaa !22
  %30 = load i32, ptr %5, align 4, !tbaa !12
  store i32 %30, ptr %23, align 4, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #3
  br label %31

31:                                               ; preds = %1, %9
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !10, i64 68}
!6 = !{!"_ZTS11CLZInWindow", !7, i64 8, !7, i64 16, !10, i64 24, !11, i64 28, !7, i64 32, !7, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!6, !10, i64 52}
!13 = !{!6, !7, i64 40}
!14 = !{!15, !7, i64 104}
!15 = !{!"_ZTSN4NHC314CMatchFinderHCE", !16, i64 0, !19, i64 8, !6, i64 16, !20, i64 88, !10, i64 92, !10, i64 96, !10, i64 100, !7, i64 104, !10, i64 112, !21, i64 120}
!16 = !{!"_ZTS12IMatchFinder", !17, i64 0}
!17 = !{!"_ZTS15IInWindowStream", !18, i64 0}
!18 = !{!"_ZTS8IUnknown"}
!19 = !{!"_ZTS23IMatchFinderSetCallback", !18, i64 0}
!20 = !{!"_ZTS13CMyUnknownImp", !10, i64 0}
!21 = !{!"_ZTS9CMyComPtrI20IMatchFinderCallbackE", !7, i64 0}
!22 = !{!10, !10, i64 0}
!23 = !{!15, !10, i64 92}


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