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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  lea    D23(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  mov    -0x1c(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x1c(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  movl   $0x0,-0x34(%rbp)
  jmp    L146
L44:
  mov    -0x1c(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    -0x34(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  mov    %rax,(%rdx)
  addl   $0x1,-0x34(%rbp)
L146:
  mov    -0x34(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L44
  movl   $0x0,-0x30(%rbp)
  jmp    L88
L8:
  movl   $0x0,-0x2c(%rbp)
  jmp    L45
L129:
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x2c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,%esi
  lea    D23(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  addl   $0x1,-0x2c(%rbp)
L45:
  mov    -0x2c(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L129
  addl   $0x1,-0x30(%rbp)
L88:
  mov    -0x30(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L8
  lea    -0x38(%rbp),%rax
  mov    %rax,%rsi
  lea    D23(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  movl   $0x0,-0x28(%rbp)
  jmp    L11
L104:
  movl   $0x0,-0x24(%rbp)
  jmp    L100
L7:
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jne    L145
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    -0x24(%rbp),%edx
  add    $0x1,%edx
  mov    %edx,(%rax)
  jmp    L117
L145:
  addl   $0x1,-0x24(%rbp)
L100:
  mov    -0x24(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L7
L117:
  addl   $0x1,-0x28(%rbp)
L11:
  mov    -0x28(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L104
  movl   $0x0,-0x20(%rbp)
  jmp    L147
L23:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,%esi
  lea    D18(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  addl   $0x1,-0x20(%rbp)
L147:
  mov    -0x20(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L23
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L61
  call   <__stack_chk_fail@plt>
L61:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D23
type: string
name: disassemble_data
arguments: data_label: D18
type: string

tool: D23: %d

tool: D18: %d 

assistant: ```c
int main() {
  int **a, n, c;
  scanf("%d", n);
  int *b;
  b = (int *)malloc(n * sizeof(int));
  a = (int **)malloc(n * sizeof(int *));
  for (int p = 0; p < n; p++) {
    a[p] = (int *)malloc(n * sizeof(int));
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", a[i][j]);
    }
  }
  scanf("%d", &c);
  for (int q = 0; q < n; q++) {
    for (int r = 0; r < n; r++) {
      if (a[q][r] == 0) {
        b[q] = r + 1;
        break;
      }
    }
  }
  for (int j = 0; j < n; j++) {
    printf("%d ", b[j]);
  }
  return 0;
}
```