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

; 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 noundef i32 @_ZN11CLZInWindow7MovePosEv(ptr noundef nonnull align 8 dereferenceable(72)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5NPat29CPatricia7MovePosEv(ptr noundef nonnull align 8 dereferenceable(160) %0) unnamed_addr #1 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %7 = getelementptr inbounds i8, ptr %6, i64 24
  %8 = call noundef i32 @_ZN11CLZInWindow7MovePosEv(ptr noundef nonnull align 8 dereferenceable(72) %7)
  store i32 %8, ptr %4, align 4, !tbaa !9
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %11, label %13

11:                                               ; preds = %1
  %12 = load i32, ptr %4, align 4, !tbaa !9
  store i32 %12, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %14

13:                                               ; preds = %1
  store i32 0, ptr %5, align 4
  br label %14

14:                                               ; preds = %13, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %15 = load i32, ptr %5, align 4
  switch i32 %15, label %32 [
    i32 0, label %16
    i32 1, label %30
  ]

16:                                               ; preds = %14
  %17 = getelementptr inbounds %"class.NPat2::CPatricia", ptr %6, i32 0, i32 10
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = getelementptr inbounds %"class.NPat2::CPatricia", ptr %6, i32 0, i32 11
  %20 = load i32, ptr %19, align 4, !tbaa !21
  %21 = icmp uge i32 %18, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %16
  call void @_ZN5NPat29CPatricia15TestRemoveNodesEv(ptr noundef nonnull align 8 dereferenceable(160) %6)
  br label %23

23:                                               ; preds = %22, %16
  %24 = getelementptr inbounds i8, ptr %6, i64 24
  %25 = getelementptr inbounds %class.CLZInWindow, ptr %24, i32 0, i32 8
  %26 = load i32, ptr %25, align 4, !tbaa !22
  %27 = icmp uge i32 %26, 2147483645
  br i1 %27, label %28, label %29

28:                                               ; preds = %23
  call void @_ZN5NPat29CPatricia27TestRemoveNodesAndNormalizeEv(ptr noundef nonnull align 8 dereferenceable(160) %6)
  br label %29

29:                                               ; preds = %28, %23
  store i32 0, ptr %2, align 4
  br label %30

30:                                               ; preds = %29, %14
  %31 = load i32, ptr %2, align 4
  ret i32 %31

32:                                               ; preds = %14
  unreachable
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5NPat29CPatricia27TestRemoveNodesAndNormalizeEv(ptr noundef nonnull align 8 dereferenceable(160)) #1 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 = { 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 = !{!12, !10, i64 128}
!12 = !{!"_ZTSN5NPat29CPatriciaE", !13, i64 0, !16, i64 8, !17, i64 16, !18, i64 24, !10, i64 96, !10, i64 100, !6, i64 104, !6, i64 112, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !19, i64 136, !10, i64 140, !6, i64 144, !20, i64 152}
!13 = !{!"_ZTS12IMatchFinder", !14, i64 0}
!14 = !{!"_ZTS15IInWindowStream", !15, i64 0}
!15 = !{!"_ZTS8IUnknown"}
!16 = !{!"_ZTS23IMatchFinderSetCallback", !15, i64 0}
!17 = !{!"_ZTS13CMyUnknownImp", !10, i64 0}
!18 = !{!"_ZTS11CLZInWindow", !6, i64 8, !6, i64 16, !10, i64 24, !19, i64 28, !6, i64 32, !6, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !10, i64 64, !10, i64 68}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"_ZTS9CMyComPtrI20IMatchFinderCallbackE", !6, i64 0}
!21 = !{!12, !10, i64 132}
!22 = !{!18, !10, i64 52}


; 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 uwtable
declare dso_local noundef i32 @_ZN11CLZInWindow7MovePosEv(ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5NPat29CPatricia7MovePosEv(ptr noundef nonnull align 8 dereferenceable(160) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = tail call noundef i32 @_ZN11CLZInWindow7MovePosEv(ptr noundef nonnull align 8 dereferenceable(72) %2)
  %.not.not = icmp eq i32 %3, 0
  br i1 %.not.not, label %4, label %15

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 128
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 132
  %8 = load i32, ptr %7, align 4, !tbaa !19
  %.not5 = icmp ult i32 %6, %8
  br i1 %.not5, label %10, label %9

9:                                                ; preds = %4
  tail call void @_ZN5NPat29CPatricia15TestRemoveNodesEv(ptr noundef nonnull align 8 dereferenceable(160) %0)
  br label %10

10:                                               ; preds = %9, %4
  %11 = getelementptr inbounds i8, ptr %0, i64 76
  %12 = load i32, ptr %11, align 4, !tbaa !20
  %13 = icmp ugt i32 %12, 2147483644
  br i1 %13, label %14, label %15

14:                                               ; preds = %10
  tail call void @_ZN5NPat29CPatricia27TestRemoveNodesAndNormalizeEv(ptr noundef nonnull align 8 dereferenceable(160) %0)
  br label %15

15:                                               ; preds = %1, %10, %14
  ret i32 %3
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5NPat29CPatricia15TestRemoveNodesEv(ptr noundef nonnull align 8 dereferenceable(160)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5NPat29CPatricia27TestRemoveNodesAndNormalizeEv(ptr noundef nonnull align 8 dereferenceable(160)) local_unnamed_addr #0 align 2

attributes #0 = { 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" }

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass