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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  lea    -0x44(%rbp),%rdx
  lea    -0x48(%rbp),%rsi
  push   %r13
  lea    D0(%rip),%r13
  push   %r12
  mov    %r13,%rdi
  push   %rbx
  sub    $0x38,%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     L285
L233:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rdi,%rsp
  jne    L233
L285:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  jne    L138
L82:
  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
L188:
  cmp    %rdi,%rsp
  je     L103
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L188
L138:
  orq    $0x0,-0x8(%rsp,%rcx,1)
  jmp    L82
L103:
  and    $0xfff,%ecx
  sub    %rcx,%rsp
  test   %rcx,%rcx
  jne    L181
L223:
  mov    %rsp,%r15
  test   %esi,%esi
  jle    L115
  shl    $0x2,%rdx
  xor    %esi,%esi
  mov    %r14,%rdi
  call   <memset@plt>
L115:
  test   %ebx,%ebx
  jle    L79
  lea    -0x3c(%rbp),%rax
  lea    -0x40(%rbp),%rbx
  mov    %r13,%rdi
  mov    $0x1,%r12d
  mov    %rax,%rdx
  mov    %rbx,%rsi
  mov    %rax,-0x60(%rbp)
  call   <scanf@plt>
  mov    -0x40(%rbp),%ecx
  lea    -0x1(%rcx),%eax
  mov    %ecx,-0x58(%rbp)
  movslq %eax,%rdx
  mov    %eax,-0x54(%rbp)
  mov    -0x3c(%rbp),%eax
  add    (%r14,%rdx,4),%eax
  mov    %eax,(%r14,%rdx,4)
  jmp    L104
  nopl   0x0(%rax)
L176:
  movslq -0x54(%rbp),%rdx
  mov    %rdx,%rcx
  mov    (%r14,%rdx,4),%edx
  cmp    %edx,%eax
  jg     L160
  mov    %edx,%eax
  jne    L280
  cmp    %ecx,%r10d
  jg     L280
L160:
  mov    %edi,-0x54(%rbp)
  mov    %r10d,-0x58(%rbp)
L280:
  add    $0x1,%r12
L104:
  mov    %eax,-0x4(%r15,%r12,8)
  mov    -0x58(%rbp),%ecx
  mov    -0x44(%rbp),%eax
  mov    %ecx,-0x8(%r15,%r12,8)
  cmp    %r12d,%eax
  jle    L113
  mov    -0x60(%rbp),%rdx
  mov    %rbx,%rsi
  mov    %r13,%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
  jg     L176
  movslq -0x54(%rbp),%rax
  mov    %rax,%rcx
  mov    (%r14,%rax,4),%eax
  cmp    %ecx,%edi
  jne    L280
  movslq -0x48(%rbp),%r10
  test   %r10d,%r10d
  jle    L280
  mov    %ecx,%edi
  xor    %edx,%edx
  jmp    L136
  nopl   (%rax)
L93:
  jne    L37
  cmp    %edx,%edi
  jle    L37
L2:
  add    $0x1,%rdx
  mov    -0x54(%rbp),%edi
  cmp    %r10,%rdx
  je     L200
L136:
  mov    (%r14,%rdx,4),%esi
  mov    %edx,-0x54(%rbp)
  cmp    %eax,%esi
  jle    L93
  add    $0x1,%rdx
  mov    -0x54(%rbp),%edi
  mov    %esi,%eax
  cmp    %r10,%rdx
  jne    L136
L200:
  add    $0x1,%edi
  mov    %edi,-0x58(%rbp)
  jmp    L280
  xchg   %ax,%ax
L113:
  test   %eax,%eax
  jle    L79
  xor    %ebx,%ebx
  lea    D15(%rip),%r12
  nopl   (%rax)
L109:
  mov    0x4(%r15,%rbx,8),%edx
  mov    (%r15,%rbx,8),%esi
  mov    %r12,%rdi
  add    $0x1,%rbx
  call   <printf@plt>
  cmp    %ebx,-0x44(%rbp)
  jg     L109
L79:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L84
  lea    -0x28(%rbp),%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L37:
  mov    %edi,-0x54(%rbp)
  jmp    L2
L181:
  orq    $0x0,-0x8(%rsp,%rcx,1)
  jmp    L223
L84:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D0
data_type: string
name: extract_symbolic_data
arguments: data_tag: D15
data_type: string

tool: D0: %d %d

tool: D15: %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;
}
```