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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    D49(%rip),%rbx
  sub    $0x8,%rsp
  nopl   0x0(%rax)
L35:
  mov    %rbx,%rdi
  call   <puts@plt>
  xor    %eax,%eax
  call   <getchar@plt>
  mov    %rax,%r13
  xor    %eax,%eax
  call   <getchar@plt>
  sub    $0x30,%r13d
  cmp    $0x1,%r13d
  ja     L35
  lea    D68(%rip),%rdi
  mov    $0x186a0,%r12d
  lea    D5(%rip),%r15
  mov    $0x40,%r14d
  call   <puts@plt>
  lea    D41(%rip),%rdi
  call   <puts@plt>
  lea    D99(%rip),%rdi
  call   <puts@plt>
  lea    D21(%rip),%rdi
  call   <puts@plt>
  lea    D119(%rip),%rdi
  call   <puts@plt>
  lea    D86(%rip),%rdi
  call   <puts@plt>
  lea    D4(%rip),%rdi
  call   <puts@plt>
  lea    D59(%rip),%rdi
  call   <puts@plt>
  mov    %r13d,%esi
  lea    D2(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    D93(%rip),%rdi
  call   <puts@plt>
  lea    D90(%rip),%rdi
  call   <puts@plt>
  xor    %eax,%eax
  call   <getchar@plt>
  xor    %eax,%eax
  call   <setup_io@plt>
  xor    %eax,%eax
  call   <setup_gpio@plt>
  xor    %eax,%eax
  call   <setup_spi@plt>
  nopl   0x0(%rax,%rax,1)
L8:
  mov    %r13d,%edi
  call   <read_adc@plt>
  mov    %r15,%rdi
  mov    %eax,%ebx
  mov    %eax,%esi
  xor    %eax,%eax
  sar    $0x4,%ebx
  call   <printf@plt>
  test   %ebx,%ebx
  jle    L45
  xor    %ebp,%ebp
  nop
L3:
  mov    $0x23,%edi
  add    $0x1,%ebp
  call   <putchar@plt>
  cmp    %ebp,%ebx
  jne    L3
L45:
  mov    %r14d,%ebp
  sub    %ebx,%ebp
  test   %ebp,%ebp
  jle    L28
  xor    %ebx,%ebx
  nopl   0x0(%rax)
L22:
  mov    $0x20,%edi
  add    $0x1,%ebx
  call   <putchar@plt>
  cmp    %ebx,%ebp
  jne    L22
L28:
  mov    $0xd,%edi
  call   <putchar@plt>
  xor    %eax,%eax
  call   <short_wait@plt>
  sub    $0x1,%r12d
  jne    L8
  mov    $0xa,%edi
  call   <putchar@plt>
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1170 <restore_io@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D49
datatype: string
name: retrieve_data
arguments: tag: D68
datatype: string
name: retrieve_data
arguments: tag: D5
datatype: string
name: retrieve_data
arguments: tag: D41
datatype: string
name: retrieve_data
arguments: tag: D99
datatype: string
name: retrieve_data
arguments: tag: D21
datatype: string
name: retrieve_data
arguments: tag: D119
datatype: string
name: retrieve_data
arguments: tag: D86
datatype: string
name: retrieve_data
arguments: tag: D4
datatype: string
name: retrieve_data
arguments: tag: D59
datatype: string
name: retrieve_data
arguments: tag: D2
datatype: string
name: retrieve_data
arguments: tag: D93
datatype: string
name: retrieve_data
arguments: tag: D90
datatype: string

tool: D49: Which channel do you want to test? Type 0 or 1.

tool: D68: These are the connections for the analogue to digital test:

tool: D5: %04d 

tool: D41: jumper connecting GP11 to SCLK

tool: D99: jumper connecting GP10 to MOSI

tool: D21: jumper connecting GP9 to MISO

tool: D119: jumper connecting GP8 to CSnA

tool: D86: Potentiometer connections:

tool: D4:   (call 1 and 3 the ends of the resistor and 2 the wiper)

tool: D59:   connect 3 to 3V3

tool: D2:   connect 2 to AD%d


tool: D93:   connect 1 to GND

tool: D90: When ready hit enter.

assistant: ```c
void main(void) {
  int r, v, s, i, chan;
  do {
    printf("Which channel do you want to test? Type 0 or 1.\n");
    chan = (int)getchar();
    (void)getchar();
  } while (chan != '0' && chan != '1');
  chan = chan - '0';
  printf("These are the connections for the analogue to digital test:\n");
  printf("jumper connecting GP11 to SCLK\n");
  printf("jumper connecting GP10 to MOSI\n");
  printf("jumper connecting GP9 to MISO\n");
  printf("jumper connecting GP8 to CSnA\n");
  printf("Potentiometer connections:\n");
  printf("  (call 1 and 3 the ends of the resistor and 2 the wiper)\n");
  printf("  connect 3 to 3V3\n");
  printf("  connect 2 to AD%d\n", chan);
  printf("  connect 1 to GND\n");
  printf("When ready hit enter.\n");
  (void)getchar();
  setup_io();
  setup_gpio();
  setup_spi();
  for (r = 0; r < 100000; r++) {
    v = read_adc(chan);
    s = v >> 4;
    printf("%04d ", v);
    for (i = 0; i < s; i++)
      putchar('#');
    for (i = 0; i < 64 - s; i++)
      putchar(' ');
    putchar(0x0D);
    short_wait();
  }
  printf("\n");
  restore_io();
}
```