user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<magic>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x3cf000(%rsp),%r11
L135:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L135
  sub    $0x988,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x3cf978(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  jle    L0
  lea    -0x1(%rdi),%eax
  mov    $0xfffffffffffffffc,%rdx
  mov    %edi,%r14d
  xor    %r12d,%r12d
  shl    $0x2,%rax
  lea    0xfb0(%rsp),%r13
  lea    D30(%rip),%rbp
  sub    %rax,%rdx
  lea    0xfb4(%rsp,%rax,1),%rbx
  mov    %rdx,0x8(%rsp)
  nopl   0x0(%rax)
L10:
  add    $0x1,%r12d
  lea    D5(%rip),%rdi
  xor    %eax,%eax
  mov    %r12d,%esi
  call   <printf@plt>
  mov    0x8(%rsp),%rax
  lea    (%rax,%rbx,1),%r15
  xchg   %ax,%ax
L145:
  mov    %r15,%rsi
  mov    %rbp,%rdi
  add    $0x4,%r15
  call   <scanf@plt>
  cmp    %rbx,%r15
  jne    L145
  lea    0xf9c(%r15),%rbx
  cmp    %r14d,%r12d
  jne    L10
  lea    (%r14,%r14,1),%ebx
  lea    0x10(%rsp),%rbp
  movslq %r14d,%rax
  mov    %r13,%r10
  movslq %ebx,%rbx
  lea    0x0(%rbp,%rax,4),%rsi
  mov    %rbp,%rcx
  xor    %r9d,%r9d
  movq   $0x0,0x10(%rsp,%rbx,4)
  mov    %r14d,%r11d
  nopl   0x0(%rax)
L73:
  movl   $0x0,(%rcx)
  mov    %r13,%rdx
  xor    %eax,%eax
  movl   $0x0,(%rsi)
  jmp    L74
  nopl   0x0(%rax,%rax,1)
L120:
  add    $0x1,%rax
  add    $0xf9c,%rdx
  cmp    %r11,%rax
  je     L45
L74:
  mov    (%r10,%rax,4),%edi
  mov    (%rdx),%r8d
  add    %edi,(%rcx)
  add    %r8d,(%rsi)
  cmp    %eax,%r9d
  jne    L120
  add    $0x1,%rax
  add    %edi,0x10(%rsp,%rbx,4)
  add    $0xf9c,%rdx
  cmp    %r11,%rax
  jne    L74
L45:
  lea    0x1(%r9),%eax
  add    $0x4,%rcx
  add    $0x4,%rsi
  add    $0x4,%r13
  add    $0xf9c,%r10
  cmp    %eax,%r14d
  je     L67
  mov    %eax,%r9d
  jmp    L73
  xchg   %ax,%ax
L67:
  cmp    $0x1,%r14d
  jne    L38
L0:
  jmp    L0
  nopl   0x0(%rax,%rax,1)
L38:
  mov    %r14d,%edx
  xor    %ebx,%ebx
  imul   %r14d,%edx
  add    $0x1,%edx
  imul   %r14d,%edx
  sar    %edx
  jmp    L150
  nopl   0x0(%rax)
L111:
  lea    0x1(%rbx),%eax
  add    $0x4,%rbp
  cmp    %r9d,%ebx
  je     L137
  mov    %eax,%ebx
L150:
  cmp    %edx,0x0(%rbp)
  je     L111
  lea    D12(%rip),%rdi
  call   <puts@plt>
  cmp    %ebx,%r14d
  je     L137
L177:
  mov    0x3cf978(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L80
  add    $0x3cf988,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L137:
  lea    D19(%rip),%rdi
  call   <puts@plt>
  jmp    L177
L80:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D30
type_guessed: string
name: parse_data
arguments: tag: D5
type_guessed: string
name: parse_data
arguments: tag: D12
type_guessed: string
name: parse_data
arguments: tag: D19
type_guessed: string

tool: D30:  %d

tool: D5: Vavedi %d red: 


tool: D12: NO MAGIC

tool: D19: MAGIC

assistant: ```c
void magic(int n) {
  int i, k, b, j, l;
  int m[999][999];
  int m1[999];
  for (i = 0; i < n; i++) {
    printf("Vavedi %d red: \n", i + 1);
    for (k = 0; k < n; k++) {
      scanf(" %d", &m[i][k]);
    }
  }
  b = (n * (n * n + 1)) / 2;
  m1[n + n] = 0;
  m1[n + n + 1] = 0;
  for (i = 0; i < n; i++) {
    m1[i] = 0;
    m1[i + n] = 0;
    for (k = 0; k < n; k++) {
      m1[i] = m1[i] + m[i][k];
      m1[i + n] = m1[i + n] + m[k][i];
      if (k == i) {
        m1[n + n] = m1[n + n] + m[i][k];
      }
    }
  }
  k = 0;
  for (i = n - 1; i <= 0; i--) {
    m1[n + n + 1] = m1[n + n + 1] + m[i][k];
    k++;
  }
  k = 0;
  for (i = 0; i < n; i++) {
    if (m1[i] == b)
      k++;
    else {
      printf("NO MAGIC\n");
      break;
    }
  }
  if (k == n)
    printf("MAGIC\n");
}
```