user: Translate the below assembly code into C programming language:

```asm
<sega_lz77>:
  endbr64
  xor    %r11d,%r11d
  test   %esi,%esi
  jle    L219
  push   %r13
  xor    %eax,%eax
  mov    $0x1,%ecx
  push   %r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    %esi,%edi
  nopl   0x0(%rax)
L29:
  movslq %r11d,%rdx
  jmp    L97
  nopl   (%rax)
L39:
  mov    %r8d,%esi
  lea    -0x2(%rcx),%r13d
  mov    %r8d,%r9d
  mov    %r10d,%ecx
  and    $0x1,%esi
  shr    %r8b
  test   %sil,%sil
  je     L190
L189:
  xor    %esi,%esi
  cmp    %edi,%eax
  jge    L288
  movslq %eax,%rsi
  add    $0x1,%eax
  movzbl (%rbx,%rsi,1),%esi
L288:
  mov    %sil,0x0(%rbp,%rdx,1)
  add    $0x1,%rdx
L97:
  mov    %ecx,%r10d
  mov    %edx,%r12d
  movslq %edx,%r11
  sub    $0x1,%r10d
  jne    L39
  cmp    %edi,%eax
  jge    L134
  movslq %eax,%rcx
  mov    $0x7,%r13d
  add    $0x1,%eax
  movzbl (%rbx,%rcx,1),%r9d
  mov    $0x8,%ecx
  mov    %r9d,%esi
  mov    %r9d,%r8d
  and    $0x1,%esi
  shr    %r8b
  test   %sil,%sil
  jne    L189
L190:
  test   %r13d,%r13d
  jne    L283
  cmp    %edi,%eax
  jge    L85
  movslq %eax,%rdx
  add    $0x1,%eax
  mov    $0x8,%r13d
  movzbl (%rbx,%rdx,1),%edx
  mov    %edx,%r8d
  shr    %r8b
  and    $0x1,%edx
  mov    %r8d,%esi
  je     L85
L322:
  cmp    %eax,%edi
  jle    L110
  movslq %eax,%rdx
  lea    0x1(%rax),%esi
  movzbl (%rbx,%rdx,1),%edx
  mov    %edx,%ecx
  cmp    %esi,%edi
  jle    L170
  movslq %esi,%rsi
  add    $0x2,%eax
  movzbl (%rbx,%rsi,1),%esi
  mov    %esi,%r9d
  or     %edx,%r9d
L137:
  test   %r9b,%r9b
  je     L78
  shl    $0x5,%esi
  shr    $0x3,%edx
  lea    -0x2000(%rsi,%rdx,1),%esi
  and    $0x7,%ecx
  je     L68
  add    $0x2,%ecx
  movzbl %cl,%edx
  mov    %r13d,%ecx
  jmp    L319
  nopl   0x0(%rax,%rax,1)
L134:
  xor    %r8d,%r8d
  mov    $0x8,%ecx
L302:
  cmp    $0x2,%ecx
  jne    L310
  cmp    %edi,%eax
  jge    L281
  movslq %eax,%rdx
  add    $0x1,%eax
  movzbl (%rbx,%rdx,1),%edx
  mov    %edx,%ecx
  mov    %edx,%r8d
  and    $0x1,%edx
  shr    %cl
  shr    $0x2,%r8b
  and    $0x1,%ecx
  lea    0x2(%rcx,%rdx,2),%edx
L125:
  mov    $0x7,%ecx
L109:
  cmp    %eax,%edi
  jle    L133
  movslq %eax,%rsi
  add    $0x1,%eax
  movzbl (%rbx,%rsi,1),%esi
  sub    $0x100,%esi
L319:
  cmp    %eax,%edi
  jg     L29
  jmp    L108
  nop
L283:
  mov    %r8d,%edx
  shr    $0x2,%r9b
  and    $0x1,%edx
  mov    %r9d,%r8d
  test   %dl,%dl
  jne    L322
  jmp    L302
  nopw   0x0(%rax,%rax,1)
L68:
  cmp    %eax,%edi
  jle    L285
  movslq %eax,%rdx
  mov    %r13d,%ecx
  add    $0x1,%eax
  movzbl (%rbx,%rdx,1),%edx
  add    $0xa,%edx
  jmp    L319
  nopw   0x0(%rax,%rax,1)
L85:
  mov    %esi,%edx
  mov    $0x6,%ecx
  and    $0x1,%edx
  add    %edx,%edx
L348:
  mov    %esi,%r8d
  shr    $0x2,%sil
  shr    %r8b
  and    $0x1,%r8d
  lea    0x2(%rdx,%r8,1),%edx
  mov    %esi,%r8d
  jmp    L109
  nopw   0x0(%rax,%rax,1)
L133:
  mov    $0xffffff00,%esi
L108:
  lea    -0x1(%rdx),%eax
  lea    0x1(%rbp,%r11,1),%rdi
  add    %r12d,%esi
  add    %rax,%rdi
  lea    0x0(%rbp,%r11,1),%rax
  sub    %eax,%esi
  nopw   0x0(%rax,%rax,1)
L162:
  lea    (%rsi,%rax,1),%ecx
  add    $0x1,%rax
  movzbl 0x0(%rbp,%rcx,1),%ecx
  mov    %cl,-0x1(%rax)
  cmp    %rax,%rdi
  jne    L162
  lea    (%r12,%rdx,1),%r11d
L110:
  pop    %rbx
  mov    %r11d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L285:
  mov    $0xa,%edx
  jmp    L108
L281:
  mov    $0x2,%edx
  xor    %r8d,%r8d
  jmp    L125
L78:
  test   %edx,%edx
  jne    L108
  jmp    L110
  nopw   0x0(%rax,%rax,1)
L219:
  mov    %r11d,%eax
  ret
L310:
  mov    %r8d,%edx
  mov    %r8d,%esi
  and    $0x1,%edx
  add    %edx,%edx
  sub    $0x3,%ecx
  jne    L348
  cmp    %edi,%eax
  jge    L138
  movslq %eax,%rcx
  add    $0x1,%eax
  movzbl (%rbx,%rcx,1),%ecx
  mov    %ecx,%r8d
  and    $0x1,%ecx
  shr    %r8b
  add    $0x2,%ecx
L81:
  add    %ecx,%edx
  mov    $0x8,%ecx
  jmp    L109
L138:
  mov    $0x2,%ecx
  xor    %r8d,%r8d
  jmp    L81
L170:
  mov    %esi,%eax
  mov    %edx,%r9d
  xor    %esi,%esi
  jmp    L137
```

assistant: ```c
int sega_lz77(unsigned char *Buf, int File_Size, unsigned char *Buf2) {
  int SrcPos;
  unsigned char CurByte;
  int BitCounter;
  unsigned char GetByte_00E1F580(void) {
    unsigned char RESULT;
    if (SrcPos >= File_Size)
      return (0);
    RESULT = Buf[SrcPos];
    SrcPos++;
    return (RESULT);
  }
  unsigned char GetBit_00E1F5D0(void) {
    unsigned char RESULT;
    BitCounter--;
    if (!BitCounter) {
      CurByte = GetByte_00E1F580();
      BitCounter = 8;
    }
    RESULT = CurByte & 1;
    CurByte >>= 1;
    return (RESULT);
  }
  unsigned int _EBP_m_4 = 0, _EBP_m_8 = 0;
  int DstPos;
  unsigned char _EAX;
  SrcPos = 0;
  DstPos = 0;
  BitCounter = 1;
  while (SrcPos < File_Size) {
    for (;;) {
      _EAX = GetBit_00E1F5D0();
      if (!_EAX)
        break;
      Buf2[DstPos++] = GetByte_00E1F580();
    }
    if (GetBit_00E1F5D0()) {
      _EBP_m_4 = GetByte_00E1F580();
      _EBP_m_8 = GetByte_00E1F580();
      _EAX = _EBP_m_8 | _EBP_m_4;
      if (!_EAX)
        break;
      _EBP_m_8 = (_EBP_m_8 << 5) + (_EBP_m_4 >> 3) - 0x2000;
      _EBP_m_4 &= 7;
      if (_EBP_m_4) {
        _EBP_m_4 += 2;
      } else {
        _EBP_m_4 = GetByte_00E1F580() + 0x0A;
      }
    } else {
      _EBP_m_4 = GetBit_00E1F5D0() * 2;
      _EBP_m_4 += GetBit_00E1F5D0() + 2;
      _EBP_m_8 = GetByte_00E1F580() - 0x100;
    }
  }
  while (_EBP_m_4 > 0) {
    Buf2[DstPos] = Buf2[DstPos + _EBP_m_8];
    DstPos++;
    _EBP_m_4--;
  }
  return (DstPos);
}
```