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

```asm
<sha1>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x230,%rsp
  mov    %rdx,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x228(%rsp)
  xor    %eax,%eax
  movl   $0x67452301,(%rsp)
  movl   $0xefcdab89,0x4(%rsp)
  movl   $0x98badcfe,0x8(%rsp)
  movl   $0x10325476,0xc(%rsp)
  movl   $0xc3d2e1f0,0x10(%rsp)
  test   $0x3f,%sil
  je     L29
  mov    %esi,%ecx
  and    $0xffffffc0,%ecx
  cmp    %ecx,%esi
  jle    L29
  movslq %ecx,%rax
  mov    %rax,%rdx
  neg    %rdx
  lea    0x20(%rsp,%rdx,4),%r8
L57:
  mov    (%rdi,%rax,4),%edx
  mov    %edx,(%r8,%rax,4)
  add    $0x1,%rax
  cmp    %eax,%esi
  jg     L57
  mov    %esi,%eax
  sub    %ecx,%eax
  lea    0x0(,%rsi,8),%r8d
  lea    0x1(%rax),%ebx
  movslq %eax,%rsi
  movl   $0x80,0x20(%rsp,%rsi,4)
  mov    %ebx,%eax
  and    $0x3f,%eax
  cmp    $0x38,%eax
  jne    L36
  jmp    L35
L29:
  lea    0x0(,%rsi,8),%r8d
  movl   $0x80,0x20(%rsp)
  mov    %esi,%ecx
  mov    $0x1,%ebx
L36:
  lea    0x1(%rbx),%eax
  cltq
L104:
  mov    %eax,%ebx
  movl   $0x0,0x1c(%rsp,%rax,4)
  add    $0x1,%rax
  mov    %ebx,%edx
  and    $0x3f,%edx
  cmp    $0x38,%edx
  jne    L104
L35:
  mov    %ecx,%esi
  movslq %ebx,%rax
  mov    %r8d,%edx
  mov    $0x38,%ecx
  sar    %cl,%edx
  mov    %edx,0x20(%rsp,%rax,4)
  lea    0x1(%rbx),%eax
  cltq
  mov    %r8d,%edx
  mov    $0x30,%ecx
  sar    %cl,%edx
  mov    %edx,0x20(%rsp,%rax,4)
  lea    0x2(%rbx),%eax
  cltq
  mov    %r8d,%edx
  mov    $0x28,%ecx
  sar    %cl,%edx
  mov    %edx,0x20(%rsp,%rax,4)
  lea    0x3(%rbx),%eax
  cltq
  mov    %r8d,%edx
  mov    $0x20,%ecx
  sar    %cl,%edx
  mov    %edx,0x20(%rsp,%rax,4)
  lea    0x4(%rbx),%eax
  cltq
  mov    %r8d,%edx
  sar    $0x18,%edx
  mov    %edx,0x20(%rsp,%rax,4)
  lea    0x5(%rbx),%eax
  cltq
  mov    %r8d,%edx
  sar    $0x10,%edx
  mov    %edx,0x20(%rsp,%rax,4)
  lea    0x6(%rbx),%eax
  cltq
  mov    %r8d,%edx
  sar    $0x8,%edx
  mov    %edx,0x20(%rsp,%rax,4)
  lea    0x7(%rbx),%eax
  cltq
  mov    %r8d,0x20(%rsp,%rax,4)
  mov    %esi,%ecx
  test   %esi,%esi
  jle    L51
  mov    %rdi,%rbp
  sub    $0x1,%ecx
  shr    $0x6,%ecx
  mov    %ecx,%ecx
  shl    $0x8,%rcx
  lea    0x100(%rdi,%rcx,1),%r14
  mov    %rsp,%r13
L91:
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <sha1_chunk@plt>
  add    $0x100,%rbp
  cmp    %r14,%rbp
  jne    L91
L51:
  cmp    $0xfffffff9,%ebx
  jl     L53
  lea    0x20(%rsp),%rbp
  add    $0x7,%ebx
  shr    $0x6,%ebx
  mov    %ebx,%ebx
  shl    $0x8,%rbx
  lea    0x120(%rsp,%rbx,1),%r13
  mov    %rsp,%rbx
L12:
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <sha1_chunk@plt>
  add    $0x100,%rbp
  cmp    %r13,%rbp
  jne    L12
L53:
  mov    $0x0,%eax
L85:
  mov    %eax,%edx
  sar    $0x2,%edx
  movslq %edx,%rdx
  mov    (%rsp,%rdx,4),%edx
  mov    %edx,%ecx
  sar    $0x18,%ecx
  mov    %ecx,(%r12,%rax,4)
  mov    %edx,%ecx
  sar    $0x10,%ecx
  mov    %ecx,0x4(%r12,%rax,4)
  mov    %edx,%ecx
  sar    $0x8,%ecx
  mov    %ecx,0x8(%r12,%rax,4)
  mov    %edx,0xc(%r12,%rax,4)
  add    $0x4,%rax
  cmp    $0x14,%rax
  jne    L85
  mov    0x228(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L89
  add    $0x230,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L89:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void sha1(uint8_t *data, uint64_t size, uint8_t *out) {
  uint32_t hash[5] = {0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0};
  uint8_t last[128];
  uint32_t last_size = 0;
  if ((size & 63) != 0) {
    for (uint32_t src = size - (size & 63); src < size; src++) {
      last[last_size++] = data[src];
    }
  }
  uint64_t bitsize = size * 8;
  size -= last_size;
  last[last_size++] = 0x80;
  while ((last_size & 63) != 56) {
    last[last_size++] = 0;
  }
  last[last_size++] = bitsize >> 56;
  last[last_size++] = bitsize >> 48;
  last[last_size++] = bitsize >> 40;
  last[last_size++] = bitsize >> 32;
  last[last_size++] = bitsize >> 24;
  last[last_size++] = bitsize >> 16;
  last[last_size++] = bitsize >> 8;
  last[last_size++] = bitsize;
  for (uint64_t cur = 0; cur < size; cur += 64) {
    sha1_chunk(data + cur, hash);
  }
  for (uint64_t cur = 0; cur < last_size; cur += 64) {
    sha1_chunk(last + cur, hash);
  }
  for (uint32_t cur = 0; cur < 20; cur += 4) {
    uint32_t val = hash[cur >> 2];
    out[cur] = val >> 24;
    out[cur + 1] = val >> 16;
    out[cur + 2] = val >> 8;
    out[cur + 3] = val;
  }
}
```