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

```asm
<sha1>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x270,%rsp
  mov    %rdi,-0x258(%rbp)
  mov    %esi,-0x25c(%rbp)
  mov    %rdx,-0x268(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x67452301,-0x230(%rbp)
  movl   $0xefcdab89,-0x22c(%rbp)
  movl   $0x98badcfe,-0x228(%rbp)
  movl   $0x10325476,-0x224(%rbp)
  movl   $0xc3d2e1f0,-0x220(%rbp)
  movl   $0x0,-0x24c(%rbp)
  mov    -0x25c(%rbp),%eax
  and    $0x3f,%eax
  test   %eax,%eax
  je     L17
  mov    -0x25c(%rbp),%eax
  and    $0xffffffc0,%eax
  mov    %eax,-0x248(%rbp)
  jmp    L0
L6:
  mov    -0x248(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x258(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x24c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24c(%rbp)
  mov    (%rcx),%edx
  cltq
  mov    %edx,-0x210(%rbp,%rax,4)
  addl   $0x1,-0x248(%rbp)
L0:
  mov    -0x248(%rbp),%eax
  cmp    -0x25c(%rbp),%eax
  jl     L6
L17:
  mov    -0x25c(%rbp),%eax
  shl    $0x3,%eax
  mov    %eax,-0x238(%rbp)
  mov    -0x24c(%rbp),%eax
  sub    %eax,-0x25c(%rbp)
  mov    -0x24c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24c(%rbp)
  cltq
  movl   $0x80,-0x210(%rbp,%rax,4)
  jmp    L45
L59:
  mov    -0x24c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24c(%rbp)
  cltq
  movl   $0x0,-0x210(%rbp,%rax,4)
L45:
  mov    -0x24c(%rbp),%eax
  and    $0x3f,%eax
  cmp    $0x38,%eax
  jne    L59
  mov    -0x24c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24c(%rbp)
  mov    $0x38,%ecx
  mov    -0x238(%rbp),%edx
  sar    %cl,%edx
  cltq
  mov    %edx,-0x210(%rbp,%rax,4)
  mov    -0x24c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24c(%rbp)
  mov    $0x30,%ecx
  mov    -0x238(%rbp),%edx
  sar    %cl,%edx
  cltq
  mov    %edx,-0x210(%rbp,%rax,4)
  mov    -0x24c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24c(%rbp)
  mov    $0x28,%ecx
  mov    -0x238(%rbp),%edx
  sar    %cl,%edx
  cltq
  mov    %edx,-0x210(%rbp,%rax,4)
  mov    -0x24c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24c(%rbp)
  mov    $0x20,%ecx
  mov    -0x238(%rbp),%edx
  sar    %cl,%edx
  cltq
  mov    %edx,-0x210(%rbp,%rax,4)
  mov    -0x24c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24c(%rbp)
  mov    -0x238(%rbp),%edx
  sar    $0x18,%edx
  cltq
  mov    %edx,-0x210(%rbp,%rax,4)
  mov    -0x24c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24c(%rbp)
  mov    -0x238(%rbp),%edx
  sar    $0x10,%edx
  cltq
  mov    %edx,-0x210(%rbp,%rax,4)
  mov    -0x24c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24c(%rbp)
  mov    -0x238(%rbp),%edx
  sar    $0x8,%edx
  cltq
  mov    %edx,-0x210(%rbp,%rax,4)
  mov    -0x24c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x24c(%rbp)
  cltq
  mov    -0x238(%rbp),%edx
  mov    %edx,-0x210(%rbp,%rax,4)
  movl   $0x0,-0x244(%rbp)
  jmp    L82
L114:
  mov    -0x244(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x258(%rbp),%rax
  add    %rax,%rdx
  lea    -0x230(%rbp),%rax
  mov    %rax,%rsi
  mov    %rdx,%rdi
  call   <sha1_chunk@plt>
  addl   $0x40,-0x244(%rbp)
L82:
  mov    -0x244(%rbp),%eax
  cmp    -0x25c(%rbp),%eax
  jl     L114
  movl   $0x0,-0x240(%rbp)
  jmp    L23
L10:
  mov    -0x240(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  lea    -0x210(%rbp),%rax
  add    %rax,%rdx
  lea    -0x230(%rbp),%rax
  mov    %rax,%rsi
  mov    %rdx,%rdi
  call   <sha1_chunk@plt>
  addl   $0x40,-0x240(%rbp)
L23:
  mov    -0x240(%rbp),%eax
  cmp    -0x24c(%rbp),%eax
  jl     L10
  movl   $0x0,-0x23c(%rbp)
  jmp    L33
L100:
  mov    -0x23c(%rbp),%eax
  sar    $0x2,%eax
  cltq
  mov    -0x230(%rbp,%rax,4),%eax
  mov    %eax,-0x234(%rbp)
  mov    -0x23c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x268(%rbp),%rax
  add    %rdx,%rax
  mov    -0x234(%rbp),%edx
  sar    $0x18,%edx
  mov    %edx,(%rax)
  mov    -0x23c(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x268(%rbp),%rax
  add    %rdx,%rax
  mov    -0x234(%rbp),%edx
  sar    $0x10,%edx
  mov    %edx,(%rax)
  mov    -0x23c(%rbp),%eax
  cltq
  add    $0x2,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x268(%rbp),%rax
  add    %rdx,%rax
  mov    -0x234(%rbp),%edx
  sar    $0x8,%edx
  mov    %edx,(%rax)
  mov    -0x23c(%rbp),%eax
  cltq
  add    $0x3,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x268(%rbp),%rax
  add    %rax,%rdx
  mov    -0x234(%rbp),%eax
  mov    %eax,(%rdx)
  addl   $0x4,-0x23c(%rbp)
L33:
  cmpl   $0x13,-0x23c(%rbp)
  jle    L100
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L83
  call   <__stack_chk_fail@plt>
L83:
  leave
  ret
```

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;
  }
}
```