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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0xc3000(%rsp),%r11
L119:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L119
  sub    $0x538,%rsp
  lea    D10(%rip),%r12
  mov    %r12,%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0xc3528(%rsp)
  xor    %eax,%eax
  lea    0x18(%rsp),%rsi
  lea    0x1c(%rsp),%rbx
  lea    0x20(%rsp),%r15
  lea    0x28(%rsp),%rbp
  call   <scanf@plt>
  mov    0x18(%rsp),%eax
  mov    %rbx,0x8(%rsp)
  lea    D17(%rip),%rbx
  lea    -0x1(%rax),%edx
  mov    %edx,0x18(%rsp)
  test   %eax,%eax
  je     L263
  nopl   0x0(%rax,%rax,1)
L109:
  mov    0x8(%rsp),%rsi
  mov    %r12,%rdi
  xor    %eax,%eax
  call   <scanf@plt>
  mov    0x1c(%rsp),%eax
  test   %eax,%eax
  jle    L179
  mov    %r15,%r14
  xor    %r13d,%r13d
  nopl   0x0(%rax)
L203:
  lea    0x4(%r14),%rdx
  mov    %r14,%rsi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <scanf@plt>
  mov    0x1c(%rsp),%ecx
  add    $0x1,%r13d
  add    $0x8,%r14
  cmp    %r13d,%ecx
  jg     L203
  test   %ecx,%ecx
  jle    L179
  lea    -0x2(%rcx),%r9d
  cmp    $0xffffffff,%r9d
  je     L131
  nopl   0x0(%rax)
L0:
  mov    %r9d,%eax
  mov    $0x1,%r8d
  lea    0x0(%rbp,%rax,8),%rdi
  mov    %r15,%rax
  nopl   0x0(%rax)
L134:
  mov    (%rax),%edx
  mov    0x8(%rax),%esi
  cmp    %esi,%edx
  jle    L168
  mov    %esi,(%rax)
  mov    0xc(%rax),%esi
  mov    0x4(%rax),%r8d
  mov    %edx,0x8(%rax)
  mov    %esi,0x4(%rax)
  mov    %r8d,0xc(%rax)
  xor    %r8d,%r8d
L168:
  add    $0x8,%rax
  cmp    %rax,%rdi
  jne    L134
  test   %r8d,%r8d
  jne    L131
  sub    $0x1,%r9d
  cmp    $0xffffffff,%r9d
  jne    L0
L131:
  xor    %r9d,%r9d
  nopw   0x0(%rax,%rax,1)
L166:
  movslq %r9d,%rax
  mov    0x20(%rsp,%rax,8),%edx
  lea    0x1(%r9),%eax
  cltq
  nopl   (%rax)
L28:
  mov    %edx,%esi
  mov    (%r15,%rax,8),%edx
  cmp    %eax,%ecx
  mov    %eax,%r13d
  setg   %dil
  cmp    %esi,%edx
  sete   %sil
  add    $0x1,%rax
  test   %sil,%dil
  jne    L28
  mov    %r13d,%edx
  mov    %r9d,%esi
  mov    %r15,%rdi
  call   <sortj@plt>
  mov    0x1c(%rsp),%ecx
  cmp    %ecx,%r13d
  jge    L125
  mov    %r13d,%r9d
  jmp    L166
  nopw   0x0(%rax,%rax,1)
L125:
  test   %ecx,%ecx
  jle    L179
  xor    %r8d,%r8d
  xor    %r9d,%r9d
  xchg   %ax,%ax
L138:
  lea    0x1(%r9),%eax
  movslq %eax,%rdx
  mov    0x20(%rsp,%rdx,8),%edi
  movslq %r9d,%rdx
  cmp    0x24(%rsp,%rdx,8),%edi
  jg     L226
  cmp    %eax,%ecx
  jle    L226
  lea    0x2(%r9),%eax
  mov    %r9d,%esi
  cltq
  jmp    L80
  nopl   0x0(%rax,%rax,1)
L83:
  lea    0x1(%rdx),%esi
  movslq %esi,%rsi
  mov    0x20(%rsp,%rsi,8),%edi
  mov    %edx,%esi
L80:
  movslq %esi,%r10
  mov    %eax,%r9d
  lea    0x1(%rsi),%edx
  cmp    %edi,0x20(%rsp,%r10,8)
  jne    L22
  cmp    %edx,%ecx
  jle    L22
L6:
  movslq %edx,%rsi
  mov    (%r15,%rax,8),%edi
  cmp    %edi,0x24(%rsp,%rsi,8)
  setge  %dil
  cmp    %eax,%ecx
  setg   %sil
  add    $0x1,%rax
  test   %sil,%dil
  jne    L83
  add    $0x1,%r8d
  cmp    %r9d,%ecx
  jg     L138
L258:
  mov    %r8d,%esi
  lea    D21(%rip),%rdi
  call   <printf@plt>
  mov    0x18(%rsp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,0x18(%rsp)
  test   %eax,%eax
  jne    L109
L263:
  mov    0xc3528(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L77
  add    $0xc3538,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L22:
  mov    %esi,%edx
  jmp    L6
  nopl   0x0(%rax)
L226:
  mov    %eax,%r9d
  add    $0x1,%r8d
  cmp    %r9d,%ecx
  jg     L138
  jmp    L258
L179:
  xor    %r8d,%r8d
  jmp    L258
L77:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_label: D10
type_infered: string
name: retrieve_data
arguments: data_label: D17
type_infered: string
name: retrieve_data
arguments: data_label: D21
type_infered: string

tool: D10: %d

tool: D17: %d %d

tool: D21: %d


assistant: ```c
int main() {
  int t, max, min, i, rare, j, N, count, a, b, temp1, temp2;
  scanf("%d", &t);
  int arr[100001][2];
  while (t--) {
    scanf("%d", &N);
    for (i = 0; i < N; i++) {
      scanf("%d %d", &arr[i][0], &arr[i][1]);
    }
    for (i = 0; i < N; i++) {
      rare = 1;
      for (j = 0; j < N - i - 1; j++)
        if (arr[j][0] > arr[j + 1][0]) {
          temp1 = arr[j][0];
          temp2 = arr[j][1];
          arr[j][0] = arr[j + 1][0];
          arr[j][1] = arr[j + 1][1];
          arr[j + 1][0] = temp1;
          arr[j + 1][1] = temp2;
          rare = 0;
        }
      if (rare)
        break;
    }
    int temp;
    for (i = 0; i < N; i++) {
      temp = i;
      while (arr[i][0] == arr[i + 1][0] && i + 1 < N)
        i++;
      sortj(arr, temp, i + 1);
    }
    count = 0;
    for (i = 0; i < N; i++) {
      j = i + 1;
      while ((arr[i][1] >= arr[j][0]) && (j < N)) {
        j++;
        if (arr[i][0] == arr[i + 1][0] && (i + 1) < N)
          i++;
      }
      i = j - 1;
      count++;
    }
    printf("%d\n", count);
  }
  return 0;
}
```