#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*/ bfd_dump_data(unsigned char *, int);
int /*<<< orphan*/ bfd_sha1hash(char *, int /*<<< orphan*/, unsigned char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strlen(char *);
void bfd_test_sha1hash(void) {
  unsigned char sha1hash[20];
  bfd_sha1hash("abc", strlen("abc"), sha1hash);
  printf("bfd_test_sha1hash: count the sha1hash for %s\n", "abc");
  bfd_dump_data(sha1hash, 20);
  printf("Should match:\n");
  printf("\tA9993E36 4706816A BA3E2571 7850C26C 9CD0D89D\n");
}


x86 assembly (clang, -O0):
<bfd_test_sha1hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    -0x20(%rbp),%rdx
lea    0xe9f(%rip),%rdi
call   1060 <bfd_sha1hash@plt>
lea    0xe97(%rip),%rdi
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x14,%esi
call   1050 <bfd_dump_data@plt>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bfd_test_sha1hash>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xea2(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
call   1070 <bfd_sha1hash@plt>
lea    0xe87(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x14,%esi
call   1060 <bfd_dump_data@plt>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"abc\00"
@.str.1 = [46 x i8] c"bfd_test_sha1hash: count the sha1hash for %s\0A\00"
@.str.2 = [15 x i8] c"Should match:\0A\00"
@.str.3 = [47 x i8] c"\09A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D\0A\00"
define void @bfd_test_sha1hash() {
%1 = alloca [20 x i8]
%2 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = call i32 @bfd_sha1hash(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %2, i8* %3)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%7 = call i32 @bfd_dump_data(i8* %6, i32 20)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"abc\00"
@.str.1 = [46 x i8] c"bfd_test_sha1hash: count the sha1hash for %s\0A\00"
@str = [14 x i8] c"Should match:\00"
@str.4 = [46 x i8] c"\09A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D\00"
define void @bfd_test_sha1hash() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @bfd_sha1hash(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %3, i8* %2)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @bfd_dump_data(i8* %2, i32 20)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.4, i64 0, i64 0))
ret void
}