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

```asm
<zlib_inflate>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x58,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x2048(%rsp)
  xor    %eax,%eax
  mov    D47(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,0x30(%rsp)
  mov    %rax,0x28(%rsp)
  mov    %rax,0x20(%rsp)
  movq   $0x0,(%rsp)
  mov    %rax,0x8(%rsp)
  mov    %rsp,%rdi
  call   <inflateInit@plt>
  mov    %eax,%ebx
  mov    D82(%rip),%rax
  cmp    %ebx,(%rax)
  jne    L23
  lea    0x40(%rsp),%r13
L134:
  mov    %rbp,%rcx
  mov    $0x1000,%edx
  mov    $0x1,%esi
  mov    %r13,%rdi
  call   <fread@plt>
  mov    %rax,(%rsp)
  mov    %rbp,%rdi
  call   <ferror@plt>
  test   %rax,%rax
  jne    L11
  cmpq   $0x0,(%rsp)
  je     L16
  mov    %r13,0x8(%rsp)
  lea    0x1040(%rsp),%r14
L45:
  movl   $0x1000,0x10(%rsp)
  mov    %r14,0x18(%rsp)
  mov    %rsp,%rdi
  mov    D29(%rip),%rax
  mov    (%rax),%esi
  call   <inflate@plt>
  mov    %eax,%ebx
  mov    D53(%rip),%rax
  cmp    %ebx,(%rax)
  je     L23
  cmp    $0x80,%ebx
  je     L83
  lea    -0x81(%rbx),%eax
  cmp    $0x1,%eax
  ja     L26
L102:
  mov    %rsp,%rdi
  call   <inflateEnd@plt>
L23:
  mov    0x2048(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L39
  mov    %ebx,%eax
  add    $0x2058,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L11:
  mov    %rsp,%rdi
  call   <inflateEnd@plt>
  mov    D0(%rip),%rax
  mov    (%rax),%ebx
  jmp    L23
L83:
  mov    $0x82,%ebx
  jmp    L102
L26:
  mov    $0x1000,%r15d
  sub    0x10(%rsp),%r15d
  mov    %r12,%rcx
  mov    %r15d,%edx
  mov    $0x1,%esi
  mov    %r14,%rdi
  call   <fwrite@plt>
  cmp    %r15d,%eax
  jne    L8
  mov    %r12,%rdi
  call   <ferror@plt>
  test   %rax,%rax
  jne    L8
  cmpl   $0x0,0x10(%rsp)
  je     L45
  mov    D52(%rip),%rax
  cmp    %ebx,(%rax)
  jne    L134
L16:
  mov    %rsp,%rdi
  call   <inflateEnd@plt>
  mov    D52(%rip),%rax
  cmp    %ebx,(%rax)
  jne    L165
  mov    D82(%rip),%rax
  mov    (%rax),%ebx
  jmp    L23
L8:
  mov    %rsp,%rdi
  call   <inflateEnd@plt>
  mov    D0(%rip),%rax
  mov    (%rax),%ebx
  jmp    L23
L165:
  mov    $0x82,%ebx
  jmp    L23
L39:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int zlib_inflate(FILE *fin, FILE *fout) {
  z_stream strm;
  unsigned char bin[0x1000];
  unsigned char bout[0x1000];
  int nleft, result;
  strm.zalloc = Z_NULL;
  strm.zfree = Z_NULL;
  strm.opaque = Z_NULL;
  strm.avail_in = 0;
  strm.next_in = Z_NULL;
  result = inflateInit(&strm);
  if (result != Z_OK)
    return result;
  do {
    strm.avail_in = fread(bin, 1, 0x1000, fin);
    if (ferror(fin)) {
      inflateEnd(&strm);
      return Z_ERRNO;
    }
    if (strm.avail_in == 0)
      break;
    strm.next_in = bin;
    do {
      strm.avail_out = 0x1000;
      strm.next_out = bout;
      result = inflate(&strm, Z_NO_FLUSH);
      if (result == Z_STREAM_ERROR)
        return result;
      switch (result) {
      case Z_NEED_DICT:
        result = Z_DATA_ERROR;
      case Z_DATA_ERROR:
      case Z_MEM_ERROR:
        inflateEnd(&strm);
        return result;
        break;
      }
      nleft = 0x1000 - strm.avail_out;
      if ((fwrite(bout, 1, nleft, fout) != nleft) || ferror(fout)) {
        inflateEnd(&strm);
        return Z_ERRNO;
      }
    } while (strm.avail_out == 0);
  } while (result != Z_STREAM_END);
  inflateEnd(&strm);
  if (result != Z_STREAM_END)
    return Z_DATA_ERROR;
  return Z_OK;
}
```