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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  lea    -0x44(%rbp),%rdx
  lea    -0x48(%rbp),%rsi
  push   %r13
  push   %r12
  lea    D3(%rip),%r12
  push   %rbx
  mov    %r12,%rdi
  sub    $0x48,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  call   <scanf@plt>
  movslq -0x48(%rbp),%rdx
  mov    %rsp,%rdi
  lea    0xf(,%rdx,4),%rax
  mov    %rdx,%rsi
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rdi
  and    $0xfffffffffffffff0,%rcx
  cmp    %rdi,%rsp
  je     L78
L135:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rdi,%rsp
  jne    L135
L78:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  jne    L99
L203:
  movslq -0x44(%rbp),%rax
  mov    %rsp,%rdi
  mov    %rsp,%r14
  mov    %rax,%rbx
  lea    0xf(,%rax,8),%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rax
  and    $0xfffffffffffffff0,%rcx
  sub    %rax,%rdi
L21:
  cmp    %rdi,%rsp
  je     L79
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L21
L99:
  orq    $0x0,-0x8(%rsp,%rcx,1)
  jmp    L203
L79:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  jne    L62
L183:
  lea    0x3(%rsp),%r8
  mov    %r8,%r15
  and    $0xfffffffffffffffc,%r8
  shr    $0x2,%r15
  mov    %r8,%r13
  test   %esi,%esi
  jle    L12
  shl    $0x2,%rdx
  xor    %esi,%esi
  mov    %r14,%rdi
  call   <memset@plt>
L12:
  test   %ebx,%ebx
  jle    L18
  lea    -0x40(%rbp),%rax
  lea    -0x3c(%rbp),%rdx
  mov    %r12,%rdi
  mov    %rax,%rsi
  mov    %rdx,-0x68(%rbp)
  mov    %rax,-0x60(%rbp)
  call   <scanf@plt>
  mov    -0x40(%rbp),%eax
  movd   -0x40(%rbp),%xmm0
  lea    -0x1(%rax),%ebx
  mov    -0x3c(%rbp),%eax
  movslq %ebx,%rcx
  add    (%r14,%rcx,4),%eax
  mov    %rcx,-0x58(%rbp)
  movd   %eax,%xmm2
  mov    %eax,(%r14,%rcx,4)
  mov    -0x44(%rbp),%eax
  punpckldq %xmm2,%xmm0
  movq   %xmm0,0x0(,%r15,4)
  mov    $0x1,%r15d
  cmp    $0x1,%eax
  jle    L178
  nopl   0x0(%rax)
L202:
  mov    -0x68(%rbp),%rdx
  mov    -0x60(%rbp),%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  mov    -0x40(%rbp),%r10d
  mov    -0x3c(%rbp),%edx
  lea    -0x1(%r10),%edi
  movslq %edi,%rsi
  mov    (%r14,%rsi,4),%eax
  add    %edx,%eax
  mov    %eax,(%r14,%rsi,4)
  test   %edx,%edx
  jle    L29
  mov    -0x58(%rbp),%rcx
  mov    (%r14,%rcx,4),%edx
  cmp    %edx,%eax
  jg     L42
  mov    %edx,%eax
  jne    L255
  cmp    %ebx,%r10d
  jg     L255
L42:
  mov    %edi,%ebx
L255:
  lea    0x1(%rbx),%ecx
  movd   %eax,%xmm1
  mov    -0x44(%rbp),%eax
  movd   %ecx,%xmm0
  punpckldq %xmm1,%xmm0
  movq   %xmm0,0x0(%r13,%r15,8)
  add    $0x1,%r15
  cmp    %r15d,%eax
  jle    L178
  movslq %ebx,%rax
  mov    %rax,-0x58(%rbp)
  jmp    L202
  cs nopw 0x0(%rax,%rax,1)
L29:
  mov    -0x58(%rbp),%rax
  mov    (%r14,%rax,4),%eax
  cmp    %ebx,%edi
  jne    L255
  movslq -0x48(%rbp),%r10
  test   %r10d,%r10d
  jle    L255
  mov    %ebx,%edi
  xor    %edx,%edx
  jmp    L269
  nopl   0x0(%rax,%rax,1)
L273:
  cmp    %edx,%edi
  jle    L280
  cmp    %esi,%eax
  jne    L280
L262:
  add    $0x1,%rdx
  cmp    %r10,%rdx
  je     L255
  mov    %ebx,%edi
L269:
  mov    (%r14,%rdx,4),%esi
  mov    %edx,%ebx
  cmp    %esi,%eax
  jge    L273
  mov    %esi,%eax
  jmp    L262
  nopl   0x0(%rax)
L178:
  test   %eax,%eax
  jle    L18
  xor    %ebx,%ebx
  lea    D2(%rip),%r12
  nopl   (%rax)
L232:
  mov    0x4(%r13,%rbx,8),%edx
  mov    0x0(%r13,%rbx,8),%esi
  mov    %r12,%rdi
  add    $0x1,%rbx
  call   <printf@plt>
  cmp    %ebx,-0x44(%rbp)
  jg     L232
L18:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L266
  lea    -0x28(%rbp),%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L280:
  mov    %edi,%ebx
  jmp    L262
L62:
  orq    $0x0,-0x8(%rsp,%rcx,1)
  jmp    L183
L266:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D3
type: string
name: parse_data
arguments: tag: D2
type: string

tool: D3: %d %d

tool: D2: %d %d


assistant: ```c
int main(void) {
  int n, q, a, v, i, j, max;
  scanf("%d %d", &n, &q);
  int fish[n], ans[q][2];
  for (i = 0; i < n; i++)
    fish[i] = 0;
  for (i = 0; i < q; i++) {
    scanf("%d %d", &a, &v);
    fish[a - 1] += v;
    if (i == 0) {
      max = a - 1;
    } else if (v > 0) {
      if (fish[a - 1] > fish[max] || (fish[a - 1] == fish[max] && a - 1 < max)) {
        max = a - 1;
      }
    } else if (a - 1 == max) {
      for (j = 0; j < n; j++) {
        if (fish[j] > fish[max] || (fish[j] == fish[max] && j < max)) {
          max = j;
        }
      }
    }
    ans[i][0] = max + 1;
    ans[i][1] = fish[max];
  }
  for (i = 0; i < q; i++)
    printf("%d %d\n", ans[i][0], ans[i][1]);
  return 0;
}
```