#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  size_t num;
  int Nh;
  int Nl;
  int md_len;
  unsigned long *h;
  scalar_t__ data;
};
typedef TYPE_1__ SHA256_CTX;

/* Variables and functions */
int /*<<< orphan*/ OPENSSL_cleanse(unsigned char *, int);
#define SHA224_DIGEST_LENGTH 129
#define SHA256_DIGEST_LENGTH 128
int SHA_CBLOCK;
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sha256_block_data_order(TYPE_1__ *, unsigned char *, int);
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)(*((p)++) = (unsigned char)(((c->Nh) >> 24) & 0xff),
         *((p)++) = (unsigned char)(((c->Nh) >> 16) & 0xff),
         *((p)++) = (unsigned char)(((c->Nh) >> 8) & 0xff),
         *((p)++) = (unsigned char)(((c->Nh)) & 0xff), c->Nh);
  (void)(*((p)++) = (unsigned char)(((c->Nl) >> 24) & 0xff),
         *((p)++) = (unsigned char)(((c->Nl) >> 16) & 0xff),
         *((p)++) = (unsigned char)(((c->Nl) >> 8) & 0xff),
         *((p)++) = (unsigned char)(((c->Nl)) & 0xff), c->Nl);
  p -= SHA_CBLOCK;
  sha256_block_data_order(c, p, 1);
  c->num = 0;
  OPENSSL_cleanse(p, 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)(*(((md))++) = (unsigned char)(((ll) >> 24) & 0xff),
               *(((md))++) = (unsigned char)(((ll) >> 16) & 0xff),
               *(((md))++) = (unsigned char)(((ll) >> 8) & 0xff),
               *(((md))++) = (unsigned char)(((ll)) & 0xff), ll);
      }
      break;
    case SHA256_DIGEST_LENGTH:
      for (nn = 0; nn < SHA256_DIGEST_LENGTH / 4; nn++) {
        ll = (c)->h[nn];
        (void)(*(((md))++) = (unsigned char)(((ll) >> 24) & 0xff),
               *(((md))++) = (unsigned char)(((ll) >> 16) & 0xff),
               *(((md))++) = (unsigned char)(((ll) >> 8) & 0xff),
               *(((md))++) = (unsigned char)(((ll)) & 0xff), ll);
      }
      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)(*(((md))++) = (unsigned char)(((ll) >> 24) & 0xff),
               *(((md))++) = (unsigned char)(((ll) >> 16) & 0xff),
               *(((md))++) = (unsigned char)(((ll) >> 8) & 0xff),
               *(((md))++) = (unsigned char)(((ll)) & 0xff), ll);
      }
      break;
    }
  } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<SHA256_Final>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x80,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2e6e(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x8,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jbe    11c4 <SHA256_Final+0x94>
mov    -0x20(%rbp),%rdi
add    -0x28(%rbp),%rdi
mov    0x2e4e(%rip),%rax
movslq (%rax),%rax
sub    -0x28(%rbp),%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1050 <sha256_block_data_order@plt>
mov    -0x20(%rbp),%rdi
add    -0x28(%rbp),%rdi
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%eax
cltq
sub    -0x28(%rbp),%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%ecx
sub    $0x8,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    0x2cd6(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1050 <sha256_block_data_order@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
mov    0x2c99(%rip),%rax
mov    (%rax),%esi
call   1040 <OPENSSL_cleanse@plt>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x38(%rbp)
sub    $0x80,%eax
je     143a <SHA256_Final+0x30a>
jmp    1370 <SHA256_Final+0x240>
mov    -0x38(%rbp),%eax
sub    $0x81,%eax
jne    14f1 <SHA256_Final+0x3c1>
jmp    1383 <SHA256_Final+0x253>
movl   $0x0,-0x34(%rbp)
cmpl   $0x20,-0x34(%rbp)
jae    1435 <SHA256_Final+0x305>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    -0x34(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    138a <SHA256_Final+0x25a>
jmp    15dd <SHA256_Final+0x4ad>
movl   $0x0,-0x34(%rbp)
cmpl   $0x20,-0x34(%rbp)
jae    14ec <SHA256_Final+0x3bc>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    -0x34(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1441 <SHA256_Final+0x311>
jmp    15dd <SHA256_Final+0x4ad>
mov    -0x18(%rbp),%rax
cmpl   $0x80,0x10(%rax)
jle    150e <SHA256_Final+0x3de>
movl   $0x0,-0x4(%rbp)
jmp    15e9 <SHA256_Final+0x4b9>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cmp    %ecx,%eax
jae    15d8 <SHA256_Final+0x4a8>
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%rax
mov    -0x34(%rbp),%ecx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
and    $0xff,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1515 <SHA256_Final+0x3e5>
jmp    15dd <SHA256_Final+0x4ad>
jmp    15e2 <SHA256_Final+0x4b2>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SHA256_Final>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%r12
mov    0x20(%rsi),%r15
movb   $0x80,(%r15,%r12,1)
add    $0x1,%r12
mov    0x2e92(%rip),%r13
movslq 0x0(%r13),%rax
lea    -0x8(%rax),%rdx
cmp    %rdx,%r12
jbe    118d <SHA256_Final+0x5d>
lea    (%r15,%r12,1),%rdi
sub    %r12d,%eax
xor    %r12d,%r12d
xor    %esi,%esi
mov    %eax,%edx
call   1030 <memset@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <sha256_block_data_order@plt>
mov    0x0(%r13),%edx
add    $0xfffffff8,%edx
lea    (%r15,%r12,1),%rdi
sub    %r12d,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movslq 0x0(%r13),%rax
mov    0xb(%rbx),%cl
mov    %cl,-0x8(%rax,%r15,1)
mov    0xa(%rbx),%cl
mov    %cl,-0x7(%rax,%r15,1)
mov    0x9(%rbx),%cl
mov    %cl,-0x6(%rax,%r15,1)
mov    0x8(%rbx),%cl
mov    %cl,-0x5(%rax,%r15,1)
mov    0xf(%rbx),%cl
mov    %cl,-0x4(%rax,%r15,1)
mov    0xe(%rbx),%cl
mov    %cl,-0x3(%rax,%r15,1)
mov    0xd(%rbx),%cl
lea    -0x1(%rax,%r15,1),%r12
mov    %cl,-0x2(%rax,%r15,1)
mov    0xc(%rbx),%cl
mov    %cl,-0x1(%rax,%r15,1)
movslq 0x0(%r13),%rax
sub    %rax,%r12
add    $0x1,%r12
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
call   1050 <sha256_block_data_order@plt>
movq   $0x0,(%rbx)
mov    0x0(%r13),%esi
mov    %r12,%rdi
call   1040 <OPENSSL_cleanse@plt>
mov    0x10(%rbx),%ecx
cmp    $0x81,%ecx
je     1258 <SHA256_Final+0x128>
cmp    $0x80,%ecx
jne    128d <SHA256_Final+0x15d>
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
mov    0x18(%rbx),%rcx
mov    (%rcx,%rax,8),%ecx
bswap  %ecx
mov    %ecx,(%r14,%rax,4)
mov    0x18(%rbx),%rcx
mov    0x8(%rcx,%rax,8),%ecx
bswap  %ecx
mov    %ecx,0x4(%r14,%rax,4)
add    $0x2,%rax
cmp    $0x20,%rax
jne    1230 <SHA256_Final+0x100>
jmp    1286 <SHA256_Final+0x156>
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
mov    0x18(%rbx),%rcx
mov    (%rcx,%rax,8),%ecx
bswap  %ecx
mov    %ecx,(%r14,%rax,4)
mov    0x18(%rbx),%rcx
mov    0x8(%rcx,%rax,8),%ecx
bswap  %ecx
mov    %ecx,0x4(%r14,%rax,4)
add    $0x2,%rax
cmp    $0x20,%rax
jne    1260 <SHA256_Final+0x130>
mov    $0x1,%eax
jmp    12d4 <SHA256_Final+0x1a4>
xor    %eax,%eax
cmp    $0x80,%ecx
jg     12d4 <SHA256_Final+0x1a4>
add    $0x3,%ecx
mov    $0x1,%eax
cmp    $0x7,%ecx
jb     12d4 <SHA256_Final+0x1a4>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
mov    0x18(%rbx),%rdx
mov    (%rdx,%rcx,8),%edx
bswap  %edx
mov    %edx,(%r14,%rcx,4)
add    $0x1,%rcx
mov    0x10(%rbx),%edx
lea    0x3(%rdx),%esi
test   %edx,%edx
cmovns %edx,%esi
sar    $0x2,%esi
cmp    %rsi,%rcx
jb     12b0 <SHA256_Final+0x180>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i64, i32, i32, i32, i64*, i64 }
@SHA_CBLOCK = global i32 0
define i32 @SHA256_Final(i8* %0, %struct.TYPE_4__* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.TYPE_4__*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
store i8* %0, i8** %4
store %struct.TYPE_4__* %1, %struct.TYPE_4__** %5
%10 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%11 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %10, i32 0, i32 5
%12 = load i64, i64* %11
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %6
%14 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%15 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %14, i32 0, i32 0
%16 = load i64, i64* %15
store i64 %16, i64* %7
%17 = load i8*, i8** %6
%18 = load i64, i64* %7
%19 = getelementptr inbounds i8, i8* %17, i64 %18
store i8 -128, i8* %19
%20 = load i64, i64* %7
%21 = add i64 %20, 1
store i64 %21, i64* %7
%22 = load i64, i64* %7
%23 = load i32, i32* @SHA_CBLOCK
%24 = sub nsw i32 %23, 8
%25 = sext i32 %24 to i64
%26 = icmp ugt i64 %22, %25
br i1 %26, label %27, label %40
27: ; preds = %2
%28 = load i8*, i8** %6
%29 = load i64, i64* %7
%30 = getelementptr inbounds i8, i8* %28, i64 %29
%31 = load i32, i32* @SHA_CBLOCK
%32 = sext i32 %31 to i64
%33 = load i64, i64* %7
%34 = sub i64 %32, %33
%35 = trunc i64 %34 to i32
%36 = call i32 @memset(i8* %30, i32 0, i32 %35)
store i64 0, i64* %7
%37 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%38 = load i8*, i8** %6
%39 = call i32 @sha256_block_data_order(%struct.TYPE_4__* %37, i8* %38, i32 1)
br label %40
40: ; preds = %27, %2
%41 = load i8*, i8** %6
%42 = load i64, i64* %7
%43 = getelementptr inbounds i8, i8* %41, i64 %42
%44 = load i32, i32* @SHA_CBLOCK
%45 = sub nsw i32 %44, 8
%46 = sext i32 %45 to i64
%47 = load i64, i64* %7
%48 = sub i64 %46, %47
%49 = trunc i64 %48 to i32
%50 = call i32 @memset(i8* %43, i32 0, i32 %49)
%51 = load i32, i32* @SHA_CBLOCK
%52 = sub nsw i32 %51, 8
%53 = load i8*, i8** %6
%54 = sext i32 %52 to i64
%55 = getelementptr inbounds i8, i8* %53, i64 %54
store i8* %55, i8** %6
%56 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%57 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %56, i32 0, i32 1
%58 = load i32, i32* %57
%59 = ashr i32 %58, 24
%60 = and i32 %59, 255
%61 = trunc i32 %60 to i8
%62 = load i8*, i8** %6
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %6
store i8 %61, i8* %62
%64 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%65 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %64, i32 0, i32 1
%66 = load i32, i32* %65
%67 = ashr i32 %66, 16
%68 = and i32 %67, 255
%69 = trunc i32 %68 to i8
%70 = load i8*, i8** %6
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %6
store i8 %69, i8* %70
%72 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%73 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %72, i32 0, i32 1
%74 = load i32, i32* %73
%75 = ashr i32 %74, 8
%76 = and i32 %75, 255
%77 = trunc i32 %76 to i8
%78 = load i8*, i8** %6
%79 = getelementptr inbounds i8, i8* %78, i32 1
store i8* %79, i8** %6
store i8 %77, i8* %78
%80 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%81 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %80, i32 0, i32 1
%82 = load i32, i32* %81
%83 = and i32 %82, 255
%84 = trunc i32 %83 to i8
%85 = load i8*, i8** %6
%86 = getelementptr inbounds i8, i8* %85, i32 1
store i8* %86, i8** %6
store i8 %84, i8* %85
%87 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%88 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %87, i32 0, i32 1
%89 = load i32, i32* %88
%90 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%91 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %90, i32 0, i32 2
%92 = load i32, i32* %91
%93 = ashr i32 %92, 24
%94 = and i32 %93, 255
%95 = trunc i32 %94 to i8
%96 = load i8*, i8** %6
%97 = getelementptr inbounds i8, i8* %96, i32 1
store i8* %97, i8** %6
store i8 %95, i8* %96
%98 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%99 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %98, i32 0, i32 2
%100 = load i32, i32* %99
%101 = ashr i32 %100, 16
%102 = and i32 %101, 255
%103 = trunc i32 %102 to i8
%104 = load i8*, i8** %6
%105 = getelementptr inbounds i8, i8* %104, i32 1
store i8* %105, i8** %6
store i8 %103, i8* %104
%106 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%107 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %106, i32 0, i32 2
%108 = load i32, i32* %107
%109 = ashr i32 %108, 8
%110 = and i32 %109, 255
%111 = trunc i32 %110 to i8
%112 = load i8*, i8** %6
%113 = getelementptr inbounds i8, i8* %112, i32 1
store i8* %113, i8** %6
store i8 %111, i8* %112
%114 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%115 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %114, i32 0, i32 2
%116 = load i32, i32* %115
%117 = and i32 %116, 255
%118 = trunc i32 %117 to i8
%119 = load i8*, i8** %6
%120 = getelementptr inbounds i8, i8* %119, i32 1
store i8* %120, i8** %6
store i8 %118, i8* %119
%121 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%122 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %121, i32 0, i32 2
%123 = load i32, i32* %122
%124 = load i32, i32* @SHA_CBLOCK
%125 = load i8*, i8** %6
%126 = sext i32 %124 to i64
%127 = sub i64 0, %126
%128 = getelementptr inbounds i8, i8* %125, i64 %127
store i8* %128, i8** %6
%129 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%130 = load i8*, i8** %6
%131 = call i32 @sha256_block_data_order(%struct.TYPE_4__* %129, i8* %130, i32 1)
%132 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%133 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %132, i32 0, i32 0
store i64 0, i64* %133
%134 = load i8*, i8** %6
%135 = load i32, i32* @SHA_CBLOCK
%136 = call i32 @OPENSSL_cleanse(i8* %134, i32 %135)
br label %137
137: ; preds = %40
%138 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%139 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %138, i32 0, i32 3
%140 = load i32, i32* %139
switch i32 %140, label %221 [
i32 129, label %141
i32 128, label %181
]
141: ; preds = %137
store i32 0, i32* %9
br label %142
142: ; preds = %177, %141
%143 = load i32, i32* %9
%144 = icmp ult i32 %143, 32
br i1 %144, label %145, label %180
145: ; preds = %142
%146 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%147 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %146, i32 0, i32 4
%148 = load i64*, i64** %147
%149 = load i32, i32* %9
%150 = zext i32 %149 to i64
%151 = getelementptr inbounds i64, i64* %148, i64 %150
%152 = load i64, i64* %151
store i64 %152, i64* %8
%153 = load i64, i64* %8
%154 = lshr i64 %153, 24
%155 = and i64 %154, 255
%156 = trunc i64 %155 to i8
%157 = load i8*, i8** %4
%158 = getelementptr inbounds i8, i8* %157, i32 1
store i8* %158, i8** %4
store i8 %156, i8* %157
%159 = load i64, i64* %8
%160 = lshr i64 %159, 16
%161 = and i64 %160, 255
%162 = trunc i64 %161 to i8
%163 = load i8*, i8** %4
%164 = getelementptr inbounds i8, i8* %163, i32 1
store i8* %164, i8** %4
store i8 %162, i8* %163
%165 = load i64, i64* %8
%166 = lshr i64 %165, 8
%167 = and i64 %166, 255
%168 = trunc i64 %167 to i8
%169 = load i8*, i8** %4
%170 = getelementptr inbounds i8, i8* %169, i32 1
store i8* %170, i8** %4
store i8 %168, i8* %169
%171 = load i64, i64* %8
%172 = and i64 %171, 255
%173 = trunc i64 %172 to i8
%174 = load i8*, i8** %4
%175 = getelementptr inbounds i8, i8* %174, i32 1
store i8* %175, i8** %4
store i8 %173, i8* %174
%176 = load i64, i64* %8
br label %177
177: ; preds = %145
%178 = load i32, i32* %9
%179 = add i32 %178, 1
store i32 %179, i32* %9
br label %142
180: ; preds = %142
br label %271
181: ; preds = %137
store i32 0, i32* %9
br label %182
182: ; preds = %217, %181
%183 = load i32, i32* %9
%184 = icmp ult i32 %183, 32
br i1 %184, label %185, label %220
185: ; preds = %182
%186 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%187 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %186, i32 0, i32 4
%188 = load i64*, i64** %187
%189 = load i32, i32* %9
%190 = zext i32 %189 to i64
%191 = getelementptr inbounds i64, i64* %188, i64 %190
%192 = load i64, i64* %191
store i64 %192, i64* %8
%193 = load i64, i64* %8
%194 = lshr i64 %193, 24
%195 = and i64 %194, 255
%196 = trunc i64 %195 to i8
%197 = load i8*, i8** %4
%198 = getelementptr inbounds i8, i8* %197, i32 1
store i8* %198, i8** %4
store i8 %196, i8* %197
%199 = load i64, i64* %8
%200 = lshr i64 %199, 16
%201 = and i64 %200, 255
%202 = trunc i64 %201 to i8
%203 = load i8*, i8** %4
%204 = getelementptr inbounds i8, i8* %203, i32 1
store i8* %204, i8** %4
store i8 %202, i8* %203
%205 = load i64, i64* %8
%206 = lshr i64 %205, 8
%207 = and i64 %206, 255
%208 = trunc i64 %207 to i8
%209 = load i8*, i8** %4
%210 = getelementptr inbounds i8, i8* %209, i32 1
store i8* %210, i8** %4
store i8 %208, i8* %209
%211 = load i64, i64* %8
%212 = and i64 %211, 255
%213 = trunc i64 %212 to i8
%214 = load i8*, i8** %4
%215 = getelementptr inbounds i8, i8* %214, i32 1
store i8* %215, i8** %4
store i8 %213, i8* %214
%216 = load i64, i64* %8
br label %217
217: ; preds = %185
%218 = load i32, i32* %9
%219 = add i32 %218, 1
store i32 %219, i32* %9
br label %182
220: ; preds = %182
br label %271
221: ; preds = %137
%222 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%223 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %222, i32 0, i32 3
%224 = load i32, i32* %223
%225 = icmp sgt i32 %224, 128
br i1 %225, label %226, label %227
226: ; preds = %221
store i32 0, i32* %3
br label %273
227: ; preds = %221
store i32 0, i32* %9
br label %228
228: ; preds = %267, %227
%229 = load i32, i32* %9
%230 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%231 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %230, i32 0, i32 3
%232 = load i32, i32* %231
%233 = sdiv i32 %232, 4
%234 = icmp ult i32 %229, %233
br i1 %234, label %235, label %270
235: ; preds = %228
%236 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%237 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %236, i32 0, i32 4
%238 = load i64*, i64** %237
%239 = load i32, i32* %9
%240 = zext i32 %239 to i64
%241 = getelementptr inbounds i64, i64* %238, i64 %240
%242 = load i64, i64* %241
store i64 %242, i64* %8
%243 = load i64, i64* %8
%244 = lshr i64 %243, 24
%245 = and i64 %244, 255
%246 = trunc i64 %245 to i8
%247 = load i8*, i8** %4
%248 = getelementptr inbounds i8, i8* %247, i32 1
store i8* %248, i8** %4
store i8 %246, i8* %247
%249 = load i64, i64* %8
%250 = lshr i64 %249, 16
%251 = and i64 %250, 255
%252 = trunc i64 %251 to i8
%253 = load i8*, i8** %4
%254 = getelementptr inbounds i8, i8* %253, i32 1
store i8* %254, i8** %4
store i8 %252, i8* %253
%255 = load i64, i64* %8
%256 = lshr i64 %255, 8
%257 = and i64 %256, 255
%258 = trunc i64 %257 to i8
%259 = load i8*, i8** %4
%260 = getelementptr inbounds i8, i8* %259, i32 1
store i8* %260, i8** %4
store i8 %258, i8* %259
%261 = load i64, i64* %8
%262 = and i64 %261, 255
%263 = trunc i64 %262 to i8
%264 = load i8*, i8** %4
%265 = getelementptr inbounds i8, i8* %264, i32 1
store i8* %265, i8** %4
store i8 %263, i8* %264
%266 = load i64, i64* %8
br label %267
267: ; preds = %235
%268 = load i32, i32* %9
%269 = add i32 %268, 1
store i32 %269, i32* %9
br label %228
270: ; preds = %228
br label %271
271: ; preds = %270, %220, %180
br label %272
272: ; preds = %271
store i32 1, i32* %3
br label %273
273: ; preds = %272, %226
%274 = load i32, i32* %3
ret i32 %274
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i64, i32, i32, i32, i64*, i64 }
@SHA_CBLOCK = global i32 0
define i32 @SHA256_Final(i8* nocapture writeonly %0, %struct.TYPE_4__* %1) {
%3 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 5
%4 = load i64, i64* %3
%5 = inttoptr i64 %4 to i8*
%6 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 0
%7 = load i64, i64* %6
%8 = getelementptr inbounds i8, i8* %5, i64 %7
store i8 -128, i8* %8
%9 = add i64 %7, 1
%10 = load i32, i32* @SHA_CBLOCK
%11 = add nsw i32 %10, -8
%12 = sext i32 %11 to i64
%13 = icmp ugt i64 %9, %12
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = getelementptr inbounds i8, i8* %5, i64 %9
%16 = trunc i64 %9 to i32
%17 = sub i32 %10, %16
%18 = tail call i32 @memset(i8* %15, i32 0, i32 %17)
%19 = tail call i32 @sha256_block_data_order(%struct.TYPE_4__* %1, i8* %5, i32 1)
%20 = load i32, i32* @SHA_CBLOCK
%21 = add nsw i32 %20, -8
br label %22
22: ; preds = %14, %2
%23 = phi i32 [ %21, %14 ], [ %11, %2 ]
%24 = phi i64 [ 0, %14 ], [ %9, %2 ]
%25 = getelementptr inbounds i8, i8* %5, i64 %24
%26 = trunc i64 %24 to i32
%27 = sub i32 %23, %26
%28 = tail call i32 @memset(i8* %25, i32 0, i32 %27)
%29 = load i32, i32* @SHA_CBLOCK
%30 = add nsw i32 %29, -8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %5, i64 %31
%33 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 1
%34 = load i32, i32* %33
%35 = lshr i32 %34, 24
%36 = trunc i32 %35 to i8
%37 = getelementptr inbounds i8, i8* %32, i64 1
store i8 %36, i8* %32
%38 = load i32, i32* %33
%39 = lshr i32 %38, 16
%40 = trunc i32 %39 to i8
%41 = getelementptr inbounds i8, i8* %37, i64 1
store i8 %40, i8* %37
%42 = load i32, i32* %33
%43 = lshr i32 %42, 8
%44 = trunc i32 %43 to i8
%45 = getelementptr inbounds i8, i8* %41, i64 1
store i8 %44, i8* %41
%46 = load i32, i32* %33
%47 = trunc i32 %46 to i8
%48 = getelementptr inbounds i8, i8* %45, i64 1
store i8 %47, i8* %45
%49 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 2
%50 = load i32, i32* %49
%51 = lshr i32 %50, 24
%52 = trunc i32 %51 to i8
%53 = getelementptr inbounds i8, i8* %48, i64 1
store i8 %52, i8* %48
%54 = load i32, i32* %49
%55 = lshr i32 %54, 16
%56 = trunc i32 %55 to i8
%57 = getelementptr inbounds i8, i8* %53, i64 1
store i8 %56, i8* %53
%58 = load i32, i32* %49
%59 = lshr i32 %58, 8
%60 = trunc i32 %59 to i8
%61 = getelementptr inbounds i8, i8* %57, i64 1
store i8 %60, i8* %57
%62 = load i32, i32* %49
%63 = trunc i32 %62 to i8
%64 = getelementptr inbounds i8, i8* %61, i64 1
store i8 %63, i8* %61
%65 = load i32, i32* @SHA_CBLOCK
%66 = sext i32 %65 to i64
%67 = sub nsw i64 0, %66
%68 = getelementptr inbounds i8, i8* %64, i64 %67
%69 = tail call i32 @sha256_block_data_order(%struct.TYPE_4__* %1, i8* %68, i32 1)
store i64 0, i64* %6
%70 = load i32, i32* @SHA_CBLOCK
%71 = tail call i32 @OPENSSL_cleanse(i8* %68, i32 %70)
%72 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 3
%73 = load i32, i32* %72
switch i32 %73, label %146 [
i32 129, label %76
i32 128, label %74
]
74: ; preds = %22
%75 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 4
br label %112
76: ; preds = %22
%77 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 4
br label %78
78: ; preds = %78, %76
%79 = phi i64 [ 0, %76 ], [ %110, %78 ]
%80 = phi i8* [ %0, %76 ], [ %109, %78 ]
%81 = load i64*, i64** %77
%82 = getelementptr inbounds i64, i64* %81, i64 %79
%83 = load i64, i64* %82
%84 = lshr i64 %83, 24
%85 = trunc i64 %84 to i8
%86 = getelementptr inbounds i8, i8* %80, i64 1
store i8 %85, i8* %80
%87 = lshr i64 %83, 16
%88 = trunc i64 %87 to i8
%89 = getelementptr inbounds i8, i8* %80, i64 2
store i8 %88, i8* %86
%90 = lshr i64 %83, 8
%91 = trunc i64 %90 to i8
%92 = getelementptr inbounds i8, i8* %80, i64 3
store i8 %91, i8* %89
%93 = trunc i64 %83 to i8
%94 = getelementptr inbounds i8, i8* %80, i64 4
store i8 %93, i8* %92
%95 = or i64 %79, 1
%96 = load i64*, i64** %77
%97 = getelementptr inbounds i64, i64* %96, i64 %95
%98 = load i64, i64* %97
%99 = lshr i64 %98, 24
%100 = trunc i64 %99 to i8
%101 = getelementptr inbounds i8, i8* %80, i64 5
store i8 %100, i8* %94
%102 = lshr i64 %98, 16
%103 = trunc i64 %102 to i8
%104 = getelementptr inbounds i8, i8* %80, i64 6
store i8 %103, i8* %101
%105 = lshr i64 %98, 8
%106 = trunc i64 %105 to i8
%107 = getelementptr inbounds i8, i8* %80, i64 7
store i8 %106, i8* %104
%108 = trunc i64 %98 to i8
%109 = getelementptr inbounds i8, i8* %80, i64 8
store i8 %108, i8* %107
%110 = add nuw nsw i64 %79, 2
%111 = icmp eq i64 %110, 32
br i1 %111, label %175, label %78
112: ; preds = %112, %74
%113 = phi i64 [ 0, %74 ], [ %144, %112 ]
%114 = phi i8* [ %0, %74 ], [ %143, %112 ]
%115 = load i64*, i64** %75
%116 = getelementptr inbounds i64, i64* %115, i64 %113
%117 = load i64, i64* %116
%118 = lshr i64 %117, 24
%119 = trunc i64 %118 to i8
%120 = getelementptr inbounds i8, i8* %114, i64 1
store i8 %119, i8* %114
%121 = lshr i64 %117, 16
%122 = trunc i64 %121 to i8
%123 = getelementptr inbounds i8, i8* %114, i64 2
store i8 %122, i8* %120
%124 = lshr i64 %117, 8
%125 = trunc i64 %124 to i8
%126 = getelementptr inbounds i8, i8* %114, i64 3
store i8 %125, i8* %123
%127 = trunc i64 %117 to i8
%128 = getelementptr inbounds i8, i8* %114, i64 4
store i8 %127, i8* %126
%129 = or i64 %113, 1
%130 = load i64*, i64** %75
%131 = getelementptr inbounds i64, i64* %130, i64 %129
%132 = load i64, i64* %131
%133 = lshr i64 %132, 24
%134 = trunc i64 %133 to i8
%135 = getelementptr inbounds i8, i8* %114, i64 5
store i8 %134, i8* %128
%136 = lshr i64 %132, 16
%137 = trunc i64 %136 to i8
%138 = getelementptr inbounds i8, i8* %114, i64 6
store i8 %137, i8* %135
%139 = lshr i64 %132, 8
%140 = trunc i64 %139 to i8
%141 = getelementptr inbounds i8, i8* %114, i64 7
store i8 %140, i8* %138
%142 = trunc i64 %132 to i8
%143 = getelementptr inbounds i8, i8* %114, i64 8
store i8 %142, i8* %141
%144 = add nuw nsw i64 %113, 2
%145 = icmp eq i64 %144, 32
br i1 %145, label %175, label %112
146: ; preds = %22
%147 = icmp sgt i32 %73, 128
br i1 %147, label %175, label %148
148: ; preds = %146
%149 = add nsw i32 %73, 3
%150 = icmp ult i32 %149, 7
br i1 %150, label %175, label %151
151: ; preds = %148
%152 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 4
br label %153
153: ; preds = %151, %153
%154 = phi i64 [ 0, %151 ], [ %170, %153 ]
%155 = phi i8* [ %0, %151 ], [ %169, %153 ]
%156 = load i64*, i64** %152
%157 = getelementptr inbounds i64, i64* %156, i64 %154
%158 = load i64, i64* %157
%159 = lshr i64 %158, 24
%160 = trunc i64 %159 to i8
%161 = getelementptr inbounds i8, i8* %155, i64 1
store i8 %160, i8* %155
%162 = lshr i64 %158, 16
%163 = trunc i64 %162 to i8
%164 = getelementptr inbounds i8, i8* %155, i64 2
store i8 %163, i8* %161
%165 = lshr i64 %158, 8
%166 = trunc i64 %165 to i8
%167 = getelementptr inbounds i8, i8* %155, i64 3
store i8 %166, i8* %164
%168 = trunc i64 %158 to i8
%169 = getelementptr inbounds i8, i8* %155, i64 4
store i8 %168, i8* %167
%170 = add nuw nsw i64 %154, 1
%171 = load i32, i32* %72
%172 = sdiv i32 %171, 4
%173 = zext i32 %172 to i64
%174 = icmp ult i64 %170, %173
br i1 %174, label %153, label %175
175: ; preds = %112, %78, %153, %148, %146
%176 = phi i32 [ 0, %146 ], [ 1, %148 ], [ 1, %153 ], [ 1, %78 ], [ 1, %112 ]
ret i32 %176
}