; LLVM IR from SSBMTonberry/pocketlzma :: ref_spec/lzma1900/CPP/7zip/Compress (LzmaDecoder)

; 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.NCompress::NLzma::CDecoder" = type { %struct.ICompressCoder, %struct.ICompressSetDecoderProperties2, %struct.ICompressSetFinishMode, %struct.ICompressGetInStreamProcessedSize, %struct.ICompressSetBufSize, %struct.ICompressSetInStream, %struct.ICompressSetOutStreamSize, %struct.ISequentialInStream, %class.CMyUnknownImp, ptr, i32, i32, i32, i8, i8, i8, i64, i64, i64, i32, i32, i32, %struct.CLzmaDec, %class.CMyComPtr }
%struct.ICompressCoder = type { %struct.IUnknown }
%struct.IUnknown = type { ptr }
%struct.ICompressSetDecoderProperties2 = type { %struct.IUnknown }
%struct.ICompressSetFinishMode = type { %struct.IUnknown }
%struct.ICompressGetInStreamProcessedSize = type { %struct.IUnknown }
%struct.ICompressSetBufSize = type { %struct.IUnknown }
%struct.ICompressSetInStream = type { %struct.IUnknown }
%struct.ICompressSetOutStreamSize = type { %struct.IUnknown }
%struct.ISequentialInStream = type { %struct.IUnknown }
%class.CMyUnknownImp = type { i32 }
%struct.CLzmaDec = type { %struct._CLzmaProps, ptr, ptr, ptr, i64, i64, ptr, i32, i32, i32, i32, [4 x i32], i32, i32, i32, i32, [20 x i8] }
%struct._CLzmaProps = type { i8, i8, i8, i8, 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 @_ZN9NCompress5NLzma8CDecoder8CodeSpecEP19ISequentialInStreamP20ISequentialOutStreamP21ICompressProgressInfo(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef, ptr noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN9NCompress5NLzma8CDecoder4CodeEP19ISequentialInStreamP20ISequentialOutStreamPKyS7_P21ICompressProgressInfo(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, ptr 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 ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  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
  %15 = load ptr, ptr %8, align 8
  %16 = getelementptr inbounds %"class.NCompress::NLzma::CDecoder", ptr %15, i32 0, i32 9
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = icmp ne ptr %17, null
  br i1 %18, label %20, label %19

19:                                               ; preds = %6
  store i32 -2147024809, ptr %7, align 4
  br label %49

20:                                               ; preds = %6
  %21 = load ptr, ptr %12, align 8, !tbaa !5
  %22 = load ptr, ptr %15, align 8, !tbaa !29
  %23 = getelementptr inbounds ptr, ptr %22, i64 9
  %24 = load ptr, ptr %23, align 8
  %25 = call noundef i32 %24(ptr noundef nonnull align 8 dereferenceable(272) %15, ptr noundef %21)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = load ptr, ptr %13, align 8, !tbaa !5
  %29 = call noundef i32 @_ZN9NCompress5NLzma8CDecoder8CodeSpecEP19ISequentialInStreamP20ISequentialOutStreamP21ICompressProgressInfo(ptr noundef nonnull align 8 dereferenceable(272) %15, ptr noundef %26, ptr noundef %27, ptr noundef %28)
  store i32 %29, ptr %14, align 4, !tbaa !31
  %30 = load i32, ptr %14, align 4, !tbaa !31
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %47

32:                                               ; preds = %20
  %33 = getelementptr inbounds %"class.NCompress::NLzma::CDecoder", ptr %15, i32 0, i32 13
  %34 = load i8, ptr %33, align 4, !tbaa !32, !range !33, !noundef !34
  %35 = trunc i8 %34 to i1
  br i1 %35, label %36, label %46

36:                                               ; preds = %32
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %46

39:                                               ; preds = %36
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = load i64, ptr %40, align 8, !tbaa !35
  %42 = getelementptr inbounds %"class.NCompress::NLzma::CDecoder", ptr %15, i32 0, i32 17
  %43 = load i64, ptr %42, align 8, !tbaa !36
  %44 = icmp ne i64 %41, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %39
  store i32 1, ptr %14, align 4, !tbaa !31
  br label %46

46:                                               ; preds = %45, %39, %36, %32
  br label %47

47:                                               ; preds = %46, %20
  %48 = load i32, ptr %14, align 4, !tbaa !31
  store i32 %48, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  br label %49

49:                                               ; preds = %47, %19
  %50 = load i32, ptr %7, align 4
  ret i32 %50
}

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, !6, i64 72}
!10 = !{!"_ZTSN9NCompress5NLzma8CDecoderE", !11, i64 0, !13, i64 8, !14, i64 16, !15, i64 24, !16, i64 32, !17, i64 40, !18, i64 48, !19, i64 56, !20, i64 64, !6, i64 72, !21, i64 80, !21, i64 84, !22, i64 88, !23, i64 92, !23, i64 93, !23, i64 94, !24, i64 96, !24, i64 104, !24, i64 112, !21, i64 120, !21, i64 124, !21, i64 128, !25, i64 136, !28, i64 264}
!11 = !{!"_ZTS14ICompressCoder", !12, i64 0}
!12 = !{!"_ZTS8IUnknown"}
!13 = !{!"_ZTS30ICompressSetDecoderProperties2", !12, i64 0}
!14 = !{!"_ZTS22ICompressSetFinishMode", !12, i64 0}
!15 = !{!"_ZTS33ICompressGetInStreamProcessedSize", !12, i64 0}
!16 = !{!"_ZTS19ICompressSetBufSize", !12, i64 0}
!17 = !{!"_ZTS20ICompressSetInStream", !12, i64 0}
!18 = !{!"_ZTS25ICompressSetOutStreamSize", !12, i64 0}
!19 = !{!"_ZTS19ISequentialInStream", !12, i64 0}
!20 = !{!"_ZTS13CMyUnknownImp", !21, i64 0}
!21 = !{!"int", !7, i64 0}
!22 = !{!"_ZTS11ELzmaStatus", !7, i64 0}
!23 = !{!"bool", !7, i64 0}
!24 = !{!"long long", !7, i64 0}
!25 = !{!"_ZTS8CLzmaDec", !26, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !27, i64 32, !27, i64 40, !6, i64 48, !21, i64 56, !21, i64 60, !21, i64 64, !21, i64 68, !7, i64 72, !21, i64 88, !21, i64 92, !21, i64 96, !21, i64 100, !7, i64 104}
!26 = !{!"_ZTS11_CLzmaProps", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !21, i64 4}
!27 = !{!"long", !7, i64 0}
!28 = !{!"_ZTS9CMyComPtrI19ISequentialInStreamE", !6, i64 0}
!29 = !{!30, !30, i64 0}
!30 = !{!"vtable pointer", !8, i64 0}
!31 = !{!21, !21, i64 0}
!32 = !{!10, !23, i64 92}
!33 = !{i8 0, i8 2}
!34 = !{}
!35 = !{!24, !24, i64 0}
!36 = !{!10, !24, i64 104}


; 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 @_ZN9NCompress5NLzma8CDecoder8CodeSpecEP19ISequentialInStreamP20ISequentialOutStreamP21ICompressProgressInfo(ptr noundef nonnull align 8 dereferenceable(272), ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN9NCompress5NLzma8CDecoder4CodeEP19ISequentialInStreamP20ISequentialOutStreamPKyS7_P21ICompressProgressInfo(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, ptr noundef %2, ptr noundef readonly %3, ptr noundef %4, ptr noundef %5) unnamed_addr #0 align 2 {
  %7 = getelementptr inbounds i8, ptr %0, i64 72
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %25, label %9

9:                                                ; preds = %6
  %10 = load ptr, ptr %0, align 8, !tbaa !28
  %11 = getelementptr inbounds i8, ptr %10, i64 72
  %12 = load ptr, ptr %11, align 8
  %13 = tail call noundef i32 %12(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %4)
  %14 = tail call noundef i32 @_ZN9NCompress5NLzma8CDecoder8CodeSpecEP19ISequentialInStreamP20ISequentialOutStreamP21ICompressProgressInfo(ptr noundef nonnull align 8 dereferenceable(272) %0, ptr noundef %1, ptr noundef %2, ptr noundef %5)
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %25

16:                                               ; preds = %9
  %17 = getelementptr inbounds i8, ptr %0, i64 92
  %18 = load i8, ptr %17, align 4, !tbaa !30, !range !31, !noundef !32
  %19 = trunc nuw i8 %18 to i1
  %20 = icmp ne ptr %3, null
  %or.cond = and i1 %20, %19
  br i1 %or.cond, label %21, label %25

21:                                               ; preds = %16
  %22 = load i64, ptr %3, align 8, !tbaa !33
  %23 = getelementptr inbounds i8, ptr %0, i64 104
  %24 = load i64, ptr %23, align 8, !tbaa !34
  %.not13 = icmp ne i64 %22, %24
  %spec.select = zext i1 %.not13 to i32
  br label %25

25:                                               ; preds = %21, %9, %16, %6
  %.010 = phi i32 [ -2147024809, %6 ], [ 0, %16 ], [ %14, %9 ], [ %spec.select, %21 ]
  ret i32 %.010
}

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, !20, i64 72}
!6 = !{!"_ZTSN9NCompress5NLzma8CDecoderE", !7, i64 0, !9, i64 8, !10, i64 16, !11, i64 24, !12, i64 32, !13, i64 40, !14, i64 48, !15, i64 56, !16, i64 64, !20, i64 72, !17, i64 80, !17, i64 84, !21, i64 88, !22, i64 92, !22, i64 93, !22, i64 94, !23, i64 96, !23, i64 104, !23, i64 112, !17, i64 120, !17, i64 124, !17, i64 128, !24, i64 136, !27, i64 264}
!7 = !{!"_ZTS14ICompressCoder", !8, i64 0}
!8 = !{!"_ZTS8IUnknown"}
!9 = !{!"_ZTS30ICompressSetDecoderProperties2", !8, i64 0}
!10 = !{!"_ZTS22ICompressSetFinishMode", !8, i64 0}
!11 = !{!"_ZTS33ICompressGetInStreamProcessedSize", !8, i64 0}
!12 = !{!"_ZTS19ICompressSetBufSize", !8, i64 0}
!13 = !{!"_ZTS20ICompressSetInStream", !8, i64 0}
!14 = !{!"_ZTS25ICompressSetOutStreamSize", !8, i64 0}
!15 = !{!"_ZTS19ISequentialInStream", !8, i64 0}
!16 = !{!"_ZTS13CMyUnknownImp", !17, i64 0}
!17 = !{!"int", !18, i64 0}
!18 = !{!"omnipotent char", !19, i64 0}
!19 = !{!"Simple C++ TBAA"}
!20 = !{!"any pointer", !18, i64 0}
!21 = !{!"_ZTS11ELzmaStatus", !18, i64 0}
!22 = !{!"bool", !18, i64 0}
!23 = !{!"long long", !18, i64 0}
!24 = !{!"_ZTS8CLzmaDec", !25, i64 0, !20, i64 8, !20, i64 16, !20, i64 24, !26, i64 32, !26, i64 40, !20, i64 48, !17, i64 56, !17, i64 60, !17, i64 64, !17, i64 68, !18, i64 72, !17, i64 88, !17, i64 92, !17, i64 96, !17, i64 100, !18, i64 104}
!25 = !{!"_ZTS11_CLzmaProps", !18, i64 0, !18, i64 1, !18, i64 2, !18, i64 3, !17, i64 4}
!26 = !{!"long", !18, i64 0}
!27 = !{!"_ZTS9CMyComPtrI19ISequentialInStreamE", !20, i64 0}
!28 = !{!29, !29, i64 0}
!29 = !{!"vtable pointer", !19, i64 0}
!30 = !{!6, !22, i64 92}
!31 = !{i8 0, i8 2}
!32 = !{}
!33 = !{!23, !23, i64 0}
!34 = !{!6, !23, i64 104}


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