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

```asm
<SHA512_finish>:
  endbr64
  mov    %rdx,%r8
  mov    %edx,%r9d
  push   %r14
  mov    %rdx,%r14
  shr    $0x3,%r8
  and    $0x7,%r9d
  push   %r13
  mov    %rsi,%r13
  and    $0xf,%r8d
  push   %r12
  shl    $0x3,%r9d
  mov    %rdi,%r12
  push   %rbp
  mov    %rsi,%rdi
  mov    %r8d,%r10d
  push   %rbx
  mov    %rsi,%rbx
  xor    %esi,%esi
  cs nopw 0x0(%rax,%rax,1)
L64:
  mov    (%rdi),%rcx
  mov    0x8(%rdi),%rdx
  add    $0x10,%rdi
  mov    %rcx,%rax
  mov    %rcx,%r11
  shr    $0x18,%r11
  shl    $0x18,%rax
  or     %r11,%rax
  mov    %rcx,%r11
  shr    $0x8,%rcx
  shl    $0x8,%r11
  and    $0xff00,%ecx
  and    $0xff0000,%r11d
  or     %r11,%rax
  mov    %rdx,%r11
  or     %rcx,%rax
  mov    %rdx,%rcx
  shr    $0x18,%r11
  shl    $0x18,%rcx
  shl    $0x20,%rax
  or     %r11,%rcx
  mov    %rdx,%r11
  shr    $0x8,%rdx
  shl    $0x8,%r11
  and    $0xff00,%edx
  and    $0xff0000,%r11d
  or     %r11,%rcx
  or     %rcx,%rdx
  or     %rdx,%rax
  mov    %rax,0x0(%r13,%rsi,8)
  add    $0x1,%rsi
  cmp    %esi,%r10d
  jge    L64
  movabs $0x8000000000000000,%rax
  lea    0x0(%r13,%r8,8),%rsi
  test   %r9d,%r9d
  je     L26
  mov    $0x40,%ecx
  mov    $0xffffffffffffffff,%rdx
  sub    %r9d,%ecx
  shl    %cl,%rdx
  mov    %r9d,%ecx
  and    (%rsi),%rdx
  shr    %cl,%rax
  or     %rdx,%rax
L26:
  add    $0x1,%r8d
  mov    %rax,(%rsi)
  cmp    $0xe,%r8d
  jle    L59
  cmp    $0x10,%r8d
  jne    L66
L87:
  lea    0x200(%r13),%rbp
  mov    %r13,%rdx
  nopl   (%rax)
L1:
  mov    0x70(%rdx),%rcx
  mov    0x8(%rdx),%rsi
  add    $0x8,%rdx
  mov    %rcx,%rax
  mov    %rcx,%rdi
  shr    $0x6,%rcx
  rol    $0x3,%rdi
  ror    $0x13,%rax
  xor    %rdi,%rax
  mov    %rsi,%rdi
  xor    %rcx,%rax
  mov    -0x8(%rdx),%rcx
  add    0x40(%rdx),%rcx
  ror    $0x8,%rdi
  add    %rcx,%rax
  mov    %rsi,%rcx
  shr    $0x7,%rsi
  ror    %rcx
  xor    %rdi,%rcx
  xor    %rsi,%rcx
  add    %rcx,%rax
  mov    %rax,0x78(%rdx)
  cmp    %rdx,%rbp
  jne    L1
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <SHA512_transform@plt>
  xor    %r8d,%r8d
L58:
  mov    $0xe,%eax
  sub    %r8d,%eax
  movslq %r8d,%r8
  lea    0x0(%r13,%r8,8),%rdx
  shl    $0x3,%rax
  lea    0x8(%rdx),%rdi
  mov    %eax,%ecx
  movq   $0x0,(%rdx)
  movq   $0x0,-0x8(%rdx,%rcx,1)
  and    $0xfffffffffffffff8,%rdi
  sub    %rdi,%rdx
  add    %edx,%eax
  shr    $0x3,%eax
  mov    %eax,%ecx
  xor    %eax,%eax
  rep stos %rax,%es:(%rdi)
L77:
  mov    %r14,%rax
  shl    $0x3,%r14
  shr    $0x3d,%rax
  mov    %r14,0x78(%r13)
  mov    %rax,0x70(%r13)
  nopl   0x0(%rax,%rax,1)
L24:
  mov    0x70(%rbx),%rdx
  mov    0x8(%rbx),%rcx
  add    $0x8,%rbx
  mov    %rdx,%rax
  mov    %rdx,%rsi
  shr    $0x6,%rdx
  rol    $0x3,%rsi
  ror    $0x13,%rax
  xor    %rsi,%rax
  mov    %rcx,%rsi
  xor    %rdx,%rax
  mov    -0x8(%rbx),%rdx
  add    0x40(%rbx),%rdx
  ror    $0x8,%rsi
  add    %rdx,%rax
  mov    %rcx,%rdx
  shr    $0x7,%rcx
  ror    %rdx
  xor    %rsi,%rdx
  xor    %rcx,%rdx
  add    %rdx,%rax
  mov    %rax,0x78(%rbx)
  cmp    %rbp,%rbx
  jne    L24
  pop    %rbx
  mov    %r13,%rsi
  pop    %rbp
  mov    %r12,%rdi
  pop    %r12
  pop    %r13
  pop    %r14
  jmp    1050 <SHA512_transform@plt>
L59:
  lea    0x200(%r13),%rbp
  jne    L58
  jmp    L77
L66:
  movq   $0x0,0x78(%r13)
  jmp    L87
```

assistant: ```c
void SHA512_finish(unsigned long long H[], unsigned long long W[], unsigned long long FileLen) {
  unsigned long *Buf = (unsigned long *)W;
  int t;
  int Witi = (FileLen % 128) / 8;
  int amari = (FileLen % 8) * 8;
  for (t = 0; t <= Witi; t++)
    W[t] = (unsigned long long)(Buf[t * 2] << 24 | Buf[t * 2] << 8 & 0xFF0000 | Buf[t * 2] >> 8 & 0xFF00 | Buf[t * 2] >> 24) << 32 | (unsigned long long)(Buf[t * 2 + 1] << 24 | Buf[t * 2 + 1] << 8 & 0xFF0000 | Buf[t * 2 + 1] >> 8 & 0xFF00 | Buf[t * 2 + 1] >> 24);
  if (amari == 0)
    W[Witi] = 0x8000000000000000ULL;
  else
    W[Witi] = W[Witi] & 0xFFFFFFFFFFFFFFFFULL << (64 - amari) | 0x8000000000000000ULL >> amari;
  Witi++;
  if (Witi >= 15) {
    for (t = Witi; t < 16; t++)
      W[t] = 0;
    for (t = 16; t < 80; t++)
      W[t] = ((((W[t - 2]) >> (19)) | ((W[t - 2]) << (64 - 19))) ^ (((W[t - 2]) >> (61)) | ((W[t - 2]) << (64 - 61))) ^ ((W[t - 2]) >> (6))) + W[t - 7] + ((((W[t - 15]) >> (1)) | ((W[t - 15]) << (64 - 1))) ^ (((W[t - 15]) >> (8)) | ((W[t - 15]) << (64 - 8))) ^ ((W[t - 15]) >> (7))) + W[t - 16];
    SHA512_transform(H, W);
    Witi = 0;
  }
  for (t = Witi; t < 14; t++)
    W[t] = 0;
  W[14] = FileLen >> 61;
  W[15] = FileLen << 3;
  for (t = 16; t < 80; t++)
    W[t] = ((((W[t - 2]) >> (19)) | ((W[t - 2]) << (64 - 19))) ^ (((W[t - 2]) >> (61)) | ((W[t - 2]) << (64 - 61))) ^ ((W[t - 2]) >> (6))) + W[t - 7] + ((((W[t - 15]) >> (1)) | ((W[t - 15]) << (64 - 1))) ^ (((W[t - 15]) >> (8)) | ((W[t - 15]) << (64 - 8))) ^ ((W[t - 15]) >> (7))) + W[t - 16];
  SHA512_transform(H, W);
}
```