#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_md5hash(char *, int /*<<< orphan*/, unsigned char *);
int /*<<< orphan*/ libhmac_md5(unsigned char *, unsigned char, unsigned char *,
                               unsigned int, unsigned char *);
int /*<<< orphan*/ memset(unsigned char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strlen(char *);
void bfd_test_md5hash(void) {
  {
    unsigned char md5hash[16];
    bfd_md5hash("abc", strlen("abc"), md5hash);
    printf("bfd_test_md5hash: count the md5hash for %s\n", "abc");
    bfd_dump_data(md5hash, 16);
    printf("Should match:\n");
    printf("\t90015098 3cd24fb0 d6963f7d 28e17f72\n");
  }
  {
    unsigned char key[16];
    unsigned int key_len = 16;
    unsigned char data[] = "Hi There";
    unsigned char data_len = 8;
    unsigned char md5hash[16];
    memset(key, 0x0b, 16);
    libhmac_md5(data, data_len, key, key_len, md5hash);
    printf("bfd_test_md5hash: count libhmac_md5 test 1\n");
    bfd_dump_data(md5hash, 16);
    printf("Should match:\n");
    printf("\t9294727a 3638bb1c 13f48ef8 158bfc9d\n");
  }
  {
    unsigned char key[] = "Jefe";
    unsigned int key_len = 4;
    unsigned char data[] = "what do ya want for nothing?";
    unsigned char data_len = 28;
    unsigned char md5hash[16];
    libhmac_md5(data, data_len, key, key_len, md5hash);
    printf("bfd_test_md5hash: count libhmac_md5 test 2\n");
    bfd_dump_data(md5hash, 16);
    printf("Should match:\n");
    printf("\t750c783e 6ab0b503 eaa86e31 0a5db738\n");
  }
  {
    unsigned char key[16];
    unsigned int key_len = 16;
    unsigned char data[50];
    unsigned char data_len = 50;
    unsigned char md5hash[16];
    memset(key, 0xAA, 16);
    memset(data, 0xDD, 50);
    libhmac_md5(data, data_len, key, key_len, md5hash);
    printf("bfd_test_md5hash: count libhmac_md5 test 3\n");
    bfd_dump_data(md5hash, 16);
    printf("Should match:\n");
    printf("\t56be3452 1d144c88 dbb8c733 f0e8b3f6\n");
  }
}


x86 assembly (clang, -O0):
<bfd_test_md5hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
lea    0xe8e(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    -0x10(%rbp),%rdx
lea    0xe7c(%rip),%rdi
call   1070 <bfd_md5hash@plt>
lea    0xe74(%rip),%rdi
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1080 <bfd_dump_data@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x10,-0x24(%rbp)
mov    0xe8f(%rip),%rax
mov    %rax,-0x2d(%rbp)
mov    0xe8d(%rip),%al
mov    %al,-0x25(%rbp)
movb   $0x8,-0x2e(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0xb,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
lea    -0x2d(%rbp),%rdi
mov    -0x2e(%rbp),%al
lea    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
lea    -0x40(%rbp),%r8
movzbl %al,%esi
call   1060 <libhmac_md5@plt>
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x10,%esi
call   1080 <bfd_dump_data@plt>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0xe6e(%rip),%eax
mov    %eax,-0x45(%rbp)
mov    0xe69(%rip),%al
mov    %al,-0x41(%rbp)
movl   $0x4,-0x4c(%rbp)
mov    0xf04(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xf01(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xefe(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xefc(%rip),%eax
mov    %eax,-0x58(%rbp)
mov    0xef7(%rip),%al
mov    %al,-0x54(%rbp)
movb   $0x1c,-0x71(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x71(%rbp),%al
lea    -0x45(%rbp),%rdx
mov    -0x4c(%rbp),%ecx
lea    -0x90(%rbp),%r8
movzbl %al,%esi
call   1060 <libhmac_md5@plt>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    $0x10,%esi
call   1080 <bfd_dump_data@plt>
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x10,-0xa4(%rbp)
movb   $0x32,-0xe1(%rbp)
lea    -0xa0(%rbp),%rdi
mov    $0xaa,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
lea    -0xe0(%rbp),%rdi
mov    $0xdd,%esi
mov    $0x32,%edx
call   1050 <memset@plt>
lea    -0xe0(%rbp),%rdi
mov    -0xe1(%rbp),%al
lea    -0xa0(%rbp),%rdx
mov    -0xa4(%rbp),%ecx
lea    -0x100(%rbp),%r8
movzbl %al,%esi
call   1060 <libhmac_md5@plt>
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x100(%rbp),%rdi
mov    $0x10,%esi
call   1080 <bfd_dump_data@plt>
lea    0xcb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bfd_test_md5hash>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xe7e(%rip),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x20(%rsp),%r14
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r14,%rdx
call   1080 <bfd_md5hash@plt>
lea    0xe61(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
mov    $0x10,%esi
call   1090 <bfd_dump_data@plt>
lea    0xf6d(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
movabs $0x6572656854206948,%rax
65 72 65
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xb,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
mov    %rsp,%rdi
lea    0x10(%rsp),%r15
mov    $0x8,%esi
mov    %rbx,%rdx
mov    $0x10,%ecx
mov    %r15,%r8
call   1070 <libhmac_md5@plt>
lea    0xe40(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    $0x10,%esi
call   1090 <bfd_dump_data@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe4a(%rip),%rdi
call   1030 <puts@plt>
movb   $0x0,0x4(%rsp)
movl   $0x6566654a,(%rsp)
movups 0xf21(%rip),%xmm0
movups %xmm0,0x2d(%rsp)
movaps 0xf08(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0x20(%rsp),%rdi
mov    %rsp,%rdx
lea    0x10(%rsp),%rbx
mov    $0x1c,%esi
mov    $0x4,%ecx
mov    %rbx,%r8
call   1070 <libhmac_md5@plt>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
call   1090 <bfd_dump_data@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe2a(%rip),%rdi
call   1030 <puts@plt>
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0xaa,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xdd,%esi
mov    $0x32,%edx
call   1060 <memset@plt>
mov    %rsp,%r12
mov    %rbx,%rdi
mov    $0x32,%esi
mov    %r15,%rdx
mov    $0x10,%ecx
mov    %r12,%r8
call   1070 <libhmac_md5@plt>
lea    0xdfa(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    $0x10,%esi
call   1090 <bfd_dump_data@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe12(%rip),%rdi
call   1030 <puts@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"abc\00"
@.str.1 = [44 x i8] c"bfd_test_md5hash: count the md5hash for %s\0A\00"
@.str.2 = [15 x i8] c"Should match:\0A\00"
@.str.3 = [38 x i8] c"\0990015098 3cd24fb0 d6963f7d 28e17f72\0A\00"
@__const.bfd_test_md5hash.data = [9 x i8] c"Hi There\00"
@.str.4 = [44 x i8] c"bfd_test_md5hash: count libhmac_md5 test 1\0A\00"
@.str.5 = [38 x i8] c"\099294727a 3638bb1c 13f48ef8 158bfc9d\0A\00"
@__const.bfd_test_md5hash.key = [5 x i8] c"Jefe\00"
@__const.bfd_test_md5hash.data.6 = [29 x i8] c"what do ya want for nothing?\00"
@.str.7 = [44 x i8] c"bfd_test_md5hash: count libhmac_md5 test 2\0A\00"
@.str.8 = [38 x i8] c"\09750c783e 6ab0b503 eaa86e31 0a5db738\0A\00"
@.str.9 = [44 x i8] c"bfd_test_md5hash: count libhmac_md5 test 3\0A\00"
@.str.10 = [38 x i8] c"\0956be3452 1d144c88 dbb8c733 f0e8b3f6\0A\00"
define void @bfd_test_md5hash() {
%1 = alloca [16 x i8]
%2 = alloca [16 x i8]
%3 = alloca i32
%4 = alloca [9 x i8]
%5 = alloca i8
%6 = alloca [16 x i8]
%7 = alloca [5 x i8]
%8 = alloca i32
%9 = alloca [29 x i8]
%10 = alloca i8
%11 = alloca [16 x i8]
%12 = alloca [16 x i8]
%13 = alloca i32
%14 = alloca [50 x i8]
%15 = alloca i8
%16 = alloca [16 x i8]
%17 = call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%19 = call i32 @bfd_md5hash(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17, i8* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%22 = call i32 @bfd_dump_data(i8* %21, i32 16)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
store i32 16, i32* %3
%25 = bitcast [9 x i8]* %4 to i8*
store i8 8, i8* %5
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%27 = call i32 @memset(i8* %26, i32 11, i32 16)
%28 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%29 = load i8, i8* %5
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%31 = load i32, i32* %3
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%33 = call i32 @libhmac_md5(i8* %28, i8 zeroext %29, i8* %30, i32 %31, i8* %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0))
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%36 = call i32 @bfd_dump_data(i8* %35, i32 16)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%39 = bitcast [5 x i8]* %7 to i8*
store i32 4, i32* %8
%40 = bitcast [29 x i8]* %9 to i8*
store i8 28, i8* %10
%41 = getelementptr inbounds [29 x i8], [29 x i8]* %9, i64 0, i64 0
%42 = load i8, i8* %10
%43 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%44 = load i32, i32* %8
%45 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%46 = call i32 @libhmac_md5(i8* %41, i8 zeroext %42, i8* %43, i32 %44, i8* %45)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.7, i64 0, i64 0))
%48 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%49 = call i32 @bfd_dump_data(i8* %48, i32 16)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
store i32 16, i32* %13
store i8 50, i8* %15
%52 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%53 = call i32 @memset(i8* %52, i32 170, i32 16)
%54 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 0
%55 = call i32 @memset(i8* %54, i32 221, i32 50)
%56 = getelementptr inbounds [50 x i8], [50 x i8]* %14, i64 0, i64 0
%57 = load i8, i8* %15
%58 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%59 = load i32, i32* %13
%60 = getelementptr inbounds [16 x i8], [16 x i8]* %16, i64 0, i64 0
%61 = call i32 @libhmac_md5(i8* %56, i8 zeroext %57, i8* %58, i32 %59, i8* %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0))
%63 = getelementptr inbounds [16 x i8], [16 x i8]* %16, i64 0, i64 0
%64 = call i32 @bfd_dump_data(i8* %63, i32 16)
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.10, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"abc\00"
@.str.1 = [44 x i8] c"bfd_test_md5hash: count the md5hash for %s\0A\00"
@__const.bfd_test_md5hash.data = [9 x i8] c"Hi There\00"
@__const.bfd_test_md5hash.key = [5 x i8] c"Jefe\00"
@__const.bfd_test_md5hash.data.6 = [29 x i8] c"what do ya want for nothing?\00"
@str.11 = [37 x i8] c"\0990015098 3cd24fb0 d6963f7d 28e17f72\00"
@str.12 = [43 x i8] c"bfd_test_md5hash: count libhmac_md5 test 1\00"
@str.14 = [37 x i8] c"\099294727a 3638bb1c 13f48ef8 158bfc9d\00"
@str.15 = [43 x i8] c"bfd_test_md5hash: count libhmac_md5 test 2\00"
@str.17 = [37 x i8] c"\09750c783e 6ab0b503 eaa86e31 0a5db738\00"
@str.18 = [43 x i8] c"bfd_test_md5hash: count libhmac_md5 test 3\00"
@str.19 = [14 x i8] c"Should match:\00"
@str.20 = [37 x i8] c"\0956be3452 1d144c88 dbb8c733 f0e8b3f6\00"
define void @bfd_test_md5hash() {
%1 = alloca [16 x i8]
%2 = alloca [16 x i8]
%3 = alloca [9 x i8]
%4 = alloca [16 x i8]
%5 = alloca [5 x i8]
%6 = alloca [29 x i8]
%7 = alloca [16 x i8]
%8 = alloca [16 x i8]
%9 = alloca [50 x i8]
%10 = alloca [16 x i8]
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @bfd_md5hash(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %11)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @bfd_dump_data(i8* %11, i32 16)
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.19, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.11, i64 0, i64 0))
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [9 x i8], [9 x i8]* %3, i64 0, i64 0
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%21 = call i32 @memset(i8* %18, i32 11, i32 16)
%22 = call i32 @libhmac_md5(i8* %19, i8 zeroext 8, i8* %18, i32 16, i8* %20)
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.12, i64 0, i64 0))
%24 = call i32 @bfd_dump_data(i8* %20, i32 16)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.19, i64 0, i64 0))
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.14, i64 0, i64 0))
%27 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%28 = getelementptr inbounds [29 x i8], [29 x i8]* %6, i64 0, i64 0
%29 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%30 = call i32 @libhmac_md5(i8* %28, i8 zeroext 28, i8* %27, i32 4, i8* %29)
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.15, i64 0, i64 0))
%32 = call i32 @bfd_dump_data(i8* %29, i32 16)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.19, i64 0, i64 0))
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.17, i64 0, i64 0))
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%36 = getelementptr inbounds [50 x i8], [50 x i8]* %9, i64 0, i64 0
%37 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%38 = call i32 @memset(i8* %35, i32 170, i32 16)
%39 = call i32 @memset(i8* %36, i32 221, i32 50)
%40 = call i32 @libhmac_md5(i8* %36, i8 zeroext 50, i8* %35, i32 16, i8* %37)
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.18, i64 0, i64 0))
%42 = call i32 @bfd_dump_data(i8* %37, i32 16)
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.19, i64 0, i64 0))
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.20, i64 0, i64 0))
ret void
}