; LLVM IR from SSBMTonberry/pocketlzma :: ref_spec/lzma1900/CPP/7zip/Archive/7z (7zHandler)

; 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.NArchive::N7z::CHandler" = type { %struct.IInArchive, %struct.IArchiveGetRawProps, %struct.ISetProperties, %struct.IOutArchive, %class.CMyUnknownImp, %"class.NArchive::N7z::COutHandler", %class.CMyComPtr, %"struct.NArchive::N7z::CDbEx", i8, i8, %class.UString, %class.CRecordVector.8, %class.CRecordVector.6 }
%struct.IInArchive = type { %struct.IUnknown }
%struct.IUnknown = type { ptr }
%struct.IArchiveGetRawProps = type { %struct.IUnknown }
%struct.ISetProperties = type { %struct.IUnknown }
%struct.IOutArchive = type { %struct.IUnknown }
%class.CMyUnknownImp = type { i32 }
%"class.NArchive::N7z::COutHandler" = type { %"class.NArchive::CMultiMethodProps.base", i64, i64, i8, i8, i8, i8, i8, i8, %struct.CBoolPair, %struct.CBoolPair, %struct.CBoolPair, %struct.CBoolPair, i8, i8 }
%"class.NArchive::CMultiMethodProps.base" = type <{ %"class.NArchive::CCommonMethodProps", i32, i32, i32, [4 x i8], %class.CObjectVector, %class.COneMethodInfo, i8 }>
%"class.NArchive::CCommonMethodProps" = type { i32, i32, i64, i64 }
%class.CObjectVector = type { %class.CRecordVector }
%class.CRecordVector = type { ptr, i32, i32 }
%class.COneMethodInfo = type { %class.CMethodProps, %class.AString, %class.UString }
%class.CMethodProps = type { %struct.CProps }
%struct.CProps = type { %class.CObjectVector.0 }
%class.CObjectVector.0 = type { %class.CRecordVector }
%class.AString = type { ptr, i32, i32 }
%struct.CBoolPair = type { i8, i8 }
%class.CMyComPtr = type { ptr }
%"struct.NArchive::N7z::CDbEx" = type <{ %"struct.NArchive::N7z::CDatabase", %"struct.NArchive::N7z::CInArchiveInfo", %class.CObjArray.3, %class.CObjArray.3, i64, i64, i8, i8, i8, i8, i8, i8, i8, i8 }>
%"struct.NArchive::N7z::CDatabase" = type { %"struct.NArchive::N7z::CFolders", %class.CRecordVector.7, %"struct.NArchive::N7z::CUInt64DefVector", %"struct.NArchive::N7z::CUInt64DefVector", %"struct.NArchive::N7z::CUInt64DefVector", %"struct.NArchive::N7z::CUInt64DefVector", %"struct.NArchive::N7z::CUInt32DefVector", %class.CRecordVector.1, %class.CBuffer, %class.CObjArray.5 }
%"struct.NArchive::N7z::CFolders" = type { i32, i32, %class.CObjArray, %"struct.NArchive::N7z::CUInt32DefVector", %class.CObjArray.3, %class.CObjArray, %class.CObjArray.3, %class.CObjArray.3, %class.CObjArray.4, %class.CObjArray.5, %class.CBuffer, %"struct.NArchive::N7z::CParsedMethods" }
%class.CObjArray = type { ptr }
%class.CObjArray.4 = type { ptr }
%"struct.NArchive::N7z::CParsedMethods" = type { i8, i32, %class.CRecordVector.6 }
%class.CRecordVector.7 = type { ptr, i32, i32 }
%"struct.NArchive::N7z::CUInt64DefVector" = type { %class.CRecordVector.1, %class.CRecordVector.6 }
%"struct.NArchive::N7z::CUInt32DefVector" = type { %class.CRecordVector.1, %class.CRecordVector.2 }
%class.CRecordVector.2 = type { ptr, i32, i32 }
%class.CRecordVector.1 = type { ptr, i32, i32 }
%class.CBuffer = type { ptr, i64 }
%class.CObjArray.5 = type { ptr }
%"struct.NArchive::N7z::CInArchiveInfo" = type { %"struct.NArchive::N7z::CArchiveVersion", i64, i64, i64, i64, %class.CRecordVector.6 }
%"struct.NArchive::N7z::CArchiveVersion" = type { i8, i8 }
%class.CObjArray.3 = type { ptr }
%class.UString = type { ptr, i32, i32 }
%class.CRecordVector.8 = type { ptr, i32, i32 }
%class.CRecordVector.6 = type { ptr, i32, i32 }

; 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
define dso_local noundef i32 @_ZN8NArchive3N7z8CHandler10GetRawPropEjjPPKvPjS5_(ptr noundef nonnull align 8 dereferenceable(696) %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) unnamed_addr #1 align 2 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  %16 = load ptr, ptr %8, align 8
  %17 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr null, ptr %17, align 8, !tbaa !5
  %18 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 0, ptr %18, align 4, !tbaa !9
  %19 = load ptr, ptr %13, align 8, !tbaa !5
  store i32 0, ptr %19, align 4, !tbaa !9
  %20 = load i32, ptr %10, align 4, !tbaa !9
  %21 = icmp eq i32 %20, 3
  br i1 %21, label %22, label %67

22:                                               ; preds = %6
  %23 = getelementptr inbounds %"class.NArchive::N7z::CHandler", ptr %16, i32 0, i32 7
  %24 = getelementptr inbounds %"struct.NArchive::N7z::CDatabase", ptr %23, i32 0, i32 9
  %25 = call noundef ptr @_ZN9CObjArrayImEcvPmEv(ptr noundef nonnull align 8 dereferenceable(8) %24)
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %66

27:                                               ; preds = %22
  %28 = getelementptr inbounds %"class.NArchive::N7z::CHandler", ptr %16, i32 0, i32 7
  %29 = getelementptr inbounds %"struct.NArchive::N7z::CDatabase", ptr %28, i32 0, i32 8
  %30 = call noundef ptr @_ZN7CBufferIhEcvPhEv(ptr noundef nonnull align 8 dereferenceable(16) %29)
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %66

32:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %33 = getelementptr inbounds %"class.NArchive::N7z::CHandler", ptr %16, i32 0, i32 7
  %34 = getelementptr inbounds %"struct.NArchive::N7z::CDatabase", ptr %33, i32 0, i32 9
  %35 = call noundef ptr @_ZN9CObjArrayImEcvPmEv(ptr noundef nonnull align 8 dereferenceable(8) %34)
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds i64, ptr %35, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !11
  store i64 %39, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %40 = getelementptr inbounds %"class.NArchive::N7z::CHandler", ptr %16, i32 0, i32 7
  %41 = getelementptr inbounds %"struct.NArchive::N7z::CDatabase", ptr %40, i32 0, i32 9
  %42 = call noundef ptr @_ZN9CObjArrayImEcvPmEv(ptr noundef nonnull align 8 dereferenceable(8) %41)
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = add i32 %43, 1
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds i64, ptr %42, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !11
  %48 = load i64, ptr %14, align 8, !tbaa !11
  %49 = sub i64 %47, %48
  %50 = mul i64 %49, 2
  store i64 %50, ptr %15, align 8, !tbaa !11
  %51 = load i64, ptr %15, align 8, !tbaa !11
  %52 = icmp ult i64 %51, 2147483648
  br i1 %52, label %53, label %65

53:                                               ; preds = %32
  %54 = getelementptr inbounds %"class.NArchive::N7z::CHandler", ptr %16, i32 0, i32 7
  %55 = getelementptr inbounds %"struct.NArchive::N7z::CDatabase", ptr %54, i32 0, i32 8
  %56 = call noundef ptr @_ZN7CBufferIhEcvPhEv(ptr noundef nonnull align 8 dereferenceable(16) %55)
  %57 = load i64, ptr %14, align 8, !tbaa !11
  %58 = mul i64 %57, 2
  %59 = getelementptr inbounds i8, ptr %56, i64 %58
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %59, ptr %60, align 8, !tbaa !5
  %61 = load i64, ptr %15, align 8, !tbaa !11
  %62 = trunc i64 %61 to i32
  %63 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 %62, ptr %63, align 4, !tbaa !9
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  store i32 81, ptr %64, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %53, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %66

66:                                               ; preds = %65, %27, %22
  store i32 0, ptr %7, align 4
  br label %68

67:                                               ; preds = %6
  store i32 0, ptr %7, align 4
  br label %68

68:                                               ; preds = %67, %66
  %69 = load i32, ptr %7, align 4
  ret i32 %69
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN9CObjArrayImEcvPmEv(ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7CBufferIhEcvPhEv(ptr noundef nonnull align 8 dereferenceable(16)) #2 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 = { 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, !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, !12, i64 0}
!12 = !{!"long", !7, i64 0}


; 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 nounwind uwtable
define dso_local noundef i32 @_ZN8NArchive3N7z8CHandler10GetRawPropEjjPPKvPjS5_(ptr noundef nonnull align 8 dereferenceable(696) %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5) unnamed_addr #0 align 2 {
  store ptr null, ptr %3, align 8, !tbaa !5
  store i32 0, ptr %4, align 4, !tbaa !9
  store i32 0, ptr %5, align 4, !tbaa !9
  %7 = icmp eq i32 %2, 3
  br i1 %7, label %8, label %32

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 536
  %10 = tail call noundef ptr @_ZN9CObjArrayImEcvPmEv(ptr noundef nonnull align 8 dereferenceable(8) %9)
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %32, label %11

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %0, i64 520
  %13 = tail call noundef ptr @_ZN7CBufferIhEcvPhEv(ptr noundef nonnull align 8 dereferenceable(16) %12)
  %.not14 = icmp eq ptr %13, null
  br i1 %.not14, label %32, label %14

14:                                               ; preds = %11
  %15 = tail call noundef ptr @_ZN9CObjArrayImEcvPmEv(ptr noundef nonnull align 8 dereferenceable(8) %9)
  %16 = zext i32 %1 to i64
  %17 = getelementptr inbounds i64, ptr %15, i64 %16
  %18 = load i64, ptr %17, align 8, !tbaa !11
  %19 = tail call noundef ptr @_ZN9CObjArrayImEcvPmEv(ptr noundef nonnull align 8 dereferenceable(8) %9)
  %20 = add i32 %1, 1
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds i64, ptr %19, i64 %21
  %23 = load i64, ptr %22, align 8, !tbaa !11
  %24 = sub i64 %23, %18
  %25 = shl i64 %24, 1
  %26 = icmp ult i64 %25, 2147483648
  br i1 %26, label %27, label %32

27:                                               ; preds = %14
  %28 = tail call noundef ptr @_ZN7CBufferIhEcvPhEv(ptr noundef nonnull align 8 dereferenceable(16) %12)
  %29 = shl i64 %18, 1
  %30 = getelementptr inbounds i8, ptr %28, i64 %29
  store ptr %30, ptr %3, align 8, !tbaa !5
  %31 = trunc nuw nsw i64 %25 to i32
  store i32 %31, ptr %4, align 4, !tbaa !9
  store i32 81, ptr %5, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %6, %8, %11, %27, %14
  ret i32 0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN7CBufferIhEcvPhEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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

!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, !12, i64 0}
!12 = !{!"long", !7, i64 0}


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