user: Please show me the C implementation that matches the assembly code listed below:

```asm
<ChapMS_v2>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x78,%rsp
  mov    %rdi,-0x68(%rbp)
  mov    %rsi,-0x70(%rbp)
  mov    %rdx,-0x78(%rbp)
  mov    %ecx,-0x7c(%rbp)
  mov    %r8,-0x88(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%rbx
  mov    D6(%rip),%rax
  mov    (%rax),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x58(%rbp)
  movslq %eax,%rdx
  mov    %rdx,-0xa0(%rbp)
  movq   $0x0,-0x98(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r14
  mov    $0x0,%r15d
  cltq
  mov    $0x10,%edx
  sub    $0x1,%rdx
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L52:
  cmp    %rdx,%rsp
  je     L65
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L52
L65:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L5
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L5:
  mov    %rsp,%rax
  add    $0x0,%rax
  mov    %rax,-0x50(%rbp)
  mov    D5(%rip),%rax
  mov    (%rax),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x48(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r12
  mov    $0x0,%r13d
  movslq %eax,%rdx
  mov    %rdx,%r10
  mov    $0x0,%r11d
  cltq
  mov    $0x10,%edx
  sub    $0x1,%rdx
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L38:
  cmp    %rdx,%rsp
  je     L39
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L38
L39:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L51
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L51:
  mov    %rsp,%rax
  add    $0x0,%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x68(%rbp),%rax
  mov    $0x31,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x68(%rbp),%rax
  mov    $0x10,%edx
  mov    $0x66,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  lea    -0x5c(%rbp),%rax
  mov    %rax,%rdi
  call   <SHA_Init@plt>
  mov    -0x68(%rbp),%rcx
  lea    -0x5c(%rbp),%rax
  mov    $0x10,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <SHA1_Update@plt>
  mov    -0x70(%rbp),%rcx
  lea    -0x5c(%rbp),%rax
  mov    $0x10,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <SHA1_Update@plt>
  mov    -0x88(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    -0x88(%rbp),%rcx
  lea    -0x5c(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <SHA1_Update@plt>
  lea    -0x5c(%rbp),%rdx
  mov    -0x40(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <SHA1_Final@plt>
  mov    -0x50(%rbp),%rdx
  mov    -0x7c(%rbp),%ecx
  mov    -0x78(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <NtPasswordHash@plt>
  mov    -0x68(%rbp),%rax
  lea    0x18(%rax),%rdx
  mov    -0x50(%rbp),%rcx
  mov    -0x40(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <ChallengeResponse@plt>
  mov    $0x0,%eax
  mov    %rbx,%rsp
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L25
  call   <__stack_chk_fail@plt>
L25:
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
```

assistant: ```c
int ChapMS_v2(unsigned char *resp, unsigned char *chl, unsigned char *secret, int secret_len, char *username) {
  unsigned char pwdhash[MD4_DIGEST_LENGTH];
  SHA_CTX ctx;
  unsigned char digest[SHA_DIGEST_LENGTH];
  memset(resp, 0, 49);
  memset(resp, 0x66, 16);
  SHA_Init(&ctx);
  SHA1_Update(&ctx, resp, 16);
  SHA1_Update(&ctx, chl, 16);
  SHA1_Update(&ctx, username, strlen(username));
  SHA1_Final(digest, &ctx);
  NtPasswordHash(secret, secret_len, pwdhash);
  ChallengeResponse(digest, pwdhash, resp + 16 + 8);
  return 0;
}
```