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
  push   %r13
  push   %r12
  push   %rbx
  lea    -0x186000(%rsp),%r11
L102:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L102
  sub    $0xa78,%rsp
  lea    D21(%rip),%rdi
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  lea    -0x186a70(%rbp),%rdx
  lea    -0x186a78(%rbp),%rsi
  call   <scanf@plt>
  mov    -0x186a78(%rbp),%rcx
  mov    %rsp,%rsi
  lea    0xf(,%rcx,8),%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rsi
  and    $0xfffffffffffffff0,%rdx
  cmp    %rsi,%rsp
  je     L43
L29:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L29
L43:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L24
L125:
  mov    %rsp,%r12
  test   %rcx,%rcx
  jle    L46
  xor    %ebx,%ebx
  nopw   0x0(%rax,%rax,1)
L5:
  mov    $0x8,%edi
  call   <malloc@plt>
  mov    %rax,(%r12,%rbx,8)
  add    $0x1,%rbx
  cmp    %rbx,-0x186a78(%rbp)
  jg     L5
L46:
  xor    %esi,%esi
  lea    -0x186a50(%rbp),%rdi
  mov    $0x186a1,%edx
  call   <memset@plt>
  lea    -0xc3540(%rbp),%r13
  xor    %esi,%esi
  mov    $0x186a1,%edx
  mov    %r13,%rdi
  call   <memset@plt>
  cmpq   $0x0,-0x186a70(%rbp)
  jle    L120
  lea    -0x186a58(%rbp),%rax
  xor    %r15d,%r15d
  xor    %ebx,%ebx
  xor    %r14d,%r14d
  mov    %rax,-0x186a98(%rbp)
  lea    -0x186a60(%rbp),%rax
  mov    %rax,-0x186a90(%rbp)
  lea    -0x186a68(%rbp),%rax
  mov    %rax,-0x186a88(%rbp)
  nopl   0x0(%rax)
L136:
  mov    -0x186a98(%rbp),%rcx
  mov    -0x186a90(%rbp),%rdx
  xor    %eax,%eax
  lea    D3(%rip),%rdi
  mov    -0x186a88(%rbp),%rsi
  call   <scanf@plt>
  mov    -0x186a60(%rbp),%rax
  xor    %r15,%rax
  cqto
  idivq  -0x186a78(%rbp)
  cmpq   $0x1,-0x186a68(%rbp)
  mov    %rdx,%rcx
  je     L9
  mov    -0x186a58(%rbp),%rax
  add    $0x1,%r14
  cqto
  idivq  -0x186a50(%rbp,%rcx,8)
  mov    (%r12,%rcx,8),%rax
  mov    (%rax,%rdx,8),%r15
  mov    %r15,-0xc3540(%rbp,%rbx,8)
  add    $0x1,%rbx
  cmp    %r14,-0x186a70(%rbp)
  jg     L136
L92:
  xor    %r12d,%r12d
  lea    D19(%rip),%r14
  nop
L25:
  mov    0x0(%r13,%r12,8),%rsi
  mov    %r14,%rdi
  add    $0x1,%r12
  call   <printf@plt>
  cmp    %rbx,%r12
  jne    L25
L120:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L34
  lea    -0x28(%rbp),%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopw   0x0(%rax,%rax,1)
L9:
  mov    -0x186a50(%rbp,%rdx,8),%rax
  mov    (%r12,%rdx,8),%rdi
  mov    %rdx,-0x186aa0(%rbp)
  add    $0x1,%r14
  lea    0x8(,%rax,8),%rsi
  call   <realloc@plt>
  mov    -0x186aa0(%rbp),%rcx
  mov    -0x186a58(%rbp),%rsi
  mov    -0x186a50(%rbp,%rcx,8),%rdx
  mov    %rax,(%r12,%rcx,8)
  mov    %rsi,(%rax,%rdx,8)
  addq   $0x1,-0x186a50(%rbp,%rcx,8)
  cmp    -0x186a70(%rbp),%r14
  jl     L136
  test   %rbx,%rbx
  jne    L92
  jmp    L120
L24:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L125
L34:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D21
type_infered: string
name: extract_symbolic_data
arguments: data_label: D3
type_infered: string
name: extract_symbolic_data
arguments: data_label: D19
type_infered: string

tool: D21: %lld %lld

tool: D3: %lld %lld %lld

tool: D19: %lld


assistant: ```c
int main() {
  long long n, q, i, l;
  long long idx[100001];
  long long out[100001];
  long long qn, x, y;
  long long lastAns;
  lastAns = 0;
  l = 0;
  scanf("%lld %lld", &n, &q);
  long long *arr[n];
  for (i = 0; i < n; i++)
    arr[i] = (long long *)malloc(sizeof(long long));
  memset(idx, 0, 100001);
  memset(out, 0, 100001);
  for (i = 0; i < q; i++) {
    scanf("%lld %lld %lld", &qn, &x, &y);
    long long seq = (x ^ lastAns) % n;
    if (qn == 1) {
      arr[seq] = realloc(arr[seq], (idx[seq] + 1) * sizeof(long long));
      arr[seq][idx[seq]] = y;
      idx[seq]++;
    } else {
      lastAns = arr[seq][y % idx[seq]];
      out[l] = lastAns;
      l++;
    }
  }
  for (i = 0; i < l; i++) {
    printf("%lld\n", out[i]);
  }
  return 0;
}
```