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

```asm
<magic>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rcx,%r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0xb8,%rsp
  mov    0xf0(%rsp),%rax
  mov    %rdi,0x38(%rsp)
  mov    %rdx,%rdi
  mov    %rsi,0x40(%rsp)
  mov    %rcx,%rsi
  mov    %rax,(%rsp)
  mov    0xf8(%rsp),%rax
  mov    %r8,0x70(%rsp)
  mov    %rax,0x50(%rsp)
  mov    0x100(%rsp),%rax
  mov    %r9,0x8(%rsp)
  mov    %rax,0x18(%rsp)
  mov    0x108(%rsp),%rax
  mov    %rax,0x78(%rsp)
  mov    0x110(%rsp),%rax
  mov    %rax,0x10(%rsp)
  mov    0x118(%rsp),%rax
  mov    %rax,0x58(%rsp)
  mov    0x120(%rsp),%rax
  mov    %rax,0x28(%rsp)
  mov    0x128(%rsp),%rax
  mov    %rax,0x20(%rsp)
  mov    0x130(%rsp),%rax
  mov    %rax,0x48(%rsp)
  mov    0x138(%rsp),%eax
  mov    %eax,0x98(%rsp)
  mov    0x140(%rsp),%rax
  mov    %rax,0x30(%rsp)
  mov    0x148(%rsp),%rax
  mov    0x168(%rsp),%r13
  mov    %rax,0x60(%rsp)
  mov    0x150(%rsp),%rax
  mov    %rax,0x68(%rsp)
  mov    0x158(%rsp),%rax
  mov    %rax,0x80(%rsp)
  mov    0x160(%rsp),%rax
  mov    %rax,0x88(%rsp)
  mov    0x170(%rsp),%rax
  mov    %rax,0x90(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0xa8(%rsp)
  xor    %eax,%eax
  call   <magiccount@plt>
  mov    %eax,%r15d
  test   %r13,%r13
  je     L868
  cmpl   $0x1,0x0(%r13)
  je     L133
L868:
  test   %r15d,%r15d
  je     L420
  jg     L323
L878:
  cmpl   $0x1,0x98(%rsp)
  sete   %r14b
  cmp    $0x2,%r15d
  setg   %bl
  and    %r14d,%ebx
  cmp    $0x1,%r15d
  jg     L515
L260:
  cmp    $0x3,%r15d
  jle    L492
  cmpl   $0x1,0x98(%rsp)
  je     L502
  cmp    $0x4,%r15d
  je     L10
  lea    D91(%rip),%rdi
  xor    %r14d,%r14d
  call   <printf@plt>
  movb   $0x0,0x9f(%rsp)
  cmp    $0x6,%r15d
  jle    L849
  nopl   0x0(%rax,%rax,1)
L547:
  lea    D27(%rip),%rdi
  call   <printf@plt>
  cmp    $0x7,%r15d
  jle    L745
L846:
  lea    D96(%rip),%rdi
  call   <printf@plt>
  cmp    $0x8,%r15d
  jle    L118
L488:
  lea    D129(%rip),%rdi
  call   <printf@plt>
  cmp    $0x9,%r15d
  jle    L38
L490:
  lea    D10(%rip),%rdi
  call   <printf@plt>
  cmp    $0xa,%r15d
  jle    L111
L190:
  lea    D163(%rip),%rdi
  call   <printf@plt>
  cmp    $0xe,%r15d
  jle    L92
L833:
  lea    D102(%rip),%rdi
  call   <printf@plt>
  jmp    L92
  nopl   0x0(%rax)
L515:
  lea    D130(%rip),%rdi
  call   <printf@plt>
  test   %bl,%bl
  je     L260
  lea    D151(%rip),%rdi
  mov    %ebx,%r14d
  call   <printf@plt>
  cmp    $0x3,%r15d
  jne    L502
L492:
  cmp    $0x5,%r15d
  setg   %al
  and    %r14d,%eax
  mov    %al,0x9f(%rsp)
L865:
  cmp    $0x6,%r15d
  jg     L547
L849:
  cmp    $0x7,%r15d
  jg     L846
L745:
  cmp    $0x8,%r15d
  jg     L488
L118:
  cmp    $0x9,%r15d
  jg     L490
L38:
  cmp    $0xa,%r15d
  jg     L190
L111:
  cmp    $0xe,%r15d
  jg     L833
L92:
  lea    0xa4(%rsp),%rdi
  call   <getint@plt>
  mov    0xa4(%rsp),%eax
  test   %eax,%eax
  je     L713
  test   %r15d,%r15d
  setg   %cl
  cmp    $0x1,%eax
  jne    L159
  test   %cl,%cl
  jne    L357
L159:
  cmp    $0x2,%eax
  jne    L575
  test   %cl,%cl
  jne    L195
L575:
  cmp    $0x1,%r15d
  jle    L659
  cmp    $0x3,%eax
  je     L19
L659:
  cmp    $0x4,%eax
  jne    L576
  test   %bl,%bl
  jne    L464
L576:
  cmp    $0x5,%eax
  je     L730
  cmp    $0x6,%eax
  je     L28
  cmp    $0x7,%eax
  jne    L425
  cmp    $0x4,%r15d
  jle    L832
  test   %r14b,%r14b
  je     L832
  mov    0x88(%rsp),%rdx
  mov    %r13,%rcx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <superstrength@plt>
  xchg   %ax,%ax
L713:
  mov    0xa8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L654
  add    $0xb8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L323:
  lea    D25(%rip),%rdi
  call   <printf@plt>
  jmp    L878
  nopl   0x0(%rax)
L10:
  xor    %r14d,%r14d
  jmp    L492
L730:
  cmp    $0x3,%r15d
  jle    L155
  test   %r14b,%r14b
  jne    L331
L155:
  cmp    $0x9,%eax
  jne    L832
  cmpb   $0x0,0x9f(%rsp)
  jne    L362
L832:
  cmp    $0xa,%eax
  jne    L784
  cmp    $0x6,%r15d
  jg     L51
L784:
  cmp    $0xb,%eax
  jne    L481
  cmp    $0x7,%r15d
  jg     L793
L481:
  cmp    $0x8,%r15d
  setg   %cl
  cmp    $0xc,%eax
  jne    L600
  test   %cl,%cl
  jne    L212
L600:
  cmp    $0xd,%eax
  jne    L577
  test   %cl,%cl
  jne    L12
L577:
  cmp    $0xe,%eax
  jne    L647
  cmp    $0x9,%r15d
  jg     L722
L647:
  cmp    $0xf,%eax
  jne    L164
  cmp    $0xa,%r15d
  jle    L164
  push   %r13
  mov    0xa0(%rsp),%eax
  mov    %r12,%rcx
  mov    %rbp,%rdx
  push   %rax
  push   0x30(%rsp)
  push   0x28(%rsp)
  push   0x98(%rsp)
  push   0x40(%rsp)
  push   0x80(%rsp)
  push   0x38(%rsp)
  mov    0x48(%rsp),%r9
  mov    0xb0(%rsp),%r8
  mov    0x80(%rsp),%rsi
  mov    0x78(%rsp),%rdi
  call   <genieofluck@plt>
  add    $0x40,%rsp
  jmp    L713
  nopl   0x0(%rax)
L502:
  lea    D74(%rip),%rdi
  mov    $0x1,%r14d
  call   <printf@plt>
  cmp    $0x4,%r15d
  jle    L492
  lea    D141(%rip),%rdi
  call   <printf@plt>
  lea    D91(%rip),%rdi
  call   <printf@plt>
  cmp    $0x5,%r15d
  jle    L508
  lea    D92(%rip),%rdi
  mov    $0x1,%r14d
  call   <printf@plt>
  movb   $0x1,0x9f(%rsp)
  jmp    L865
  nopl   (%rax)
L195:
  mov    0x8(%rsp),%rdx
  mov    %r13,%rcx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <futureperception@plt>
  jmp    L713
  nopl   0x0(%rax,%rax,1)
L19:
  mov    0x40(%rsp),%rsi
  mov    0x38(%rsp),%rdi
  mov    %r13,%r8
  mov    %r12,%rcx
  mov    %rbp,%rdx
  call   <healing@plt>
  jmp    L713
  nopl   (%rax)
L164:
  cmp    $0xe,%r15d
  setg   %dl
  cmp    $0x10,%eax
  jne    L280
  test   %dl,%dl
  je     L280
  mov    (%rsp),%rdx
  xor    %r9d,%r9d
  mov    $0x6,%ecx
  mov    %r12,%rsi
  mov    0x98(%rsp),%r8d
  mov    %rbp,%rdi
  call   <stonestatue@plt>
  jmp    L713
  nopl   0x0(%rax)
L280:
  cmp    $0x11,%eax
  jne    L704
  test   %dl,%dl
  je     L704
  mov    0x18(%rsp),%rdx
  xor    %r8d,%r8d
  mov    %r13,%rcx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <godvision@plt>
  jmp    L713
  nopl   0x0(%rax)
L704:
  lea    D59(%rip),%rdi
  call   <printf@plt>
  jmp    L713
  nopl   0x0(%rax)
L420:
  mov    0xa8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L654
  lea    D76(%rip),%rdi
L340:
  add    $0xb8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    11c0 <printf@plt>
  nopl   0x0(%rax)
L28:
  cmp    $0x3,%r15d
  jle    L155
  test   %r14b,%r14b
  je     L155
  mov    0x80(%rsp),%rdx
  mov    %r13,%rcx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <doubleattack@plt>
  jmp    L713
  xchg   %ax,%ax
L133:
  mov    0xa8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L654
  lea    D124(%rip),%rdi
  jmp    L340
L357:
  mov    (%rsp),%rdx
  mov    %r13,%rcx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <remotevision@plt>
  jmp    L713
  nopw   0x0(%rax,%rax,1)
L464:
  push   0x48(%rsp)
  mov    %r12,%rsi
  mov    %rbp,%rdi
  push   0x28(%rsp)
  push   0x40(%rsp)
  push   0x40(%rsp)
  push   0x78(%rsp)
  push   0x38(%rsp)
  mov    0x48(%rsp),%r9
  mov    0x80(%rsp),%r8
  mov    0x30(%rsp),%rcx
  mov    0x38(%rsp),%rdx
  call   <escape@plt>
  add    $0x30,%rsp
  jmp    L713
  nopl   0x0(%rax,%rax,1)
L331:
  mov    0x68(%rsp),%rcx
  mov    0x60(%rsp),%rdx
  mov    %r13,%r8
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <paralysis@plt>
  jmp    L713
  nopl   (%rax)
L12:
  sub    $0x8,%rsp
  mov    %r12,%rsi
  mov    %rbp,%rdi
  push   %r13
  mov    0x38(%rsp),%r9
  mov    0xa8(%rsp),%r8d
  mov    0x20(%rsp),%rcx
  mov    0x10(%rsp),%rdx
  call   <hellbomb@plt>
  pop    %rax
  pop    %rdx
  jmp    L713
  nopw   0x0(%rax,%rax,1)
L722:
  mov    0x48(%rsp),%rdx
  mov    %r13,%rcx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <curse@plt>
  jmp    L713
  nopl   0x0(%rax,%rax,1)
L425:
  cmp    $0x8,%eax
  jne    L155
  cmp    $0x4,%r15d
  jle    L155
  mov    0x20(%rsp),%rdx
  mov    %r13,%rcx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <antimagic@plt>
  jmp    L713
  nopl   0x0(%rax,%rax,1)
L362:
  sub    $0x8,%rsp
  mov    %r12,%rcx
  mov    %rbp,%rdx
  push   0x38(%rsp)
  push   0xa0(%rsp)
  push   0x60(%rsp)
  push   0x40(%rsp)
  push   0x50(%rsp)
  push   0x88(%rsp)
  push   0x48(%rsp)
  push   0xb8(%rsp)
  push   0x60(%rsp)
  push   0xa0(%rsp)
  push   0x58(%rsp)
  mov    0x68(%rsp),%r9
  mov    0xd0(%rsp),%r8
  mov    0xa0(%rsp),%rsi
  mov    0x98(%rsp),%rdi
  call   <stealingspirit@plt>
  add    $0x60,%rsp
  jmp    L713
  nopl   (%rax)
L51:
  push   %r13
  mov    %r12,%rsi
  mov    %rbp,%rdi
  push   0x38(%rsp)
  mov    0x38(%rsp),%r9
  mov    0x20(%rsp),%r8
  mov    0x10(%rsp),%rcx
  mov    0x18(%rsp),%rdx
  call   <bodyswitch@plt>
  pop    %rcx
  pop    %rsi
  jmp    L713
  nopl   0x0(%rax)
L793:
  sub    $0x8,%rsp
  mov    %r12,%rsi
  mov    %rbp,%rdi
  mov    0xa0(%rsp),%eax
  push   %rax
  push   0x58(%rsp)
  push   0x38(%rsp)
  push   0x50(%rsp)
  push   0x50(%rsp)
  push   0x88(%rsp)
  push   0x48(%rsp)
  mov    0x58(%rsp),%r9
  mov    0x90(%rsp),%r8
  mov    0x40(%rsp),%rcx
  mov    0x48(%rsp),%rdx
  call   <teleport@plt>
  add    $0x40,%rsp
  jmp    L713
  nopw   0x0(%rax,%rax,1)
L212:
  mov    0x18(%rsp),%rdx
  mov    %r13,%rcx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <revelation@plt>
  jmp    L713
L654:
  call   <__stack_chk_fail@plt>
L508:
  movb   $0x0,0x9f(%rsp)
  mov    $0x1,%r14d
  jmp    L865
```

tool_calls: name: parse_data
arguments: tag: D91
datatype: string
name: parse_data
arguments: tag: D27
datatype: string
name: parse_data
arguments: tag: D96
datatype: string
name: parse_data
arguments: tag: D129
datatype: string
name: parse_data
arguments: tag: D10
datatype: string
name: parse_data
arguments: tag: D163
datatype: string
name: parse_data
arguments: tag: D102
datatype: string
name: parse_data
arguments: tag: D130
datatype: string
name: parse_data
arguments: tag: D151
datatype: string
name: parse_data
arguments: tag: D25
datatype: string
name: parse_data
arguments: tag: D74
datatype: string
name: parse_data
arguments: tag: D141
datatype: string
name: parse_data
arguments: tag: D92
datatype: string
name: parse_data
arguments: tag: D59
datatype: string
name: parse_data
arguments: tag: D76
datatype: string
name: parse_data
arguments: tag: D124
datatype: string

tool: D91: [8]: AntiMagic


tool: D27: [10]: BodySwitch


tool: D96: [11]: Teleport


tool: D129: [12]: Revelation
[13]: HellBomb


tool: D10: [14]: Curse


tool: D163: [15]: GenieofLuck


tool: D102: [16]: StoneStatue
[17]: GodVision


tool: D130: [3]: Healing


tool: D151: [4]: Escape


tool: D25: What spell do you want to cast?
[0]: Nothing
[1]: RemoteVision
[2]: FuturePerception


tool: D74: [5]: Paralysis
[6]: DoubleAttack


tool: D141: [7]: SuperStrength


tool: D92: [9]: StealingSpirit


tool: D59: You can't do that!


tool: D76: You don't have magic potions.


tool: D124: You are exausted and can't do magic.


assistant: ```c
void magic(int *hpmax, int *hpnow, int *aces, int *inv, int *slave, int *future, int *map, int *loot, int *vision, int *end, int *pos, int *floor, int *start, int *antimag, int *checkcurse, int combat, int *control, int *contator, int *modenemy, int *datt, int *modatt, int *nomag, char *s) {
  int v = magiccount(aces, inv);
  int k;
  if ((nomag) && (*nomag == 1)) {
    printf("You are exausted and can't do magic.\n");
    return;
  }
  if (v == 0) {
    printf("You don't have magic potions.\n");
    return;
  }
  if (v >= 1)
    printf("What spell do you want to cast?\n[0]: Nothing\n[1]: RemoteVision\n[2]: FuturePerception\n");
  if (v >= 2)
    printf("[3]: Healing\n");
  if ((v >= 3) && (combat == 1))
    printf("[4]: Escape\n");
  if (v >= 4) {
    if (combat == 1)
      printf("[5]: Paralysis\n[6]: DoubleAttack\n");
  }
  if (v >= 5) {
    if (combat == 1)
      printf("[7]: SuperStrength\n");
    printf("[8]: AntiMagic\n");
  }
  if ((v >= 6) && (combat == 1))
    printf("[9]: StealingSpirit\n");
  if (v >= 7)
    printf("[10]: BodySwitch\n");
  if (v >= 8)
    printf("[11]: Teleport\n");
  if (v >= 9)
    printf("[12]: Revelation\n[13]: HellBomb\n");
  if (v >= 10)
    printf("[14]: Curse\n");
  if (v >= 11)
    printf("[15]: GenieofLuck\n");
  if (v >= 15)
    printf("[16]: StoneStatue\n[17]: GodVision\n");
  getint(&k);
  if (k == 0)
    return;
  if ((k == 1) && (v >= 1))
    remotevision(aces, inv, map, nomag);
  else if ((k == 2) && (v >= 1))
    futureperception(aces, inv, future, nomag);
  else if ((k == 3) && (v >= 2))
    healing(hpmax, hpnow, aces, inv, nomag);
  else if ((k == 4) && (v >= 3) && (combat == 1))
    escape(aces, inv, future, map, loot, vision, pos, floor, start, control, antimag, checkcurse);
  else if ((k == 5) && (v >= 4) && (combat == 1))
    paralysis(aces, inv, contator, modenemy, nomag);
  else if ((k == 6) && (v >= 4) && (combat == 1))
    doubleattack(aces, inv, datt, nomag);
  else if ((k == 7) && (v >= 5) && (combat == 1))
    superstrength(aces, inv, modatt, nomag);
  else if ((k == 8) && (v >= 5))
    antimagic(aces, inv, antimag, nomag);
  else if ((k == 9) && (v >= 6) && (combat == 1))
    stealingspirit(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end, pos, floor, start, antimag, checkcurse, s, control);
  else if ((k == 10) && (v >= 7))
    bodyswitch(aces, inv, future, map, pos, start, control, nomag);
  else if ((k == 11) && (v >= 8))
    teleport(aces, inv, future, map, loot, vision, pos, floor, start, control, antimag, checkcurse, combat);
  else if ((k == 12) && (v >= 9))
    revelation(aces, inv, vision, nomag);
  else if ((k == 13) && (v >= 9))
    hellbomb(aces, inv, map, pos, combat, start, nomag);
  else if ((k == 14) && (v >= 10))
    curse(aces, inv, checkcurse, nomag);
  else if ((k == 15) && (v >= 11))
    genieofluck(hpmax, hpnow, aces, inv, slave, future, map, loot, vision, end, pos, antimag, combat, nomag);
  else if ((k == 16) && (v >= 15))
    stonestatue(aces, inv, map, 6, combat, 0);
  else if ((k == 17) && (v >= 15))
    godvision(aces, inv, vision, nomag, 0);
  else
    printf("You can't do that!\n");
}
```