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

```asm
<gemoffer>:
  endbr64
  push   %r15
  pxor   %xmm0,%xmm0
  push   %r14
  xor    %r14d,%r14d
  push   %r13
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  push   %rbx
  mov    $0xffffffff,%ebx
  sub    $0xc8,%rsp
  mov    0x100(%rsp),%rax
  mov    %rdi,0x18(%rsp)
  lea    0x6c(%rsp),%rbp
  mov    %rsi,0x20(%rsp)
  mov    0x120(%rsp),%r15
  mov    %rax,0x40(%rsp)
  mov    0x108(%rsp),%rax
  mov    %rdx,0x28(%rsp)
  mov    %rax,0x8(%rsp)
  mov    0x110(%rsp),%rax
  mov    %r8,0x30(%rsp)
  mov    %rax,0x48(%rsp)
  mov    0x118(%rsp),%rax
  mov    %r9,0x38(%rsp)
  mov    %rax,0x50(%rsp)
  mov    0x128(%rsp),%rax
  mov    %rax,0x58(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0xb8(%rsp)
  xor    %eax,%eax
  movl   $0xa,0x6c(%rsp)
  movq   $0x0,0x90(%rsp)
  movaps %xmm0,0x70(%rsp)
  movaps %xmm0,0x80(%rsp)
  jmp    L315
  nopl   0x0(%rax)
L101:
  lea    -0xe(%rax),%edx
  cmp    $0x8,%edx
  ja     L313
  movslq %eax,%rdx
  mov    %eax,%ecx
  add    $0x1,%ebx
  imul   $0x4ec4ec4f,%rdx,%rdx
  sar    $0x1f,%ecx
  sar    $0x22,%rdx
  sub    %ecx,%edx
  lea    (%rdx,%rdx,2),%ecx
  lea    (%rdx,%rcx,4),%ecx
  mov    %eax,%edx
  sub    %ecx,%edx
  add    %edx,%r14d
  movslq %ebx,%rdx
  mov    %eax,0x70(%rsp,%rdx,4)
L210:
  movslq (%r15),%rax
  mov    0x8(%rsp),%r13
  mov    0x0(%r13,%rax,4),%edi
  call   <valueitem@plt>
  cmp    %r14d,%eax
  jle    L323
  movslq (%r15),%rax
  mov    0x0(%r13,%rax,4),%edi
  call   <valueitem@plt>
  mov    %r14d,%edx
  lea    D49(%rip),%rdi
  mov    %eax,%esi
  xor    %eax,%eax
  call   <printf@plt>
L322:
  movslq (%r15),%rax
  mov    0x8(%rsp),%rcx
  mov    (%rcx,%rax,4),%edi
  call   <valueitem@plt>
  cmp    %r14d,%eax
  jle    L262
L315:
  lea    D8(%rip),%rdi
  call   <puts@plt>
  mov    %rbp,%rdi
  call   <getint@plt>
  movslq 0x6c(%rsp),%rax
  cmp    $0x9,%eax
  ja     L219
  mov    (%r12,%rax,4),%eax
  test   %eax,%eax
  jne    L101
L219:
  lea    D67(%rip),%rdi
  call   <puts@plt>
  mov    %rbp,%rdi
  call   <getint@plt>
  cmpl   $0x1,0x6c(%rsp)
  jne    L210
  nopl   0x0(%rax)
L262:
  mov    0xb8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L82
  add    $0xc8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L323:
  mov    %r14d,%esi
  lea    D90(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    0xa0(%rsp),%r13
  movl   $0x0,0x6c(%rsp)
  xor    %eax,%eax
  cmp    $0xffffffff,%ebx
  je     L311
  nopl   0x0(%rax,%rax,1)
L76:
  cltq
  mov    %r13,%rdi
  mov    0x70(%rsp,%rax,4),%esi
  call   <nameitem@plt>
  mov    %r13,%rsi
  cmp    %ebx,0x6c(%rsp)
  je     L301
  lea    D65(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x6c(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0x6c(%rsp)
  cmp    %ebx,%eax
  jle    L76
L311:
  lea    0x1(%rbx),%eax
  movl   $0xffffffff,0x6c(%rsp)
  lea    D29(%rip),%r13
  mov    %eax,0x14(%rsp)
  jmp    L146
L173:
  cmp    $0x1,%eax
  je     L195
L32:
  test   %eax,%eax
  jns    L322
L146:
  mov    %r13,%rdi
  call   <puts@plt>
  mov    %rbp,%rdi
  call   <getint@plt>
  mov    0x6c(%rsp),%eax
  test   %eax,%eax
  jne    L173
  lea    D36(%rip),%rdi
  call   <puts@plt>
  mov    %rbp,%rdi
  call   <getint@plt>
  cmpl   $0x1,0x6c(%rsp)
  je     L38
  lea    D32(%rip),%rdi
  call   <puts@plt>
  mov    0x6c(%rsp),%eax
  test   %eax,%eax
  je     L38
  pxor   %xmm0,%xmm0
  movl   $0xa,0x6c(%rsp)
  mov    $0xffffffff,%ebx
  movq   $0x0,0x90(%rsp)
  movaps %xmm0,0x70(%rsp)
  movaps %xmm0,0x80(%rsp)
  jmp    L322
  nop
L195:
  movl   $0x0,0x6c(%rsp)
  cmp    $0xffffffff,%ebx
  je     L185
  movslq 0x70(%rsp),%rax
  movl   $0x0,(%r12,%rax,4)
  test   %ebx,%ebx
  je     L327
  movslq 0x74(%rsp),%rax
  movl   $0x0,(%r12,%rax,4)
  cmp    $0x1,%ebx
  je     L327
  movslq 0x78(%rsp),%rax
  movl   $0x0,(%r12,%rax,4)
  cmp    $0x2,%ebx
  je     L327
  movslq 0x7c(%rsp),%rax
  movl   $0x0,(%r12,%rax,4)
  cmp    $0x3,%ebx
  je     L327
  movslq 0x80(%rsp),%rax
  movl   $0x0,(%r12,%rax,4)
  cmp    $0x4,%ebx
  je     L327
  movslq 0x84(%rsp),%rax
  movl   $0x0,(%r12,%rax,4)
  cmp    $0x5,%ebx
  je     L327
  movslq 0x88(%rsp),%rax
  movl   $0x0,(%r12,%rax,4)
  cmp    $0x6,%ebx
  je     L327
  movslq 0x8c(%rsp),%rax
  movl   $0x0,(%r12,%rax,4)
  cmp    $0x7,%ebx
  je     L327
  movslq 0x90(%rsp),%rax
  movl   $0x0,(%r12,%rax,4)
  cmp    $0x8,%ebx
  je     L327
  movslq 0x94(%rsp),%rax
  movl   $0x0,(%r12,%rax,4)
L327:
  mov    0x14(%rsp),%eax
  mov    %eax,0x6c(%rsp)
L185:
  sub    $0x8,%rsp
  mov    %r12,%rcx
  push   $0x0
  push   $0x1
  push   $0x0
  push   0x78(%rsp)
  push   %r15
  push   0x80(%rsp)
  push   0x80(%rsp)
  push   0x48(%rsp)
  push   0x88(%rsp)
  mov    0x88(%rsp),%r9
  mov    0x80(%rsp),%r8
  mov    0x78(%rsp),%rdx
  mov    0x70(%rsp),%rsi
  mov    0x68(%rsp),%rdi
  call   <treasure@plt>
  mov    0xbc(%rsp),%eax
  add    $0x50,%rsp
  jmp    L32
  nopl   (%rax)
L301:
  lea    D80(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x6c(%rsp),%eax
  add    $0x1,%eax
  mov    %eax,0x6c(%rsp)
  cmp    %eax,%ebx
  jge    L76
  jmp    L311
  xchg   %ax,%ax
L313:
  lea    D4(%rip),%rdi
  call   <puts@plt>
  mov    %rbp,%rdi
  call   <getint@plt>
  cmpl   $0x1,0x6c(%rsp)
  jne    L210
L38:
  lea    D14(%rip),%rdi
  call   <puts@plt>
  jmp    L262
L82:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_label: D49
type: string
name: read_data
arguments: data_label: D8
type: string
name: read_data
arguments: data_label: D67
type: string
name: read_data
arguments: data_label: D90
type: string
name: read_data
arguments: data_label: D65
type: string
name: read_data
arguments: data_label: D29
type: string
name: read_data
arguments: data_label: D36
type: string
name: read_data
arguments: data_label: D32
type: string
name: read_data
arguments: data_label: D80
type: string
name: read_data
arguments: data_label: D4
type: string
name: read_data
arguments: data_label: D14
type: string

tool: D49: 'My item is valued %d gems and you offer is worth %d gems.'


tool: D8: 'What gem do you want to offer?'

tool: D67: 'Are you kidding me? Do you want to abort the trade?'
[0]: No
[1]: Yes

tool: D90: 'I'm satisfied with your offer of %d gems:

tool: D65:  %s gems,

tool: D29: 'Do you accept the trade?'
[0]: No
[1]: Yes

tool: D36: 'Do you want to abort the trade?'
[0]: No
[1]: Yes

tool: D32: 'Do you want to propose another offer?'
[0]: No
[1]: Yes

tool: D80:  %s gems.'


tool: D4: 'That's not a gem! Do you want to abort the trade?'
[0]: No
[1]: Yes

tool: D14: You aborted the trade.

assistant: ```c
void gemoffer(int *hpmax, int *hpnow, int *aces, int *inv, int *slave, int *future, int *map, int *loot, int *vision, int *end, int *pos, int *antimag) {
  int value = 0;
  int k;
  int offgem[10];
  for (k = 0; k < 10; k++) {
    offgem[k] = 0;
  }
  char s[20];
  int p = -1;
  do {
    printf("'What gem do you want to offer?'\n");
    getint(&k);
    if ((k < 0) || (k >= 10) || (*(inv + k) == 0)) {
      printf("'Are you kidding me? Do you want to abort the trade?'\n[0]: No\n[1]: Yes\n");
      getint(&k);
      if (k == 1)
        return;
    } else if ((*(inv + k) > 22) || (*(inv + k) < 14)) {
      printf("'That's not a gem! Do you want to abort the trade?'\n[0]: No\n[1]: Yes\n");
      getint(&k);
      if (k == 1) {
        printf("You aborted the trade.\n");
        return;
      }
    } else {
      value += *(inv + k) % 13;
      p++;
      offgem[p] = *(inv + k);
    }
    if (value < valueitem(*(loot + *pos)))
      printf("'My item is valued %d gems and you offer is worth %d gems.'\n", valueitem(*(loot + *pos)), value);
    else {
      printf("'I'm satisfied with your offer of %d gems:", value);
      for (k = 0; k <= p; k++) {
        nameitem(s, offgem[k]);
        if (k == p) {
          printf(" %s gems.'\n", s);
        } else {
          printf(" %s gems,", s);
        }
      }
      k = -1;
      do {
        printf("'Do you accept the trade?'\n[0]: No\n[1]: Yes\n");
        getint(&k);
        if (k == 0) {
          printf("'Do you want to abort the trade?'\n[0]: No\n[1]: Yes\n");
          getint(&k);
          if (k == 1) {
            printf("You aborted the trade.\n");
            return;
          }
          printf("'Do you want to propose another offer?'\n[0]: No\n[1]: Yes\n");
          if (k == 0) {
            printf("You aborted the trade.\n");
            return;
          }
          for (k = 0; k < 10; k++) {
            offgem[k] = 0;
          }
          p = -1;
        } else if (k == 1) {
          for (k = 0; k <= p; k++) {
            *(inv + offgem[k]) = 0;
          }
          treasure(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end, pos, antimag, 0, 1, 0);
        }
      } while (k < 0);
    }
  } while (value < valueitem(*(loot + *pos)));
}
```