; 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.NHC4::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 @_ZN4NHC44HashEPKhRjS2_(ptr noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4NHC414CMatchFinderHC17DummyLongestMatchEv(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
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  %9 = getelementptr inbounds %class.CLZInWindow, ptr %8, i32 0, i32 12
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %11 = getelementptr inbounds i8, ptr %7, i64 16
  %12 = getelementptr inbounds %class.CLZInWindow, ptr %11, i32 0, i32 8
  %13 = load i32, ptr %12, align 4, !tbaa !13
  %14 = sub i32 %10, %13
  %15 = icmp ult i32 %14, 4
  br i1 %15, label %16, label %17

16:                                               ; preds = %1
  br label %67

17:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %18 = getelementptr inbounds i8, ptr %7, i64 16
  %19 = getelementptr inbounds %class.CLZInWindow, ptr %18, i32 0, i32 6
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %7, i64 16
  %22 = getelementptr inbounds %class.CLZInWindow, ptr %21, i32 0, i32 8
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds i8, ptr %20, i64 %24
  store ptr %25, 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
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = call noundef i32 @_ZN4NHC44HashEPKhRjS2_(ptr noundef %26, ptr noundef nonnull align 4 dereferenceable(4) %4, ptr noundef nonnull align 4 dereferenceable(4) %5)
  store i32 %27, ptr %6, align 4, !tbaa !15
  %28 = getelementptr inbounds i8, ptr %7, i64 16
  %29 = getelementptr inbounds %class.CLZInWindow, ptr %28, i32 0, i32 8
  %30 = load i32, ptr %29, align 4, !tbaa !13
  %31 = getelementptr inbounds %"class.NHC4::CMatchFinderHC", ptr %7, i32 0, i32 7
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = load i32, ptr %5, align 4, !tbaa !15
  %34 = add i32 1049600, %33
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds i32, ptr %32, i64 %35
  store i32 %30, ptr %36, align 4, !tbaa !15
  %37 = getelementptr inbounds i8, ptr %7, i64 16
  %38 = getelementptr inbounds %class.CLZInWindow, ptr %37, i32 0, i32 8
  %39 = load i32, ptr %38, align 4, !tbaa !13
  %40 = getelementptr inbounds %"class.NHC4::CMatchFinderHC", ptr %7, i32 0, i32 7
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %42 = load i32, ptr %4, align 4, !tbaa !15
  %43 = add i32 1048576, %42
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds i32, ptr %41, i64 %44
  store i32 %39, ptr %45, align 4, !tbaa !15
  %46 = getelementptr inbounds %"class.NHC4::CMatchFinderHC", ptr %7, i32 0, i32 7
  %47 = load ptr, ptr %46, align 8, !tbaa !16
  %48 = load i32, ptr %6, align 4, !tbaa !15
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds i32, ptr %47, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !15
  %52 = getelementptr inbounds %"class.NHC4::CMatchFinderHC", ptr %7, i32 0, i32 7
  %53 = load ptr, ptr %52, align 8, !tbaa !16
  %54 = getelementptr inbounds %"class.NHC4::CMatchFinderHC", ptr %7, i32 0, i32 4
  %55 = load i32, ptr %54, align 4, !tbaa !24
  %56 = add i32 1311744, %55
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds i32, ptr %53, i64 %57
  store i32 %51, ptr %58, align 4, !tbaa !15
  %59 = getelementptr inbounds i8, ptr %7, i64 16
  %60 = getelementptr inbounds %class.CLZInWindow, ptr %59, i32 0, i32 8
  %61 = load i32, ptr %60, align 4, !tbaa !13
  %62 = getelementptr inbounds %"class.NHC4::CMatchFinderHC", ptr %7, i32 0, i32 7
  %63 = load ptr, ptr %62, align 8, !tbaa !16
  %64 = load i32, ptr %6, align 4, !tbaa !15
  %65 = zext i32 %64 to i64
  %66 = getelementptr inbounds i32, ptr %63, i64 %65
  store i32 %61, ptr %66, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  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 %67

67:                                               ; preds = %17, %16
  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 = !{!"_ZTSN4NHC414CMatchFinderHCE", !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 @_ZN4NHC44HashEPKhRjS2_(ptr noundef, ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

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

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

36:                                               ; preds = %1, %10
  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 = !{!"_ZTSN4NHC414CMatchFinderHCE", !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,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass