#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 */
struct timeval {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ SHA1(char *, int, unsigned char *);
int SHA_DIGEST_LENGTH;
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, unsigned char, unsigned long);
int main(void) {
  unsigned long c;
  char buf[10];
  struct timeval start, end;
  unsigned char sha1_hash[SHA_DIGEST_LENGTH];
  memset(buf, 'A', 10);
  SHA1(buf, 10, sha1_hash);
  for (c = 0; c < 20; c++)
    printf("%d-%lu\n", sha1_hash[c], c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
lea    -0x1a(%rbp),%rdi
mov    $0x41,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
mov    -0x40(%rbp),%rdx
lea    -0x1a(%rbp),%rdi
mov    $0xa,%esi
call   1050 <SHA1@plt>
movq   $0x0,-0x10(%rbp)
cmpq   $0x14,-0x10(%rbp)
jae    11d2 <main+0xa2>
mov    -0x40(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x10(%rbp),%rdx
lea    0xe47(%rip),%rdi
movzbl %al,%esi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1198 <main+0x68>
movl   $0x0,-0x4(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsp,%r15
mov    0x2e9d(%rip),%rax
mov    (%rax),%r12d
mov    %rsp,%r13
add    $0xf,%r12
and    $0xfffffffffffffff0,%r12
mov    %r13,%rbx
sub    %r12,%rbx
mov    %rbx,%rsp
lea    -0x32(%rbp),%r14
mov    %r14,%rdi
mov    $0x41,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
mov    %r14,%rdi
mov    $0xa,%esi
mov    %rbx,%rdx
call   1050 <SHA1@plt>
movzbl (%rbx),%esi
lea    0xe6e(%rip),%r14
mov    %r14,%rdi
xor    %edx,%edx
call   1030 <printf@plt>
movzbl 0x1(%rbx),%esi
mov    $0x1,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0x2(%rbx),%esi
mov    $0x2,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0x3(%rbx),%esi
mov    $0x3,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0x4(%rbx),%esi
mov    $0x4,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0x5(%rbx),%esi
mov    $0x5,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0x6(%rbx),%esi
mov    $0x6,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0x7(%rbx),%esi
mov    $0x7,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0x8(%rbx),%esi
mov    $0x8,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0x9(%rbx),%esi
mov    $0x9,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0xa(%rbx),%esi
mov    $0xa,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0xb(%rbx),%esi
mov    $0xb,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0xc(%rbx),%esi
mov    $0xc,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0xd(%rbx),%esi
mov    $0xd,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0xe(%rbx),%esi
mov    $0xe,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0xf(%rbx),%esi
mov    $0xf,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0x10(%rbx),%esi
mov    $0x10,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0x11(%rbx),%esi
mov    $0x11,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
movzbl 0x12(%rbx),%esi
mov    $0x12,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
neg    %r12
movzbl 0x13(%r13,%r12,1),%esi
mov    $0x13,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@SHA_DIGEST_LENGTH = global i32 0
@.str = [8 x i8] c"%d-%lu\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [10 x i8]
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %1
%8 = load i32, i32* @SHA_DIGEST_LENGTH
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %6
%11 = alloca i8, i64 %9
store i64 %9, i64* %7
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i8 signext 65, i32 10)
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%15 = call i32 @SHA1(i8* %14, i32 10, i8* %11)
store i64 0, i64* %2
br label %16
16: ; preds = %25, %0
%17 = load i64, i64* %2
%18 = icmp ult i64 %17, 20
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = load i64, i64* %2
%21 = getelementptr inbounds i8, i8* %11, i64 %20
%22 = load i8, i8* %21
%23 = load i64, i64* %2
%24 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %22, i64 %23)
br label %25
25: ; preds = %19
%26 = load i64, i64* %2
%27 = add i64 %26, 1
store i64 %27, i64* %2
br label %16
28: ; preds = %16
store i32 0, i32* %1
%29 = load i8*, i8** %6
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@SHA_DIGEST_LENGTH = global i32 0
@.str = [8 x i8] c"%d-%lu\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @SHA_DIGEST_LENGTH
%4 = zext i32 %3 to i64
%5 = tail call i8* @llvm.stacksave()
%6 = alloca i8, i64 %4
%7 = call i32 @memset(i8* %2, i8 signext 65, i32 10)
%8 = call i32 @SHA1(i8* %2, i32 10, i8* %6)
%9 = load i8, i8* %6
%10 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %9, i64 0)
%11 = getelementptr inbounds i8, i8* %6, i64 1
%12 = load i8, i8* %11
%13 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %12, i64 1)
%14 = getelementptr inbounds i8, i8* %6, i64 2
%15 = load i8, i8* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %15, i64 2)
%17 = getelementptr inbounds i8, i8* %6, i64 3
%18 = load i8, i8* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %18, i64 3)
%20 = getelementptr inbounds i8, i8* %6, i64 4
%21 = load i8, i8* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %21, i64 4)
%23 = getelementptr inbounds i8, i8* %6, i64 5
%24 = load i8, i8* %23
%25 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %24, i64 5)
%26 = getelementptr inbounds i8, i8* %6, i64 6
%27 = load i8, i8* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %27, i64 6)
%29 = getelementptr inbounds i8, i8* %6, i64 7
%30 = load i8, i8* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %30, i64 7)
%32 = getelementptr inbounds i8, i8* %6, i64 8
%33 = load i8, i8* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %33, i64 8)
%35 = getelementptr inbounds i8, i8* %6, i64 9
%36 = load i8, i8* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %36, i64 9)
%38 = getelementptr inbounds i8, i8* %6, i64 10
%39 = load i8, i8* %38
%40 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %39, i64 10)
%41 = getelementptr inbounds i8, i8* %6, i64 11
%42 = load i8, i8* %41
%43 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %42, i64 11)
%44 = getelementptr inbounds i8, i8* %6, i64 12
%45 = load i8, i8* %44
%46 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %45, i64 12)
%47 = getelementptr inbounds i8, i8* %6, i64 13
%48 = load i8, i8* %47
%49 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %48, i64 13)
%50 = getelementptr inbounds i8, i8* %6, i64 14
%51 = load i8, i8* %50
%52 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %51, i64 14)
%53 = getelementptr inbounds i8, i8* %6, i64 15
%54 = load i8, i8* %53
%55 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %54, i64 15)
%56 = getelementptr inbounds i8, i8* %6, i64 16
%57 = load i8, i8* %56
%58 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %57, i64 16)
%59 = getelementptr inbounds i8, i8* %6, i64 17
%60 = load i8, i8* %59
%61 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %60, i64 17)
%62 = getelementptr inbounds i8, i8* %6, i64 18
%63 = load i8, i8* %62
%64 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %63, i64 18)
%65 = getelementptr inbounds i8, i8* %6, i64 19
%66 = load i8, i8* %65
%67 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %66, i64 19)
ret i32 0
}