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

```asm
<main>:
  endbr64
  push   %r15
  lea    D29(%rip),%r15
  push   %r14
  lea    D2(%rip),%r14
  push   %r13
  lea    D115(%rip),%r13
  push   %r12
  lea    D17(%rip),%r12
  push   %rbp
  lea    D68(%rip),%rbp
  push   %rbx
  lea    D30(%rip),%rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%rax
  mov    %rax,0x8(%rsp)
  cs nopw 0x0(%rax,%rax,1)
L12:
  mov    %r15,%rdi
  call   <puts@plt>
  mov    %r14,%rdi
  call   <puts@plt>
  mov    %r13,%rdi
  call   <puts@plt>
  mov    %r12,%rdi
  call   <puts@plt>
  mov    %rbp,%rdi
  call   <puts@plt>
  lea    D21(%rip),%rdi
  call   <puts@plt>
  mov    0x8(%rsp),%rsi
  xor    %eax,%eax
  lea    D1(%rip),%rdi
  call   <scanf@plt>
  cmpl   $0x4,0x10(%rsp)
  ja     L80
  mov    0x10(%rsp),%eax
  movslq (%rbx,%rax,4),%rax
  add    %rbx,%rax
  notrack jmp *%rax
  xor    %edi,%edi
L57:
  call   <del@plt>
  mov    %eax,0x14(%rsp)
  mov    %eax,%esi
  cmp    $0xffffffff,%eax
  je     L44
  lea    D69(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
L44:
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    0x10(%rsp),%eax
  test   %eax,%eax
  jne    L12
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L75
  add    $0x28,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
  lea    0x14(%rsp),%rsi
  lea    D80(%rip),%rdi
  xor    %eax,%eax
  call   <scanf@plt>
  mov    0x14(%rsp),%esi
  mov    $0x1,%edi
  call   <add@plt>
  jmp    L44
  nopl   0x0(%rax,%rax,1)
  lea    0x14(%rsp),%rsi
  lea    D80(%rip),%rdi
  xor    %eax,%eax
  call   <scanf@plt>
  mov    0x14(%rsp),%esi
  xor    %edi,%edi
  call   <add@plt>
  jmp    L44
  nopl   0x0(%rax,%rax,1)
  lea    D23(%rip),%rdi
  call   <puts@plt>
  jmp    L44
  nopl   0x0(%rax)
  mov    $0x1,%edi
  jmp    L57
L80:
  lea    D55(%rip),%rdi
  call   <puts@plt>
  jmp    L44
L75:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D29
type_infered: string
name: disassemble_data
arguments: label: D2
type_infered: string
name: disassemble_data
arguments: label: D115
type_infered: string
name: disassemble_data
arguments: label: D17
type_infered: string
name: disassemble_data
arguments: label: D68
type_infered: string
name: disassemble_data
arguments: label: D21
type_infered: string
name: disassemble_data
arguments: label: D1
type_infered: string
name: disassemble_data
arguments: label: D69
type_infered: string
name: disassemble_data
arguments: label: D80
type_infered: string
name: disassemble_data
arguments: label: D23
type_infered: string
name: disassemble_data
arguments: label: D55
type_infered: string

tool: D29: Choose an action 

tool: D2: 0: Exit

tool: D115: 1: Add to   FRONT

tool: D17: 2: Add to   REAR 

tool: D68: 3: Del from FRONT

tool: D21: 4: Del from REAR 

tool: D1:  %u%*c

tool: D69: %d


tool: D80:  %d%*c

tool: D23: Bye!

tool: D55: Invalid Input!

assistant: ```c
int main() {
  unsigned ch;
  int p;
  do {
    puts("Choose an action ");
    puts("0: Exit");
    puts("1: Add to   FRONT");
    puts("2: Add to   REAR ");
    puts("3: Del from FRONT");
    puts("4: Del from REAR ");
    scanf(" %u%*c", &ch);
    switch (ch) {
    case 0:
      puts("Bye!");
      break;
    case 1:
      scanf(" %d%*c", &p);
      add(0, p);
      break;
    case 2:
      scanf(" %d%*c", &p);
      add(1, p);
      break;
    case 3:
      if ((p = del(0)) != -1)
        printf("%d\n", p);
      break;
    case 4:
      if ((p = del(1)) != -1)
        printf("%d\n", p);
      break;
    default:
      printf("Invalid Input!\n");
      break;
    }
    putchar('\n');
  } while (ch);
  return 0;
}
```