; LLVM IR from chdb-io/chdb :: base/poco/Foundation/src/SHA1Engine.ll (ZN4Poco10SHA1Engine5resetEv)

; 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.Poco::SHA1Engine" = type { %"class.Poco::DigestEngine", %"struct.Poco::SHA1Engine::Context", %"class.std::vector" }
%"class.Poco::DigestEngine" = type { ptr }
%"struct.Poco::SHA1Engine::Context" = type { [5 x i32], i32, i32, [16 x i32], i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl" = type { %"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" }
%"struct.std::_Vector_base<unsigned char, std::allocator<unsigned char>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4Poco10SHA1Engine5resetEv(ptr noundef nonnull align 8 dereferenceable(128) %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.Poco::SHA1Engine", ptr %3, i32 0, i32 1
  %5 = getelementptr inbounds %"struct.Poco::SHA1Engine::Context", ptr %4, i32 0, i32 0
  %6 = getelementptr inbounds [5 x i32], ptr %5, i64 0, i64 0
  store i32 1732584193, ptr %6, align 8, !tbaa !9
  %7 = getelementptr inbounds %"class.Poco::SHA1Engine", ptr %3, i32 0, i32 1
  %8 = getelementptr inbounds %"struct.Poco::SHA1Engine::Context", ptr %7, i32 0, i32 0
  %9 = getelementptr inbounds [5 x i32], ptr %8, i64 0, i64 1
  store i32 -271733879, ptr %9, align 4, !tbaa !9
  %10 = getelementptr inbounds %"class.Poco::SHA1Engine", ptr %3, i32 0, i32 1
  %11 = getelementptr inbounds %"struct.Poco::SHA1Engine::Context", ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds [5 x i32], ptr %11, i64 0, i64 2
  store i32 -1732584194, ptr %12, align 8, !tbaa !9
  %13 = getelementptr inbounds %"class.Poco::SHA1Engine", ptr %3, i32 0, i32 1
  %14 = getelementptr inbounds %"struct.Poco::SHA1Engine::Context", ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds [5 x i32], ptr %14, i64 0, i64 3
  store i32 271733878, ptr %15, align 4, !tbaa !9
  %16 = getelementptr inbounds %"class.Poco::SHA1Engine", ptr %3, i32 0, i32 1
  %17 = getelementptr inbounds %"struct.Poco::SHA1Engine::Context", ptr %16, i32 0, i32 0
  %18 = getelementptr inbounds [5 x i32], ptr %17, i64 0, i64 4
  store i32 -1009589776, ptr %18, align 8, !tbaa !9
  %19 = getelementptr inbounds %"class.Poco::SHA1Engine", ptr %3, i32 0, i32 1
  %20 = getelementptr inbounds %"struct.Poco::SHA1Engine::Context", ptr %19, i32 0, i32 1
  store i32 0, ptr %20, align 4, !tbaa !11
  %21 = getelementptr inbounds %"class.Poco::SHA1Engine", ptr %3, i32 0, i32 1
  %22 = getelementptr inbounds %"struct.Poco::SHA1Engine::Context", ptr %21, i32 0, i32 2
  store i32 0, ptr %22, align 8, !tbaa !19
  %23 = getelementptr inbounds %"class.Poco::SHA1Engine", ptr %3, i32 0, i32 1
  %24 = getelementptr inbounds %"struct.Poco::SHA1Engine::Context", ptr %23, i32 0, i32 4
  store i32 0, ptr %24, align 4, !tbaa !20
  %25 = getelementptr inbounds %"class.Poco::SHA1Engine", ptr %3, i32 0, i32 1
  %26 = getelementptr inbounds %"struct.Poco::SHA1Engine::Context", ptr %25, i32 0, i32 3
  %27 = getelementptr inbounds [16 x i32], ptr %26, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 4 %27, i8 0, i64 64, i1 false)
  ret void
}

; 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 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 = { 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, !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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 28}
!12 = !{!"_ZTSN4Poco10SHA1EngineE", !13, i64 0, !14, i64 8, !15, i64 104}
!13 = !{!"_ZTSN4Poco12DigestEngineE"}
!14 = !{!"_ZTSN4Poco10SHA1Engine7ContextE", !7, i64 0, !10, i64 20, !10, i64 24, !7, i64 28, !10, i64 92}
!15 = !{!"_ZTSSt6vectorIhSaIhEE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIhSaIhEE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIhSaIhEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!12, !10, i64 32}
!20 = !{!12, !10, i64 100}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @_ZN4Poco10SHA1Engine5resetEv(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(128) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  store <4 x i32> <i32 1732584193, i32 -271733879, i32 -1732584194, i32 271733878>, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 -1009589776, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 28
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(76) %4, i8 0, i64 76, i1 false)
  ret void
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass