user: Please show me the C implementation that matches the assembly code listed below:

```asm
<light_start>:
  endbr64
  push   %r15
  push   %r14
  mov    %edi,%r14d
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  jmp    L32
  nopw   0x0(%rax,%rax,1)
L50:
  mov    $0x1,%edi
  call   <msleep@plt>
L32:
  xor    %eax,%eax
  call   <b_button@plt>
  test   %rax,%rax
  jne    L50
  call   <c_button@plt>
  test   %rax,%rax
  jne    L50
  call   <display_clear@plt>
  lea    D51(%rip),%rdx
  xor    %esi,%esi
  xor    %edi,%edi
  xor    %eax,%eax
  xor    %ebx,%ebx
  mov    $0x270f,%r12d
  xor    %ebp,%ebp
  call   <display_printf@plt>
  lea    D4(%rip),%rdx
  xor    %edi,%edi
  xor    %eax,%eax
  mov    $0x1,%esi
  lea    D68(%rip),%r13
  call   <display_printf@plt>
  lea    D73(%rip),%rdx
  xor    %edi,%edi
  xor    %eax,%eax
  mov    $0x2,%esi
  call   <display_printf@plt>
  lea    D71(%rip),%rdx
  xor    %edi,%edi
  xor    %eax,%eax
  mov    $0x3,%esi
  call   <display_printf@plt>
  jmp    L3
  nopl   0x0(%rax)
L0:
  lea    D69(%rip),%rdx
  mov    $0x5,%esi
  mov    $0xa,%edi
  xor    %eax,%eax
  call   <display_printf@plt>
L31:
  mov    $0x32,%edi
  call   <msleep@plt>
L3:
  xor    %eax,%eax
  call   <b_button@plt>
  test   %rax,%rax
  jne    L78
  xor    %eax,%eax
  call   <c_button@plt>
  test   %rax,%rax
  jne    L78
  mov    %r14d,%edi
  call   <analog10@plt>
  mov    %r13,%rdx
  mov    $0x5,%edi
  cmp    %eax,%ebp
  mov    %eax,%r15d
  cmovl  %eax,%ebp
  cmp    %eax,%r12d
  cmovg  %eax,%r12d
  xor    %esi,%esi
  mov    %ebp,%ecx
  lea    (%r12,%rbp,1),%eax
  mov    %eax,%ebx
  shr    $0x1f,%ebx
  add    %eax,%ebx
  xor    %eax,%eax
  call   <display_printf@plt>
  mov    %r12d,%ecx
  mov    %r13,%rdx
  mov    $0x1,%esi
  mov    $0x5,%edi
  xor    %eax,%eax
  sar    %ebx
  call   <display_printf@plt>
  mov    %r15d,%ecx
  mov    %r13,%rdx
  mov    $0x2,%esi
  mov    $0x6,%edi
  xor    %eax,%eax
  call   <display_printf@plt>
  xor    %eax,%eax
  mov    %ebx,%ecx
  mov    %r13,%rdx
  mov    $0x3,%esi
  mov    $0x5,%edi
  call   <display_printf@plt>
  cmp    %ebx,%r15d
  jg     L0
  lea    D35(%rip),%rdx
  mov    $0x5,%esi
  mov    $0xa,%edi
  xor    %eax,%eax
  call   <display_printf@plt>
  jmp    L31
  nopl   0x0(%rax,%rax,1)
L78:
  xor    %eax,%eax
  call   <display_clear@plt>
  lea    D34(%rip),%rdx
  xor    %edi,%edi
  xor    %eax,%eax
  mov    $0x4,%esi
  call   <display_printf@plt>
  jmp    L23
  cs nopw 0x0(%rax,%rax,1)
L72:
  xor    %eax,%eax
  call   <c_button@plt>
  test   %rax,%rax
  jne    L92
  mov    $0x32,%edi
  call   <msleep@plt>
L23:
  mov    %r14d,%edi
  call   <analog10@plt>
  cmp    %ebx,%eax
  jg     L72
L92:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: parse_data
arguments: data_label: D51
datatype: string
name: parse_data
arguments: data_label: D4
datatype: string
name: parse_data
arguments: data_label: D68
datatype: string
name: parse_data
arguments: data_label: D73
datatype: string
name: parse_data
arguments: data_label: D71
datatype: string
name: parse_data
arguments: data_label: D69
datatype: string
name: parse_data
arguments: data_label: D35
datatype: string
name: parse_data
arguments: data_label: D34
datatype: string

tool: D51: Max:

tool: D4: Min:

tool: D68: %d   

tool: D73: Curr:

tool: D71: avg:

tool: D69: XX

tool: D35: OO

tool: D34: 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);
  }
}
```