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

```asm
<brief2>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,0x10(%rsp)
  mov    %rsi,0x18(%rsp)
  mov    %rdx,0x28(%rsp)
  mov    %rcx,0x20(%rsp)
  mov    %r8,0x38(%rsp)
  mov    %r9d,0xc(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  movl   $0x0,0x44(%rsp)
  lea    D397(%rip),%r12
  lea    0x44(%rsp),%rbp
  lea    D386(%rip),%rbx
L156:
  mov    %r12,%rdi
  call   <puts@plt>
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  mov    $0x1,%ecx
  mov    $0x1,%edx
  mov    $0x0,%esi
  mov    0x44(%rsp),%edi
  mov    $0x0,%eax
  call   <teste@plt>
  mov    0x44(%rsp),%r14d
  cmp    $0x1,%r14d
  jne    L156
  lea    D1(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  cmpl   $0x0,0x90(%rsp)
  jle    L228
  mov    %r14d,%ebx
  lea    D218(%rip),%rbp
  mov    0x90(%rsp),%r12d
L460:
  mov    %ebx,%esi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x1,%ebx
  cmp    %ebx,%r12d
  jge    L460
L228:
  lea    D83(%rip),%rdi
  call   <puts@plt>
  cmpl   $0x0,0xc(%rsp)
  jle    L339
  mov    0x90(%rsp),%eax
  lea    -0x1(%rax),%eax
  lea    0x8(,%rax,8),%r12
  mov    $0x0,%r13d
  lea    D279(%rip),%r15
  mov    %r14d,0x34(%rsp)
  jmp    L122
L318:
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L167:
  add    $0x8,%rbx
  cmp    %r12,%rbx
  je     L412
L479:
  mov    0x0(%rbp),%rax
  mov    (%rax,%rbx,1),%rax
  mov    (%rax),%esi
  cmp    $0x7e,%esi
  je     L318
  cmpl   $0x1,0x4(%rax)
  jne    L318
  lea    D324(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L167
L412:
  cmp    $0x1,%r13d
  je     L49
  cmp    $0x2,%r13d
  je     L3
  cmp    $0x3,%r13d
  je     L383
  cmp    $0x4,%r13d
  je     L12
  lea    D83(%rip),%rdi
  call   <puts@plt>
  mov    %r14d,%r13d
L18:
  cmp    0xc(%rsp),%r13d
  jge    L371
L122:
  lea    0x1(%r13),%r14d
  mov    %r14d,%esi
  lea    D132(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  cmpl   $0x0,0x90(%rsp)
  jle    L412
  movslq %r13d,%rax
  mov    0x18(%rsp),%rcx
  lea    (%rcx,%rax,8),%rbp
  mov    $0x0,%ebx
  jmp    L479
L49:
  mov    0x20(%rsp),%rax
  mov    (%rax),%eax
  mov    %eax,0x30(%rsp)
  lea    0x1(%rax),%esi
  lea    D283(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x2,%r13d
  jmp    L18
L3:
  mov    0x28(%rsp),%rax
  mov    (%rax),%eax
  mov    %eax,0x30(%rsp)
  lea    0x1(%rax),%esi
  lea    D70(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x3,%r13d
  jmp    L18
L383:
  mov    0x38(%rsp),%rax
  mov    (%rax),%esi
  lea    D321(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x4,%r13d
  jmp    L18
L12:
  mov    0x98(%rsp),%esi
  lea    D191(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x5,%r13d
  jmp    L18
L137:
  mov    (%rax),%esi
  lea    D279(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L11:
  add    $0x8,%rbx
  cmp    %rbx,%r12
  je     L384
L80:
  mov    0x0(%rbp),%rax
  mov    (%rax,%rbx,1),%rax
  cmpl   $0x0,0x4(%rax)
  jne    L137
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L11
L384:
  lea    D83(%rip),%rdi
  call   <puts@plt>
  add    $0x8,%rbp
  cmp    0xc(%rsp),%r15d
  je     L4
L389:
  add    $0x1,%r15d
  mov    %r15d,%esi
  lea    D132(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  test   %r14d,%r14d
  jle    L384
  mov    $0x0,%ebx
  jmp    L80
L4:
  mov    0x18(%rsp),%r14d
L317:
  lea    D92(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    0x20(%rsp),%r15
  mov    %r15,%rsi
  lea    D386(%rip),%rbx
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  lea    D380(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    0x28(%rsp),%rbp
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  mov    $0x2,%ecx
  mov    0xc(%rsp),%edx
  mov    $0x1,%esi
  mov    %r15,%rbx
  mov    (%r15),%edi
  mov    $0x0,%eax
  call   <teste@plt>
  mov    $0x2,%ecx
  mov    0x90(%rsp),%edx
  mov    $0x1,%esi
  mov    %rbp,%r15
  mov    0x0(%rbp),%edi
  mov    $0x0,%eax
  call   <teste@plt>
  mov    %rbx,%rcx
  subl   $0x1,(%rbx)
  mov    0x0(%rbp),%eax
  mov    %eax,0x18(%rsp)
  sub    $0x1,%eax
  mov    %eax,0x0(%rbp)
  movslq (%rbx),%rdx
  cltq
  mov    0x10(%rsp),%rsi
  mov    (%rsi,%rdx,8),%rdx
  mov    (%rdx,%rax,8),%rax
  cmpl   $0x1,0x4(%rax)
  jne    L33
  lea    D379(%rip),%r13
  lea    D92(%rip),%r12
  lea    D386(%rip),%rbx
  lea    D380(%rip),%rbp
  mov    %r14d,0x18(%rsp)
  mov    %rcx,%r14
L237:
  mov    %r13,%rdi
  call   <puts@plt>
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %r14,%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %r15,%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  mov    $0x2,%ecx
  mov    0xc(%rsp),%edx
  mov    $0x1,%esi
  mov    (%r14),%edi
  mov    $0x0,%eax
  call   <teste@plt>
  mov    $0x2,%ecx
  mov    0x90(%rsp),%edx
  mov    $0x1,%esi
  mov    (%r15),%edi
  mov    $0x0,%eax
  call   <teste@plt>
  subl   $0x1,(%r14)
  mov    (%r15),%eax
  sub    $0x1,%eax
  mov    %eax,(%r15)
  movslq (%r14),%rdx
  cltq
  mov    0x10(%rsp),%rcx
  mov    (%rcx,%rdx,8),%rdx
  mov    (%rdx,%rax,8),%rax
  cmpl   $0x1,0x4(%rax)
  je     L237
  mov    0x18(%rsp),%r14d
L33:
  movl   $0x1,0x4(%rax)
  mov    $0x13,%ebx
L113:
  mov    $0xa,%edi
  call   <putchar@plt>
  sub    $0x1,%ebx
  jne    L113
  lea    D1(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  cmpl   $0x0,0x90(%rsp)
  jle    L464
  lea    D218(%rip),%rbx
  mov    0x90(%rsp),%ebp
L262:
  mov    %r14d,%esi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x1,%r14d
  cmp    %r14d,%ebp
  jge    L262
L464:
  lea    D83(%rip),%rdi
  call   <puts@plt>
  cmpl   $0x0,0xc(%rsp)
  jle    L369
  mov    0x10(%rsp),%rbp
  mov    0x90(%rsp),%eax
  lea    -0x1(%rax),%eax
  lea    0x8(,%rax,8),%r12
  mov    $0x0,%r15d
  lea    D279(%rip),%r14
  lea    D266(%rip),%r13
  jmp    L48
L100:
  mov    (%rax),%esi
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L485:
  add    $0x8,%rbx
  cmp    %rbx,%r12
  je     L135
L78:
  mov    0x0(%rbp),%rax
  mov    (%rax,%rbx,1),%rax
  cmpl   $0x0,0x4(%rax)
  jne    L100
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L485
L135:
  lea    D83(%rip),%rdi
  call   <puts@plt>
  add    $0x8,%rbp
  cmp    0xc(%rsp),%r15d
  je     L369
L48:
  add    $0x1,%r15d
  mov    %r15d,%esi
  lea    D132(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  cmpl   $0x0,0x90(%rsp)
  jle    L135
  mov    $0x0,%ebx
  jmp    L78
L369:
  mov    0x20(%rsp),%rax
  movslq (%rax),%rax
  mov    0x28(%rsp),%rdx
  movslq (%rdx),%rdx
  mov    0x10(%rsp),%rcx
  mov    (%rcx,%rax,8),%rax
  mov    (%rax,%rdx,8),%rax
  cmpl   $0x7e,(%rax)
  je     L102
  lea    D72(%rip),%rdi
  call   <puts@plt>
  mov    0x98(%rsp),%eax
  sub    $0x1,%eax
L331:
  mov    0x48(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L213
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L102:
  lea    D43(%rip),%rdi
  call   <puts@plt>
  mov    0x98(%rsp),%eax
  jmp    L331
L181:
  lea    D83(%rip),%rdi
  call   <puts@plt>
  jmp    L241
L371:
  mov    0x34(%rsp),%r14d
  lea    D234(%rip),%rdi
  call   <puts@plt>
  lea    D1(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  cmpl   $0x0,0x90(%rsp)
  jle    L181
L197:
  mov    %r14d,%ebx
  lea    D218(%rip),%rbp
  mov    0x90(%rsp),%r12d
L420:
  mov    %ebx,%esi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x1,%ebx
  cmp    %ebx,%r12d
  jge    L420
  lea    D83(%rip),%rdi
  call   <puts@plt>
  cmpl   $0x0,0xc(%rsp)
  jle    L317
L241:
  mov    0x10(%rsp),%rbp
  mov    0x90(%rsp),%eax
  lea    -0x1(%rax),%eax
  lea    0x8(,%rax,8),%r12
  mov    $0x0,%r15d
  lea    D266(%rip),%r13
  mov    %r14d,0x18(%rsp)
  mov    0x90(%rsp),%r14d
  jmp    L389
L339:
  lea    D234(%rip),%rdi
  call   <puts@plt>
  lea    D1(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  cmpl   $0x0,0x90(%rsp)
  jg     L197
  lea    D83(%rip),%rdi
  call   <puts@plt>
  jmp    L317
L213:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D397
data_type: string
name: retrieve_data
arguments: data_tag: D386
data_type: string
name: retrieve_data
arguments: data_tag: D1
data_type: string
name: retrieve_data
arguments: data_tag: D218
data_type: string
name: retrieve_data
arguments: data_tag: D83
data_type: string
name: retrieve_data
arguments: data_tag: D279
data_type: string
name: retrieve_data
arguments: data_tag: D324
data_type: string
name: retrieve_data
arguments: data_tag: D132
data_type: string
name: retrieve_data
arguments: data_tag: D283
data_type: string
name: retrieve_data
arguments: data_tag: D70
data_type: string
name: retrieve_data
arguments: data_tag: D321
data_type: string
name: retrieve_data
arguments: data_tag: D191
data_type: string
name: retrieve_data
arguments: data_tag: D92
data_type: string
name: retrieve_data
arguments: data_tag: D380
data_type: string
name: retrieve_data
arguments: data_tag: D379
data_type: string
name: retrieve_data
arguments: data_tag: D266
data_type: string
name: retrieve_data
arguments: data_tag: D72
data_type: string
name: retrieve_data
arguments: data_tag: D43
data_type: string
name: retrieve_data
arguments: data_tag: D234
data_type: string

tool: D397: Mesmo? (Sim: 1| Nao: 0)

tool: D386: %i

tool: D1:   

tool: D218: |%2i

tool: D83: |

tool: D279: |%2c

tool: D324: | *

tool: D132: %2i

tool: D283: |	 Ultima jogada (L): %2i


tool: D70: |	 Ultima jogada (C): %2i


tool: D321: |	 Seu life: %2i


tool: D191: |	 Life do adversario: %2i


tool: D92: 
 Proxima jogada: (linha)	

tool: D380: 
 Proxima jogada: (coluna)	

tool: D379: Voce ja atirou nesse quadrante. Escolha outro:

tool: D266: | ?

tool: D72: Ahoy! Voce acertou alguma coisa ali!

tool: D43: Voce acertou a agua, marujo! Mire melhor a proxima!

tool: D234: 
Seu tabuleiro eh o de cima


assistant: ```c
int brief2(int ***player1, int ***player2, int *lastx, int *lasty, int *pontlife, int linhas, int colunas, int lifepl) {
  int i, j;
  int bool = 0;
  while (bool != 1) {
    printf("Mesmo? (Sim: 1| Nao: 0)\n");
    scanf("%i", &bool);
    teste(bool, 0, 1, 1);
  }
  printf("  ");
  for (j = 1; j <= colunas; j++)
    printf("|%2i", j);
  printf("|\n");
  for (j = 0; j < linhas; j++) {
    printf("%2i", j + 1);
    for (int k = 0; k < colunas; k++) {
      if (player2[j][k][0] != '~' && player2[j][k][1] == 1)
        printf("| *");
      else
        printf("|%2c", player2[j][k][0]);
    }
    if (j == 1)
      printf("|\t Ultima jogada (L): %2i\n", *lasty + 1);
    else if (j == 2)
      printf("|\t Ultima jogada (C): %2i\n", *lastx + 1);
    else if (j == 3)
      printf("|\t Seu life: %2i\n", *pontlife);
    else if (j == 4)
      printf("|\t Life do adversario: %2i\n", lifepl);
    else
      printf("|\n");
  }
  printf("\nSeu tabuleiro eh o de cima\n\n");
  printf("  ");
  for (j = 1; j <= colunas; j++)
    printf("|%2i", j);
  printf("|\n");
  for (j = 0; j < linhas; j++) {
    printf("%2i", j + 1);
    for (int k = 0; k < colunas; k++) {
      if (player1[j][k][1] == 0)
        printf("| ?");
      else
        printf("|%2c", player1[j][k][0]);
    }
    printf("|\n");
  }
  printf("\n Proxima jogada: (linha)\t");
  scanf("%i", lasty);
  printf("\n Proxima jogada: (coluna)\t");
  scanf("%i", lastx);
  teste(*lasty, 1, linhas, 2);
  teste(*lastx, 1, colunas, 2);
  *lasty = *lasty - 1;
  *lastx = *lastx - 1;
  while (player1[*lasty][*lastx][1] == 1) {
    printf("Voce ja atirou nesse quadrante. Escolha outro:\n");
    printf("\n Proxima jogada: (linha)\t");
    scanf("%i", lasty);
    printf("\n Proxima jogada: (coluna)\t");
    scanf("%i", lastx);
    teste(*lasty, 1, linhas, 2);
    teste(*lastx, 1, colunas, 2);
    *lasty = *lasty - 1;
    *lastx = *lastx - 1;
  }
  player1[*lasty][*lastx][1] = 1;
  for (j = 1; j < 20; j++)
    printf("\n");
  printf("  ");
  for (j = 1; j <= colunas; j++)
    printf("|%2i", j);
  printf("|\n");
  for (j = 0; j < linhas; j++) {
    printf("%2i", j + 1);
    for (int k = 0; k < colunas; k++) {
      if (player1[j][k][1] == 0)
        printf("| ?");
      else
        printf("|%2c", player1[j][k][0]);
    }
    printf("|\n");
  }
  if (player1[*lasty][*lastx][0] == '~')
    printf("Voce acertou a agua, marujo! Mire melhor a proxima!\n");
  else {
    printf("Ahoy! Voce acertou alguma coisa ali!\n");
    lifepl--;
  }
  return (lifepl);
}
```