#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*/ SHA1(unsigned char *, int /*<<< orphan*/, unsigned char *);
int /*<<< orphan*/ printf(char *, unsigned char);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ strlen(char *);
int main() {
  int i;
  unsigned char hash[20];
  unsigned char in[] = {0x1e, 0xfe, 0xba, 0x22, 0xe7, 0x70, 0xe9, 0x5f};
  SHA1(in, strlen((char *)in), hash);
  for (i = 0; i < 20; ++i) {
    printf("%d", i % 10);
  }
  putchar('\n');
  for (i = 0; i < 20; ++i) {
    printf("%x", hash[i]);
  }
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
lea    -0x20(%rbp),%rdx
call   1060 <SHA1@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jge    11b5 <main+0x75>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %dl,%al
lea    0xe69(%rip),%rdi
movzbl %al,%esi
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1181 <main+0x41>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jge    11f3 <main+0xb3>
movslq -0x8(%rbp),%rax
lea    0xe30(%rip),%rdi
movzbl -0x20(%rbp,%rax,1),%esi
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c6 <main+0x86>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movabs $0x5fe970e722bafe1e,%rax
70 e9 5f
mov    %rax,0x18(%rsp)
lea    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <SHA1@plt>
mov    $0x14,%ebp
xor    %ebx,%ebx
lea    0xe81(%rip),%r14
nop
movzbl %bl,%ebx
imul   $0xcd,%ebx,%eax
shr    $0xa,%eax
and    $0xfffffffe,%eax
lea    (%rax,%rax,4),%eax
mov    %ebx,%ecx
sub    %al,%cl
movzbl %cl,%esi
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%bl
add    $0xffffffff,%ebp
jne    1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
movzbl (%rsp),%esi
lea    0xe45(%rip),%rbx
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0x1(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0x2(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0x3(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0x4(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0x5(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0x6(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0x7(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0x8(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0x9(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0xa(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0xb(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0xc(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0xd(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0xe(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0xf(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0x10(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0x11(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0x12(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
movzbl 0x13(%rsp),%esi
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.in = [8 x i8] c"\1E\FE\BA\22\E7p\E9_"
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%x\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [20 x i8]
%4 = alloca [8 x i8]
store i32 0, i32* %1
%5 = bitcast [8 x i8]* %4 to i8*
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%10 = call i32 @SHA1(i8* %6, i32 %8, i8* %9)
store i32 0, i32* %2
br label %11
11: ; preds = %19, %0
%12 = load i32, i32* %2
%13 = icmp slt i32 %12, 20
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i32, i32* %2
%16 = srem i32 %15, 10
%17 = trunc i32 %16 to i8
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %17)
br label %19
19: ; preds = %14
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %11
22: ; preds = %11
%23 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %2
br label %24
24: ; preds = %33, %22
%25 = load i32, i32* %2
%26 = icmp slt i32 %25, 20
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %31)
br label %33
33: ; preds = %27
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
store i32 %35, i32* %2
br label %24
36: ; preds = %24
%37 = call i32 @putchar(i8 signext 10)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%x\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca i64
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = bitcast i64* %2 to i8*
store i64 6911179241199173150, i64* %2
%5 = call i32 @strlen(i8* %4)
%6 = call i32 @SHA1(i8* %4, i32 %5, i8* %3)
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ 0, %0 ], [ %12, %7 ]
%9 = trunc i32 %8 to i8
%10 = urem i8 %9, 10
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 zeroext %10)
%12 = add nuw nsw i32 %8, 1
%13 = icmp eq i32 %12, 20
br i1 %13, label %14, label %7
14: ; preds = %7
%15 = call i32 @putchar(i8 signext 10)
%16 = load i8, i8* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %16)
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 1
%19 = load i8, i8* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %19)
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 2
%22 = load i8, i8* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %22)
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 3
%25 = load i8, i8* %24
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %25)
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 4
%28 = load i8, i8* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %28)
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 5
%31 = load i8, i8* %30
%32 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %31)
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 6
%34 = load i8, i8* %33
%35 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %34)
%36 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 7
%37 = load i8, i8* %36
%38 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %37)
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 8
%40 = load i8, i8* %39
%41 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %40)
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 9
%43 = load i8, i8* %42
%44 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %43)
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 10
%46 = load i8, i8* %45
%47 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %46)
%48 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 11
%49 = load i8, i8* %48
%50 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %49)
%51 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 12
%52 = load i8, i8* %51
%53 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %52)
%54 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 13
%55 = load i8, i8* %54
%56 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %55)
%57 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 14
%58 = load i8, i8* %57
%59 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %58)
%60 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 15
%61 = load i8, i8* %60
%62 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %61)
%63 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 16
%64 = load i8, i8* %63
%65 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %64)
%66 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 17
%67 = load i8, i8* %66
%68 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %67)
%69 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 18
%70 = load i8, i8* %69
%71 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %70)
%72 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 19
%73 = load i8, i8* %72
%74 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %73)
%75 = call i32 @putchar(i8 signext 10)
ret i32 0
}