user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<nextpkg>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    (%rdx),%rbx
  mov    (%rcx),%r10d
  movl   $0x0,(%rdi)
  test   %r10d,%r10d
  je     L77
  mov    %rsi,%r11
  mov    %rdx,%r8
  mov    %rcx,%rsi
  movzbl (%rbx),%r9d
  lea    -0x1(%r10),%eax
  test   %eax,%eax
  jle    L132
  test   %r9b,%r9b
  jns    L132
  test   $0x40,%r9b
  jne    L8
  mov    %r9d,%ecx
  and    $0x3,%ecx
  mov    %r9d,%edx
  and    $0x3,%edx
  cmp    $0x3,%edx
  je     L156
  mov    $0x1,%ebp
  shl    %cl,%ebp
  cmp    %ebp,%eax
  jl     L176
  lea    0x1(%rbx),%r12
  lea    0x1(%rbp),%eax
  add    %rax,%rbx
  mov    %r12,%rdx
  mov    $0x0,%eax
L105:
  shl    $0x8,%eax
  add    $0x1,%rdx
  movzbl -0x1(%rdx),%ecx
  or     %ecx,%eax
  cmp    %rbx,%rdx
  jne    L105
  mov    %ebp,%edx
  add    %r12,%rdx
  not    %ebp
  lea    0x0(%rbp,%r10,1),%ecx
  shr    $0x2,%r9d
  and    $0xf,%r9d
L171:
  cmp    %ecx,%eax
  jg     L191
  movslq %eax,%r10
  add    %rdx,%r10
  mov    %r10,(%r8)
  sub    %eax,%ecx
  mov    %ecx,(%rsi)
  mov    %eax,(%r11)
  mov    %r9d,(%rdi)
L208:
  mov    %rdx,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L8:
  and    $0x3f,%r9d
  movzbl 0x1(%rbx),%edx
  movzbl %dl,%eax
  lea    -0x2(%r10),%ecx
  cmp    $0xbf,%eax
  jg     L144
  lea    0x2(%rbx),%rdx
  jmp    L171
L144:
  movzbl %dl,%edx
  sub    $0xc0,%edx
  cmp    $0x1f,%edx
  ja     L203
  test   %ecx,%ecx
  jle    L115
  lea    0x3(%rbx),%rdx
  sub    $0xc0,%eax
  shl    $0x8,%eax
  movzbl 0x2(%rbx),%ecx
  lea    0xc0(%rax,%rcx,1),%eax
  lea    -0x3(%r10),%ecx
  jmp    L171
L203:
  cmp    $0x4,%ecx
  jle    L226
  cmp    $0xff,%eax
  jne    L226
  movzbl 0x2(%rbx),%eax
  shl    $0x18,%eax
  movzbl 0x3(%rbx),%edx
  shl    $0x10,%edx
  or     %edx,%eax
  movzbl 0x5(%rbx),%edx
  or     %edx,%eax
  movzbl 0x4(%rbx),%edx
  shl    $0x8,%edx
  or     %edx,%eax
  lea    0x6(%rbx),%rdx
  lea    -0x6(%r10),%ecx
  jmp    L171
L77:
  mov    $0x0,%edx
  jmp    L208
L132:
  mov    $0x0,%edx
  jmp    L208
L156:
  mov    $0x0,%edx
  jmp    L208
L176:
  mov    $0x0,%edx
  jmp    L208
L115:
  mov    $0x0,%edx
  jmp    L208
L226:
  mov    $0x0,%edx
  jmp    L208
L191:
  mov    $0x0,%edx
  jmp    L208
```

assistant: ```c
unsigned char *nextpkg(int *tagp, int *pkgl, unsigned char **pp, int *ppl) {
  int x, l;
  unsigned char *p = *pp;
  int pl = *ppl;
  int tag;
  *tagp = 0;
  if (!pl)
    return 0;
  x = *p++;
  pl--;
  if (!(x & 128) || pl <= 0)
    return 0;
  if ((x & 64) == 0) {
    tag = (x & 0x3c) >> 2;
    x &= 3;
    if (x == 3)
      return 0;
    l = 1 << x;
    if (pl < l)
      return 0;
    x = 0;
    while (l--) {
      x = x << 8 | *p++;
      pl--;
    }
    l = x;
  } else {
    tag = (x & 0x3f);
    x = *p++;
    pl--;
    if (x < 192)
      l = x;
    else if (x >= 192 && x < 224) {
      if (pl <= 0)
        return 0;
      l = ((x - 192) << 8) + *p++ + 192;
      pl--;
    } else if (x == 255) {
      if (pl <= 4)
        return 0;
      l = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
      p += 4;
      pl -= 4;
    } else
      return 0;
  }
  if (pl < l)
    return 0;
  *pp = p + l;
  *ppl = pl - l;
  *pkgl = l;
  *tagp = tag;
  return p;
}
```