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

```asm
<nextpkg>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x40(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  movl   $0x0,(%rax)
  cmpl   $0x0,-0x10(%rbp)
  jne    L240
  mov    $0x0,%eax
  jmp    L93
L240:
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x18(%rbp)
  subl   $0x1,-0x10(%rbp)
  mov    -0x18(%rbp),%eax
  and    $0x80,%eax
  test   %eax,%eax
  je     L50
  cmpl   $0x0,-0x10(%rbp)
  jg     L141
L50:
  mov    $0x0,%eax
  jmp    L93
L141:
  mov    -0x18(%rbp),%eax
  and    $0x40,%eax
  test   %eax,%eax
  jne    L30
  mov    -0x18(%rbp),%eax
  sar    $0x2,%eax
  and    $0xf,%eax
  mov    %eax,-0xc(%rbp)
  andl   $0x3,-0x18(%rbp)
  cmpl   $0x3,-0x18(%rbp)
  jne    L31
  mov    $0x0,%eax
  jmp    L93
L31:
  mov    -0x18(%rbp),%eax
  mov    $0x1,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x10(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jge    L197
  mov    $0x0,%eax
  jmp    L93
L197:
  movl   $0x0,-0x18(%rbp)
  jmp    L191
L124:
  mov    -0x18(%rbp),%eax
  shl    $0x8,%eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  or     %ecx,%eax
  mov    %eax,-0x18(%rbp)
  subl   $0x1,-0x10(%rbp)
L191:
  mov    -0x14(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x14(%rbp)
  test   %eax,%eax
  jne    L124
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  jmp    L65
L30:
  mov    -0x18(%rbp),%eax
  and    $0x3f,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  mov    %eax,-0x18(%rbp)
  subl   $0x1,-0x10(%rbp)
  cmpl   $0xbf,-0x18(%rbp)
  jg     L148
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  jmp    L65
L148:
  cmpl   $0xbf,-0x18(%rbp)
  jle    L136
  cmpl   $0xdf,-0x18(%rbp)
  jg     L136
  cmpl   $0x0,-0x10(%rbp)
  jg     L187
  mov    $0x0,%eax
  jmp    L93
L187:
  mov    -0x18(%rbp),%eax
  sub    $0xc0,%eax
  shl    $0x8,%eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  movzbl (%rax),%eax
  movzbl %al,%eax
  add    %ecx,%eax
  add    $0xc0,%eax
  mov    %eax,-0x14(%rbp)
  subl   $0x1,-0x10(%rbp)
  jmp    L65
L136:
  cmpl   $0xff,-0x18(%rbp)
  jne    L258
  cmpl   $0x4,-0x10(%rbp)
  jg     L266
  mov    $0x0,%eax
  jmp    L93
L266:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  shl    $0x18,%eax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  shl    $0x10,%eax
  or     %eax,%edx
  mov    -0x8(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  shl    $0x8,%eax
  or     %eax,%edx
  mov    -0x8(%rbp),%rax
  add    $0x3,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  or     %edx,%eax
  mov    %eax,-0x14(%rbp)
  addq   $0x4,-0x8(%rbp)
  subl   $0x4,-0x10(%rbp)
  jmp    L65
L258:
  mov    $0x0,%eax
  jmp    L93
L65:
  mov    -0x10(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jge    L85
  mov    $0x0,%eax
  jmp    L93
L85:
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x10(%rbp),%eax
  sub    -0x14(%rbp),%eax
  mov    %eax,%edx
  mov    -0x40(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x30(%rbp),%rax
  mov    -0x14(%rbp),%edx
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    -0xc(%rbp),%edx
  mov    %edx,(%rax)
  mov    -0x8(%rbp),%rax
L93:
  pop    %rbp
  ret
```

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;
}
```