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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  lea    -0x7a1000(%rsp),%r11
L0:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L0
  sub    $0x260,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x7a1260(%rbp),%rax
  mov    %rax,%rsi
  lea    D32(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  movq   $0x1,-0x7a1238(%rbp)
  jmp    L130
L128:
  lea    -0x7a1250(%rbp),%rdx
  lea    -0x7a1258(%rbp),%rax
  mov    %rax,%rsi
  lea    D29(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  movq   $0x0,-0x7a1230(%rbp)
  jmp    L8
L112:
  movq   $0x0,-0x7a1228(%rbp)
  jmp    L177
L40:
  lea    -0x7a1210(%rbp),%rdx
  mov    -0x7a1230(%rbp),%rax
  imul   $0x3e8,%rax,%rcx
  mov    -0x7a1228(%rbp),%rax
  add    %rcx,%rax
  shl    $0x3,%rax
  add    %rdx,%rax
  mov    %rax,%rsi
  lea    D32(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  addq   $0x1,-0x7a1228(%rbp)
L177:
  mov    -0x7a1250(%rbp),%rax
  cmp    %rax,-0x7a1228(%rbp)
  jl     L40
  addq   $0x1,-0x7a1230(%rbp)
L8:
  mov    -0x7a1258(%rbp),%rax
  cmp    %rax,-0x7a1230(%rbp)
  jl     L112
  lea    D24(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  movq   $0x0,-0x7a1248(%rbp)
  jmp    L47
L104:
  movq   $0x0,-0x7a1240(%rbp)
  jmp    L151
L131:
  mov    -0x7a1248(%rbp),%rax
  imul   $0x3e8,%rax,%rdx
  mov    -0x7a1240(%rbp),%rax
  add    %rdx,%rax
  mov    -0x7a1210(%rbp,%rax,8),%rax
  mov    %rax,%rsi
  lea    D43(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  addq   $0x1,-0x7a1240(%rbp)
L151:
  mov    -0x7a1250(%rbp),%rax
  cmp    %rax,-0x7a1240(%rbp)
  jl     L131
  mov    $0xa,%edi
  call   <putchar@plt>
  addq   $0x1,-0x7a1248(%rbp)
L47:
  mov    -0x7a1258(%rbp),%rax
  cmp    %rax,-0x7a1248(%rbp)
  jl     L104
  mov    -0x7a1258(%rbp),%rax
  mov    %rax,-0x7a1220(%rbp)
  movq   $0x0,-0x7a1248(%rbp)
  jmp    L11
L116:
  mov    -0x7a1250(%rbp),%rax
  lea    -0x7a1210(%rbp),%rcx
  mov    -0x7a1248(%rbp),%rdx
  imul   $0x1f40,%rdx,%rdx
  add    %rcx,%rdx
  mov    %rax,%rsi
  mov    %rdx,%rdi
  call   <sort_rows@plt>
  addq   $0x1,-0x7a1248(%rbp)
L11:
  mov    -0x7a1248(%rbp),%rax
  cmp    -0x7a1220(%rbp),%rax
  jl     L116
  mov    -0x7a1250(%rbp),%rax
  mov    %rax,-0x7a1218(%rbp)
  movq   $0x0,-0x7a1248(%rbp)
  jmp    L65
L117:
  mov    -0x7a1218(%rbp),%rdx
  lea    -0x7a1210(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <sort_cols@plt>
  addq   $0x1,-0x7a1248(%rbp)
L65:
  mov    -0x7a1248(%rbp),%rax
  cmp    -0x7a1218(%rbp),%rax
  jl     L117
  lea    D46(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  movq   $0x0,-0x7a1248(%rbp)
  jmp    L84
L69:
  movq   $0x0,-0x7a1240(%rbp)
  jmp    L161
L85:
  mov    -0x7a1248(%rbp),%rax
  imul   $0x3e8,%rax,%rdx
  mov    -0x7a1240(%rbp),%rax
  add    %rdx,%rax
  mov    -0x7a1210(%rbp,%rax,8),%rax
  mov    %rax,%rsi
  lea    D43(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  addq   $0x1,-0x7a1240(%rbp)
L161:
  mov    -0x7a1250(%rbp),%rax
  cmp    %rax,-0x7a1240(%rbp)
  jl     L85
  mov    $0xa,%edi
  call   <putchar@plt>
  addq   $0x1,-0x7a1248(%rbp)
L84:
  mov    -0x7a1258(%rbp),%rax
  cmp    %rax,-0x7a1248(%rbp)
  jl     L69
  mov    $0xa,%edi
  call   <putchar@plt>
  addq   $0x1,-0x7a1238(%rbp)
L130:
  mov    -0x7a1260(%rbp),%rax
  cmp    %rax,-0x7a1238(%rbp)
  jle    L128
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L49
  call   <__stack_chk_fail@plt>
L49:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D32
type_guessed: string
name: disassemble_data
arguments: label: D29
type_guessed: string
name: disassemble_data
arguments: label: D24
type_guessed: string
name: disassemble_data
arguments: label: D43
type_guessed: string
name: disassemble_data
arguments: label: D46
type_guessed: string

tool: D32: %lld

tool: D29: %lld %lld

tool: D24: Original array:

tool: D43: %lld 

tool: D46: Sorted Array:

assistant: ```c
int main() {
  long long int arr[1000][1000];
  long long int i, j, row_size, col_size;
  long long int k, x, y, z, t, n, m;
  scanf("%lld", &t);
  for (k = 1; k <= t; k++) {
    scanf("%lld %lld", &n, &m);
    for (x = 0; x < n; x++) {
      for (y = 0; y < m; y++) {
        scanf("%lld", &arr[x][y]);
      }
    }
    printf("Original array:\n");
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        printf("%lld ", arr[i][j]);
      }
      printf("\n");
    }
    row_size = n;
    for (i = 0; i < row_size; i++) {
      sort_rows(arr[i], m);
    }
    col_size = m;
    for (i = 0; i < col_size; i++) {
      sort_cols(arr, col_size);
    }
    printf("Sorted Array:\n");
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        printf("%lld ", arr[i][j]);
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}
```