user: 请将以下的汇编代码转换成C语言代码：

```asm
<main>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    D17(%rip),%rbx
  sub    $0x48,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  lea    0xc(%rsp),%r13
  lea    0x8(%rsp),%r12
  lea    0x4(%rsp),%rbp
  nopl   0x0(%rax)
L72:
  mov    %rbp,%rsi
  mov    %r13,%rcx
  mov    %r12,%rdx
  mov    %rbx,%rdi
  call   <scanf@plt>
  mov    0x4(%rsp),%esi
  test   %esi,%esi
  js     L72
  mov    0x8(%rsp),%eax
  cmp    $0x1,%eax
  ja     L72
  movslq 0xc(%rsp),%rdx
  cmp    $0x7,%edx
  ja     L72
  test   %esi,%esi
  je     L187
  mov    %esi,%ecx
  and    $0x1,%ecx
  mov    %ecx,0x10(%rsp)
  mov    %esi,%ecx
  sar    %ecx
  je     L112
  and    $0x1,%ecx
  mov    %ecx,0x14(%rsp)
  mov    %esi,%ecx
  sar    $0x2,%ecx
  je     L84
  and    $0x1,%ecx
  mov    %ecx,0x18(%rsp)
  mov    %esi,%ecx
  sar    $0x3,%ecx
  je     L207
  and    $0x1,%ecx
  mov    %ecx,0x1c(%rsp)
  mov    %esi,%ecx
  sar    $0x4,%ecx
  je     L176
  and    $0x1,%ecx
  mov    %ecx,0x20(%rsp)
  mov    %esi,%ecx
  sar    $0x5,%ecx
  je     L217
  and    $0x1,%ecx
  mov    %ecx,0x24(%rsp)
  mov    %esi,%ecx
  sar    $0x6,%ecx
  je     L179
  and    $0x1,%ecx
  mov    %ecx,0x28(%rsp)
  mov    %esi,%ecx
  sar    $0x7,%ecx
  je     L205
  and    $0x1,%ecx
  mov    $0x7,%edi
  mov    %ecx,0x2c(%rsp)
  mov    %esi,%ecx
  sar    $0x8,%ecx
L125:
  mov    %eax,0x10(%rsp,%rdx,4)
  movslq %edi,%rax
  mov    0x10(%rsp,%rax,4),%edx
  lea    -0x1(%rdi),%eax
  mov    %ecx,0x4(%rsp)
  cltq
  mov    0x10(%rsp,%rax,4),%eax
  lea    (%rax,%rdx,2),%edx
  lea    -0x2(%rdi),%eax
  cltq
  mov    0x10(%rsp,%rax,4),%eax
  lea    (%rax,%rdx,2),%esi
  lea    -0x3(%rdi),%eax
  cmp    $0x2,%edi
  je     L187
  cltq
  mov    0x10(%rsp,%rax,4),%eax
  lea    (%rax,%rsi,2),%esi
  lea    -0x4(%rdi),%eax
  cmp    $0x3,%edi
  je     L187
  cltq
  mov    0x10(%rsp,%rax,4),%eax
  lea    (%rax,%rsi,2),%esi
  lea    -0x5(%rdi),%eax
  cmp    $0x4,%edi
  je     L187
  cltq
  mov    0x10(%rsp,%rax,4),%eax
  lea    (%rax,%rsi,2),%esi
  lea    -0x6(%rdi),%eax
  cmp    $0x5,%edi
  je     L187
  movslq %eax,%rdx
  mov    0x10(%rsp,%rdx,4),%edx
  lea    (%rdx,%rsi,2),%esi
  test   %eax,%eax
  je     L187
  mov    0x10(%rsp),%eax
  lea    (%rax,%rsi,2),%esi
L187:
  lea    D16(%rip),%rdi
  call   <printf@plt>
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L227
  add    $0x48,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L217:
  mov    $0x4,%edi
  jmp    L125
L112:
  mov    %eax,0x10(%rsp,%rdx,4)
  mov    0x10(%rsp),%esi
  movl   $0x0,0x4(%rsp)
  jmp    L187
L84:
  mov    %eax,0x10(%rsp,%rdx,4)
  mov    0x14(%rsp),%edx
  mov    0x10(%rsp),%eax
  movl   $0x0,0x4(%rsp)
  lea    (%rax,%rdx,2),%esi
  jmp    L187
L207:
  mov    $0x2,%edi
  jmp    L125
L176:
  mov    $0x3,%edi
  jmp    L125
L179:
  mov    $0x5,%edi
  jmp    L125
L205:
  mov    $0x6,%edi
  jmp    L125
L227:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D17
type_infered: string
name: retrieve_data
arguments: data_tag: D16
type_infered: string

tool: D17: %d %d %d

tool: D16: %d

assistant: ```c
int main() {
  int n, v, p, i = 0, array[8], a = 0, j = 0;
  do {
    scanf("%d %d %d", &n, &v, &p);
  } while (n < 0 || v < 0 || v > 1 || p < 0 || p > 7);
  while (n > 0) {
    array[i] = n % 2;
    n = n / 2;
    i++;
  }
  array[p] = v;
  for (j = i - 1; j >= 0; j--) {
    a = (a * 2) + array[j];
  }
  printf("%d", a);
}
```