user: 请从给定的汇编指令推导出C源代码：

```asm
<cdb_seek>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edi,%ebx
  mov    %rsi,%rdi
  sub    $0x88,%rsp
  mov    %rsi,0x18(%rsp)
  mov    %edx,%esi
  mov    %edx,0x20(%rsp)
  mov    %rcx,0x10(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x78(%rsp)
  xor    %eax,%eax
  call   <cdb_hash@plt>
  xor    %edx,%edx
  mov    %ebx,%edi
  lea    0x0(,%rax,8),%esi
  mov    %eax,%r15d
  and    $0x7f8,%esi
  call   <lseek@plt>
  test   %rax,%rax
  js     L37
  lea    0x30(%rsp),%rbp
  mov    $0x8,%edx
  mov    %ebx,%edi
  mov    %rbp,%rsi
  call   <cdb_bread@plt>
  test   %rax,%rax
  js     L37
  lea    0x34(%rsp),%r13
  mov    %r13,%rdi
  call   <cdb_unpack@plt>
  mov    %eax,0x8(%rsp)
  test   %eax,%eax
  jne    L11
L249:
  xor    %eax,%eax
  jmp    L108
  nopw   0x0(%rax,%rax,1)
L11:
  mov    0x8(%rsp),%r14d
  mov    %r15d,%eax
  xor    %edx,%edx
  mov    %rbp,%rdi
  shr    $0x8,%eax
  div    %r14d
  mov    %edx,%r12d
  call   <cdb_unpack@plt>
  mov    %r15d,0xc(%rsp)
  mov    $0x1,%edx
  mov    %eax,0x24(%rsp)
  nopl   0x0(%rax)
L204:
  lea    0x0(,%r12,8),%esi
  test   %edx,%edx
  jne    L239
L81:
  mov    $0x8,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <cdb_bread@plt>
  test   %rax,%rax
  js     L37
  mov    %r13,%rdi
  call   <cdb_unpack@plt>
  mov    %eax,%r15d
  test   %eax,%eax
  je     L249
  mov    %rbp,%rdi
  call   <cdb_unpack@plt>
  xor    %edx,%edx
  cmp    0xc(%rsp),%eax
  je     L164
L248:
  sub    $0x1,%r14d
  je     L249
  add    $0x1,%r12d
  xor    %esi,%esi
  cmp    %r12d,0x8(%rsp)
  jne    L204
  xor    %r12d,%r12d
L239:
  add    0x24(%rsp),%esi
  xor    %edx,%edx
  mov    %ebx,%edi
  call   <lseek@plt>
  test   %rax,%rax
  jns    L81
  nopl   0x0(%rax,%rax,1)
L37:
  mov    $0xffffffff,%eax
L108:
  mov    0x78(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L148
  add    $0x88,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L164:
  mov    %r15d,%esi
  mov    %ebx,%edi
  call   <lseek@plt>
  test   %rax,%rax
  js     L37
  mov    $0x8,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <cdb_bread@plt>
  test   %rax,%rax
  js     L37
  mov    %rbp,%rdi
  call   <cdb_unpack@plt>
  cmp    0x20(%rsp),%eax
  je     L156
L203:
  mov    $0x1,%edx
  jmp    L248
  nopl   0x0(%rax,%rax,1)
L156:
  mov    0x10(%rsp),%r15
  test   %r15,%r15
  je     L224
  mov    %r13,%rdi
  call   <cdb_unpack@plt>
  mov    %eax,(%r15)
L224:
  mov    0x20(%rsp),%eax
  test   %eax,%eax
  je     L16
  mov    0x20(%rsp),%eax
  mov    0x18(%rsp),%r15
  mov    %r14d,0x28(%rsp)
  mov    %r12d,0x2c(%rsp)
  mov    %eax,%r14d
  jmp    L243
  nopl   (%rax)
L97:
  mov    %r12d,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <memcmp@plt>
  test   %rax,%rax
  jne    L1
  mov    %r12d,%eax
  add    %rax,%r15
  sub    %r12d,%r14d
  je     L16
L243:
  mov    $0x40,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  cmp    %edx,%r14d
  cmovbe %r14d,%edx
  mov    %edx,%r12d
  call   <cdb_bread@plt>
  test   %rax,%rax
  jns    L97
  jmp    L37
  nopl   0x0(%rax)
L16:
  mov    $0x1,%eax
  jmp    L108
L1:
  mov    0x28(%rsp),%r14d
  mov    0x2c(%rsp),%r12d
  jmp    L203
L148:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int cdb_seek(int fd, const void *key, unsigned klen, unsigned *dlenp) {
  unsigned htstart;
  unsigned htsize;
  unsigned httodo;
  unsigned hti;
  unsigned pos;
  unsigned hval;
  unsigned char rbuf[64];
  int needseek = 1;
  hval = cdb_hash(key, klen);
  pos = (hval & 0xff) << 3;
  if (lseek(fd, pos, 0) < 0 || cdb_bread(fd, rbuf, 8) < 0)
    return -1;
  if ((htsize = cdb_unpack(rbuf + 4)) == 0)
    return 0;
  hti = (hval >> 8) % htsize;
  httodo = htsize;
  htstart = cdb_unpack(rbuf);
  for (;;) {
    if (needseek && lseek(fd, htstart + (hti << 3), 0) < 0)
      return -1;
    if (cdb_bread(fd, rbuf, 8) < 0)
      return -1;
    if ((pos = cdb_unpack(rbuf + 4)) == 0)
      return 0;
    if (cdb_unpack(rbuf) != hval)
      needseek = 0;
    else {
      if (lseek(fd, pos, 0) < 0 || cdb_bread(fd, rbuf, 8) < 0)
        return -1;
      if (cdb_unpack(rbuf) == klen) {
        unsigned l = klen, c;
        const char *k = (const char *)key;
        if (dlenp)
          *dlenp = cdb_unpack(rbuf + 4);
        for (;;) {
          if (!l)
            return 1;
          c = l > sizeof(rbuf) ? sizeof(rbuf) : l;
          if (cdb_bread(fd, rbuf, c) < 0)
            return -1;
          if (memcmp(rbuf, k, c) != 0)
            break;
          k += c;
          l -= c;
        }
      }
      needseek = 1;
    }
    if (!--httodo)
      return 0;
    if (++hti == htsize) {
      hti = 0;
      needseek = 1;
    }
  }
}
```