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

/* Variables and functions */
int /*<<< orphan*/ SHA1Block(unsigned char const *, int);
int /*<<< orphan*/ SHA1Done();
int /*<<< orphan*/ SHA1Init();
void SHA1Once(const unsigned char *data, int len) {
  SHA1Init();
  while (len >= 0) {
    SHA1Block(data, len > 64 ? 64 : len);
    len -= 64;
    data += 64;
  }
  SHA1Done();
}


x86 assembly (clang, -O0):
<SHA1Once>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1040 <SHA1Init@plt>
cmpl   $0x0,-0xc(%rbp)
jl     119b <SHA1Once+0x6b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x40,-0xc(%rbp)
jle    116f <SHA1Once+0x3f>
mov    $0x40,%eax
mov    %eax,-0x1c(%rbp)
jmp    1175 <SHA1Once+0x45>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <SHA1Block@plt>
mov    -0xc(%rbp),%eax
sub    $0x40,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x8(%rbp)
jmp    1146 <SHA1Once+0x16>
mov    $0x0,%al
call   1050 <SHA1Done@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SHA1Once>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r15
xor    %eax,%eax
call   1040 <SHA1Init@plt>
test   %ebp,%ebp
js     116f <SHA1Once+0x3f>
mov    $0x40,%r14d
mov    %ebp,%ebx
nop
sub    $0x40,%ebx
cmovae %r14d,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
call   1030 <SHA1Block@plt>
add    $0x40,%r15
lea    0x40(%rbx),%eax
mov    %ebx,%ebp
cmp    $0x3f,%eax
ja     1150 <SHA1Once+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <SHA1Done@plt>

LLVM IR (-O0):
define void @SHA1Once(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = call i32 (...) @SHA1Init()
br label %6
6: ; preds = %16, %2
%7 = load i32, i32* %4
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 64
br i1 %12, label %13, label %14
13: ; preds = %9
br label %16
14: ; preds = %9
%15 = load i32, i32* %4
br label %16
16: ; preds = %14, %13
%17 = phi i32 [ 64, %13 ], [ %15, %14 ]
%18 = call i32 @SHA1Block(i8* %10, i32 %17)
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 64
store i32 %20, i32* %4
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 64
store i8* %22, i8** %3
br label %6
23: ; preds = %6
%24 = call i32 (...) @SHA1Done()
ret void
}

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