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

```asm
<SHA256_Final>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  mov    0x20(%rsi),%r12
  mov    (%rsi),%rdi
  movb   $0x80,(%r12,%rdi,1)
  add    $0x1,%rdi
  mov    D14(%rip),%rax
  mov    (%rax),%edx
  lea    -0x8(%rdx),%eax
  cltq
  cmp    %rdi,%rax
  jb     L74
L65:
  mov    D14(%rip),%r13
  mov    0x0(%r13),%eax
  lea    -0x8(%rax),%edx
  sub    %edi,%edx
  add    %r12,%rdi
  mov    $0x0,%esi
  call   <memset@plt>
  movslq 0x0(%r13),%rax
  lea    -0x8(%r12,%rax,1),%rax
  mov    0x8(%rbp),%edx
  bswap  %edx
  mov    %edx,(%rax)
  mov    0xc(%rbp),%edx
  bswap  %edx
  mov    %edx,0x4(%rax)
  lea    0x8(%rax),%r12
  movslq 0x0(%r13),%rax
  sub    %rax,%r12
  mov    $0x1,%edx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <sha256_block_data_order@plt>
  movq   $0x0,0x0(%rbp)
  mov    0x0(%r13),%edx
  mov    $0x0,%esi
  mov    %r12,%rdi
  call   <memset@plt>
  mov    0x10(%rbp),%eax
  cmp    $0x80,%eax
  je     L57
  cmp    $0x81,%eax
  jne    L14
  mov    $0x0,%edx
L88:
  mov    0x18(%rbp),%rax
  mov    (%rax,%rdx,1),%rax
  bswap  %eax
  mov    %eax,(%rbx)
  add    $0x4,%rbx
  add    $0x8,%rdx
  cmp    $0x100,%rdx
  jne    L88
  mov    $0x1,%edx
L41:
  mov    %edx,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L74:
  sub    %edi,%edx
  add    %r12,%rdi
  mov    $0x0,%esi
  call   <memset@plt>
  mov    $0x1,%edx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <sha256_block_data_order@plt>
  mov    $0x0,%edi
  jmp    L65
L57:
  mov    $0x0,%edx
L94:
  mov    0x18(%rbp),%rax
  mov    (%rax,%rdx,1),%rax
  bswap  %eax
  mov    %eax,(%rbx)
  add    $0x4,%rbx
  add    $0x8,%rdx
  cmp    $0x100,%rdx
  jne    L94
  mov    $0x1,%edx
  jmp    L41
L14:
  mov    $0x0,%edx
  cmp    $0x80,%eax
  jg     L41
  add    $0x3,%eax
  cmp    $0x6,%eax
  jbe    L6
  mov    $0x0,%edx
L51:
  mov    %edx,%ecx
  mov    0x18(%rbp),%rax
  mov    (%rax,%rcx,8),%rax
  bswap  %eax
  mov    %eax,(%rbx,%rdx,4)
  add    $0x1,%rdx
  mov    0x10(%rbp),%ecx
  lea    0x3(%rcx),%eax
  test   %ecx,%ecx
  cmovns %ecx,%eax
  sar    $0x2,%eax
  cmp    %edx,%eax
  ja     L51
  mov    $0x1,%edx
  jmp    L41
L6:
  mov    $0x1,%edx
  jmp    L41
```

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 xn;
    switch ((c)->md_len) {
    case SHA224_DIGEST_LENGTH:
      for (xn = 0; xn < SHA224_DIGEST_LENGTH / 4; xn++) {
        ll = (c)->h[xn];
        ({
          unsigned int r = (ll);
          asm("bswapl %0" : "=r"(r) : "0"(r));
          *((unsigned int *)((md))) = r;
          ((md)) += 4;
          r;
        });
      }
      break;
    case SHA256_DIGEST_LENGTH:
      for (xn = 0; xn < SHA256_DIGEST_LENGTH / 4; xn++) {
        ll = (c)->h[xn];
        ({
          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 (xn = 0; xn < (c)->md_len / 4; xn++) {
        ll = (c)->h[xn];
        ({
          unsigned int r = (ll);
          asm("bswapl %0" : "=r"(r) : "0"(r));
          *((unsigned int *)((md))) = r;
          ((md)) += 4;
          r;
        });
      }
      break;
    }
  } while (0);
  return 1;
}
```