; 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.NPat2H::CPatricia" = type { %struct.IMatchFinder, %struct.IMatchFinderSetCallback, %class.CMyUnknownImp, %class.CLZInWindow, i32, i32, ptr, 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

declare noundef zeroext i1 @_ZN11CLZInWindow6CreateEjjj(ptr noundef nonnull align 8 dereferenceable(72), i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind
declare noundef ptr @_Z7MyAllocm(i64 noundef) #2

; 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 void @_ZN6NPat2H9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(168)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6NPat2H9CPatricia6CreateEjjjj(ptr noundef nonnull align 8 dereferenceable(168) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #3 align 2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !9
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  %18 = load ptr, ptr %7, align 8
  call void @_ZN6NPat2H9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(168) %18)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 32, ptr %12, align 4, !tbaa !9
  %19 = load i32, ptr %12, align 4, !tbaa !9
  %20 = icmp slt i32 %19, 32
  br i1 %20, label %21, label %28

21:                                               ; preds = %5
  %22 = load i32, ptr %10, align 4, !tbaa !9
  %23 = mul i32 %22, 8
  %24 = load i32, ptr %12, align 4, !tbaa !9
  %25 = shl i32 1, %24
  %26 = icmp ugt i32 %23, %25
  br i1 %26, label %27, label %28

27:                                               ; preds = %21
  store i32 -2147024809, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %109

28:                                               ; preds = %21, %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 65535, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %29 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %29, ptr %15, align 4, !tbaa !9
  %30 = load i32, ptr %15, align 4, !tbaa !9
  %31 = add i32 %30, 65535
  store i32 %31, ptr %15, align 4, !tbaa !9
  %32 = load i32, ptr %15, align 4, !tbaa !9
  %33 = and i32 %32, -65536
  store i32 %33, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 524288, ptr %16, align 4, !tbaa !9
  %34 = load i32, ptr %15, align 4, !tbaa !9
  %35 = icmp ult i32 %34, 524288
  br i1 %35, label %36, label %37

36:                                               ; preds = %28
  store i32 524288, ptr %15, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %36, %28
  %38 = load i32, ptr %15, align 4, !tbaa !9
  %39 = add i32 %38, 256
  store i32 %39, ptr %15, align 4, !tbaa !9
  %40 = getelementptr inbounds i8, ptr %18, i64 24
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = add i32 %41, %42
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = load i32, ptr %11, align 4, !tbaa !9
  %46 = add i32 %44, %45
  %47 = load i32, ptr %15, align 4, !tbaa !9
  %48 = call noundef zeroext i1 @_ZN11CLZInWindow6CreateEjjj(ptr noundef nonnull align 8 dereferenceable(72) %40, i32 noundef %43, i32 noundef %46, i32 noundef %47)
  br i1 %48, label %50, label %49

49:                                               ; preds = %37
  store i32 -2147024882, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %108

50:                                               ; preds = %37
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 4
  store i32 %51, ptr %52, align 8, !tbaa !11
  %53 = load i32, ptr %10, align 4, !tbaa !9
  %54 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 5
  store i32 %53, ptr %54, align 4, !tbaa !21
  %55 = call noundef ptr @_Z7MyAllocm(i64 noundef 67108864) #4
  %56 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 6
  store ptr %55, ptr %56, align 8, !tbaa !22
  %57 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 6
  %58 = load ptr, ptr %57, align 8, !tbaa !22
  %59 = icmp eq ptr %58, null
  br i1 %59, label %60, label %61

60:                                               ; preds = %50
  call void @_ZN6NPat2H9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(168) %18)
  store i32 -2147024882, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %108

61:                                               ; preds = %50
  %62 = call noundef ptr @_Z7MyAllocm(i64 noundef 262144) #4
  %63 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 7
  store ptr %62, ptr %63, align 8, !tbaa !23
  %64 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 7
  %65 = load ptr, ptr %64, align 8, !tbaa !23
  %66 = icmp eq ptr %65, null
  br i1 %66, label %67, label %68

67:                                               ; preds = %61
  call void @_ZN6NPat2H9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(168) %18)
  store i32 -2147024882, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %108

68:                                               ; preds = %61
  %69 = load i32, ptr %8, align 4, !tbaa !9
  %70 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 4
  %71 = load i32, ptr %70, align 8, !tbaa !11
  %72 = mul i32 %71, 4
  %73 = udiv i32 %72, 8
  %74 = add i32 %69, %73
  %75 = add i32 %74, 524288
  %76 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 12
  store i32 %75, ptr %76, align 4, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 -2147483648, ptr %17, align 4, !tbaa !9
  %77 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 12
  %78 = load i32, ptr %77, align 4, !tbaa !24
  %79 = add i32 %78, 32
  %80 = icmp ugt i32 %79, -2147483648
  br i1 %80, label %81, label %82

81:                                               ; preds = %68
  store i32 -2147024809, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %107

82:                                               ; preds = %68
  %83 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 12
  %84 = load i32, ptr %83, align 4, !tbaa !24
  %85 = add i32 %84, 12
  %86 = zext i32 %85 to i64
  %87 = mul i64 %86, 24
  %88 = call noundef ptr @_Z7MyAllocm(i64 noundef %87) #4
  %89 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 8
  store ptr %88, ptr %89, align 8, !tbaa !25
  %90 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 8
  %91 = load ptr, ptr %90, align 8, !tbaa !25
  %92 = icmp eq ptr %91, null
  br i1 %92, label %93, label %94

93:                                               ; preds = %82
  call void @_ZN6NPat2H9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(168) %18)
  store i32 -2147024882, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %107

94:                                               ; preds = %82
  %95 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 5
  %96 = load i32, ptr %95, align 4, !tbaa !21
  %97 = add i32 %96, 1
  %98 = zext i32 %97 to i64
  %99 = mul i64 %98, 4
  %100 = call noundef ptr @_Z7MyAllocm(i64 noundef %99) #4
  %101 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 15
  store ptr %100, ptr %101, align 8, !tbaa !26
  %102 = getelementptr inbounds %"class.NPat2H::CPatricia", ptr %18, i32 0, i32 15
  %103 = load ptr, ptr %102, align 8, !tbaa !26
  %104 = icmp eq ptr %103, null
  br i1 %104, label %105, label %106

105:                                              ; preds = %94
  call void @_ZN6NPat2H9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(168) %18)
  store i32 -2147024882, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %107

106:                                              ; preds = %94
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %107

107:                                              ; preds = %106, %105, %93, %81
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %108

108:                                              ; preds = %107, %67, %60, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %109

109:                                              ; preds = %108, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %110 = load i32, ptr %6, align 4
  ret i32 %110
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 "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 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 96}
!12 = !{!"_ZTSN6NPat2H9CPatriciaE", !13, i64 0, !16, i64 8, !17, i64 16, !18, i64 24, !10, i64 96, !10, i64 100, !6, i64 104, !6, i64 112, !6, i64 120, !10, i64 128, !10, i64 132, !10, i64 136, !10, i64 140, !19, i64 144, !10, i64 148, !6, i64 152, !20, i64 160}
!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 100}
!22 = !{!12, !6, i64 104}
!23 = !{!12, !6, i64 112}
!24 = !{!12, !10, i64 140}
!25 = !{!12, !6, i64 120}
!26 = !{!12, !6, i64 152}


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

declare noundef zeroext i1 @_ZN11CLZInWindow6CreateEjjj(ptr noundef nonnull align 8 dereferenceable(72), i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind
declare noundef ptr @_Z7MyAllocm(i64 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -2147024882, 1) i32 @_ZN6NPat2H9CPatricia6CreateEjjjj(ptr noundef nonnull align 8 dereferenceable(168) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #2 align 2 {
  tail call void @_ZN6NPat2H9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(168) %0)
  %6 = add i32 %1, 65535
  %7 = and i32 %6, -65536
  %8 = icmp ult i32 %6, 524288
  %9 = or disjoint i32 %7, 256
  %10 = select i1 %8, i32 524544, i32 %9
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = add i32 %2, %1
  %13 = add i32 %4, %3
  %14 = tail call noundef zeroext i1 @_ZN11CLZInWindow6CreateEjjj(ptr noundef nonnull align 8 dereferenceable(72) %11, i32 noundef %12, i32 noundef %13, i32 noundef %10)
  br i1 %14, label %15, label %49

15:                                               ; preds = %5
  %16 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 %1, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 100
  store i32 %3, ptr %17, align 4, !tbaa !19
  %18 = tail call noundef ptr @_Z7MyAllocm(i64 noundef 67108864) #3
  %19 = getelementptr inbounds i8, ptr %0, i64 104
  store ptr %18, ptr %19, align 8, !tbaa !20
  %20 = icmp eq ptr %18, null
  br i1 %20, label %.sink.split, label %21

21:                                               ; preds = %15
  %22 = tail call noundef ptr @_Z7MyAllocm(i64 noundef 262144) #3
  %23 = getelementptr inbounds i8, ptr %0, i64 112
  store ptr %22, ptr %23, align 8, !tbaa !21
  %24 = icmp eq ptr %22, null
  br i1 %24, label %.sink.split, label %25

25:                                               ; preds = %21
  %26 = load i32, ptr %16, align 8, !tbaa !5
  %27 = lshr i32 %26, 1
  %28 = and i32 %27, 536870911
  %29 = add i32 %28, %1
  %30 = add i32 %29, 524288
  %31 = getelementptr inbounds i8, ptr %0, i64 140
  store i32 %30, ptr %31, align 4, !tbaa !22
  %32 = add i32 %29, -2146959329
  %33 = icmp ult i32 %32, 2147483647
  br i1 %33, label %49, label %34

34:                                               ; preds = %25
  %35 = add nsw i32 %29, 524300
  %36 = zext i32 %35 to i64
  %37 = mul nuw nsw i64 %36, 24
  %38 = tail call noundef ptr @_Z7MyAllocm(i64 noundef %37) #3
  %39 = getelementptr inbounds i8, ptr %0, i64 120
  store ptr %38, ptr %39, align 8, !tbaa !23
  %40 = icmp eq ptr %38, null
  br i1 %40, label %.sink.split, label %41

41:                                               ; preds = %34
  %42 = load i32, ptr %17, align 4, !tbaa !19
  %43 = add i32 %42, 1
  %44 = zext i32 %43 to i64
  %45 = shl nuw nsw i64 %44, 2
  %46 = tail call noundef ptr @_Z7MyAllocm(i64 noundef %45) #3
  %47 = getelementptr inbounds i8, ptr %0, i64 152
  store ptr %46, ptr %47, align 8, !tbaa !24
  %48 = icmp eq ptr %46, null
  br i1 %48, label %.sink.split, label %49

.sink.split:                                      ; preds = %41, %34, %21, %15
  tail call void @_ZN6NPat2H9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(168) %0)
  br label %49

49:                                               ; preds = %.sink.split, %5, %41, %25
  %.1 = phi i32 [ -2147024882, %5 ], [ -2147024809, %25 ], [ 0, %41 ], [ -2147024882, %.sink.split ]
  ret i32 %.1
}

attributes #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 = { nounwind "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, !12, i64 96}
!6 = !{!"_ZTSN6NPat2H9CPatriciaE", !7, i64 0, !10, i64 8, !11, i64 16, !15, i64 24, !12, i64 96, !12, i64 100, !16, i64 104, !16, i64 112, !16, i64 120, !12, i64 128, !12, i64 132, !12, i64 136, !12, i64 140, !17, i64 144, !12, i64 148, !16, i64 152, !18, i64 160}
!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 100}
!20 = !{!6, !16, i64 104}
!21 = !{!6, !16, i64 112}
!22 = !{!6, !12, i64 140}
!23 = !{!6, !16, i64 120}
!24 = !{!6, !16, i64 152}


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