user: 请从给定的汇编指令推导出C源代码:

```asm
<magic_square>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x3cf000(%rsp),%r11
L96:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L96
  sub    $0x988,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x3cf978(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  jle    L161
  lea    -0x1(%rdi),%eax
  mov    $0xfffffffffffffffc,%rdx
  mov    %edi,%r14d
  xor    %r12d,%r12d
  shl    $0x2,%rax
  lea    0xfb0(%rsp),%r13
  lea    D37(%rip),%rbp
  sub    %rax,%rdx
  lea    0xfb4(%rsp,%rax,1),%rbx
  mov    %rdx,0x8(%rsp)
  nopl   0x0(%rax)
L159:
  add    $0x1,%r12d
  lea    D6(%rip),%rdi
  xor    %eax,%eax
  mov    %r12d,%esi
  call   <printf@plt>
  mov    0x8(%rsp),%rax
  lea    (%rax,%rbx,1),%r15
  xchg   %ax,%ax
L157:
  mov    %r15,%rsi
  mov    %rbp,%rdi
  add    $0x4,%r15
  call   <scanf@plt>
  cmp    %rbx,%r15
  jne    L157
  lea    0xf9c(%r15),%rbx
  cmp    %r14d,%r12d
  jne    L159
  lea    (%r14,%r14,1),%r11d
  lea    0x10(%rsp),%rbx
  movslq %r14d,%rbp
  mov    %r13,%r8
  movslq %r11d,%r11
  lea    (%rbx,%rbp,4),%rsi
  mov    %rbx,%rcx
  xor    %r9d,%r9d
  movq   $0x0,0x10(%rsp,%r11,4)
  mov    %r14d,%r10d
  nopl   0x0(%rax,%rax,1)
L27:
  movl   $0x0,(%rcx)
  mov    %r13,%rdx
  xor    %eax,%eax
  movl   $0x0,(%rsi)
  jmp    L35
  nopl   0x0(%rax,%rax,1)
L40:
  add    $0x1,%rax
  add    $0xf9c,%rdx
  cmp    %r10,%rax
  je     L140
L35:
  mov    (%r8,%rax,4),%edi
  add    %edi,(%rcx)
  mov    (%rdx),%edi
  add    %edi,(%rsi)
  cmp    %eax,%r9d
  jne    L40
  add    $0x1,%rax
  mov    (%r8,%rbp,4),%edi
  add    $0xf9c,%rdx
  add    %edi,0x10(%rsp,%r11,4)
  cmp    %r10,%rax
  jne    L35
L140:
  lea    0x1(%r9),%eax
  add    $0x4,%rcx
  add    $0x4,%rsi
  add    $0x4,%r13
  add    $0xf9c,%r8
  cmp    %eax,%r14d
  je     L141
  mov    %eax,%r9d
  jmp    L27
  nopl   0x0(%rax)
L141:
  cmp    $0x1,%r14d
  jne    L144
L161:
  jmp    L161
L144:
  mov    %r14d,%edx
  xor    %ebp,%ebp
  imul   %r14d,%edx
  add    $0x1,%edx
  imul   %r14d,%edx
  sar    %edx
  jmp    L51
  nopl   0x0(%rax)
L147:
  lea    0x1(%rbp),%eax
  add    $0x4,%rbx
  cmp    %r9d,%ebp
  je     L0
  mov    %eax,%ebp
L51:
  cmp    %edx,(%rbx)
  je     L147
  lea    D31(%rip),%rdi
  call   <puts@plt>
  cmp    %ebp,%r14d
  je     L0
L169:
  mov    0x3cf978(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L69
  add    $0x3cf988,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L0:
  lea    D30(%rip),%rdi
  call   <puts@plt>
  jmp    L169
L69:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D37
datatype: string
name: unpack_data
arguments: data_label: D6
datatype: string
name: unpack_data
arguments: data_label: D31
datatype: string
name: unpack_data
arguments: data_label: D30
datatype: string

tool: D37:  %d

tool: D6: Enter %d line: 

tool: D31: NO MAGIC

tool: D30: MAGIC

assistant: ```c
void magic_square(int a) {
  int i, b, c;
  int ar[999][999];
  int ar1[999];
  for (i = 0; i < a; i++) {
    printf("Enter %d line: ", i + 1);
    for (b = 0; b < a; b++) {
      scanf(" %d", &ar[i][b]);
    }
  }
  c = (a * (a * a + 1)) / 2;
  ar1[a + a] = 0;
  ar1[a + a + 1] = 0;
  for (i = 0; i < a; i++) {
    ar1[i] = 0;
    ar1[i + a] = 0;
    for (b = 0; b < a; b++) {
      ar1[i] = ar1[i] + ar[i][b];
      ar1[i + a] = ar1[i + a] + ar[b][i];
      if (b == i) {
        ar1[a + a] = ar1[a + a] + ar[i][a];
      }
    }
  }
  b = 0;
  for (i = a - 1; i <= 0; i--) {
    ar1[a + a + 1] = ar1[a + a + 1] + ar[i][b];
    b++;
  }
  b = 0;
  for (i = 0; i < a; i++) {
    if (ar1[i] == c)
      b++;
    else {
      printf("NO MAGIC\n");
      break;
    }
  }
  if (b == a)
    printf("MAGIC\n");
}
```