user: Converte this assembly snippet into its equivalent C code:

```asm
<lzrestore_tek0>:
  endbr64
  push   %r15
  xor    %eax,%eax
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  call   <getnum_s8@plt>
  mov    $0x2,%edi
  mov    %eax,%r13d
  call   <getbc@plt>
  mov    $0x1,%edi
  mov    %eax,0xc(%rsp)
  call   <getbc@plt>
  mov    $0x2,%edi
  mov    %eax,%ebp
  call   <getbc@plt>
  mov    $0x2,%edi
  mov    %eax,0x18(%rsp)
  call   <getbc@plt>
  mov    %eax,0x1c(%rsp)
  lea    0x1(%r15),%rax
  mov    %rax,0x10(%rsp)
  nopl   0x0(%rax)
L8:
  mov    0x18(%rsp),%edi
  call   <getnum_l0a@plt>
  test   %eax,%eax
  js     L109
  movslq %r12d,%rcx
  sub    $0x1,%eax
  lea    (%r15,%rcx,1),%r14
  add    0x10(%rsp),%rcx
  lea    (%rcx,%rax,1),%rbx
  jmp    L104
  xchg   %ax,%ax
L43:
  mov    %al,(%r14)
  add    $0x1,%r14
  add    $0x1,%r12d
  cmp    %rbx,%r14
  je     L224
L104:
  mov    $0x8,%edi
  call   <getbc@plt>
  test   %eax,%eax
  jns    L43
L224:
  mov    0x1c(%rsp),%edi
  call   <getnum_l0a@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  js     L109
  nopl   0x0(%rax)
L122:
  mov    %r13d,%edi
  call   <getnum_df@plt>
  mov    %eax,%r14d
  xor    %eax,%eax
  test   %ebp,%ebp
  jne    L121
  call   <getnum_l1a@plt>
  test   %eax,%eax
  js     L8
L24:
  mov    0xc(%rsp),%esi
  movslq %r12d,%rcx
  movslq %r14d,%rdi
  lea    (%rdi,%rcx,1),%r9
  lea    (%rax,%rsi,1),%edx
  lea    -0x1(%rdx),%r8d
  mov    %edx,%r10d
  cmp    $0x6,%r8d
  jbe    L174
  cmp    $0xfffffffffffffff0,%rdi
  ja     L174
  cmp    $0xe,%r8d
  jbe    L225
  mov    %edx,%edi
  lea    (%r15,%r9,1),%r11
  lea    (%r15,%rcx,1),%r10
  xor    %eax,%eax
  shr    $0x4,%edi
  shl    $0x4,%rdi
  nop
L19:
  movdqu (%r11,%rax,1),%xmm0
  movups %xmm0,(%r10,%rax,1)
  add    $0x10,%rax
  cmp    %rdi,%rax
  jne    L19
  mov    %edx,%eax
  mov    %edx,%r10d
  and    $0xfffffff0,%eax
  lea    (%r12,%rax,1),%edi
  sub    %eax,%r10d
  cmp    %eax,%edx
  je     L113
L0:
  sub    %eax,%edx
  lea    -0x1(%rdx),%r11d
  cmp    $0x6,%r11d
  jbe    L235
  add    %r15,%r9
  add    %r15,%rcx
  mov    (%r9,%rax,1),%r9
  mov    %r9,(%rcx,%rax,1)
  mov    %edx,%eax
  and    $0xfffffff8,%eax
  add    %eax,%edi
  sub    %eax,%r10d
  cmp    %eax,%edx
  je     L113
L235:
  lea    (%r14,%rdi,1),%eax
  cltq
  movzbl (%r15,%rax,1),%edx
  movslq %edi,%rax
  mov    %dl,(%r15,%rax,1)
  lea    0x1(%rdi),%eax
  cmp    $0x1,%r10d
  je     L113
  lea    (%r14,%rax,1),%edx
  cltq
  movslq %edx,%rdx
  movzbl (%r15,%rdx,1),%edx
  mov    %dl,(%r15,%rax,1)
  lea    0x2(%rdi),%eax
  cmp    $0x2,%r10d
  je     L113
  lea    (%r14,%rax,1),%edx
  cltq
  movslq %edx,%rdx
  movzbl (%r15,%rdx,1),%edx
  mov    %dl,(%r15,%rax,1)
  lea    0x3(%rdi),%eax
  cmp    $0x3,%r10d
  je     L113
  lea    (%r14,%rax,1),%edx
  cltq
  movslq %edx,%rdx
  movzbl (%r15,%rdx,1),%edx
  mov    %dl,(%r15,%rax,1)
  lea    0x4(%rdi),%eax
  cmp    $0x4,%r10d
  je     L113
  lea    (%r14,%rax,1),%edx
  cltq
  movslq %edx,%rdx
  movzbl (%r15,%rdx,1),%edx
  mov    %dl,(%r15,%rax,1)
  lea    0x5(%rdi),%eax
  cmp    $0x5,%r10d
  je     L113
  lea    (%r14,%rax,1),%edx
  cltq
  movslq %edx,%rdx
  movzbl (%r15,%rdx,1),%edx
  mov    %dl,(%r15,%rax,1)
  lea    0x6(%rdi),%eax
  cmp    $0x6,%r10d
  je     L113
  lea    (%r14,%rax,1),%esi
  cltq
  movslq %esi,%rsi
  movzbl (%r15,%rsi,1),%edx
  mov    %dl,(%r15,%rax,1)
L113:
  lea    0x1(%r12,%r8,1),%r12d
  sub    $0x1,%ebx
  jne    L122
  jmp    L8
  nopw   0x0(%rax,%rax,1)
L121:
  call   <getnum_l1b@plt>
  test   %eax,%eax
  jns    L24
  jmp    L8
  nopw   0x0(%rax,%rax,1)
L174:
  lea    (%r15,%rcx,1),%rax
  mov    %r8d,%edx
  add    0x10(%rsp),%rcx
  add    %rdx,%rcx
  nop
L71:
  movzbl (%rax,%rdi,1),%edx
  add    $0x1,%rax
  mov    %dl,-0x1(%rax)
  cmp    %rcx,%rax
  jne    L71
  jmp    L113
L225:
  mov    %r12d,%edi
  xor    %eax,%eax
  jmp    L0
L109:
  add    $0x28,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int lzrestore_tek0(unsigned char *buf, int k, int i, int outlimit) {
  int len, distance, j, z0, z1;
  unsigned int dis_s, l_ofs, method;
  dis_s = getnum_s8();
  l_ofs = getbc(2);
  method = getbc(1);
  z0 = getbc(2);
  z1 = getbc(2);
  i = 0;
  for (;;) {
    j = getnum_l0a(z0);
    if (j < 0)
      break;
    do {
      len = getbc(8);
      if (len < 0)
        break;
      buf[i++] = len;
    } while (--j);
    j = getnum_l0a(z1);
    if (j < 0)
      break;
    do {
      distance = getnum_df(dis_s);
      if (method == 0) {
        len = getnum_l1a();
      } else {
        len = getnum_l1b();
      }
      if (len < 0)
        break;
      len += l_ofs;
      do {
        buf[i] = buf[i + distance];
        i++;
      } while (--len);
    } while (--j);
  }
  return i;
}
```