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

```asm
<light_start>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  jmp    L81
L62:
  mov    $0x1,%edi
  call   <msleep@plt>
L81:
  mov    $0x0,%eax
  call   <b_button@plt>
  test   %rax,%rax
  jne    L62
  mov    $0x0,%eax
  call   <c_button@plt>
  test   %rax,%rax
  jne    L62
  movl   $0x0,-0x10(%rbp)
  movl   $0x270f,-0xc(%rbp)
  movl   $0x0,-0x4(%rbp)
  movl   $0x0,-0x8(%rbp)
  mov    $0x0,%eax
  call   <display_clear@plt>
  lea    D61(%rip),%rax
  mov    %rax,%rdx
  mov    $0x0,%esi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <display_printf@plt>
  lea    D78(%rip),%rax
  mov    %rax,%rdx
  mov    $0x1,%esi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <display_printf@plt>
  lea    D109(%rip),%rax
  mov    %rax,%rdx
  mov    $0x2,%esi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <display_printf@plt>
  lea    D10(%rip),%rax
  mov    %rax,%rdx
  mov    $0x3,%esi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <display_printf@plt>
  jmp    L48
L123:
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <analog10@plt>
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jle    L120
  mov    -0x4(%rbp),%eax
  mov    %eax,-0x10(%rbp)
L120:
  mov    -0x4(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jge    L87
  mov    -0x4(%rbp),%eax
  mov    %eax,-0xc(%rbp)
L87:
  mov    -0x10(%rbp),%edx
  mov    -0xc(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x8(%rbp)
  mov    -0x10(%rbp),%eax
  mov    %eax,%ecx
  lea    D22(%rip),%rax
  mov    %rax,%rdx
  mov    $0x0,%esi
  mov    $0x5,%edi
  mov    $0x0,%eax
  call   <display_printf@plt>
  mov    -0xc(%rbp),%eax
  mov    %eax,%ecx
  lea    D22(%rip),%rax
  mov    %rax,%rdx
  mov    $0x1,%esi
  mov    $0x5,%edi
  mov    $0x0,%eax
  call   <display_printf@plt>
  mov    -0x4(%rbp),%eax
  mov    %eax,%ecx
  lea    D22(%rip),%rax
  mov    %rax,%rdx
  mov    $0x2,%esi
  mov    $0x6,%edi
  mov    $0x0,%eax
  call   <display_printf@plt>
  mov    -0x8(%rbp),%eax
  mov    %eax,%ecx
  lea    D22(%rip),%rax
  mov    %rax,%rdx
  mov    $0x3,%esi
  mov    $0x5,%edi
  mov    $0x0,%eax
  call   <display_printf@plt>
  mov    -0x4(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jle    L26
  lea    D98(%rip),%rax
  mov    %rax,%rdx
  mov    $0x5,%esi
  mov    $0xa,%edi
  mov    $0x0,%eax
  call   <display_printf@plt>
  jmp    L22
L26:
  lea    D63(%rip),%rax
  mov    %rax,%rdx
  mov    $0x5,%esi
  mov    $0xa,%edi
  mov    $0x0,%eax
  call   <display_printf@plt>
L22:
  mov    $0x32,%edi
  call   <msleep@plt>
L48:
  mov    $0x0,%eax
  call   <b_button@plt>
  test   %rax,%rax
  jne    L109
  mov    $0x0,%eax
  call   <c_button@plt>
  test   %rax,%rax
  je     L123
L109:
  mov    $0x0,%eax
  call   <display_clear@plt>
  lea    D8(%rip),%rax
  mov    %rax,%rdx
  mov    $0x4,%esi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <display_printf@plt>
  jmp    L41
L93:
  mov    $0x32,%edi
  call   <msleep@plt>
L41:
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <analog10@plt>
  cmp    %eax,-0x8(%rbp)
  jge    L3
  mov    $0x0,%eax
  call   <c_button@plt>
  test   %rax,%rax
  je     L93
L3:
  nop
  leave
  ret
```

tool_calls: name: read_data
arguments: data_tag: D61
datatype: string
name: read_data
arguments: data_tag: D78
datatype: string
name: read_data
arguments: data_tag: D109
datatype: string
name: read_data
arguments: data_tag: D10
datatype: string
name: read_data
arguments: data_tag: D22
datatype: string
name: read_data
arguments: data_tag: D98
datatype: string
name: read_data
arguments: data_tag: D63
datatype: string
name: read_data
arguments: data_tag: D8
datatype: string

tool: D61: Max:

tool: D78: Min:

tool: D109: Curr:

tool: D10: avg:

tool: D22: %d   

tool: D98: XX

tool: D63: OO

tool: D8: Prepared to begin: left to skip

assistant: ```c
void light_start(int sensor) {
  ;
  while (!(!(b_button() || c_button()))) {
    msleep(1);
  };
  int max = 0, min = 9999, curr = 0, avg = 0;
  display_clear();
  display_printf(0, 0, "Max:");
  display_printf(0, 1, "Min:");
  display_printf(0, 2, "Curr:");
  display_printf(0, 3, "avg:");
  while (!b_button() && !c_button()) {
    curr = analog10(sensor);
    if (curr > max) {
      max = curr;
    }
    if (curr < min) {
      min = curr;
    }
    avg = (max + min) / 2;
    display_printf(5, 0, "%d   ", max);
    display_printf(5, 1, "%d   ", min);
    display_printf(6, 2, "%d   ", curr);
    display_printf(5, 3, "%d   ", avg);
    if (curr > avg) {
      display_printf(10, 5, "XX");
    } else {
      display_printf(10, 5, "OO");
    }
    msleep(50);
  }
  display_clear();
  display_printf(0, 4, "Prepared to begin: left to skip");
  while (analog10(sensor) > avg && !(c_button())) {
    msleep(50);
  }
}
```