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

```asm
<SHA256_Final>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  mov    0x20(%rsi),%r12
  mov    (%rsi),%rax
  mov    D4(%rip),%r13
  movb   $0x80,(%r12,%rax,1)
  add    $0x1,%rax
  mov    0x0(%r13),%edx
  lea    (%r12,%rax,1),%rdi
  mov    %eax,%esi
  lea    -0x8(%rdx),%ecx
  movslq %ecx,%rcx
  cmp    %rax,%rcx
  jb     L37
L31:
  sub    %esi,%edx
  xor    %esi,%esi
  sub    $0x8,%edx
  call   <memset@plt>
  movslq 0x0(%r13),%rax
  mov    0x8(%rbp),%edx
  mov    %rbp,%rdi
  bswap  %edx
  lea    -0x8(%r12,%rax,1),%rax
  mov    %edx,(%rax)
  lea    0x8(%rax),%r12
  mov    0xc(%rbp),%edx
  bswap  %edx
  mov    %edx,0x4(%rax)
  movslq 0x0(%r13),%rax
  mov    $0x1,%edx
  sub    %rax,%r12
  mov    %r12,%rsi
  call   <sha256_block_data_order@plt>
  mov    0x0(%r13),%edx
  xor    %esi,%esi
  mov    %r12,%rdi
  movq   $0x0,0x0(%rbp)
  call   <memset@plt>
  mov    0x10(%rbp),%eax
  cmp    $0x80,%eax
  je     L59
  cmp    $0x81,%eax
  jne    L24
  mov    0x18(%rbp),%rcx
  xor    %edx,%edx
L76:
  mov    (%rcx,%rdx,2),%eax
  bswap  %eax
  mov    %eax,(%rbx,%rdx,1)
  add    $0x4,%rdx
  cmp    $0x80,%rdx
  jne    L76
L35:
  mov    $0x1,%r8d
L19:
  add    $0x8,%rsp
  mov    %r8d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L59:
  mov    0x18(%rbp),%rcx
  xor    %edx,%edx
  cs nopw 0x0(%rax,%rax,1)
L85:
  mov    (%rcx,%rdx,2),%eax
  bswap  %eax
  mov    %eax,(%rbx,%rdx,1)
  add    $0x4,%rdx
  cmp    $0x80,%rdx
  jne    L85
  jmp    L35
  nopw   0x0(%rax,%rax,1)
L24:
  xor    %r8d,%r8d
  cmp    $0x80,%eax
  jg     L19
  add    $0x3,%eax
  cmp    $0x6,%eax
  jbe    L35
  mov    0x18(%rbp),%rsi
  xor    %edx,%edx
  nopl   0x0(%rax,%rax,1)
L12:
  mov    %edx,%eax
  mov    (%rsi,%rax,8),%rax
  bswap  %eax
  mov    %eax,(%rbx,%rdx,4)
  mov    0x10(%rbp),%ecx
  add    $0x1,%rdx
  lea    0x3(%rcx),%eax
  test   %ecx,%ecx
  cmovns %ecx,%eax
  sar    $0x2,%eax
  cmp    %edx,%eax
  ja     L12
  jmp    L35
  cs nopw 0x0(%rax,%rax,1)
L37:
  sub    %eax,%edx
  xor    %esi,%esi
  call   <memset@plt>
  mov    $0x1,%edx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <sha256_block_data_order@plt>
  mov    0x0(%r13),%edx
  mov    %r12,%rdi
  xor    %esi,%esi
  jmp    L31
```

assistant: ```c
int SHA256_Final(unsigned char *md, SHA256_CTX *c) {
  unsigned char *p = (unsigned char *)c->data;
  size_t n = c->num;
  p[n] = 0x80;
  n++;
  if (n > (SHA_CBLOCK - 8)) {
    memset(p + n, 0, SHA_CBLOCK - n);
    n = 0;
    sha256_block_data_order(c, p, 1);
  }
  memset(p + n, 0, SHA_CBLOCK - 8 - n);
  p += SHA_CBLOCK - 8;
  (void)({
    unsigned int r = (c->Nh);
    asm("bswapl %0" : "=r"(r) : "0"(r));
    *((unsigned int *)(p)) = r;
    (p) += 4;
    r;
  });
  (void)({
    unsigned int r = (c->Nl);
    asm("bswapl %0" : "=r"(r) : "0"(r));
    *((unsigned int *)(p)) = r;
    (p) += 4;
    r;
  });
  p -= SHA_CBLOCK;
  sha256_block_data_order(c, p, 1);
  c->num = 0;
  memset(p, 0, SHA_CBLOCK);
  do {
    unsigned long ll;
    unsigned int nn;
    switch ((c)->md_len) {
    case SHA224_DIGEST_LENGTH:
      for (nn = 0; nn < SHA224_DIGEST_LENGTH / 4; nn++) {
        ll = (c)->h[nn];
        (void)({
          unsigned int r = (ll);
          asm("bswapl %0" : "=r"(r) : "0"(r));
          *((unsigned int *)((md))) = r;
          ((md)) += 4;
          r;
        });
      }
      break;
    case SHA256_DIGEST_LENGTH:
      for (nn = 0; nn < SHA256_DIGEST_LENGTH / 4; nn++) {
        ll = (c)->h[nn];
        (void)({
          unsigned int r = (ll);
          asm("bswapl %0" : "=r"(r) : "0"(r));
          *((unsigned int *)((md))) = r;
          ((md)) += 4;
          r;
        });
      }
      break;
    default:
      if ((c)->md_len > SHA256_DIGEST_LENGTH)
        return 0;
      for (nn = 0; nn < (c)->md_len / 4; nn++) {
        ll = (c)->h[nn];
        (void)({
          unsigned int r = (ll);
          asm("bswapl %0" : "=r"(r) : "0"(r));
          *((unsigned int *)((md))) = r;
          ((md)) += 4;
          r;
        });
      }
      break;
    }
  } while (0);
  return 1;
}
```