#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 /*<<< orphan*/ MD5_Final(unsigned char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Update(int /*<<< orphan*/ *, unsigned char *,
                              unsigned int);
int cmpp_md5(unsigned char *md, unsigned char *src, unsigned int len) {
  if (md && src && len > 0) {
    MD5_CTX ctx;
    MD5_Init(&ctx);
    MD5_Update(&ctx, src, len);
    MD5_Final(md, &ctx);
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<cmpp_md5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1195 <cmpp_md5+0x65>
cmpq   $0x0,-0x18(%rbp)
je     1195 <cmpp_md5+0x65>
cmpl   $0x0,-0x1c(%rbp)
jbe    1195 <cmpp_md5+0x65>
lea    -0x20(%rbp),%rdi
call   1040 <MD5_Init@plt>
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    -0x20(%rbp),%rdi
call   1050 <MD5_Update@plt>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <MD5_Final@plt>
movl   $0x0,-0x4(%rbp)
jmp    119c <cmpp_md5+0x6c>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmpp_md5>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%eax
test   %rdi,%rdi
je     117b <cmpp_md5+0x4b>
mov    %rsi,%rbp
test   %rsi,%rsi
je     117b <cmpp_md5+0x4b>
mov    %edx,%r14d
test   %edx,%edx
je     117b <cmpp_md5+0x4b>
mov    %rdi,%rbx
lea    0x4(%rsp),%r15
mov    %r15,%rdi
call   1040 <MD5_Init@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1050 <MD5_Update@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <MD5_Final@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @cmpp_md5(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %24
11: ; preds = %3
%12 = load i8*, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i32, i32* %7
%16 = icmp ugt i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = call i32 @MD5_Init(i32* %8)
%19 = load i8*, i8** %6
%20 = load i32, i32* %7
%21 = call i32 @MD5_Update(i32* %8, i8* %19, i32 %20)
%22 = load i8*, i8** %5
%23 = call i32 @MD5_Final(i8* %22, i32* %8)
store i32 0, i32* %4
br label %25
24: ; preds = %14, %11, %3
store i32 -1, i32* %4
br label %25
25: ; preds = %24, %17
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
define i32 @cmpp_md5(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = icmp ne i8* %0, null
%6 = icmp ne i8* %1, null
%7 = and i1 %5, %6
%8 = icmp ne i32 %2, 0
%9 = and i1 %7, %8
br i1 %9, label %10, label %15
10: ; preds = %3
%11 = bitcast i32* %4 to i8*
%12 = call i32 @MD5_Init(i32* %4)
%13 = call i32 @MD5_Update(i32* %4, i8* %1, i32 %2)
%14 = call i32 @MD5_Final(i8* %0, i32* %4)
br label %15
15: ; preds = %3, %10
%16 = phi i32 [ 0, %10 ], [ -1, %3 ]
ret i32 %16
}