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    L119
  mov    $0x0,%eax
  jmp    L201
L119:
  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     L43
  cmpl   $0x0,-0x10(%rbp)
  jg     L182
L43:
  mov    $0x0,%eax
  jmp    L201
L182:
  mov    -0x18(%rbp),%eax
  and    $0x40,%eax
  test   %eax,%eax
  jne    L105
  mov    -0x18(%rbp),%eax
  sar    $0x2,%eax
  and    $0xf,%eax
  mov    %eax,-0xc(%rbp)
  andl   $0x3,-0x18(%rbp)
  cmpl   $0x3,-0x18(%rbp)
  jne    L202
  mov    $0x0,%eax
  jmp    L201
L202:
  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    L1
  mov    $0x0,%eax
  jmp    L201
L1:
  movl   $0x0,-0x18(%rbp)
  jmp    L30
L36:
  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)
L30:
  mov    -0x14(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x14(%rbp)
  test   %eax,%eax
  jne    L36
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  jmp    L249
L105:
  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     L205
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  jmp    L249
L205:
  cmpl   $0xbf,-0x18(%rbp)
  jle    L253
  cmpl   $0xdf,-0x18(%rbp)
  jg     L253
  cmpl   $0x0,-0x10(%rbp)
  jg     L188
  mov    $0x0,%eax
  jmp    L201
L188:
  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    L249
L253:
  cmpl   $0xff,-0x18(%rbp)
  jne    L136
  cmpl   $0x4,-0x10(%rbp)
  jg     L233
  mov    $0x0,%eax
  jmp    L201
L233:
  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    L249
L136:
  mov    $0x0,%eax
  jmp    L201
L249:
  mov    -0x10(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jge    L245
  mov    $0x0,%eax
  jmp    L201
L245:
  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
L201:
  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;
}
```