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

; 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::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 }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8NArchive5NLzma8CHandler5CloseEv(ptr noundef nonnull align 8 dereferenceable(104) %0) unnamed_addr #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %3, i32 0, i32 7
  store i8 0, ptr %4, align 8, !tbaa !9
  %5 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %3, i32 0, i32 11
  store i8 0, ptr %5, align 4, !tbaa !21
  %6 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %3, i32 0, i32 12
  store i8 0, ptr %6, align 1, !tbaa !22
  %7 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %3, i32 0, i32 13
  store i8 0, ptr %7, align 2, !tbaa !23
  %8 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %3, i32 0, i32 9
  store i8 0, ptr %8, align 2, !tbaa !24
  %9 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %3, i32 0, i32 10
  store i8 0, ptr %9, align 1, !tbaa !25
  %10 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %3, i32 0, i32 14
  store i8 0, ptr %10, align 1, !tbaa !26
  %11 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %3, i32 0, i32 15
  store i8 0, ptr %11, align 8, !tbaa !27
  %12 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %3, i32 0, i32 16
  store i64 0, ptr %12, align 8, !tbaa !28
  %13 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %3, i32 0, i32 8
  store i8 0, ptr %13, align 1, !tbaa !29
  %14 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %3, i32 0, i32 5
  call void @_ZN9CMyComPtrI9IInStreamE7ReleaseEv(ptr noundef nonnull align 8 dereferenceable(8) %14)
  %15 = getelementptr inbounds %"class.NArchive::NLzma::CHandler", ptr %3, i32 0, i32 6
  call void @_ZN9CMyComPtrI19ISequentialInStreamE7ReleaseEv(ptr noundef nonnull align 8 dereferenceable(8) %15)
  ret i32 0
}

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

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

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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !18, i64 64}
!10 = !{!"_ZTSN8NArchive5NLzma8CHandlerE", !11, i64 0, !13, i64 8, !14, i64 16, !16, i64 24, !18, i64 40, !19, i64 48, !20, i64 56, !18, i64 64, !18, i64 65, !18, i64 66, !18, i64 67, !18, i64 68, !18, i64 69, !18, i64 70, !18, i64 71, !18, i64 72, !17, i64 80, !17, i64 88, !17, i64 96}
!11 = !{!"_ZTS10IInArchive", !12, i64 0}
!12 = !{!"_ZTS8IUnknown"}
!13 = !{!"_ZTS15IArchiveOpenSeq", !12, i64 0}
!14 = !{!"_ZTS13CMyUnknownImp", !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTSN8NArchive5NLzma7CHeaderE", !17, i64 0, !7, i64 8, !7, i64 9}
!17 = !{!"long long", !7, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{!"_ZTS9CMyComPtrI9IInStreamE", !6, i64 0}
!20 = !{!"_ZTS9CMyComPtrI19ISequentialInStreamE", !6, i64 0}
!21 = !{!10, !18, i64 68}
!22 = !{!10, !18, i64 69}
!23 = !{!10, !18, i64 70}
!24 = !{!10, !18, i64 66}
!25 = !{!10, !18, i64 67}
!26 = !{!10, !18, i64 71}
!27 = !{!10, !18, i64 72}
!28 = !{!10, !17, i64 80}
!29 = !{!10, !18, 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"

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN8NArchive5NLzma8CHandler5CloseEv(ptr noundef nonnull align 8 dereferenceable(104) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 64
  %3 = getelementptr inbounds i8, ptr %0, i64 80
  store i64 0, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(9) %2, i8 0, i64 9, i1 false)
  tail call void @_ZN9CMyComPtrI9IInStreamE7ReleaseEv(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %5 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void @_ZN9CMyComPtrI19ISequentialInStreamE7ReleaseEv(ptr noundef nonnull align 8 dereferenceable(8) %5)
  ret i32 0
}

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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 nounwind willreturn memory(argmem: write) }

!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, !15, i64 80}
!6 = !{!"_ZTSN8NArchive5NLzma8CHandlerE", !7, i64 0, !9, i64 8, !10, i64 16, !14, i64 24, !16, i64 40, !17, i64 48, !19, i64 56, !16, i64 64, !16, i64 65, !16, i64 66, !16, i64 67, !16, i64 68, !16, i64 69, !16, i64 70, !16, i64 71, !16, i64 72, !15, i64 80, !15, i64 88, !15, i64 96}
!7 = !{!"_ZTS10IInArchive", !8, i64 0}
!8 = !{!"_ZTS8IUnknown"}
!9 = !{!"_ZTS15IArchiveOpenSeq", !8, i64 0}
!10 = !{!"_ZTS13CMyUnknownImp", !11, i64 0}
!11 = !{!"int", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"_ZTSN8NArchive5NLzma7CHeaderE", !15, i64 0, !12, i64 8, !12, i64 9}
!15 = !{!"long long", !12, i64 0}
!16 = !{!"bool", !12, i64 0}
!17 = !{!"_ZTS9CMyComPtrI9IInStreamE", !18, i64 0}
!18 = !{!"any pointer", !12, i64 0}
!19 = !{!"_ZTS9CMyComPtrI19ISequentialInStreamE", !18, i64 0}


; Effective O3 passes: GlobalOptPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass