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

```asm
<generate_leak>:
  endbr64
  push   %r12
  mov    %esi,%r12d
  lea    D55(%rip),%rsi
  push   %rbp
  mov    %rdi,%rbp
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rsp)
  call   <strcmp@plt>
  test   %rax,%rax
  je     L153
  lea    D96(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L160
  lea    D57(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L4
  lea    D127(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L72
  lea    D137(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L175
  lea    D71(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L129
  lea    D92(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L6
  lea    D163(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L9
  lea    D1(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L102
  mov    %rbp,%rsi
  lea    D85(%rip),%rdi
  call   <printf@plt>
  jmp    L108
  nop
L160:
  mov    $0x1,%esi
  mov    %r12d,%edi
  call   <calloc@plt>
  lea    D34(%rip),%rdi
  mov    %rax,%rsi
  call   <printf@plt>
L108:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L185
  add    $0x18,%rsp
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L153:
  mov    %r12d,%edi
  call   <malloc@plt>
  lea    D179(%rip),%rdi
  mov    %rax,%rsi
  call   <printf@plt>
  jmp    L108
  nopl   0x0(%rax)
L72:
  mov    %rsp,%rdi
  mov    %r12d,%edx
  mov    $0x200,%esi
  call   <posix_memalign@plt>
  mov    (%rsp),%rsi
  lea    D183(%rip),%rdi
  call   <printf@plt>
  jmp    L108
  nopw   0x0(%rax,%rax,1)
L4:
  mov    $0xa,%edi
  call   <malloc@plt>
  mov    %r12d,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  lea    D166(%rip),%rdi
  mov    %rax,%rsi
  call   <printf@plt>
  jmp    L108
  nopl   0x0(%rax)
L175:
  mov    %r12d,%edi
  call   <valloc@plt>
  lea    D90(%rip),%rdi
  mov    %rax,%rsi
  call   <printf@plt>
  jmp    L108
  nopl   0x0(%rax)
L9:
  mov    %r12d,%esi
  mov    $0x200,%edi
  call   <aligned_alloc@plt>
  lea    D17(%rip),%rdi
  mov    %rax,%rsi
  call   <printf@plt>
  jmp    L108
  nopl   0x0(%rax)
L129:
  mov    %r12d,%esi
  mov    $0x200,%edi
  call   <memalign@plt>
  lea    D167(%rip),%rdi
  mov    %rax,%rsi
  call   <printf@plt>
  jmp    L108
  nopl   0x0(%rax)
L6:
  mov    %r12d,%edi
  call   <pvalloc@plt>
  lea    D95(%rip),%rdi
  mov    %rax,%rsi
  call   <printf@plt>
  jmp    L108
  nopl   0x0(%rax)
L102:
  mov    %r12d,%edi
  call   <malloc@plt>
  lea    D177(%rip),%rdi
  mov    %rax,%rbp
  mov    %rax,%rsi
  call   <printf@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  jmp    L108
L185:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D55
type_guessed: string
name: read_data
arguments: label: D96
type_guessed: string
name: read_data
arguments: label: D57
type_guessed: string
name: read_data
arguments: label: D127
type_guessed: string
name: read_data
arguments: label: D137
type_guessed: string
name: read_data
arguments: label: D71
type_guessed: string
name: read_data
arguments: label: D92
type_guessed: string
name: read_data
arguments: label: D163
type_guessed: string
name: read_data
arguments: label: D1
type_guessed: string
name: read_data
arguments: label: D85
type_guessed: string
name: read_data
arguments: label: D34
type_guessed: string
name: read_data
arguments: label: D179
type_guessed: string
name: read_data
arguments: label: D183
type_guessed: string
name: read_data
arguments: label: D166
type_guessed: string
name: read_data
arguments: label: D90
type_guessed: string
name: read_data
arguments: label: D17
type_guessed: string
name: read_data
arguments: label: D167
type_guessed: string
name: read_data
arguments: label: D95
type_guessed: string
name: read_data
arguments: label: D177
type_guessed: string

tool: D55: malloc

tool: D96: calloc

tool: D57: realloc

tool: D127: posix_memalign

tool: D137: valloc

tool: D71: memalign

tool: D92: pvalloc

tool: D163: aligned_alloc

tool: D1: no_leak

tool: D85: unknown leak type '%s'


tool: D34: leaking via calloc, %p


tool: D179: leaking via malloc, %p


tool: D183: leaking via posix_memalign, %p


tool: D166: leaking via realloc, %p


tool: D90: leaking via valloc, %p


tool: D17: leaking via aligned_alloc, %p


tool: D167: leaking via memalign, %p


tool: D95: leaking via pvalloc, %p


tool: D177: ptr = %p


assistant: ```c
void generate_leak(const char *kind, int amount) {
  void *ptr = NULL;
  if (strcmp(kind, "malloc") == 0) {
    printf("leaking via malloc, %p\n", malloc(amount));
    return;
  }
  if (strcmp(kind, "calloc") == 0) {
    printf("leaking via calloc, %p\n", calloc(amount, 1));
    return;
  }
  if (strcmp(kind, "realloc") == 0) {
    printf("leaking via realloc, %p\n", realloc(malloc(10), amount));
    return;
  }
  if (strcmp(kind, "posix_memalign") == 0) {
    posix_memalign(&ptr, 512, amount);
    printf("leaking via posix_memalign, %p\n", ptr);
    return;
  }
  if (strcmp(kind, "valloc") == 0) {
    printf("leaking via valloc, %p\n", valloc(amount));
    return;
  }
  if (strcmp(kind, "memalign") == 0) {
    printf("leaking via memalign, %p\n", memalign(512, amount));
    return;
  }
  if (strcmp(kind, "pvalloc") == 0) {
    printf("leaking via pvalloc, %p\n", pvalloc(amount));
    return;
  }
  if (strcmp(kind, "aligned_alloc") == 0) {
    printf("leaking via aligned_alloc, %p\n", aligned_alloc(512, amount));
    return;
  }
  if (strcmp(kind, "no_leak") == 0) {
    void *ptr = malloc(amount);
    printf("ptr = %p\n", ptr);
    free(ptr);
    return;
  }
  printf("unknown leak type '%s'\n", kind);
}
```