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

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

%struct.ISzAlloc = type { ptr, ptr }
%"class.NArchive::NLzma::CDecoder" = type { %class.CMyComPtr, ptr, %class.CMyComPtr.0, ptr }
%class.CMyComPtr = type { ptr }
%class.CMyComPtr.0 = type { ptr }
%"class.NArchive::NLzma::CHandler" = type { %struct.IInArchive, %struct.IArchiveOpenSeq, %class.CMyUnknownImp, %"struct.NArchive::NLzma::CHeader", i8, %class.CMyComPtr.9, %class.CMyComPtr.1, i8, i8, i8, i8, i8, i8, i8, i8, i8, i64, i64, i64 }
%struct.IInArchive = type { %struct.IUnknown }
%struct.IUnknown = type { ptr }
%struct.IArchiveOpenSeq = type { %struct.IUnknown }
%class.CMyUnknownImp = type { i32 }
%"struct.NArchive::NLzma::CHeader" = type { i64, i8, [5 x i8] }
%class.CMyComPtr.9 = type { ptr }
%class.CMyComPtr.1 = type { ptr }

@g_Alloc = external global %struct.ISzAlloc, align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN8NArchive5NLzma7CHeader5ParseEPKhb(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, i1 noundef zeroext) #0 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8NArchive5NLzma8CHandler4OpenEP9IInStreamPKyP20IArchiveOpenCallback(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca [128 x i8], align 16
  %13 = alloca i64, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca %"class.NArchive::NLzma::CDecoder", align 8
  %20 = alloca i32, align 4
  %21 = alloca [2048 x i8], align 16
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  %26 = alloca ptr, align 8
  %27 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  %28 = load ptr, ptr %6, align 8
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = getelementptr inbounds ptr, ptr %29, i64 6
  %31 = load ptr, ptr %30, align 8
  %32 = call noundef i32 %31(ptr noundef nonnull align 8 dereferenceable(104) %28)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %33 = call noundef i32 @_ZNK8NArchive5NLzma8CHandler13GetHeaderSizeEv(ptr noundef nonnull align 8 dereferenceable(104) %28)
  store i32 %33, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 128, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 128, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store i64 128, ptr %13, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds [128 x i8], ptr %12, i64 0, i64 0
  %36 = call noundef i32 @_Z10ReadStreamP19ISequentialInStreamPvPm(ptr noundef %34, ptr noundef %35, ptr noundef %13) #6
  store i32 %36, ptr %14, align 4, !tbaa !11
  %37 = load i32, ptr %14, align 4, !tbaa !11
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %41

39:                                               ; preds = %4
  %40 = load i32, ptr %14, align 4, !tbaa !11
  store i32 %40, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %42

41:                                               ; preds = %4
  store i32 0, ptr %15, align 4
  br label %42

42:                                               ; preds = %41, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  %43 = load i32, ptr %15, align 4
  switch i32 %43, label %148 [
    i32 0, label %44
  ]

44:                                               ; preds = %42
  %45 = load i64, ptr %13, align 8, !tbaa !13
  %46 = load i32, ptr %10, align 4, !tbaa !11
  %47 = add i32 %46, 2
  %48 = zext i32 %47 to i64
  %49 = icmp ult i64 %45, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %44
  store i32 1, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %148

51:                                               ; preds = %44
  %52 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %28, i32 0, i32 3
  %53 = getelementptr inbounds [128 x i8], ptr %12, i64 0, i64 0
  %54 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %28, i32 0, i32 4
  %55 = load i8, ptr %54, align 8, !tbaa !15, !range !26, !noundef !27
  %56 = trunc i8 %55 to i1
  %57 = call noundef zeroext i1 @_ZN8NArchive5NLzma7CHeader5ParseEPKhb(ptr noundef nonnull align 8 dereferenceable(16) %52, ptr noundef %53, i1 noundef zeroext %56)
  br i1 %57, label %59, label %58

58:                                               ; preds = %51
  store i32 1, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %148

59:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %60 = getelementptr inbounds [128 x i8], ptr %12, i64 0, i64 0
  %61 = load i32, ptr %10, align 4, !tbaa !11
  %62 = zext i32 %61 to i64
  %63 = getelementptr inbounds i8, ptr %60, i64 %62
  store ptr %63, ptr %16, align 8, !tbaa !5
  %64 = load ptr, ptr %16, align 8, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %64, i64 0
  %66 = load i8, ptr %65, align 1, !tbaa !28
  %67 = zext i8 %66 to i32
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %59
  store i32 1, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %147

70:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %71 = load ptr, ptr %7, align 8, !tbaa !5
  %72 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %28, i32 0, i32 16
  %73 = load ptr, ptr %71, align 8, !tbaa !9
  %74 = getelementptr inbounds ptr, ptr %73, i64 6
  %75 = load ptr, ptr %74, align 8
  %76 = call noundef i32 %75(ptr noundef nonnull align 8 dereferenceable(8) %71, i64 noundef 0, i32 noundef 2, ptr noundef %72)
  store i32 %76, ptr %17, align 4, !tbaa !11
  %77 = load i32, ptr %17, align 4, !tbaa !11
  %78 = icmp ne i32 %77, 0
  br i1 %78, label %79, label %81

79:                                               ; preds = %70
  %80 = load i32, ptr %17, align 4, !tbaa !11
  store i32 %80, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %82

81:                                               ; preds = %70
  store i32 0, ptr %15, align 4
  br label %82

82:                                               ; preds = %81, %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  %83 = load i32, ptr %15, align 4
  switch i32 %83, label %147 [
    i32 0, label %84
  ]

84:                                               ; preds = %82
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %85 = load i64, ptr %13, align 8, !tbaa !13
  %86 = load i32, ptr %10, align 4, !tbaa !11
  %87 = zext i32 %86 to i64
  %88 = sub i64 %85, %87
  store i64 %88, ptr %18, align 8, !tbaa !13
  %89 = load i64, ptr %18, align 8, !tbaa !13
  %90 = icmp ugt i64 %89, 10
  br i1 %90, label %91, label %104

91:                                               ; preds = %84
  %92 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %28, i32 0, i32 3
  %93 = getelementptr inbounds %"struct.NArchive::NLzma::CHeader", ptr %92, i32 0, i32 0
  %94 = load i64, ptr %93, align 8, !tbaa !29
  %95 = icmp eq i64 %94, 0
  br i1 %95, label %96, label %104

96:                                               ; preds = %91
  %97 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %28, i32 0, i32 3
  %98 = getelementptr inbounds %"struct.NArchive::NLzma::CHeader", ptr %97, i32 0, i32 2
  %99 = getelementptr inbounds [5 x i8], ptr %98, i64 0, i64 0
  %100 = load i8, ptr %99, align 1, !tbaa !28
  %101 = zext i8 %100 to i32
  %102 = icmp eq i32 %101, 0
  br i1 %102, label %103, label %104

103:                                              ; preds = %96
  store i32 1, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %146

104:                                              ; preds = %96, %91, %84
  call void @llvm.lifetime.start.p0(i64 32, ptr %19) #6
  call void @_ZN8NArchive5NLzma8CDecoderC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %19)
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  store i32 2048, ptr %20, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 2048, ptr %21) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  store i64 2048, ptr %22, align 8, !tbaa !13
  %105 = load i64, ptr %22, align 8, !tbaa !13
  %106 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %28, i32 0, i32 3
  %107 = getelementptr inbounds %"struct.NArchive::NLzma::CHeader", ptr %106, i32 0, i32 0
  %108 = load i64, ptr %107, align 8, !tbaa !29
  %109 = icmp ugt i64 %105, %108
  br i1 %109, label %110, label %114

110:                                              ; preds = %104
  %111 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %28, i32 0, i32 3
  %112 = getelementptr inbounds %"struct.NArchive::NLzma::CHeader", ptr %111, i32 0, i32 0
  %113 = load i64, ptr %112, align 8, !tbaa !29
  store i64 %113, ptr %22, align 8, !tbaa !13
  br label %114

114:                                              ; preds = %110, %104
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  %115 = load i64, ptr %22, align 8, !tbaa !13
  store i64 %115, ptr %23, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #6
  %116 = getelementptr inbounds [2048 x i8], ptr %21, i64 0, i64 0
  %117 = load ptr, ptr %16, align 8, !tbaa !5
  %118 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %28, i32 0, i32 3
  %119 = getelementptr inbounds %"struct.NArchive::NLzma::CHeader", ptr %118, i32 0, i32 2
  %120 = getelementptr inbounds [5 x i8], ptr %119, i64 0, i64 0
  %121 = invoke i32 @LzmaDecode(ptr noundef %116, ptr noundef %23, ptr noundef %117, ptr noundef %18, ptr noundef %120, i32 noundef 5, i32 noundef 0, ptr noundef %24, ptr noundef @g_Alloc)
          to label %122 unwind label %129

122:                                              ; preds = %114
  store i32 %121, ptr %25, align 4, !tbaa !11
  %123 = load i32, ptr %25, align 4, !tbaa !11
  %124 = icmp ne i32 %123, 0
  br i1 %124, label %125, label %134

125:                                              ; preds = %122
  %126 = load i32, ptr %25, align 4, !tbaa !11
  %127 = icmp ne i32 %126, 6
  br i1 %127, label %128, label %133

128:                                              ; preds = %125
  store i32 1, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %145

129:                                              ; preds = %139, %134, %114
  %130 = landingpad { ptr, i32 }
          cleanup
  %131 = extractvalue { ptr, i32 } %130, 0
  store ptr %131, ptr %26, align 8
  %132 = extractvalue { ptr, i32 } %130, 1
  store i32 %132, ptr %27, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 2048, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @_ZN8NArchive5NLzma8CDecoderD1Ev(ptr noundef nonnull align 8 dereferenceable(32) %19) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 128, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %150

133:                                              ; preds = %125
  br label %134

134:                                              ; preds = %133, %122
  %135 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %28, i32 0, i32 7
  store i8 1, ptr %135, align 8, !tbaa !30
  %136 = load ptr, ptr %7, align 8, !tbaa !5
  %137 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %28, i32 0, i32 5
  %138 = invoke noundef ptr @_ZN9CMyComPtrI9IInStreamEaSEPS0_(ptr noundef nonnull align 8 dereferenceable(8) %137, ptr noundef %136)
          to label %139 unwind label %129

139:                                              ; preds = %134
  %140 = load ptr, ptr %7, align 8, !tbaa !5
  %141 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %28, i32 0, i32 6
  %142 = invoke noundef ptr @_ZN9CMyComPtrI19ISequentialInStreamEaSEPS0_(ptr noundef nonnull align 8 dereferenceable(8) %141, ptr noundef %140)
          to label %143 unwind label %129

143:                                              ; preds = %139
  %144 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %28, i32 0, i32 8
  store i8 1, ptr %144, align 1, !tbaa !31
  store i32 0, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %145

145:                                              ; preds = %143, %128
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 2048, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @_ZN8NArchive5NLzma8CDecoderD1Ev(ptr noundef nonnull align 8 dereferenceable(32) %19) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %19) #6
  br label %146

146:                                              ; preds = %145, %103
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  br label %147

147:                                              ; preds = %146, %82, %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  br label %148

148:                                              ; preds = %147, %58, %50, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 128, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %149 = load i32, ptr %5, align 4
  ret i32 %149

150:                                              ; preds = %129
  %151 = load ptr, ptr %26, align 8
  %152 = load i32, ptr %27, align 4
  %153 = insertvalue { ptr, i32 } poison, ptr %151, 0
  %154 = insertvalue { ptr, i32 } %153, i32 %152, 1
  resume { ptr, i32 } %154
}

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

; Function Attrs: nounwind
declare noundef i32 @_Z10ReadStreamP19ISequentialInStreamPvPm(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8NArchive5NLzma8CDecoderC2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4 align 2

declare i32 @LzmaDecode(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) #5

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

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

declare void @_ZN8NArchive5NLzma8CDecoderD1Ev(ptr)

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 = { inlinehint 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 = { "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 #6 = { 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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !23, i64 40}
!16 = !{!"_ZTSN8NArchive5NLzma8CHandlerE", !17, i64 0, !19, i64 8, !20, i64 16, !21, i64 24, !23, i64 40, !24, i64 48, !25, i64 56, !23, i64 64, !23, i64 65, !23, i64 66, !23, i64 67, !23, i64 68, !23, i64 69, !23, i64 70, !23, i64 71, !23, i64 72, !22, i64 80, !22, i64 88, !22, i64 96}
!17 = !{!"_ZTS10IInArchive", !18, i64 0}
!18 = !{!"_ZTS8IUnknown"}
!19 = !{!"_ZTS15IArchiveOpenSeq", !18, i64 0}
!20 = !{!"_ZTS13CMyUnknownImp", !12, i64 0}
!21 = !{!"_ZTSN8NArchive5NLzma7CHeaderE", !22, i64 0, !7, i64 8, !7, i64 9}
!22 = !{!"long long", !7, i64 0}
!23 = !{!"bool", !7, i64 0}
!24 = !{!"_ZTS9CMyComPtrI9IInStreamE", !6, i64 0}
!25 = !{!"_ZTS9CMyComPtrI19ISequentialInStreamE", !6, i64 0}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{!7, !7, i64 0}
!29 = !{!16, !22, i64 24}
!30 = !{!16, !23, i64 64}
!31 = !{!16, !23, i64 65}


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

%struct.ISzAlloc = type { ptr, ptr }
%"class.NArchive::NLzma::CDecoder" = type { %class.CMyComPtr, ptr, %class.CMyComPtr.0, ptr }
%class.CMyComPtr = type { ptr }
%class.CMyComPtr.0 = type { ptr }

@g_Alloc = external global %struct.ISzAlloc, align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN8NArchive5NLzma7CHeader5ParseEPKhb(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, i1 noundef zeroext) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8NArchive5NLzma8CHandler4OpenEP9IInStreamPKyP20IArchiveOpenCallback(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef %1, ptr nocapture noundef readnone %2, ptr nocapture noundef readnone %3) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca [128 x i8], align 16
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca %"class.NArchive::NLzma::CDecoder", align 8
  %9 = alloca [2048 x i8], align 16
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = load ptr, ptr %0, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %12, i64 48
  %14 = load ptr, ptr %13, align 8
  %15 = tail call noundef i32 %14(ptr noundef nonnull align 8 dereferenceable(104) %0)
  %16 = tail call noundef i32 @_ZNK8NArchive5NLzma8CHandler13GetHeaderSizeEv(ptr noundef nonnull align 8 dereferenceable(104) %0)
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %5) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #7
  store i64 128, ptr %6, align 8, !tbaa !8
  %17 = call noundef i32 @_Z10ReadStreamP19ISequentialInStreamPvPm(ptr noundef %1, ptr noundef nonnull %5, ptr noundef nonnull %6) #7
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %18, label %65

18:                                               ; preds = %4
  %19 = load i64, ptr %6, align 8, !tbaa !8
  %20 = add i32 %16, 2
  %21 = zext i32 %20 to i64
  %22 = icmp ult i64 %19, %21
  br i1 %22, label %65, label %23

23:                                               ; preds = %18
  %24 = getelementptr inbounds i8, ptr %0, i64 24
  %25 = getelementptr inbounds i8, ptr %0, i64 40
  %26 = load i8, ptr %25, align 8, !tbaa !11, !range !24, !noundef !25
  %27 = trunc nuw i8 %26 to i1
  %28 = call noundef zeroext i1 @_ZN8NArchive5NLzma7CHeader5ParseEPKhb(ptr noundef nonnull align 8 dereferenceable(16) %24, ptr noundef nonnull %5, i1 noundef zeroext %27)
  br i1 %28, label %29, label %65

29:                                               ; preds = %23
  %30 = zext i32 %16 to i64
  %31 = getelementptr inbounds i8, ptr %5, i64 %30
  %32 = load i8, ptr %31, align 1, !tbaa !26
  %.not28 = icmp eq i8 %32, 0
  br i1 %.not28, label %33, label %65

33:                                               ; preds = %29
  %34 = getelementptr inbounds i8, ptr %0, i64 80
  %35 = load ptr, ptr %1, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %35, i64 48
  %37 = load ptr, ptr %36, align 8
  %38 = call noundef i32 %37(ptr noundef nonnull align 8 dereferenceable(8) %1, i64 noundef 0, i32 noundef 2, ptr noundef nonnull %34)
  %.not29 = icmp eq i32 %38, 0
  br i1 %.not29, label %39, label %65

39:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #7
  %40 = load i64, ptr %6, align 8, !tbaa !8
  %41 = sub i64 %40, %30
  store i64 %41, ptr %7, align 8, !tbaa !8
  %42 = icmp ugt i64 %41, 10
  %43 = load i64, ptr %24, align 8
  %44 = icmp eq i64 %43, 0
  %or.cond31 = select i1 %42, i1 %44, i1 false
  %45 = getelementptr inbounds i8, ptr %0, i64 33
  %46 = load i8, ptr %45, align 1
  %47 = icmp eq i8 %46, 0
  %or.cond34 = select i1 %or.cond31, i1 %47, i1 false
  br i1 %or.cond34, label %64, label %48

48:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %8) #7
  call void @_ZN8NArchive5NLzma8CDecoderC2Ev(ptr noundef nonnull align 8 dereferenceable(32) %8)
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %9) #7
  %49 = load i64, ptr %24, align 8, !tbaa !27
  %spec.select = call i64 @llvm.umin.i64(i64 %49, i64 2048)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #7
  store i64 %spec.select, ptr %10, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #7
  %50 = invoke i32 @LzmaDecode(ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %31, ptr noundef nonnull %7, ptr noundef nonnull %45, i32 noundef 5, i32 noundef 0, ptr noundef nonnull %11, ptr noundef nonnull @g_Alloc)
          to label %51 unwind label %52

51:                                               ; preds = %48
  switch i32 %50, label %63 [
    i32 6, label %54
    i32 0, label %54
  ]

52:                                               ; preds = %58, %54, %48
  %53 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %9) #7
  call void @_ZN8NArchive5NLzma8CDecoderD1Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %5) #7
  resume { ptr, i32 } %53

54:                                               ; preds = %51, %51
  %55 = getelementptr inbounds i8, ptr %0, i64 64
  store i8 1, ptr %55, align 8, !tbaa !28
  %56 = getelementptr inbounds i8, ptr %0, i64 48
  %57 = invoke noundef ptr @_ZN9CMyComPtrI9IInStreamEaSEPS0_(ptr noundef nonnull align 8 dereferenceable(8) %56, ptr noundef nonnull %1)
          to label %58 unwind label %52

58:                                               ; preds = %54
  %59 = getelementptr inbounds i8, ptr %0, i64 56
  %60 = invoke noundef ptr @_ZN9CMyComPtrI19ISequentialInStreamEaSEPS0_(ptr noundef nonnull align 8 dereferenceable(8) %59, ptr noundef nonnull %1)
          to label %61 unwind label %52

61:                                               ; preds = %58
  %62 = getelementptr inbounds i8, ptr %0, i64 65
  store i8 1, ptr %62, align 1, !tbaa !29
  br label %63

63:                                               ; preds = %51, %61
  %.2 = phi i32 [ 0, %61 ], [ 1, %51 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #7
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %9) #7
  call void @_ZN8NArchive5NLzma8CDecoderD1Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %8) #7
  br label %64

64:                                               ; preds = %39, %63
  %.3 = phi i32 [ %.2, %63 ], [ 1, %39 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #7
  br label %65

65:                                               ; preds = %64, %33, %29, %23, %18, %4
  %.5 = phi i32 [ %17, %4 ], [ 1, %18 ], [ 1, %23 ], [ %.3, %64 ], [ %38, %33 ], [ 1, %29 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %5) #7
  ret i32 %.5
}

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

; Function Attrs: nounwind
declare noundef i32 @_Z10ReadStreamP19ISequentialInStreamPvPm(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN8NArchive5NLzma8CDecoderC2Ev(ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #4 align 2

declare i32 @LzmaDecode(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

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

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

declare void @_ZN8NArchive5NLzma8CDecoderD1Ev(ptr) local_unnamed_addr

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #6

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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 = { inlinehint 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 = { "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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !20, i64 40}
!12 = !{!"_ZTSN8NArchive5NLzma8CHandlerE", !13, i64 0, !15, i64 8, !16, i64 16, !18, i64 24, !20, i64 40, !21, i64 48, !23, i64 56, !20, i64 64, !20, i64 65, !20, i64 66, !20, i64 67, !20, i64 68, !20, i64 69, !20, i64 70, !20, i64 71, !20, i64 72, !19, i64 80, !19, i64 88, !19, i64 96}
!13 = !{!"_ZTS10IInArchive", !14, i64 0}
!14 = !{!"_ZTS8IUnknown"}
!15 = !{!"_ZTS15IArchiveOpenSeq", !14, i64 0}
!16 = !{!"_ZTS13CMyUnknownImp", !17, i64 0}
!17 = !{!"int", !10, i64 0}
!18 = !{!"_ZTSN8NArchive5NLzma7CHeaderE", !19, i64 0, !10, i64 8, !10, i64 9}
!19 = !{!"long long", !10, i64 0}
!20 = !{!"bool", !10, i64 0}
!21 = !{!"_ZTS9CMyComPtrI9IInStreamE", !22, i64 0}
!22 = !{!"any pointer", !10, i64 0}
!23 = !{!"_ZTS9CMyComPtrI19ISequentialInStreamE", !22, i64 0}
!24 = !{i8 0, i8 2}
!25 = !{}
!26 = !{!10, !10, i64 0}
!27 = !{!12, !19, i64 24}
!28 = !{!12, !20, i64 64}
!29 = !{!12, !20, i64 65}


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