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

```asm
<btr>:
  endbr64
  push   %r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  push   %r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  sub    $0x38,%rsp
  mov    %ecx,0x8(%rsp)
  mov    0x70(%rsp),%eax
  mov    %r8d,0xc(%rsp)
  cmp    $0x4,%edi
  je     L52
  mov    0x78(%rsp),%edx
  test   %edx,%edx
  js     L87
  mov    %r8d,%esi
  add    %esi,%esi
  mov    %esi,0x24(%rsp)
  js     L87
  mov    0x80(%rsp),%ecx
  add    $0x1,%esi
  mov    %edi,%r13d
  mov    %r14d,%r12d
  mov    %esi,0x2c(%rsp)
  mov    0x88(%rsp),%edx
  mov    0x90(%rsp),%esi
  lea    (%rax,%rcx,2),%edi
  add    %r9d,%eax
  lea    0x0(,%r14,4),%ecx
  mov    %eax,0x18(%rsp)
  mov    0xa0(%rsp),%eax
  add    %edx,%esi
  add    0x98(%rsp),%eax
  mov    %edi,0x28(%rsp)
  mov    %ecx,0x10(%rsp)
  movl   $0x0,0x20(%rsp)
  mov    %esi,0x14(%rsp)
  mov    %eax,0x1c(%rsp)
  nopl   0x0(%rax)
L103:
  mov    0x20(%rsp),%eax
  mov    0x24(%rsp),%r15d
  xor    %ebx,%ebx
  mov    0x28(%rsp),%r14d
  sub    %eax,%r15d
  add    %eax,%r14d
  mov    0x90(%rsp),%eax
  test   %eax,%eax
  js     L7
  mov    %r12d,%eax
  mov    %r14d,%r12d
  mov    %eax,%r14d
  jmp    L17
  nopl   0x0(%rax,%rax,1)
L61:
  test   $0x3,%r12b
  je     L111
  mov    %r12d,%edx
  sar    $0x1f,%edx
  shr    $0x1e,%edx
  lea    (%r12,%rdx,1),%ecx
  and    $0x3,%ecx
  sub    %ecx,%edx
  add    $0x4,%edx
  cmp    0xa0(%rsp),%edx
  jle    L8
L111:
  mov    0xa8(%rsp),%esi
  mov    %r14d,%r8d
  mov    %r12d,%edx
  mov    %r13d,%edi
  push   %rsi
  mov    0x24(%rsp),%ecx
  mov    %ebp,%esi
  push   %rcx
  mov    %r15d,%ecx
  push   $0x0
  push   %rax
  push   %rbx
  mov    0xa8(%rsp),%eax
  push   %rax
  mov    0xa8(%rsp),%eax
  push   %rax
  mov    0x50(%rsp),%eax
  push   %rax
  push   $0x0
  mov    0x54(%rsp),%eax
  push   %rax
  mov    0x58(%rsp),%r9d
  call   <buy@plt>
  add    $0x50,%rsp
L101:
  add    $0x1,%ebx
  add    $0x1,%r12d
  cmp    %ebx,0x90(%rsp)
  jl     L109
L17:
  mov    0xa0(%rsp),%edx
  mov    0x14(%rsp),%eax
  add    %r12d,%edx
  sub    %ebx,%eax
  cmp    %edx,0x10(%rsp)
  jg     L61
  mov    0xa8(%rsp),%esi
  mov    %r14d,%r8d
  mov    %r15d,%ecx
  add    $0x1,%r12d
  push   %rsi
  mov    0xa0(%rsp),%edi
  mov    %ebp,%esi
  push   %rdi
  mov    %r13d,%edi
  push   $0x0
  push   %rax
  push   %rbx
  mov    0xa8(%rsp),%eax
  add    $0x1,%ebx
  push   %rax
  mov    0xa8(%rsp),%eax
  push   %rax
  mov    0x50(%rsp),%eax
  push   %rax
  push   $0x0
  mov    0x54(%rsp),%eax
  push   %rax
  mov    0x58(%rsp),%r9d
  call   <buy@plt>
  add    $0x50,%rsp
  cmp    %ebx,0x90(%rsp)
  jge    L17
L109:
  mov    %r14d,%r12d
L7:
  addl   $0x1,0x20(%rsp)
  mov    0x20(%rsp),%eax
  cmp    %eax,0x78(%rsp)
  jl     L87
  cmp    %eax,0x2c(%rsp)
  jne    L103
L87:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L8:
  mov    %r12d,%ecx
  lea    0x6(%r12),%esi
  mov    %r14d,%r8d
  mov    %r13d,%edi
  add    $0x3,%ecx
  cmovns %ecx,%esi
  mov    0xa8(%rsp),%ecx
  push   %rcx
  mov    0x24(%rsp),%ecx
  and    $0xfffffffc,%esi
  sub    %edx,%ecx
  mov    %esi,%edx
  mov    %ebp,%esi
  push   %rcx
  mov    %r15d,%ecx
  push   $0x0
  push   %rax
  push   %rbx
  mov    0xa8(%rsp),%eax
  push   %rax
  mov    0xa8(%rsp),%eax
  push   %rax
  mov    0x50(%rsp),%eax
  push   %rax
  push   $0x0
  mov    0x54(%rsp),%eax
  push   %rax
  mov    0x58(%rsp),%r9d
  call   <buy@plt>
  add    $0x50,%rsp
  jmp    L101
L52:
  mov    0x80(%rsp),%esi
  mov    %r14d,%r8d
  mov    $0x4,%edi
  lea    (%rax,%rsi,2),%edx
  mov    0xc(%rsp),%esi
  lea    (%rsi,%rsi,1),%eax
  cmp    0x78(%rsp),%eax
  cmovg  0x78(%rsp),%eax
  xor    %ecx,%ecx
  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   %rsi
  mov    0x58(%rsp),%r9d
  mov    %ebp,%esi
  call   <buy@plt>
  add    $0x50,%rsp
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

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);
        }
      }
    }
  }
}
```