user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
L4:
  lea    D163(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  call   <getchar@plt>
  mov    %eax,-0x8(%rbp)
  mov    $0x0,%eax
  call   <getchar@plt>
  cmpl   $0x30,-0x8(%rbp)
  je     L8
  cmpl   $0x31,-0x8(%rbp)
  jne    L4
L8:
  subl   $0x30,-0x8(%rbp)
  lea    D32(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D35(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D167(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D16(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D92(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D106(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D6(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    -0x8(%rbp),%eax
  mov    %eax,%esi
  lea    D192(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D189(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  call   <getchar@plt>
  mov    $0x0,%eax
  call   <setup_io@plt>
  mov    $0x0,%eax
  call   <setup_gpio@plt>
  mov    $0x0,%eax
  call   <setup_spi@plt>
  movl   $0x0,-0x4(%rbp)
  mov    -0x4(%rbp),%edx
  mov    -0x8(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <write_dac@plt>
  lea    D111(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D189(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  call   <getchar@plt>
  movl   $0x400,-0x4(%rbp)
  mov    -0x4(%rbp),%edx
  mov    -0x8(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <write_dac@plt>
  lea    D94(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D189(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  call   <getchar@plt>
  movl   $0x7f0,-0x4(%rbp)
  mov    -0x4(%rbp),%edx
  mov    -0x8(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <write_dac@plt>
  lea    D164(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D189(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  call   <getchar@plt>
  movl   $0xaa0,-0x4(%rbp)
  mov    -0x4(%rbp),%edx
  mov    -0x8(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <write_dac@plt>
  lea    D62(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D189(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  call   <getchar@plt>
  movl   $0xff0,-0x4(%rbp)
  mov    -0x4(%rbp),%edx
  mov    -0x8(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <write_dac@plt>
  lea    D41(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    D189(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  call   <getchar@plt>
  mov    $0x0,%eax
  call   <restore_io@plt>
  nop
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: tag: D163
datatype: string
name: disassemble_data
arguments: tag: D32
datatype: string
name: disassemble_data
arguments: tag: D35
datatype: string
name: disassemble_data
arguments: tag: D167
datatype: string
name: disassemble_data
arguments: tag: D16
datatype: string
name: disassemble_data
arguments: tag: D92
datatype: string
name: disassemble_data
arguments: tag: D106
datatype: string
name: disassemble_data
arguments: tag: D6
datatype: string
name: disassemble_data
arguments: tag: D192
datatype: string
name: disassemble_data
arguments: tag: D189
datatype: string
name: disassemble_data
arguments: tag: D111
datatype: string
name: disassemble_data
arguments: tag: D94
datatype: string
name: disassemble_data
arguments: tag: D164
datatype: string
name: disassemble_data
arguments: tag: D62
datatype: string
name: disassemble_data
arguments: tag: D41
datatype: string

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

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

tool: D35: jumper connecting GP11 to SCLK

tool: D167: jumper connecting GP10 to MOSI

tool: D16: jumper connecting GP9 to MISO

tool: D92: jumper connecting GP7 to CSnB

tool: D106: Multimeter connections (set your meter to read V DC):

tool: D6:   connect black probe to GND

tool: D192:   connect red probe to DA%d on J29


tool: D189: When ready hit enter.

tool: D111: Your meter should read about 0V

tool: D94: Your meter should read about 0.5V

tool: D164: Your meter should read about 1.02V

tool: D62: Your meter should read about 1.36V

tool: D41: Your meter should read about 2.04V

assistant: ```c
void main(void) {
  int d, chan, dummy;
  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 digital to analogue 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 GP7 to CSnB\n");
  printf("Multimeter connections (set your meter to read V DC):\n");
  printf("  connect black probe to GND\n");
  printf("  connect red probe to DA%d on J29\n", chan);
  printf("When ready hit enter.\n");
  (void)getchar();
  setup_io();
  setup_gpio();
  setup_spi();
  d = 0x000;
  write_dac(chan, d);
  printf("Your meter should read about 0V\n");
  printf("When ready hit enter.\n");
  (void)getchar();
  d = 0x400;
  write_dac(chan, d);
  printf("Your meter should read about 0.5V\n");
  printf("When ready hit enter.\n");
  (void)getchar();
  d = 0x7F0;
  write_dac(chan, d);
  printf("Your meter should read about 1.02V\n");
  printf("When ready hit enter.\n");
  (void)getchar();
  d = 0xAA0;
  write_dac(chan, d);
  printf("Your meter should read about 1.36V\n");
  printf("When ready hit enter.\n");
  (void)getchar();
  d = 0xFF0;
  write_dac(chan, d);
  printf("Your meter should read about 2.04V\n");
  printf("When ready hit enter.\n");
  (void)getchar();
  restore_io();
}
```