user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1d8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x1c8(%rsp)
  xor    %eax,%eax
  lea    0x20(%rsp),%rdx
  lea    0x1c(%rsp),%rsi
  lea    D27(%rip),%rdi
  call   <scanf@plt>
  movl   $0x0,0xc(%rsp)
  lea    D33(%rip),%r12
  lea    D27(%rip),%r14
  jmp    L127
L9:
  mov    0x24(%rsp),%edx
  lea    0x1(%rbp),%eax
  cmp    %edx,%eax
  jge    L81
  movslq %ebp,%rcx
  lea    0x30(%rsp,%rcx,4),%rax
  sub    $0x2,%edx
  sub    %ebp,%edx
  add    %rcx,%rdx
  lea    0x34(%rsp,%rdx,4),%rcx
L124:
  mov    0x4(%rax),%edx
  mov    %edx,(%rax)
  add    $0x4,%rax
  cmp    %rcx,%rax
  jne    L124
L81:
  add    $0x1,%ebx
  cmp    %ebx,0x24(%rsp)
  jle    L11
L103:
  lea    0x2c(%rsp),%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  mov    0x28(%rsp),%eax
  cmp    %eax,0x2c(%rsp)
  jne    L9
  add    $0x1,%ebp
  jmp    L81
L11:
  add    $0x1,%r13d
  cmp    %r13d,0x20(%rsp)
  jle    L90
L95:
  mov    %r15,%rdx
  mov    (%rsp),%rsi
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  cmpl   $0x0,0x24(%rsp)
  jle    L11
  mov    $0x0,%ebx
  mov    $0x0,%ebp
  jmp    L103
L90:
  mov    0x30(%rsp),%esi
  lea    D2(%rip),%rdi
  call   <printf@plt>
  lea    0x20(%rsp),%rdx
  lea    0x1c(%rsp),%rsi
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
L127:
  mov    0x1c(%rsp),%eax
  or     0x20(%rsp),%eax
  je     L7
  addl   $0x1,0xc(%rsp)
  mov    0xc(%rsp),%eax
  mov    %eax,%esi
  lea    D32(%rip),%rdi
  call   <printf@plt>
  cmpl   $0x0,0x1c(%rsp)
  jle    L15
  lea    0x30(%rsp),%rbp
  mov    $0x0,%ebx
L93:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  add    $0x1,%ebx
  add    $0x4,%rbp
  cmp    %ebx,0x1c(%rsp)
  jg     L93
L15:
  cmpl   $0x0,0x20(%rsp)
  jle    L90
  mov    $0x0,%r13d
  lea    0x28(%rsp),%r15
  lea    0x24(%rsp),%rax
  mov    %rax,(%rsp)
  jmp    L95
L7:
  mov    0x1c8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L45
  mov    $0x0,%eax
  add    $0x1d8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L45:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D27
type: string
name: extract_symbolic_data
arguments: label: D33
type: string
name: extract_symbolic_data
arguments: label: D2
type: string
name: extract_symbolic_data
arguments: label: D32
type: string

tool: D27: %d %d

tool: D33: %d

tool: D2: %d



tool: D32: Teste %d


assistant: ```c
int main() {
  int teste = 0;
  int participantes, rodadas;
  int part[100];
  int npart;
  int ordem;
  int acao;
  int posacao;
  int i, j, k;
  scanf("%d %d", &participantes, &rodadas);
  while (participantes || rodadas) {
    printf("Teste %d\n", ++teste);
    for (i = 0; i < participantes; i++)
      scanf("%d", &(part[i]));
    for (i = 0; i < rodadas; i++) {
      scanf("%d %d", &npart, &ordem);
      posacao = 0;
      for (j = 0; j < npart; j++) {
        scanf("%d", &acao);
        if (acao == ordem)
          posacao++;
        else
          for (k = posacao + 1; k < npart; k++)
            part[k - 1] = part[k];
      }
    }
    printf("%d\n\n", part[0]);
    scanf("%d %d", &participantes, &rodadas);
  }
  return 0;
}
```