; 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.NPat2R::CPatricia" = type { %struct.IMatchFinder, %struct.IMatchFinderSetCallback, %class.CMyUnknownImp, %class.CLZInWindow, i32, i32, ptr, ptr, i32, i32, i8, 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 nounwind uwtable
declare dso_local void @_ZN6NPat2R9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(152)) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6NPat2R9CPatricia6CreateEjjjj(ptr noundef nonnull align 8 dereferenceable(152) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #4 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
  %18 = 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
  %19 = load ptr, ptr %7, align 8
  call void @_ZN6NPat2R9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(152) %19)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 32, ptr %12, align 4, !tbaa !9
  %20 = load i32, ptr %12, align 4, !tbaa !9
  %21 = icmp slt i32 %20, 32
  br i1 %21, label %22, label %29

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

28:                                               ; preds = %22
  store i32 -2147024809, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %94

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

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

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

50:                                               ; preds = %38
  store i32 -2147024882, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %93

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

61:                                               ; preds = %51
  call void @_ZN6NPat2R9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(152) %19)
  store i32 -2147024882, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %93

62:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %63 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %63, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  store i32 -2147483648, ptr %18, align 4, !tbaa !9
  %64 = load i32, ptr %17, align 4, !tbaa !9
  %65 = add i32 %64, 32
  %66 = icmp ugt i32 %65, -2147483648
  br i1 %66, label %67, label %68

67:                                               ; preds = %62
  store i32 -2147024809, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %92

68:                                               ; preds = %62
  %69 = load i32, ptr %17, align 4, !tbaa !9
  %70 = add i32 %69, 12
  %71 = zext i32 %70 to i64
  %72 = mul i64 %71, 24
  %73 = call noundef ptr @_Z7MyAllocm(i64 noundef %72) #5
  %74 = getelementptr inbounds %"class.NPat2R::CPatricia", ptr %19, i32 0, i32 7
  store ptr %73, ptr %74, align 8, !tbaa !23
  %75 = getelementptr inbounds %"class.NPat2R::CPatricia", ptr %19, i32 0, i32 7
  %76 = load ptr, ptr %75, align 8, !tbaa !23
  %77 = icmp eq ptr %76, null
  br i1 %77, label %78, label %79

78:                                               ; preds = %68
  call void @_ZN6NPat2R9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(152) %19)
  store i32 -2147024882, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %92

79:                                               ; preds = %68
  %80 = getelementptr inbounds %"class.NPat2R::CPatricia", ptr %19, i32 0, i32 5
  %81 = load i32, ptr %80, align 4, !tbaa !21
  %82 = add i32 %81, 1
  %83 = zext i32 %82 to i64
  %84 = mul i64 %83, 4
  %85 = call noundef ptr @_Z7MyAllocm(i64 noundef %84) #5
  %86 = getelementptr inbounds %"class.NPat2R::CPatricia", ptr %19, i32 0, i32 13
  store ptr %85, ptr %86, align 8, !tbaa !24
  %87 = getelementptr inbounds %"class.NPat2R::CPatricia", ptr %19, i32 0, i32 13
  %88 = load ptr, ptr %87, align 8, !tbaa !24
  %89 = icmp eq ptr %88, null
  br i1 %89, label %90, label %91

90:                                               ; preds = %79
  call void @_ZN6NPat2R9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(152) %19)
  store i32 -2147024882, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %92

91:                                               ; preds = %79
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %92

92:                                               ; preds = %91, %90, %78, %67
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %93

93:                                               ; preds = %92, %61, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %94

94:                                               ; preds = %93, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  %95 = load i32, ptr %6, align 4
  ret i32 %95
}

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 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 #4 = { 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 #5 = { 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 = !{!"_ZTSN6NPat2R9CPatriciaE", !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, !19, i64 128, !19, i64 129, !10, i64 132, !6, i64 136, !20, i64 144}
!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, !6, i64 136}


; 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 nounwind uwtable
declare dso_local void @_ZN6NPat2R9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(152)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -2147024882, 1) i32 @_ZN6NPat2R9CPatricia6CreateEjjjj(ptr noundef nonnull align 8 dereferenceable(152) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #3 align 2 {
  tail call void @_ZN6NPat2R9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(152) %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 %39

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 262144) #4
  %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 = add i32 %1, -2147483617
  %23 = icmp ult i32 %22, 2147483647
  br i1 %23, label %39, label %24

24:                                               ; preds = %21
  %25 = add nsw i32 %1, 12
  %26 = zext i32 %25 to i64
  %27 = mul nuw nsw i64 %26, 24
  %28 = tail call noundef ptr @_Z7MyAllocm(i64 noundef %27) #4
  %29 = getelementptr inbounds i8, ptr %0, i64 112
  store ptr %28, ptr %29, align 8, !tbaa !21
  %30 = icmp eq ptr %28, null
  br i1 %30, label %.sink.split, label %31

31:                                               ; preds = %24
  %32 = load i32, ptr %17, align 4, !tbaa !19
  %33 = add i32 %32, 1
  %34 = zext i32 %33 to i64
  %35 = shl nuw nsw i64 %34, 2
  %36 = tail call noundef ptr @_Z7MyAllocm(i64 noundef %35) #4
  %37 = getelementptr inbounds i8, ptr %0, i64 136
  store ptr %36, ptr %37, align 8, !tbaa !22
  %38 = icmp eq ptr %36, null
  br i1 %38, label %.sink.split, label %39

.sink.split:                                      ; preds = %31, %24, %15
  tail call void @_ZN6NPat2R9CPatricia10FreeMemoryEv(ptr noundef nonnull align 8 dereferenceable(152) %0)
  br label %39

39:                                               ; preds = %.sink.split, %5, %31, %21
  %.1 = phi i32 [ -2147024882, %5 ], [ -2147024809, %21 ], [ 0, %31 ], [ -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 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 = { 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, !12, i64 96}
!6 = !{!"_ZTSN6NPat2R9CPatriciaE", !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, !17, i64 128, !17, i64 129, !12, i64 132, !16, i64 136, !18, i64 144}
!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, !16, i64 136}


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