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

```asm
<removemost>:
  endbr64
  push   %r13
  mov    %rdi,%r13
  mov    %rdx,%rdi
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rcx,%rbp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <checkpositiveace@plt>
  test   %rax,%rax
  je     L117
  cmpl   $0x1,0x4(%rbx)
  je     L66
  cmpl   $0x1,(%rbx)
  je     L41
  cmpl   $0x1,0x8(%rbx)
  je     L98
  cmpl   $0x1,0xc(%rbx)
  je     L2
L117:
  mov    %rbp,%rdi
  call   <checkpositiveinv@plt>
  test   %eax,%eax
  je     L116
  mov    %rbp,%rdi
  mov    %rsp,%r12
  call   <mostvalueinv@plt>
  mov    0x0(%rbp),%esi
  mov    %r12,%rdi
  call   <nameitem@plt>
  mov    %r12,%rsi
  lea    D59(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  movl   $0x0,0x0(%rbp)
L49:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L56
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L116:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L56
  lea    D29(%rip),%rdi
L52:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    10c0 <puts@plt>
  nopw   0x0(%rax,%rax,1)
L98:
  movl   $0x0,0x8(%rbx)
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L56
  lea    D31(%rip),%rdi
  jmp    L52
L2:
  movl   $0x0,0xc(%rbx)
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L56
  lea    D32(%rip),%rdi
  jmp    L52
L66:
  movl   $0x0,0x4(%rbx)
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L56
  lea    D40(%rip),%rdi
  jmp    L52
L41:
  movl   $0x0,(%rbx)
  lea    D2(%rip),%rdi
  call   <puts@plt>
  mov    0x0(%r13),%eax
  lea    -0x5(%rax),%edi
  mov    %edi,0x0(%r13)
  mov    (%r12),%esi
  call   <min@plt>
  mov    %eax,(%r12)
  jmp    L49
L56:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D59
type: string
name: retrieve_data
arguments: data_tag: D29
type: string
name: retrieve_data
arguments: data_tag: D31
type: string
name: retrieve_data
arguments: data_tag: D32
type: string
name: retrieve_data
arguments: data_tag: D40
type: string
name: retrieve_data
arguments: data_tag: D2
type: string

tool: D59: 'Not bad, I will take your %s.'
The black priestess disappears!


tool: D29: 'Damn, your bag is empty!'
The black priestess disappears!

tool: D31: 'Nice, I will take your Scepter of Leynos.'
The black priestess disappears!

tool: D32: 'Nice, I will take your Bracelet of Armok.'
The black priestess disappears!

tool: D40: 'Nice, I will take your Bag of Meres.'
The black priestess disappears!

tool: D2: 'Nice, I will take your Ruby of Gaza.'
The black priestess disappears!

assistant: ```c
void removemost(int *hpmax, int *hpnow, int *aces, int *inv) {
  if (checkpositiveace(aces)) {
    if (*(aces + 1) == 1) {
      *(aces + 1) = 0;
      printf("'Nice, I will take your Bag of Meres.'\nThe black priestess disappears!\n");
      return;
    }
    if (*(aces) == 1) {
      *(aces) = 0;
      printf("'Nice, I will take your Ruby of Gaza.'\nThe black priestess disappears!\n");
      *hpmax = *hpmax - 5;
      *hpnow = min(*hpmax, *hpnow);
      return;
    }
    if (*(aces + 2) == 1) {
      *(aces + 2) = 0;
      printf("'Nice, I will take your Scepter of Leynos.'\nThe black priestess disappears!\n");
      return;
    }
    if (*(aces + 3) == 1) {
      *(aces + 3) = 0;
      printf("'Nice, I will take your Bracelet of Armok.'\nThe black priestess disappears!\n");
      return;
    }
  }
  if (!checkpositiveinv(inv)) {
    printf("'Damn, your bag is empty!'\nThe black priestess disappears!\n");
    return;
  }
  int p = mostvalueinv(inv);
  if (p = 0) {
    printf("'I can't take anything from you!'\nThe black priestess disappears!\n");
    return;
  }
  char s[20];
  nameitem(s, *(inv + p));
  printf("'Not bad, I will take your %s.'\nThe black priestess disappears!\n", s);
  *(inv + p) = 0;
}
```