; LLVM IR from SSBMTonberry/pocketlzma :: ref_spec/lzma1900/CPP/7zip/Common/CreateCoder.ll (Z14CreateCoder_IdybR13CCreatedCoder)

; 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.CMyComPtr.1 = type { ptr }
%struct.CCreatedCoder = type { %class.CMyComPtr, %class.CMyComPtr.0, i8, i8, i32 }
%class.CMyComPtr = type { ptr }
%class.CMyComPtr.0 = type { ptr }
%class.CFilterCoder = type { %struct.ICompressCoder, %struct.ICompressSetOutStreamSize, %struct.ICompressInitEncoder, %struct.ICompressSetInStream, %struct.ISequentialInStream, %struct.ICompressSetOutStream, %struct.ISequentialOutStream, %struct.IOutStreamFinish, %struct.ICompressSetBufSize, %struct.ICryptoSetPassword, %struct.ICryptoProperties, %struct.ICompressSetCoderProperties, %struct.ICompressWriteCoderProperties, %struct.ICryptoResetInitVector, %struct.ICompressSetDecoderProperties2, %class.CMyUnknownImp, %struct.CAlignedMidBuffer, i32, i32, i32, i8, i8, i64, i64, %class.CMyComPtr.2, %class.CMyComPtr.3, i32, i32, i32, %class.CMyComPtr.4, %class.CMyComPtr.5, %class.CMyComPtr.6, %class.CMyComPtr.7, %class.CMyComPtr.8, %class.CMyComPtr.9, %class.CMyComPtr.1 }
%struct.ICompressCoder = type { %struct.IUnknown }
%struct.IUnknown = type { ptr }
%struct.ICompressSetOutStreamSize = type { %struct.IUnknown }
%struct.ICompressInitEncoder = type { %struct.IUnknown }
%struct.ICompressSetInStream = type { %struct.IUnknown }
%struct.ISequentialInStream = type { %struct.IUnknown }
%struct.ICompressSetOutStream = type { %struct.IUnknown }
%struct.ISequentialOutStream = type { %struct.IUnknown }
%struct.IOutStreamFinish = type { %struct.IUnknown }
%struct.ICompressSetBufSize = type { %struct.IUnknown }
%struct.ICryptoSetPassword = type { %struct.IUnknown }
%struct.ICryptoProperties = type { %struct.IUnknown }
%struct.ICompressSetCoderProperties = type { %struct.IUnknown }
%struct.ICompressWriteCoderProperties = type { %struct.IUnknown }
%struct.ICryptoResetInitVector = type { %struct.IUnknown }
%struct.ICompressSetDecoderProperties2 = type { %struct.IUnknown }
%class.CMyUnknownImp = type { i32 }
%struct.CAlignedMidBuffer = type { ptr }
%class.CMyComPtr.2 = type { ptr }
%class.CMyComPtr.3 = type { ptr }
%class.CMyComPtr.4 = type { ptr }
%class.CMyComPtr.5 = type { ptr }
%class.CMyComPtr.6 = type { ptr }
%class.CMyComPtr.7 = type { ptr }
%class.CMyComPtr.8 = type { ptr }
%class.CMyComPtr.9 = 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 ptr @_ZN9CMyComPtrI14ICompressCoderEaSEPS0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #1 align 2

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #3

declare void @_ZN12CFilterCoderC1Eb(ptr noundef nonnull align 8 dereferenceable(256), i1 noundef zeroext) unnamed_addr #4

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #5

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z14CreateCoder_IdybR9CMyComPtrI15ICompressFilterER13CCreatedCoder(i64 noundef, i1 noundef zeroext, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(24)) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z14CreateCoder_IdybR13CCreatedCoder(i64 noundef %0, i1 noundef zeroext %1, ptr noundef nonnull align 8 dereferenceable(24) %2) #1 personality ptr @__gxx_personality_v0 {
  %4 = alloca i64, align 8
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca %class.CMyComPtr.1, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  %12 = zext i1 %1 to i8
  store i8 %12, ptr %5, align 1, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  call void @_ZN9CMyComPtrI15ICompressFilterEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  %13 = load i64, ptr %4, align 8, !tbaa !5
  %14 = load i8, ptr %5, align 1, !tbaa !9, !range !13, !noundef !14
  %15 = trunc i8 %14 to i1
  %16 = load ptr, ptr %6, align 8, !tbaa !11
  %17 = invoke noundef i32 @_Z14CreateCoder_IdybR9CMyComPtrI15ICompressFilterER13CCreatedCoder(i64 noundef %13, i1 noundef zeroext %15, ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(24) %16)
          to label %18 unwind label %39

18:                                               ; preds = %3
  store i32 %17, ptr %8, align 4, !tbaa !15
  %19 = invoke noundef ptr @_ZNK9CMyComPtrI15ICompressFilterEcvPS0_Ev(ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %20 unwind label %39

20:                                               ; preds = %18
  %21 = icmp ne ptr %19, null
  br i1 %21, label %22, label %52

22:                                               ; preds = %20
  %23 = load ptr, ptr %6, align 8, !tbaa !11
  %24 = getelementptr inbounds %struct.CCreatedCoder, ptr %23, i32 0, i32 3
  store i8 1, ptr %24, align 1, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %25 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 256) #7
          to label %26 unwind label %43

26:                                               ; preds = %22
  %27 = load i8, ptr %5, align 1, !tbaa !9, !range !13, !noundef !14
  %28 = trunc i8 %27 to i1
  invoke void @_ZN12CFilterCoderC1Eb(ptr noundef nonnull align 8 dereferenceable(256) %25, i1 noundef zeroext %28)
          to label %29 unwind label %47

29:                                               ; preds = %26
  store ptr %25, ptr %11, align 8, !tbaa !11
  %30 = load ptr, ptr %11, align 8, !tbaa !11
  %31 = load ptr, ptr %6, align 8, !tbaa !11
  %32 = getelementptr inbounds %struct.CCreatedCoder, ptr %31, i32 0, i32 0
  %33 = invoke noundef ptr @_ZN9CMyComPtrI14ICompressCoderEaSEPS0_(ptr noundef nonnull align 8 dereferenceable(8) %32, ptr noundef %30)
          to label %34 unwind label %43

34:                                               ; preds = %29
  %35 = load ptr, ptr %11, align 8, !tbaa !11
  %36 = getelementptr inbounds %class.CFilterCoder, ptr %35, i32 0, i32 35
  %37 = invoke noundef ptr @_ZN9CMyComPtrI15ICompressFilterEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %36, ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %38 unwind label %43

38:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %52

39:                                               ; preds = %18, %3
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %9, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %10, align 4
  br label %54

43:                                               ; preds = %34, %29, %22
  %44 = landingpad { ptr, i32 }
          cleanup
  %45 = extractvalue { ptr, i32 } %44, 0
  store ptr %45, ptr %9, align 8
  %46 = extractvalue { ptr, i32 } %44, 1
  store i32 %46, ptr %10, align 4
  br label %51

47:                                               ; preds = %26
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %9, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %10, align 4
  call void @_ZdlPvm(ptr noundef %25, i64 noundef 256) #8
  br label %51

51:                                               ; preds = %47, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %54

52:                                               ; preds = %38, %20
  %53 = load i32, ptr %8, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @_ZN9CMyComPtrI15ICompressFilterED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  ret i32 %53

54:                                               ; preds = %51, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @_ZN9CMyComPtrI15ICompressFilterED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr %9, align 8
  %57 = load i32, ptr %10, align 4
  %58 = insertvalue { ptr, i32 } poison, ptr %56, 0
  %59 = insertvalue { ptr, i32 } %58, i32 %57, 1
  resume { ptr, i32 } %59
}

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 = { nobuiltin allocsize(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 = { "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 = { nobuiltin 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!18, !10, i64 17}
!18 = !{!"_ZTS13CCreatedCoder", !19, i64 0, !20, i64 8, !10, i64 16, !10, i64 17, !16, i64 20}
!19 = !{!"_ZTS9CMyComPtrI14ICompressCoderE", !12, i64 0}
!20 = !{!"_ZTS9CMyComPtrI15ICompressCoder2E", !12, 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"

%class.CMyComPtr.1 = type { ptr }

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

; Function Attrs: mustprogress 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 ptr @_ZN9CMyComPtrI14ICompressCoderEaSEPS0_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #1 align 2

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #3

declare void @_ZN12CFilterCoderC1Eb(ptr noundef nonnull align 8 dereferenceable(256), i1 noundef zeroext) unnamed_addr #4

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #5

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z14CreateCoder_IdybR9CMyComPtrI15ICompressFilterER13CCreatedCoder(i64 noundef, i1 noundef zeroext, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z14CreateCoder_IdybR13CCreatedCoder(i64 noundef %0, i1 noundef zeroext %1, ptr noundef nonnull align 8 dereferenceable(24) %2) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %4 = alloca %class.CMyComPtr.1, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  call void @_ZN9CMyComPtrI15ICompressFilterEC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %5 = invoke noundef i32 @_Z14CreateCoder_IdybR9CMyComPtrI15ICompressFilterER13CCreatedCoder(i64 noundef %0, i1 noundef zeroext %1, ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(24) %2)
          to label %6 unwind label %17

6:                                                ; preds = %3
  %7 = call noundef ptr @_ZNK9CMyComPtrI15ICompressFilterEcvPS0_Ev(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %23, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %2, i64 17
  store i8 1, ptr %9, align 1, !tbaa !5
  %10 = invoke noalias noundef nonnull dereferenceable(256) ptr @_Znwm(i64 noundef 256) #7
          to label %11 unwind label %19

11:                                               ; preds = %8
  invoke void @_ZN12CFilterCoderC1Eb(ptr noundef nonnull align 8 dereferenceable(256) %10, i1 noundef zeroext %1)
          to label %12 unwind label %21

12:                                               ; preds = %11
  %13 = invoke noundef ptr @_ZN9CMyComPtrI14ICompressCoderEaSEPS0_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull %10)
          to label %14 unwind label %19

14:                                               ; preds = %12
  %15 = getelementptr inbounds i8, ptr %10, i64 248
  %16 = invoke noundef ptr @_ZN9CMyComPtrI15ICompressFilterEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef nonnull align 8 dereferenceable(8) %4)
          to label %23 unwind label %19

17:                                               ; preds = %3
  %18 = landingpad { ptr, i32 }
          cleanup
  br label %24

19:                                               ; preds = %14, %12, %8
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %24

21:                                               ; preds = %11
  %22 = landingpad { ptr, i32 }
          cleanup
  call void @_ZdlPvm(ptr noundef nonnull %10, i64 noundef 256) #8
  br label %24

23:                                               ; preds = %14, %6
  call void @_ZN9CMyComPtrI15ICompressFilterED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  ret i32 %5

24:                                               ; preds = %19, %21, %17
  %.pn.pn = phi { ptr, i32 } [ %18, %17 ], [ %20, %19 ], [ %22, %21 ]
  call void @_ZN9CMyComPtrI15ICompressFilterED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  resume { ptr, i32 } %.pn.pn
}

attributes #0 = { mustprogress 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 = { nobuiltin allocsize(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 = { "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 = { nobuiltin 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 #6 = { nounwind }
attributes #7 = { builtin allocsize(0) }
attributes #8 = { builtin 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 17}
!6 = !{!"_ZTS13CCreatedCoder", !7, i64 0, !11, i64 8, !12, i64 16, !12, i64 17, !13, i64 20}
!7 = !{!"_ZTS9CMyComPtrI14ICompressCoderE", !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS9CMyComPtrI15ICompressCoder2E", !8, i64 0}
!12 = !{!"bool", !9, i64 0}
!13 = !{!"int", !9, i64 0}


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