#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 */

/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ write_block(int /*<<< orphan*/ const *);
void sha256_update(const uint8_t *input, unsigned int count) {
  int i, len_blocks;
  len_blocks = count / (512 / 8);
  if (len_blocks != 0) {
    for (i = 0; i < len_blocks * (512 / 8); i += (512 / 8))
      write_block(input + i);
  }
}


x86 assembly (clang, -O0):
<sha256_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shr    $0x6,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1171 <sha256_update+0x61>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x6,%ecx
cmp    %ecx,%eax
jge    116c <sha256_update+0x5c>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1030 <write_block@plt>
mov    -0x10(%rbp),%eax
add    $0x40,%eax
mov    %eax,-0x10(%rbp)
jmp    1139 <sha256_update+0x29>
jmp    1171 <sha256_update+0x61>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sha256_update>:
push   %r15
push   %r14
push   %rbx
cmp    $0x40,%esi
jb     1148 <sha256_update+0x38>
and    $0xffffffc0,%esi
jle    1148 <sha256_update+0x38>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <write_block@plt>
add    $0x40,%rbx
add    $0x100,%r15
cmp    %r14,%rbx
jb     1130 <sha256_update+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @sha256_update(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = udiv i32 %7, 64
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %2
store i32 0, i32* %5
br label %12
12: ; preds = %23, %11
%13 = load i32, i32* %5
%14 = load i32, i32* %6
%15 = mul nsw i32 %14, 64
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %26
17: ; preds = %12
%18 = load i32*, i32** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = call i32 @write_block(i32* %21)
br label %23
23: ; preds = %17
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 64
store i32 %25, i32* %5
br label %12
26: ; preds = %12
br label %27
27: ; preds = %26, %2
ret void
}

LLVM IR (-O2):
define void @sha256_update(i32* %0, i32 %1) {
%3 = and i32 %1, -64
%4 = icmp ugt i32 %1, 63
%5 = icmp sgt i32 %3, 0
%6 = and i1 %4, %5
br i1 %6, label %7, label %15
7: ; preds = %2
%8 = zext i32 %3 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %13, %9 ]
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = tail call i32 @write_block(i32* %11)
%13 = add nuw nsw i64 %10, 64
%14 = icmp ult i64 %13, %8
br i1 %14, label %9, label %15
15: ; preds = %9, %2
ret void
}