; LLVM IR from SSBMTonberry/pocketlzma :: ref_spec/lzma1900/CPP/7zip/Crypto/MyAes.ll (ZN7NCrypto12CAesCbcCoderC2Ebj)

; 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.NCrypto::CAesCbcCoder" = type { %struct.ICompressFilter, %struct.ICryptoProperties, %struct.ICompressSetCoderProperties, %class.CMyUnknownImp, ptr, i32, i32, i8, i8, [71 x i32], [16 x i8] }
%struct.ICompressFilter = type { %struct.IUnknown }
%struct.IUnknown = type { ptr }
%struct.ICryptoProperties = type { %struct.IUnknown }
%struct.ICompressSetCoderProperties = type { %struct.IUnknown }
%class.CMyUnknownImp = type { i32 }

@_ZTVN7NCrypto12CAesCbcCoderE = external dso_local unnamed_addr constant { [12 x ptr], [9 x ptr], [8 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7NCrypto12CAesCbcCoderC2Ebj(ptr noundef nonnull align 8 dereferenceable(352) %0, i1 noundef zeroext %1, i32 noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  %9 = zext i1 %1 to i8
  store i8 %9, ptr %5, align 1, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !11
  %10 = load ptr, ptr %4, align 8
  call void @_ZN15ICompressFilterC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %10) #4
  %11 = getelementptr inbounds i8, ptr %10, i64 8
  call void @_ZN17ICryptoPropertiesC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %11) #4
  %12 = getelementptr inbounds i8, ptr %10, i64 16
  call void @_ZN27ICompressSetCoderPropertiesC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %12) #4
  %13 = getelementptr inbounds i8, ptr %10, i64 24
  invoke void @_ZN13CMyUnknownImpC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %13)
          to label %14 unwind label %38

14:                                               ; preds = %3
  store ptr getelementptr inbounds inrange(-16, 80) ({ [12 x ptr], [9 x ptr], [8 x ptr] }, ptr @_ZTVN7NCrypto12CAesCbcCoderE, i32 0, i32 0, i32 2), ptr %10, align 8, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %10, i64 8
  store ptr getelementptr inbounds inrange(-16, 56) ({ [12 x ptr], [9 x ptr], [8 x ptr] }, ptr @_ZTVN7NCrypto12CAesCbcCoderE, i32 0, i32 1, i32 2), ptr %15, align 8, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %10, i64 16
  store ptr getelementptr inbounds inrange(-16, 48) ({ [12 x ptr], [9 x ptr], [8 x ptr] }, ptr @_ZTVN7NCrypto12CAesCbcCoderE, i32 0, i32 2, i32 2), ptr %16, align 8, !tbaa !13
  %17 = getelementptr inbounds %"class.NCrypto::CAesCbcCoder", ptr %10, i32 0, i32 6
  %18 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %18, ptr %17, align 4, !tbaa !15
  %19 = getelementptr inbounds %"class.NCrypto::CAesCbcCoder", ptr %10, i32 0, i32 7
  store i8 0, ptr %19, align 8, !tbaa !22
  %20 = getelementptr inbounds %"class.NCrypto::CAesCbcCoder", ptr %10, i32 0, i32 8
  %21 = load i8, ptr %5, align 1, !tbaa !9, !range !23, !noundef !24
  %22 = trunc i8 %21 to i1
  %23 = zext i1 %22 to i8
  store i8 %23, ptr %20, align 1, !tbaa !25
  %24 = getelementptr inbounds %"class.NCrypto::CAesCbcCoder", ptr %10, i32 0, i32 9
  %25 = getelementptr inbounds [71 x i32], ptr %24, i64 0, i64 0
  %26 = ptrtoint ptr %25 to i64
  %27 = trunc i64 %26 to i32
  %28 = sub i32 0, %27
  %29 = and i32 %28, 15
  %30 = zext i32 %29 to i64
  %31 = udiv i64 %30, 4
  %32 = trunc i64 %31 to i32
  %33 = getelementptr inbounds %"class.NCrypto::CAesCbcCoder", ptr %10, i32 0, i32 5
  store i32 %32, ptr %33, align 8, !tbaa !26
  %34 = getelementptr inbounds %"class.NCrypto::CAesCbcCoder", ptr %10, i32 0, i32 10
  %35 = getelementptr inbounds [16 x i8], ptr %34, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 8 %35, i8 0, i64 16, i1 false)
  %36 = invoke noundef zeroext i1 @_ZN7NCrypto12CAesCbcCoder12SetFunctionsEj(ptr noundef nonnull align 8 dereferenceable(352) %10, i32 noundef 0)
          to label %37 unwind label %42

37:                                               ; preds = %14
  ret void

38:                                               ; preds = %3
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %7, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %8, align 4
  br label %47

42:                                               ; preds = %14
  %43 = landingpad { ptr, i32 }
          cleanup
  %44 = extractvalue { ptr, i32 } %43, 0
  store ptr %44, ptr %7, align 8
  %45 = extractvalue { ptr, i32 } %43, 1
  store i32 %45, ptr %8, align 4
  %46 = getelementptr inbounds i8, ptr %10, i64 24
  call void @_ZN13CMyUnknownImpD2Ev(ptr noundef nonnull align 4 dereferenceable(4) %46) #4
  br label %47

47:                                               ; preds = %42, %38
  %48 = getelementptr inbounds i8, ptr %10, i64 16
  call void @_ZN8IUnknownD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %48) #4
  %49 = getelementptr inbounds i8, ptr %10, i64 8
  call void @_ZN8IUnknownD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %49) #4
  call void @_ZN8IUnknownD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %10) #4
  br label %50

50:                                               ; preds = %47
  %51 = load ptr, ptr %7, align 8
  %52 = load i32, ptr %8, align 4
  %53 = insertvalue { ptr, i32 } poison, ptr %51, 0
  %54 = insertvalue { ptr, i32 } %53, i32 %52, 1
  resume { ptr, i32 } %54
}

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

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

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN7NCrypto12CAesCbcCoder12SetFunctionsEj(ptr noundef nonnull align 8 dereferenceable(352), i32 noundef) #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8IUnknownD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #2 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" }
attributes #1 = { inlinehint 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"vtable pointer", !8, i64 0}
!15 = !{!16, !12, i64 44}
!16 = !{!"_ZTSN7NCrypto12CAesCbcCoderE", !17, i64 0, !19, i64 8, !20, i64 16, !21, i64 24, !6, i64 32, !12, i64 40, !12, i64 44, !10, i64 48, !10, i64 49, !7, i64 52, !7, i64 336}
!17 = !{!"_ZTS15ICompressFilter", !18, i64 0}
!18 = !{!"_ZTS8IUnknown"}
!19 = !{!"_ZTS17ICryptoProperties", !18, i64 0}
!20 = !{!"_ZTS27ICompressSetCoderProperties", !18, i64 0}
!21 = !{!"_ZTS13CMyUnknownImp", !12, i64 0}
!22 = !{!16, !10, i64 48}
!23 = !{i8 0, i8 2}
!24 = !{}
!25 = !{!16, !10, i64 49}
!26 = !{!16, !12, i64 40}


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

@_ZTVN7NCrypto12CAesCbcCoderE = external dso_local unnamed_addr constant { [12 x ptr], [9 x ptr], [8 x ptr] }, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7NCrypto12CAesCbcCoderC2Ebj(ptr noundef nonnull align 8 dereferenceable(352) %0, i1 noundef zeroext %1, i32 noundef %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = zext i1 %1 to i8
  tail call void @_ZN15ICompressFilterC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN17ICryptoPropertiesC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @_ZN27ICompressSetCoderPropertiesC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %6) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @_ZN13CMyUnknownImpC2Ev(ptr noundef nonnull align 4 dereferenceable(4) %7)
  store ptr getelementptr inbounds inrange(-16, 80) (i8, ptr @_ZTVN7NCrypto12CAesCbcCoderE, i64 16), ptr %0, align 8, !tbaa !5
  store ptr getelementptr inbounds inrange(-16, 56) (i8, ptr @_ZTVN7NCrypto12CAesCbcCoderE, i64 112), ptr %5, align 8, !tbaa !5
  store ptr getelementptr inbounds inrange(-16, 48) (i8, ptr @_ZTVN7NCrypto12CAesCbcCoderE, i64 184), ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 44
  store i32 %2, ptr %8, align 4, !tbaa !8
  %9 = getelementptr inbounds i8, ptr %0, i64 48
  store i8 0, ptr %9, align 8, !tbaa !19
  %10 = getelementptr inbounds i8, ptr %0, i64 49
  store i8 %4, ptr %10, align 1, !tbaa !20
  %11 = getelementptr inbounds i8, ptr %0, i64 52
  %12 = ptrtoint ptr %11 to i64
  %13 = trunc i64 %12 to i32
  %14 = sub nsw i32 0, %13
  %15 = lshr exact i32 %14, 2
  %16 = and i32 %15, 3
  %17 = getelementptr inbounds i8, ptr %0, i64 40
  store i32 %16, ptr %17, align 8, !tbaa !21
  %18 = getelementptr inbounds i8, ptr %0, i64 336
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %18, i8 0, i64 16, i1 false)
  %19 = tail call noundef zeroext i1 @_ZN7NCrypto12CAesCbcCoder12SetFunctionsEj(ptr noundef nonnull align 8 dereferenceable(352) %0, i32 noundef 0)
  ret void
}

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

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

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

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN7NCrypto12CAesCbcCoder12SetFunctionsEj(ptr noundef nonnull align 8 dereferenceable(352), i32 noundef) 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" }
attributes #1 = { inlinehint 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !15, i64 44}
!9 = !{!"_ZTSN7NCrypto12CAesCbcCoderE", !10, i64 0, !12, i64 8, !13, i64 16, !14, i64 24, !17, i64 32, !15, i64 40, !15, i64 44, !18, i64 48, !18, i64 49, !16, i64 52, !16, i64 336}
!10 = !{!"_ZTS15ICompressFilter", !11, i64 0}
!11 = !{!"_ZTS8IUnknown"}
!12 = !{!"_ZTS17ICryptoProperties", !11, i64 0}
!13 = !{!"_ZTS27ICompressSetCoderProperties", !11, i64 0}
!14 = !{!"_ZTS13CMyUnknownImp", !15, i64 0}
!15 = !{!"int", !16, i64 0}
!16 = !{!"omnipotent char", !7, i64 0}
!17 = !{!"any pointer", !16, i64 0}
!18 = !{!"bool", !16, i64 0}
!19 = !{!9, !18, i64 48}
!20 = !{!9, !18, i64 49}
!21 = !{!9, !15, i64 40}


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