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

```asm
<qlist_pack>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %ecx,-0x40(%rbp)
  subl   $0x9,-0x3c(%rbp)
  cmpl   $0x0,-0x3c(%rbp)
  jns    L136
  mov    $0xffffffff,%eax
  jmp    L116
L136:
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x30(%rbp)
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x48(%rbp),%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x40(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x30(%rbp),%rax
  movabs $0xdeadbeefdeadbaaf,%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <qlist_put_delta@plt>
  cltq
  shl    $0x2,%rax
  add    %rax,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  setae  %al
  movzbl %al,%eax
  mov    $0x0,%esi
  mov    %eax,%edi
  call   <__builtin_expect@plt>
  test   %rax,%rax
  je     L103
  mov    $0xffffffff,%eax
  jmp    L116
L103:
  movq   $0x0,-0x20(%rbp)
  jmp    L143
L29:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,-0x20(%rbp)
  setg   %al
  movzbl %al,%eax
  mov    $0x0,%esi
  mov    %eax,%edi
  call   <__builtin_expect@plt>
  test   %rax,%rax
  je     L106
  mov    $0xfffffffe,%eax
  jmp    L116
L106:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  sub    -0x20(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x20(%rbp)
  addq   $0x8,-0x28(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L33
  mov    -0x28(%rbp),%rax
  sub    $0x8,%rax
  cmp    %rax,-0x48(%rbp)
  je     L33
  mov    $0x1,%eax
  jmp    L36
L33:
  mov    $0x0,%eax
L36:
  mov    $0x0,%esi
  mov    %eax,%edi
  call   <__builtin_expect@plt>
  test   %rax,%rax
  je     L147
  jmp    L143
L147:
  mov    -0x8(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <qlist_put_delta@plt>
  cltq
  shl    $0x2,%rax
  add    %rax,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  setae  %al
  movzbl %al,%eax
  mov    $0x0,%esi
  mov    %eax,%edi
  call   <__builtin_expect@plt>
  test   %rax,%rax
  je     L143
  mov    $0xffffffff,%eax
  jmp    L116
L143:
  mov    -0x28(%rbp),%rax
  cmp    -0x10(%rbp),%rax
  jb     L29
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <qlist_put_stop@plt>
  cltq
  shl    $0x2,%rax
  add    %rax,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  sub    -0x38(%rbp),%rax
  sar    $0x2,%rax
L116:
  leave
  ret
```

assistant: ```c
int qlist_pack(uint8_t *qbuf_start, int qbuf_sz, uint64_t *items_start, int items_sz) {
  qbuf_sz -= 9;
  if (qbuf_sz < 0)
    return (-1);
  uint8_t *qbuf = qbuf_start;
  uint8_t *qbuf_end = qbuf + qbuf_sz;
  uint64_t *items = items_start;
  uint64_t *items_end = items + items_sz;
  qbuf += qlist_put_delta(qbuf, 0xDEADBEEFDEADBAAFLL);
  if (__builtin_expect(!!(qbuf >= qbuf_end), 0))
    return (-1);
  uint64_t last_item = 0;
  uint64_t delta;
  while (items < items_end) {
    if (__builtin_expect(!!(*items < last_item), 0))
      return (-2);
    delta = *items - last_item;
    last_item = *items;
    items++;
    if (__builtin_expect(!!(0 == delta && (items - 1) != items_start), 0))
      continue;
    qbuf += qlist_put_delta(qbuf, delta);
    if (__builtin_expect(!!(qbuf >= qbuf_end), 0))
      return (-1);
  }
  qbuf += qlist_put_stop(qbuf);
  return (qbuf - qbuf_start);
}
```