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

```asm
<btr>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %edi,0x14(%rsp)
  mov    %esi,%r14d
  mov    %edx,0xc(%rsp)
  mov    %ecx,0x10(%rsp)
  mov    %r8d,%r15d
  mov    %r9d,0x18(%rsp)
  mov    0x78(%rsp),%r13d
  cmp    $0x4,%edi
  je     L114
  test   %r13d,%r13d
  js     L124
  mov    %r8d,%edi
  add    %edi,%edi
  mov    %edi,0x28(%rsp)
  js     L124
  mov    0x70(%rsp),%eax
  mov    0x80(%rsp),%esi
  lea    (%rax,%rsi,2),%eax
  lea    0x0(,%rdx,4),%esi
  mov    %esi,0x1c(%rsp)
  mov    %edi,0x24(%rsp)
  add    %edi,%eax
  mov    %eax,0x2c(%rsp)
  mov    %r14d,0x20(%rsp)
  mov    0x90(%rsp),%r14d
  jmp    L88
L114:
  mov    0x70(%rsp),%eax
  mov    0x80(%rsp),%esi
  lea    (%rax,%rsi,2),%edx
  lea    (%r8,%r8,1),%eax
  cmp    %r13d,%eax
  cmovg  %r13d,%eax
  add    %eax,%edx
  add    0x90(%rsp),%edx
  add    0xa0(%rsp),%edx
  push   $0x0
  push   $0x0
  push   $0x0
  push   $0x0
  push   $0x0
  push   $0x0
  push   $0x0
  push   $0x0
  push   $0x0
  push   %r8
  mov    0x60(%rsp),%r9d
  mov    0x5c(%rsp),%r8d
  mov    $0x0,%ecx
  mov    %r14d,%esi
  mov    $0x4,%edi
  call   <buy@plt>
  add    $0x50,%rsp
L124:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L91:
  mov    0xa8(%rsp),%edi
  push   %rdi
  mov    0xa8(%rsp),%edx
  add    0xa0(%rsp),%edx
  push   %rdx
  push   $0x0
  push   %r12
  push   %rbp
  mov    0xa8(%rsp),%edi
  push   %rdi
  push   %r13
  mov    0x50(%rsp),%edx
  add    0xa8(%rsp),%edx
  push   %rdx
  push   $0x0
  push   %r15
  mov    0x60(%rsp),%r9d
  mov    0x5c(%rsp),%r8d
  mov    0x58(%rsp),%ecx
  mov    %eax,%edx
  mov    0x70(%rsp),%esi
  mov    0x64(%rsp),%edi
  call   <buy@plt>
  add    $0x50,%rsp
L135:
  add    $0x1,%ebp
  add    $0x1,%ebx
  sub    $0x1,%r12d
  cmp    %ebp,%r14d
  jl     L86
L34:
  mov    %ebx,%eax
  mov    %ebx,%edx
  add    0xa0(%rsp),%edx
  cmp    %edx,0x1c(%rsp)
  jle    L75
  test   $0x3,%bl
  je     L91
  cltd
  shr    $0x1e,%edx
  lea    (%rbx,%rdx,1),%ecx
  and    $0x3,%ecx
  sub    %ecx,%edx
  lea    0x4(%rdx),%ecx
  cmp    0xa0(%rsp),%ecx
  jg     L91
  lea    0x6(%rbx),%edx
  add    $0x3,%eax
  cmovns %eax,%edx
  and    $0xfffffffc,%edx
  mov    0xa8(%rsp),%eax
  push   %rax
  mov    0xa8(%rsp),%eax
  add    0xa0(%rsp),%eax
  sub    %ecx,%eax
  push   %rax
  push   $0x0
  push   %r12
  push   %rbp
  mov    0xa8(%rsp),%eax
  push   %rax
  push   %r13
  mov    0x50(%rsp),%eax
  add    0xa8(%rsp),%eax
  push   %rax
  push   $0x0
  push   %r15
  mov    0x60(%rsp),%r9d
  mov    0x5c(%rsp),%r8d
  mov    0x58(%rsp),%ecx
  mov    0x70(%rsp),%esi
  mov    0x64(%rsp),%edi
  call   <buy@plt>
  add    $0x50,%rsp
  jmp    L135
L75:
  mov    0xa8(%rsp),%eax
  push   %rax
  mov    0xa0(%rsp),%eax
  push   %rax
  push   $0x0
  push   %r12
  push   %rbp
  mov    0xa8(%rsp),%eax
  push   %rax
  push   %r13
  mov    0x50(%rsp),%eax
  add    0xa8(%rsp),%eax
  push   %rax
  push   $0x0
  push   %r15
  mov    0x60(%rsp),%r9d
  mov    0x5c(%rsp),%r8d
  mov    0x58(%rsp),%ecx
  mov    0x70(%rsp),%esi
  mov    0x64(%rsp),%edi
  call   <buy@plt>
  add    $0x50,%rsp
  jmp    L135
L86:
  mov    0x28(%rsp),%eax
  add    $0x1,%eax
  mov    0x24(%rsp),%ecx
  sub    %ecx,%eax
  cmp    %eax,%r13d
  jl     L124
  sub    $0x1,%ecx
  mov    %ecx,0x24(%rsp)
  cmp    $0xffffffff,%ecx
  je     L124
L88:
  test   %r14d,%r14d
  js     L86
  mov    0x2c(%rsp),%ebx
  mov    0x24(%rsp),%eax
  sub    %eax,%ebx
  mov    %r14d,%r12d
  add    0x88(%rsp),%r12d
  mov    $0x0,%ebp
  mov    %eax,0x8(%rsp)
  jmp    L34
```

assistant: ```c
void btr(int turn, int gold, int shield, int bomb, int animus, int tarsierw, int tarsier, int perforator, int shadowfang, int immolitew, int immolite, int nitrocybew, int nitrocybe, int nsup) {
  if (turn == 4) {
    int perf = perforator < animus * 2 ? perforator : animus * 2;
    buy(turn, gold, tarsier + shadowfang * 2 + perf + immolite + nitrocybe, 0, shield, bomb, animus, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  } else {
    for (int perf = 0; perf <= perforator && perf <= animus * 2; perf++) {
      for (int immo = 0; immo <= immolite; immo++) {
        int attack = tarsier + shadowfang * 2 + perf + immo;
        int red = animus * 2 - perf;
        if (shield * 4 > attack + nitrocybe && attack % 4 != 0 && nitrocybe >= (4 - attack % 4)) {
          buy(turn, gold, (attack + 3) / 4 * 4, red, shield, bomb, animus, 0, tarsierw + tarsier, perforator, shadowfang, immo, immolitew + immolite - immo, 0, nitrocybew + nitrocybe - (4 - attack % 4), nsup);
        } else if (shield * 4 > attack + nitrocybe) {
          buy(turn, gold, attack, red, shield, bomb, animus, 0, tarsierw + tarsier, perforator, shadowfang, immo, immolitew + immolite - immo, 0, nitrocybew + nitrocybe, nsup);
        } else {
          buy(turn, gold, attack + nitrocybe, red, shield, bomb, animus, 0, tarsierw + tarsier, perforator, shadowfang, immo, immolitew + immolite - immo, 0, nitrocybew, nsup);
        }
      }
    }
  }
}
```