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

```asm
<luminousarc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %esi,-0x44(%rbp)
  mov    %rdx,-0x50(%rbp)
  mov    %ecx,-0x48(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  lea    -0x1000(%rsp),%rax
  cmp    %rax,%rsp
  je     L40
L189:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rax,%rsp
  jne    L189
L40:
  sub    $0x10,%rsp
  orq    $0x0,0x8(%rsp)
  mov    -0x48(%rbp),%eax
  mov    %rsp,%r8
  test   %eax,%eax
  jle    L23
  mov    $0x3,%ebx
  xor    %r15d,%r15d
  xor    %r10d,%r10d
  xor    %eax,%eax
  xor    %esi,%esi
  xor    %r11d,%r11d
  mov    $0xffc00ffd,%edi
  nopl   0x0(%rax,%rax,1)
L159:
  cmp    $0x3,%ebx
  je     L26
  sar    $0x2,%r15d
  sar    $0x2,%ebx
  mov    %r15d,%edx
  and    $0x3,%edx
  cmp    $0x2,%edx
  je     L113
L238:
  cmp    $0x3,%edx
  je     L247
  cmp    $0x1,%edx
  je     L88
  lea    0x1(%rsi),%edx
  cmp    -0x44(%rbp),%edx
  jge    L231
  mov    -0x58(%rbp),%r14
  movslq %edx,%rdx
  movslq %esi,%rcx
  add    $0x2,%esi
  movzbl (%r14,%rdx,1),%edx
  movzbl (%r14,%rcx,1),%ecx
  mov    %edx,%r14d
  shl    $0x8,%edx
  and    $0xf00,%edx
  sar    $0x4,%r14d
  or     %ecx,%edx
  lea    0x3(%r14),%r9d
  add    $0x5,%edx
  mov    %r9d,-0x5c(%rbp)
  cmp    %edx,%r10d
  jl     L231
  lea    0x1004(%rax),%ecx
  movslq %r11d,%r12
  add    -0x50(%rbp),%r12
  sub    %edx,%ecx
  lea    (%r9,%rcx,1),%r13d
  nopl   (%rax)
L104:
  mov    %ecx,%edx
  mov    %ecx,%r9d
  add    $0x1,%ecx
  add    $0x1,%r12
  imul   %rdi,%rdx
  shr    $0x2c,%rdx
  imul   $0x1004,%edx,%edx
  sub    %edx,%r9d
  movslq %r9d,%rdx
  movslq %eax,%r9
  add    $0x1,%eax
  movzbl (%r8,%rdx,1),%edx
  mov    %dl,(%r8,%r9,1)
  mov    %dl,-0x1(%r12)
  mov    %rax,%rdx
  imul   %rdi,%rax
  shr    $0x2c,%rax
  imul   $0x1004,%eax,%r9d
  mov    %edx,%eax
  sub    %r9d,%eax
  cmp    %r13d,%ecx
  jne    L104
  lea    0x3(%r14,%r11,1),%r11d
  add    -0x5c(%rbp),%r10d
L29:
  cmp    -0x48(%rbp),%r10d
  jl     L159
L216:
  mov    -0x44(%rbp),%ebx
  cmp    %ebx,%esi
  jl     L79
  cs nopw 0x0(%rax,%rax,1)
L103:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L92
  lea    -0x28(%rbp),%rsp
  mov    %r11d,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   (%rax)
L26:
  cmp    -0x44(%rbp),%esi
  jge    L231
  mov    -0x58(%rbp),%rbx
  movslq %esi,%rdx
  add    $0x1,%esi
  movzbl (%rbx,%rdx,1),%r15d
  mov    $0xc0,%ebx
  mov    %r15d,%edx
  and    $0x3,%edx
  cmp    $0x2,%edx
  jne    L238
L113:
  cmp    -0x44(%rbp),%esi
  jge    L231
  mov    -0x58(%rbp),%rcx
  movslq %esi,%rdx
  mov    -0x50(%rbp),%r14
  add    $0x1,%r10d
  add    $0x1,%esi
  movzbl (%rcx,%rdx,1),%edx
  movslq %r11d,%rcx
  add    $0x1,%r11d
  mov    %dl,(%r14,%rcx,1)
  movslq %eax,%rcx
  add    $0x1,%eax
  mov    %dl,(%r8,%rcx,1)
  mov    %rax,%rdx
  imul   %rdi,%rax
  shr    $0x2c,%rax
  imul   $0x1004,%eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  jmp    L29
  nopw   0x0(%rax,%rax,1)
L88:
  cmp    -0x44(%rbp),%esi
  jge    L231
  lea    0x1(%rsi),%ecx
  movslq %esi,%rsi
  mov    %ecx,-0x5c(%rbp)
  mov    -0x58(%rbp),%rcx
  movzbl (%rcx,%rsi,1),%r13d
  mov    %r13d,%edx
  sar    $0x2,%r13d
  and    $0x3,%edx
  lea    0x2(%r13),%r14d
  add    $0x1,%edx
  cmp    %edx,%r10d
  jl     L231
  lea    0x1004(%rax),%ecx
  movslq %r11d,%r9
  add    -0x50(%rbp),%r9
  sub    %edx,%ecx
  lea    (%r14,%rcx,1),%r12d
L207:
  mov    %ecx,%edx
  mov    %ecx,%esi
  add    $0x1,%ecx
  add    $0x1,%r9
  imul   %rdi,%rdx
  shr    $0x2c,%rdx
  imul   $0x1004,%edx,%edx
  sub    %edx,%esi
  movslq %esi,%rdx
  movslq %eax,%rsi
  add    $0x1,%eax
  movzbl (%r8,%rdx,1),%edx
  mov    %dl,(%r8,%rsi,1)
  mov    %dl,-0x1(%r9)
  mov    %rax,%rdx
  imul   %rdi,%rax
  shr    $0x2c,%rax
  imul   $0x1004,%eax,%esi
  mov    %edx,%eax
  sub    %esi,%eax
  cmp    %r12d,%ecx
  jne    L207
  mov    -0x5c(%rbp),%esi
  lea    0x2(%r13,%r11,1),%r11d
  add    %r14d,%r10d
  jmp    L29
  nopl   0x0(%rax,%rax,1)
L247:
  lea    0x1(%r11),%edx
  movslq %esi,%rcx
  movslq %r11d,%r11
  sub    %esi,%r10d
  sub    %r11,%rcx
  movslq %edx,%rdx
  lea    0x4(%r11),%r12
  add    -0x58(%rbp),%rcx
L239:
  cmp    %esi,-0x44(%rbp)
  jle    L231
  movzbl -0x1(%rcx,%rdx,1),%r9d
  mov    -0x50(%rbp),%r14
  add    $0x1,%esi
  mov    %edx,%r11d
  lea    (%r10,%rsi,1),%r13d
  mov    %r9b,-0x1(%r14,%rdx,1)
  movslq %eax,%r14
  add    $0x1,%eax
  add    $0x1,%rdx
  mov    %r9b,(%r8,%r14,1)
  mov    %rax,%r9
  imul   %rdi,%rax
  shr    $0x2c,%rax
  imul   $0x1004,%eax,%r14d
  mov    %r9d,%eax
  sub    %r14d,%eax
  cmp    %r12,%rdx
  jne    L239
  mov    %r13d,%r10d
  jmp    L29
L79:
  and    $0xfffffffc,%esi
  lea    0x4(%rsi),%eax
  cmp    %ebx,%eax
  jge    L103
  nopw   0x0(%rax,%rax,1)
L231:
  mov    $0xffffffff,%r11d
  jmp    L103
L23:
  xor    %esi,%esi
  xor    %r11d,%r11d
  jmp    L216
L92:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int luminousarc(unsigned char *instream, int inLength, unsigned char *outstream, int decompressedSize) {
  int i, o = 0;
  int readBytes = 0;
  int bufferLength = 0xFFF + 5;
  unsigned char buffer[bufferLength];
  int bufferOffset = 0;
  int currentOutSize = 0;
  int flags = 0, mask = 3;
  while (currentOutSize < decompressedSize) {
    if (mask == 3) {
      if (readBytes >= inLength)
        return (-1);
      flags = instream[readBytes++];
      if (flags < 0)
        return (-1);
      mask = 0xC0;
    } else {
      mask >>= 2;
      flags >>= 2;
    }
    switch (flags & 0x3) {
    case 0: {
      if (readBytes + 1 >= inLength) {
        return (-1);
      }
      int byte1 = instream[readBytes++];
      int byte2 = instream[readBytes++];
      if (byte2 < 0)
        return (-1);
      int length = byte2 >> 4;
      length += 3;
      int disp = ((byte2 & 0x0F) << 8) | byte1;
      disp += 5;
      if (disp > currentOutSize)
        return (-1);
      int bufIdx = bufferOffset + bufferLength - disp;
      for (i = 0; i < length; i++) {
        unsigned char next = buffer[bufIdx % bufferLength];
        bufIdx++;
        outstream[o++] = next;
        buffer[bufferOffset] = next;
        bufferOffset = (bufferOffset + 1) % bufferLength;
      }
      currentOutSize += length;
      break;
    }
    case 1: {
      if (readBytes >= inLength) {
        return (-1);
      }
      int b = instream[readBytes++];
      if (b < 0)
        return (-1);
      int length = b >> 2;
      length += 2;
      int disp = (b & 0x03);
      disp += 1;
      if (disp > currentOutSize)
        return (-1);
      int bufIdx = bufferOffset + bufferLength - disp;
      for (i = 0; i < length; i++) {
        unsigned char next = buffer[bufIdx % bufferLength];
        bufIdx++;
        outstream[o++] = next;
        buffer[bufferOffset] = next;
        bufferOffset = (bufferOffset + 1) % bufferLength;
      }
      currentOutSize += length;
      break;
    }
    case 2: {
      if (readBytes >= inLength)
        return (-1);
      int next = instream[readBytes++];
      if (next < 0)
        return (-1);
      currentOutSize++;
      outstream[o++] = next;
      buffer[bufferOffset] = (unsigned char)next;
      bufferOffset = (bufferOffset + 1) % bufferLength;
      break;
    }
    case 3: {
      for (i = 0; i < 3; i++) {
        if (readBytes >= inLength)
          return (-1);
        int next = instream[readBytes++];
        if (next < 0)
          return (-1);
        currentOutSize++;
        outstream[o++] = next;
        buffer[bufferOffset] = (unsigned char)next;
        bufferOffset = (bufferOffset + 1) % bufferLength;
      }
      break;
    }
    default:
      return (-1);
    }
  }
  if (readBytes < inLength) {
    if ((readBytes ^ (readBytes & 3)) + 4 < inLength)
      return (-1);
  }
  return (o);
}
```