user: 请将以下的汇编代码转换成C语言代码:

```asm
<dact_mzlib2_decompress>:
  endbr64
  push   %r13
  mov    %rdi,%r13
  lea    (%rdx,%rdx,1),%edi
  push   %r12
  movslq %edi,%rdi
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %rdi,(%rsp)
  call   <malloc@plt>
  mov    %r12d,%ecx
  mov    %r13,%rdx
  mov    %rsp,%rsi
  mov    %rax,%rdi
  mov    %rax,%rbp
  xor    %r12d,%r12d
  call   <uncompress@plt>
  mov    D16(%rip),%rdx
  cmp    %eax,(%rdx)
  jne    L47
  movzwl 0x0(%rbp),%r9d
  xor    %r11d,%r11d
  rol    $0x8,%r9w
  movzwl %r9w,%edi
  cmp    $0x1ff,%r9w
  lea    0x2(%rdi),%r10d
  setbe  %r11b
  test   %edi,%edi
  je     L85
  lea    -0x1(%rdi),%eax
  xor    %edx,%edx
  lea    D8(%rip),%rsi
  shr    %eax
  lea    0x1(%rax),%r8d
  add    %r8,%r8
  nopl   0x0(%rax)
L35:
  movzbl 0x2(%rbp,%rdx,1),%eax
  movzbl 0x3(%rbp,%rdx,1),%r12d
  mov    %edx,%ecx
  add    $0x2,%rdx
  sar    %ecx
  shl    $0x8,%eax
  movslq %ecx,%rcx
  or     %r12d,%eax
  cltq
  mov    %rax,(%rsi,%rcx,8)
  cmp    %r8,%rdx
  jne    L35
L85:
  mov    (%rsp),%r8
  xor    %r12d,%r12d
  cmp    %r10,%r8
  jbe    L54
  mov    $0x2,%eax
  sub    %r11d,%eax
  cmp    $0x1ff,%r9w
  movslq %eax,%r9
  jbe    L49
  lea    0x2(%rdi),%ecx
  xor    %eax,%eax
  lea    D8(%rip),%rsi
  nopw   0x0(%rax,%rax,1)
L43:
  movzbl 0x0(%rbp,%rcx,1),%edx
  movzbl 0x1(%rbp,%rcx,1),%edi
  lea    0x1(%rax),%r11d
  mov    %eax,%r10d
  add    %r9,%rcx
  add    $0x2,%eax
  shl    $0x8,%edx
  or     %edi,%edx
  movslq %edx,%rdx
  mov    (%rsi,%rdx,8),%rdi
  mov    %rdi,%rdx
  movzbl %dh,%edx
  mov    %dl,(%rbx,%r10,1)
  mov    %r11d,%edx
  mov    %dil,(%rbx,%rdx,1)
  cmp    %rcx,%r8
  ja     L43
  mov    %eax,%r12d
L54:
  mov    %rbp,%rdi
  call   <free@plt>
L47:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L48
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L49:
  lea    0x2(%rdi),%edx
  xor    %eax,%eax
  lea    D8(%rip),%rsi
  nopl   0x0(%rax)
L55:
  movzbl 0x0(%rbp,%rdx,1),%ecx
  lea    0x1(%rax),%r11d
  mov    %eax,%r10d
  add    %r9,%rdx
  add    $0x2,%eax
  mov    (%rsi,%rcx,8),%rdi
  mov    %rdi,%rcx
  movzbl %ch,%ecx
  mov    %cl,(%rbx,%r10,1)
  mov    %r11d,%ecx
  mov    %dil,(%rbx,%rcx,1)
  cmp    %r8,%rdx
  jb     L55
  mov    %eax,%r12d
  jmp    L54
L48:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int dact_mzlib2_decompress(unsigned char *curr_block, unsigned char *out_block, int blk_size, int bufsize) {
  static uint16_t lookup_table[65536];
  uint16_t curr_val, repl_val;
  unsigned long dest_size = (blk_size * 2);
  unsigned char *tmp_block;
  unsigned int m = 0, hdrsize;
  int retval, i, low_byte = 0;
  tmp_block = malloc(dest_size);
  retval = uncompress(tmp_block, &dest_size, curr_block, blk_size);
  if (retval != Z_OK)
    return (0);
  hdrsize = ((unsigned int)(((tmp_block[0] << 8) | tmp_block[1]))) + 2;
  if ((hdrsize - 2) < 0x200)
    low_byte = 1;
  for (i = 2; i < hdrsize; i += 2) {
    lookup_table[(i - 2) / 2] = ((tmp_block[i] << 8) | tmp_block[i + 1]);
  }
  for (i = hdrsize; i < (dest_size); i += (2 - low_byte)) {
    if (low_byte) {
      curr_val = tmp_block[i];
    } else {
      curr_val = ((tmp_block[i] << 8) | tmp_block[i + 1]);
    }
    repl_val = lookup_table[curr_val];
    out_block[m++] = repl_val >> 8;
    out_block[m++] = repl_val & 0xff;
  }
  free(tmp_block);
  return (m);
}
```