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

```asm
<bureadupto>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %edi,%ebx
  mov    %rsi,0x28(%rsp)
  mov    %edx,%r14d
  mov    %rcx,0x20(%rsp)
  mov    %r8,0x18(%rsp)
  mov    %r9,0x10(%rsp)
  mov    0x70(%rsp),%r12d
  test   %rsi,%rsi
  je     L82
  movl   $0x0,(%rsi)
L82:
  mov    0x20(%rsp),%rax
  test   %rax,%rax
  je     L27
  movl   $0x0,(%rax)
L27:
  cmpq   $0x0,0x18(%rsp)
  je     L231
  cmp    $0x1,%r14d
  jle    L29
  test   %r12d,%r12d
  je     L112
L181:
  mov    %ebx,%edi
  call   <jelio_buffer@plt>
  mov    %rax,0x8(%rsp)
  test   %rax,%rax
  je     L110
  movslq %r12d,%r15
  mov    0x18(%rsp),%rax
  sub    %r15,%rax
  lea    0x1(%rax),%rbp
  sub    $0x1,%r14d
  mov    $0x0,%r13d
  jmp    L69
L29:
  mov    0x18(%rsp),%rax
  movb   $0x0,(%rax)
  mov    $0x0,%ebx
  jmp    L85
L112:
  mov    0x10(%rsp),%rdi
  call   <strlen@plt>
  mov    %eax,%r12d
  jmp    L181
L222:
  mov    %r13d,%ebx
  mov    0x28(%rsp),%rax
  test   %rax,%rax
  je     L176
  movl   $0x1,(%rax)
L176:
  movslq %ebx,%rax
  mov    0x18(%rsp),%rcx
  movb   $0x0,(%rcx,%rax,1)
L85:
  mov    %ebx,%eax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L70:
  add    $0x1,%rbp
  cmp    %r14d,%ebx
  je     L93
  mov    %ebx,%r13d
L69:
  mov    0x8(%rsp),%rdi
  call   <jelio_buffer_getc@plt>
  cmp    $0xffffffff,%eax
  je     L222
  mov    %al,-0x1(%rbp,%r15,1)
  lea    0x1(%r13),%ebx
  cmp    %ebx,%r12d
  jg     L70
  mov    %r12d,%edx
  mov    0x10(%rsp),%rsi
  mov    %rbp,%rdi
  call   <memcmp@plt>
  test   %eax,%eax
  jne    L70
  mov    0x20(%rsp),%rax
  test   %rax,%rax
  je     L176
  movl   $0x1,(%rax)
  jmp    L176
L93:
  cmp    %ebx,%r12d
  cmovge %r13d,%r12d
  cmp    $0x1,%ebx
  jle    L176
  test   %r12d,%r12d
  jle    L176
  movslq %r12d,%rbp
  jmp    L61
L135:
  sub    $0x1,%rbp
  sub    $0x1,%r12d
  je     L176
L61:
  movslq %ebx,%rax
  sub    %rbp,%rax
  mov    0x18(%rsp),%rcx
  lea    (%rcx,%rax,1),%r13
  mov    %r12d,%edx
  mov    0x10(%rsp),%rsi
  mov    %r13,%rdi
  call   <memcmp@plt>
  test   %eax,%eax
  jne    L135
  mov    %r12d,%edx
  mov    %r13,%rsi
  mov    0x8(%rsp),%rdi
  call   <jelio_buffer_ungetc@plt>
  sub    %r12d,%ebx
  jmp    L135
L231:
  mov    $0xffffffff,%ebx
  jmp    L85
L110:
  mov    $0xffffffff,%ebx
  jmp    L85
```

assistant: ```c
int bureadupto(int fd, int *opt_eof, int maxlen, int *opt_complete, char *rbuf, char *upto, int upto_len) {
  int count = 0;
  int buf;
  struct jelio_buf *jb;
  if (opt_eof)
    *opt_eof = 0;
  if (opt_complete)
    *opt_complete = 0;
  if (!rbuf)
    return -1;
  if (maxlen < 2) {
    *rbuf = 0;
    return 0;
  }
  maxlen--;
  if (upto_len == 0)
    upto_len = strlen(upto);
  jb = jelio_buffer(fd);
  if (!jb)
    return -1;
  while (1) {
    buf = jelio_buffer_getc(jb);
    if (buf == -1) {
      if (opt_eof)
        *opt_eof = 1;
      break;
    }
    *(rbuf + count) = buf;
    count++;
    if (count >= upto_len)
      if (!memcmp(rbuf + count - upto_len, upto, upto_len)) {
        if (opt_complete)
          *opt_complete = 1;
        break;
      }
    if (count >= maxlen) {
      int i;
      if (upto_len >= count)
        upto_len = count - 1;
      if (count > 1)
        for (i = upto_len; i > 0; i--)
          if (!memcmp(rbuf + count - i, upto, i)) {
            jelio_buffer_ungetc(jb, rbuf + count - i, i);
            count -= i;
          }
      break;
    }
  }
  *(rbuf + count) = 0;
  return count;
}
```