user: Converte this assembly snippet into its equivalent C code:

```asm
<verify_hash>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  cmpb   $0x24,(%rsi)
  je     L44
L24:
  mov    $0x4,%eax
L173:
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L115
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   0x0(%rax)
L44:
  lea    0x1(%rsi),%rdi
  mov    $0x24,%esi
  call   <strchr@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L24
  movb   $0x0,(%rax)
  lea    0x1(%rax),%r15
  mov    $0x24,%esi
  mov    %r15,%rdi
  call   <strchr@plt>
  mov    %rax,-0x58(%rbp)
  test   %rax,%rax
  je     L24
  movb   $0x0,(%rax)
  lea    0x1(%rax),%r12
  mov    D7(%rip),%rax
  mov    %rsp,%rsi
  movslq (%rax),%rax
  add    $0xf,%rax
  mov    %rax,%rdi
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rdi
  and    $0xfffffffffffffff0,%rcx
  sub    %rdi,%rsi
  cmp    %rsi,%rsp
  je     L92
L61:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L61
L92:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  je     L20
  orq    $0x0,-0x8(%rsp,%rcx,1)
L20:
  mov    %rax,%rdi
  mov    %rsp,%rsi
  mov    %rax,%rcx
  mov    %rsp,-0x50(%rbp)
  and    $0xfffffffffffff000,%rdi
  and    $0xfffffffffffffff0,%rcx
  sub    %rdi,%rsi
  cmp    %rsi,%rsp
  je     L82
L7:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L7
L82:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  je     L67
  orq    $0x0,-0x8(%rsp,%rcx,1)
L67:
  mov    %rax,%rcx
  mov    %rsp,%rsi
  and    $0xfffffffffffff000,%rax
  mov    %rsp,-0x68(%rbp)
  sub    %rax,%rsi
  and    $0xfffffffffffffff0,%rcx
  cmp    %rsi,%rsp
  je     L60
L171:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L171
L60:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  je     L53
  orq    $0x0,-0x8(%rsp,%rcx,1)
L53:
  movzbl 0x1(%rbx),%edi
  mov    %rsp,-0x60(%rbp)
  test   %dil,%dil
  je     L149
  mov    -0x50(%rbp),%r14
  nopl   0x0(%rax)
L70:
  movzbl 0x1(%r15),%r13d
  add    $0x2,%r15
  add    $0x1,%r14
  call   <__get_raw@plt>
  mov    %eax,%ebx
  movzbl %r13b,%edi
  call   <__get_raw@plt>
  shl    $0x4,%ebx
  or     %eax,%ebx
  mov    %bl,-0x1(%r14)
  movzbl (%r15),%edi
  test   %dil,%dil
  jne    L70
L149:
  mov    -0x58(%rbp),%rax
  movzbl 0x1(%rax),%edi
  test   %dil,%dil
  je     L71
  mov    -0x60(%rbp),%r15
  nopl   0x0(%rax,%rax,1)
L62:
  movzbl 0x1(%r12),%r13d
  add    $0x2,%r12
  add    $0x1,%r15
  call   <__get_raw@plt>
  mov    %eax,%ebx
  movzbl %r13b,%edi
  call   <__get_raw@plt>
  shl    $0x4,%ebx
  or     %eax,%ebx
  mov    %bl,-0x1(%r15)
  movzbl (%r12),%edi
  test   %dil,%dil
  jne    L62
L71:
  mov    D7(%rip),%rax
  mov    -0x68(%rbp),%rbx
  mov    -0x48(%rbp),%rdx
  mov    -0x50(%rbp),%rsi
  mov    (%rax),%ecx
  mov    %rbx,%rdi
  call   <generate_hash@plt>
  mov    D7(%rip),%rax
  mov    -0x60(%rbp),%rsi
  mov    %rbx,%rdi
  mov    (%rax),%edx
  call   <memcmp@plt>
  mov    $0x3,%edx
  test   %eax,%eax
  cmovne %edx,%eax
  jmp    L173
L115:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int verify_hash(char *given_password, char *stored_password) {
  char *stored_salt, *stored_hash, *algorithm;
  if (*stored_password != '$')
    return 4;
  stored_password++;
  algorithm = stored_password;
  stored_salt = strchr(algorithm, '$');
  if (!stored_salt)
    return 4;
  *stored_salt = 0;
  stored_salt++;
  stored_hash = strchr(stored_salt, '$');
  if (!stored_hash)
    return 4;
  *stored_hash = 0;
  stored_hash++;
  unsigned char salt[SHA512_DIGEST_LENGTH];
  unsigned char hash[SHA512_DIGEST_LENGTH];
  unsigned char compare_hash[SHA512_DIGEST_LENGTH];
  int i = 0;
  while (*stored_salt) {
    unsigned char v1, v2;
    v1 = *stored_salt;
    v2 = *(stored_salt + 1);
    v1 = __get_raw(v1);
    v2 = __get_raw(v2);
    salt[i] = (v1 << 4) | v2;
    stored_salt += 2;
    i++;
  }
  i = 0;
  while (*stored_hash) {
    unsigned char v1, v2;
    v1 = *stored_hash;
    v2 = *(stored_hash + 1);
    v1 = __get_raw(v1);
    v2 = __get_raw(v2);
    compare_hash[i] = (v1 << 4) | v2;
    stored_hash += 2;
    i++;
  }
  generate_hash(hash, salt, given_password, SHA512_DIGEST_LENGTH);
  if (!memcmp(hash, compare_hash, SHA512_DIGEST_LENGTH))
    return 0;
  return 3;
}
```