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

```asm
<string_to_key>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <Getc@plt>
  mov    %rax,%rbx
  mov    %eax,%r12d
  xor    %eax,%eax
  call   <Getc@plt>
  cmp    $0x2,%ebx
  je     L9
  mov    %eax,%ebp
  jle    L169
  cmp    $0x3,%ebx
  je     L122
  cmp    $0x65,%ebx
  jne    L78
  lea    0x4(%rsp),%r12
  lea    0x8(%rsp),%rbp
  mov    %r12,%rbx
L188:
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <Getc@plt>
  mov    %al,-0x1(%rbx)
  cmp    %rbp,%rbx
  jne    L188
  mov    $0x3,%edx
  lea    D16(%rip),%rsi
  mov    %r12,%rdi
  call   <memcmp@plt>
  test   %eax,%eax
  jne    L21
  movsbl 0x7(%rsp),%eax
  lea    0x3e8(%rax),%esi
  cmp    $0x1,%eax
  je     L189
  cmp    $0x3ea,%esi
  je     L22
  lea    D8(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
L95:
  xor    %r12d,%r12d
  jmp    L174
L169:
  test   %ebx,%ebx
  je     L67
  cmp    $0x1,%ebx
  jne    L78
  mov    $0x1,%esi
  lea    D71(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x9,%edi
  call   <putchar@plt>
  mov    %ebp,%edi
  call   <hash_algs@plt>
  lea    D18(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x8,%edi
  call   <dump@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  nopl   0x0(%rax,%rax,1)
L174:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L79
  add    $0x10,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L67:
  xor    %esi,%esi
  lea    D26(%rip),%rdi
  xor    %eax,%eax
  mov    $0x1,%r12d
  call   <printf@plt>
  mov    $0x9,%edi
  call   <putchar@plt>
  mov    %ebp,%edi
  call   <hash_algs@plt>
  jmp    L174
  nopl   0x0(%rax)
L9:
  mov    $0x2,%esi
  lea    D110(%rip),%rdi
  xor    %eax,%eax
  mov    $0x1,%r12d
  call   <printf@plt>
  jmp    L174
  nopl   0x0(%rax,%rax,1)
L122:
  mov    $0x3,%esi
  lea    D57(%rip),%rdi
  xor    %eax,%eax
  mov    $0x1,%r12d
  call   <printf@plt>
  mov    $0x9,%edi
  call   <putchar@plt>
  mov    %ebp,%edi
  call   <hash_algs@plt>
  lea    D18(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x8,%edi
  call   <dump@plt>
  mov    $0xa,%edi
  call   <putchar@plt>
  xor    %eax,%eax
  call   <Getc@plt>
  lea    D45(%rip),%rdi
  mov    %eax,%esi
  mov    %eax,%edx
  sar    $0x4,%eax
  and    $0xf,%esi
  lea    0x6(%rax),%ecx
  xor    %eax,%eax
  add    $0x10,%esi
  shl    %cl,%esi
  call   <printf@plt>
  jmp    L174
L78:
  mov    %r12d,%esi
  lea    D83(%rip),%rdi
  xor    %eax,%eax
  mov    $0x1,%r12d
  call   <printf@plt>
  jmp    L174
  nopl   0x0(%rax)
L21:
  mov    $0x65,%esi
  lea    D81(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L95
L189:
  mov    $0x3e9,%esi
  lea    D28(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L95
  nopl   0x0(%rax,%rax,1)
L22:
  xor    %eax,%eax
  call   <Getc@plt>
  mov    $0x3ea,%esi
  lea    D80(%rip),%rdi
  mov    %rax,%rbx
  xor    %eax,%eax
  call   <printf@plt>
  mov    %ebx,%edi
  call   <dump@plt>
  lea    D99(%rip),%rdi
  call   <puts@plt>
  jmp    L95
L79:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D16
data_type: string
name: retrieve_data
arguments: label: D8
data_type: string
name: retrieve_data
arguments: label: D71
data_type: string
name: retrieve_data
arguments: label: D18
data_type: string
name: retrieve_data
arguments: label: D26
data_type: string
name: retrieve_data
arguments: label: D110
data_type: string
name: retrieve_data
arguments: label: D57
data_type: string
name: retrieve_data
arguments: label: D45
data_type: string
name: retrieve_data
arguments: label: D83
data_type: string
name: retrieve_data
arguments: label: D81
data_type: string
name: retrieve_data
arguments: label: D28
data_type: string
name: retrieve_data
arguments: label: D80
data_type: string
name: retrieve_data
arguments: label: D99
data_type: string

tool: D16: GNU

tool: D8: 	GnuPG unknown extension (s2k %d)


tool: D71: 	Salted string-to-key(s2k %d):


tool: D18: 		Salt - 

tool: D26: 	Simple string-to-key(s2k %d):


tool: D110: 	Reserved string-to-key(s2k %d)


tool: D57: 	Iterated and salted string-to-key(s2k %d):


tool: D45: 		Count - %d(coded count %d)


tool: D83: 	Unknown string-to-key(s2k %d)


tool: D81: 	Private/experimental string-to-key(s2k %d)


tool: D28: 	GnuPG gnu-dummy (s2k %d)


tool: D80: 	GnuPG gnu-divert-to-card (s2k %d)
	Serial Number: 

tool: 

assistant: ```c
extern int string_to_key(void) {
  int has_iv = 1;
  int type = Getc();
  int hash = Getc();
  switch (type) {
  case 0:
    printf("\tSimple string-to-key(s2k %d):\n", type);
    printf("\t");
    hash_algs(hash);
    break;
  case 1:
    printf("\tSalted string-to-key(s2k %d):\n", type);
    printf("\t");
    hash_algs(hash);
    printf("\t\tSalt - ");
    dump(8);
    printf("\n");
    break;
  case 2:
    printf("\tReserved string-to-key(s2k %d)\n", type);
    break;
  case 3:
    printf("\tIterated and salted string-to-key(s2k %d):\n", type);
    printf("\t");
    hash_algs(hash);
    printf("\t\tSalt - ");
    dump(8);
    printf("\n");
    {
      int count, c = Getc();
      count = (16 + (c & 15)) << ((c >> 4) + 6);
      printf("\t\tCount - %d(coded count %d)\n", count, c);
    }
    break;
  case 101:
    has_iv = 0;
    {
      char temp[4];
      int j, snlen;
      for (j = 0; j < 4; j++)
        temp[j] = Getc();
      if (!memcmp(temp, "GNU", 3)) {
        type = 1000 + temp[3];
        switch (type) {
        case 1001:
          printf("\tGnuPG gnu-dummy (s2k %d)\n", type);
          break;
        case 1002:
          snlen = Getc();
          printf("\tGnuPG gnu-divert-to-card (s2k %d)\n\tSerial Number: ", type);
          dump(snlen);
          puts("");
          break;
        default:
          printf("\tGnuPG unknown extension (s2k %d)\n", type);
          break;
        }
      } else {
        printf("\tPrivate/experimental string-to-key(s2k %d)\n", type);
      }
    }
    break;
  default:
    printf("\tUnknown string-to-key(s2k %d)\n", type);
  }
  return has_iv;
}
```