#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 */
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ MD5_CTX;

/* Variables and functions */
int MD5_DIGEST_LENGTH;
int /*<<< orphan*/ MD5_Final(unsigned char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Update(int /*<<< orphan*/ *, unsigned char *,
                              unsigned long);
int /*<<< orphan*/ printf(char *, unsigned char);
int /*<<< orphan*/ putchar(char);
int print_hash(void *input, unsigned long length) {
  MD5_CTX context;
  unsigned char buffer[MD5_DIGEST_LENGTH];
  unsigned i;
  if (!MD5_Init(&context))
    return 0;
  if (!MD5_Update(&context, (unsigned char *)input, length))
    return 0;
  if (!MD5_Final(buffer, &context))
    return 0;
  for (i = 0; i < sizeof(buffer); ++i)
    printf("%02x", buffer[i]);
  putchar('\n');
  return 1;
}


x86 assembly (clang, -O0):
<print_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2e79(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x28(%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,-0x30(%rbp)
lea    -0x1c(%rbp),%rdi
call   1060 <MD5_Init@plt>
cmp    $0x0,%eax
jne    11b5 <print_hash+0x65>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    125f <print_hash+0x10f>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rdi
call   1070 <MD5_Update@plt>
cmp    $0x0,%eax
jne    11e2 <print_hash+0x92>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    125f <print_hash+0x10f>
mov    -0x40(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <MD5_Final@plt>
cmp    $0x0,%eax
jne    120b <print_hash+0xbb>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x38(%rbp)
jmp    125f <print_hash+0x10f>
movl   $0x0,-0x34(%rbp)
mov    -0x48(%rbp),%rcx
mov    -0x34(%rbp),%eax
cmp    %rcx,%rax
jae    1247 <print_hash+0xf7>
mov    -0x40(%rbp),%rax
mov    -0x34(%rbp),%ecx
lea    0xdd0(%rip),%rdi
movzbl (%rax,%rcx,1),%esi
call   1050 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1212 <print_hash+0xc2>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_hash>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r12
mov    %rsp,-0x38(%rbp)
mov    0x2e6e(%rip),%rax
mov    (%rax),%r13d
mov    %rsp,%r15
lea    0xf(%r13),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    -0x2c(%rbp),%rdi
call   1060 <MD5_Init@plt>
xor    %r14d,%r14d
test   %eax,%eax
je     11f8 <print_hash+0xa8>
lea    -0x2c(%rbp),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1070 <MD5_Update@plt>
test   %eax,%eax
je     11f8 <print_hash+0xa8>
lea    -0x2c(%rbp),%rsi
mov    %r15,%rdi
call   1040 <MD5_Final@plt>
test   %eax,%eax
mov    -0x38(%rbp),%r12
je     11fc <print_hash+0xac>
test   %r13,%r13
je     11e6 <print_hash+0x96>
xor    %ebx,%ebx
lea    0xe35(%rip),%r14
nopl   0x0(%rax,%rax,1)
movzbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    11d0 <print_hash+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%r14d
jmp    11fc <print_hash+0xac>
mov    -0x38(%rbp),%r12
mov    %r12,%rsp
mov    %r14d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MD5_DIGEST_LENGTH = global i32 0
@.str = [5 x i8] c"%02x\00"
define i32 @print_hash(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
%11 = load i32, i32* @MD5_DIGEST_LENGTH
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %7
%14 = alloca i8, i64 %12
store i64 %12, i64* %8
%15 = call i32 @MD5_Init(i32* %6)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %2
store i32 0, i32* %3
store i32 1, i32* %10
br label %44
18: ; preds = %2
%19 = load i8*, i8** %4
%20 = load i64, i64* %5
%21 = call i32 @MD5_Update(i32* %6, i8* %19, i64 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %18
store i32 0, i32* %3
store i32 1, i32* %10
br label %44
24: ; preds = %18
%25 = call i32 @MD5_Final(i8* %14, i32* %6)
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %24
store i32 0, i32* %3
store i32 1, i32* %10
br label %44
28: ; preds = %24
store i32 0, i32* %9
br label %29
29: ; preds = %39, %28
%30 = load i32, i32* %9
%31 = zext i32 %30 to i64
%32 = icmp ult i64 %31, %12
br i1 %32, label %33, label %42
33: ; preds = %29
%34 = load i32, i32* %9
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %14, i64 %35
%37 = load i8, i8* %36
%38 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %37)
br label %39
39: ; preds = %33
%40 = load i32, i32* %9
%41 = add i32 %40, 1
store i32 %41, i32* %9
br label %29
42: ; preds = %29
%43 = call i32 @putchar(i8 signext 10)
store i32 1, i32* %3
store i32 1, i32* %10
br label %44
44: ; preds = %42, %27, %23, %17
%45 = load i8*, i8** %7
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@MD5_DIGEST_LENGTH = global i32 0
@.str = [5 x i8] c"%02x\00"
define i32 @print_hash(i8* %0, i64 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i32, i32* @MD5_DIGEST_LENGTH
%6 = zext i32 %5 to i64
%7 = tail call i8* @llvm.stacksave()
%8 = alloca i8, i64 %6
%9 = call i32 @MD5_Init(i32* %3)
%10 = icmp eq i32 %9, 0
br i1 %10, label %28, label %11
11: ; preds = %2
%12 = call i32 @MD5_Update(i32* %3, i8* %0, i64 %1)
%13 = icmp eq i32 %12, 0
br i1 %13, label %28, label %14
14: ; preds = %11
%15 = call i32 @MD5_Final(i8* %8, i32* %3)
%16 = icmp eq i32 %15, 0
br i1 %16, label %28, label %17
17: ; preds = %14
%18 = icmp eq i32 %5, 0
br i1 %18, label %26, label %19
19: ; preds = %17, %19
%20 = phi i64 [ %24, %19 ], [ 0, %17 ]
%21 = getelementptr inbounds i8, i8* %8, i64 %20
%22 = load i8, i8* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %22)
%24 = add nuw nsw i64 %20, 1
%25 = icmp eq i64 %24, %6
br i1 %25, label %26, label %19
26: ; preds = %19, %17
%27 = call i32 @putchar(i8 signext 10)
br label %28
28: ; preds = %14, %11, %2, %26
%29 = phi i32 [ 1, %26 ], [ 0, %2 ], [ 0, %11 ], [ 0, %14 ]
ret i32 %29
}