#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*/ MD5_CTX;

/* Variables and functions */
int MD5_DIGEST_LENGTH;
int MD5_Final(unsigned char *, int /*<<< orphan*/ *);
int MD5_Init(int /*<<< orphan*/ *);
int MD5_Update(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strlen(char *);
int main(void) {
  MD5_CTX md5_ctx;
  int result;
  unsigned char md5[MD5_DIGEST_LENGTH];
  int i;
  char str[] = "ABCDE";
  result = MD5_Init(&md5_ctx);
  if (result == 1) {
    printf("MD5_Init success!\n");
  } else {
    printf("MD5_Init error!\n");
    return -1;
  }
  result = MD5_Update(&md5_ctx, str, strlen(str));
  if (result == 1) {
    printf("MD5_Update success!\n");
  } else {
    printf("MD5_Update error!\n");
    return -2;
  }
  result = MD5_Final(md5, &md5_ctx);
  if (result == 1) {
    printf("MD5_Final success!\n");
  } else {
    printf("MD5_Final error!\n");
    return -3;
  }
  printf("md5 = ");
  for (i = 0; i < MD5_DIGEST_LENGTH; i++) {
    printf("%02x", md5[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    0xe6f(%rip),%eax
mov    %eax,-0x2a(%rbp)
mov    0xe69(%rip),%ax
mov    %ax,-0x26(%rbp)
lea    -0x8(%rbp),%rdi
call   1060 <MD5_Init@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    11c8 <main+0x78>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11e9 <main+0x99>
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    1303 <main+0x1b3>
lea    -0x2a(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    -0x2a(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
lea    -0x8(%rbp),%rdi
call   1070 <MD5_Update@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1229 <main+0xd9>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    124a <main+0xfa>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    1303 <main+0x1b3>
mov    -0x38(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1030 <MD5_Final@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1277 <main+0x127>
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1298 <main+0x148>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xfffffffd,-0x4(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    1303 <main+0x1b3>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2d29(%rip),%rcx
cmp    (%rcx),%eax
jge    12e7 <main+0x197>
mov    -0x38(%rbp),%rax
movslq -0x24(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12ad <main+0x15d>
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x18(%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    0x2e55(%rip),%r13
mov    0x0(%r13),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
movw   $0x45,-0x30(%rbp)
movl   $0x44434241,-0x34(%rbp)
lea    -0x2c(%rbp),%rdi
call   1080 <MD5_Init@plt>
cmp    $0x1,%eax
jne    127c <main+0x10c>
lea    0xe5c(%rip),%rdi
call   1040 <puts@plt>
lea    -0x34(%rbp),%r14
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    -0x2c(%rbp),%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1090 <MD5_Update@plt>
cmp    $0x1,%eax
jne    1290 <main+0x120>
lea    0xe51(%rip),%rdi
call   1040 <puts@plt>
lea    -0x2c(%rbp),%rsi
mov    %rbx,%rdi
call   1050 <MD5_Final@plt>
cmp    $0x1,%eax
jne    12a4 <main+0x134>
mov    %r15,-0x40(%rbp)
lea    0xe51(%rip),%rdi
call   1040 <puts@plt>
lea    0xde0(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1070 <printf@plt>
cmpl   $0x0,0x0(%r13)
jle    126c <main+0xfc>
lea    0xdcf(%rip),%r15
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rbx,%r12,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%r12
movslq 0x0(%r13),%rax
cmp    %rax,%r12
jl     1250 <main+0xe0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x40(%rbp),%r15
jmp    12b6 <main+0x146>
lea    0xd8f(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%r14d
jmp    12b6 <main+0x146>
lea    0xd9d(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffe,%r14d
jmp    12b6 <main+0x146>
lea    0xdaf(%rip),%rdi
call   1040 <puts@plt>
mov    $0xfffffffd,%r14d
mov    %r15,%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
@__const.main.str = [6 x i8] c"ABCDE\00"
@.str = [19 x i8] c"MD5_Init success!\0A\00"
@.str.1 = [17 x i8] c"MD5_Init error!\0A\00"
@.str.2 = [21 x i8] c"MD5_Update success!\0A\00"
@.str.3 = [19 x i8] c"MD5_Update error!\0A\00"
@.str.4 = [20 x i8] c"MD5_Final success!\0A\00"
@.str.5 = [18 x i8] c"MD5_Final error!\0A\00"
@.str.6 = [7 x i8] c"md5 = \00"
@.str.7 = [5 x i8] c"%02x\00"
@.str.8 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca [6 x i8]
%8 = alloca i32
store i32 0, i32* %1
%9 = load i32, i32* @MD5_DIGEST_LENGTH
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %4
%12 = alloca i8, i64 %10
store i64 %10, i64* %5
%13 = bitcast [6 x i8]* %7 to i8*
%14 = call i32 @MD5_Init(i32* %2)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %21
19: ; preds = %0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
store i32 1, i32* %8
br label %58
21: ; preds = %17
%22 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
%25 = call i32 @MD5_Update(i32* %2, i8* %22, i32 %24)
store i32 %25, i32* %3
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %30
28: ; preds = %21
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %32
30: ; preds = %21
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
store i32 -2, i32* %1
store i32 1, i32* %8
br label %58
32: ; preds = %28
%33 = call i32 @MD5_Final(i8* %12, i32* %2)
store i32 %33, i32* %3
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %40
38: ; preds = %32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
store i32 -3, i32* %1
store i32 1, i32* %8
br label %58
40: ; preds = %36
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %6
br label %42
42: ; preds = %53, %40
%43 = load i32, i32* %6
%44 = load i32, i32* @MD5_DIGEST_LENGTH
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %56
46: ; preds = %42
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %12, i64 %48
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %46
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
br label %42
56: ; preds = %42
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %1
store i32 1, i32* %8
br label %58
58: ; preds = %56, %38, %30, %19
%59 = load i8*, i8** %4
%60 = load i32, i32* %1
ret i32 %60
}

LLVM IR (-O2):
@MD5_DIGEST_LENGTH = global i32 0
@__const.main.str = [6 x i8] c"ABCDE\00"
@.str.6 = [7 x i8] c"md5 = \00"
@.str.7 = [5 x i8] c"%02x\00"
@str = [16 x i8] c"MD5_Init error!\00"
@str.9 = [18 x i8] c"MD5_Init success!\00"
@str.10 = [18 x i8] c"MD5_Update error!\00"
@str.11 = [20 x i8] c"MD5_Update success!\00"
@str.12 = [17 x i8] c"MD5_Final error!\00"
@str.13 = [19 x i8] c"MD5_Final success!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = bitcast i32* %1 to i8*
%4 = load i32, i32* @MD5_DIGEST_LENGTH
%5 = zext i32 %4 to i64
%6 = tail call i8* @llvm.stacksave()
%7 = alloca i8, i64 %5
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%9 = call i32 @MD5_Init(i32* %1)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.9, i64 0, i64 0))
%13 = call i32 @strlen(i8* %8)
%14 = call i32 @MD5_Update(i32* %1, i8* %8, i32 %13)
%15 = icmp eq i32 %14, 1
br i1 %15, label %18, label %22
16: ; preds = %0
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %43
18: ; preds = %11
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.11, i64 0, i64 0))
%20 = call i32 @MD5_Final(i8* %7, i32* %1)
%21 = icmp eq i32 %20, 1
br i1 %21, label %24, label %29
22: ; preds = %11
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.10, i64 0, i64 0))
br label %43
24: ; preds = %18
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.13, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%27 = load i32, i32* @MD5_DIGEST_LENGTH
%28 = icmp sgt i32 %27, 0
br i1 %28, label %31, label %41
29: ; preds = %18
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.12, i64 0, i64 0))
br label %43
31: ; preds = %24, %31
%32 = phi i64 [ %37, %31 ], [ 0, %24 ]
%33 = getelementptr inbounds i8, i8* %7, i64 %32
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %35)
%37 = add nuw nsw i64 %32, 1
%38 = load i32, i32* @MD5_DIGEST_LENGTH
%39 = sext i32 %38 to i64
%40 = icmp slt i64 %37, %39
br i1 %40, label %31, label %41
41: ; preds = %31, %24
%42 = call i32 @putchar(i32 10)
br label %43
43: ; preds = %41, %29, %22, %16
%44 = phi i32 [ 0, %41 ], [ -3, %29 ], [ -2, %22 ], [ -1, %16 ]
ret i32 %44
}