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

/* Variables and functions */
int MD5_DIGEST_LENGTH;
int /*<<< orphan*/ MD5_Final(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Update(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                              size_t);
int /*<<< orphan*/ memcmp(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int verify(uint8_t *hash, uint8_t *data, size_t length) {
  uint8_t buffer[MD5_DIGEST_LENGTH];
  MD5_CTX ctx;
  MD5_Init(&ctx);
  MD5_Update(&ctx, data, length);
  MD5_Final(buffer, &ctx);
  return !memcmp(buffer, hash, MD5_DIGEST_LENGTH);
}


x86 assembly (clang, -O0):
<verify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
lea    -0x2c(%rbp),%rdi
call   1050 <MD5_Init@plt>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x2c(%rbp),%rdi
call   1060 <MD5_Update@plt>
mov    -0x38(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1030 <MD5_Final@plt>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    0x2e29(%rip),%rax
mov    (%rax),%edx
call   1040 <memcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
mov    0x2e82(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x2c(%rbp),%r13
mov    %r13,%rdi
call   1050 <MD5_Init@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1060 <MD5_Update@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <MD5_Final@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <memcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%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
define i32 @verify(i32* %0, i32* %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i64 %2, i64* %6
%10 = load i32, i32* @MD5_DIGEST_LENGTH
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %7
%13 = alloca i32, i64 %11
store i64 %11, i64* %8
%14 = call i32 @MD5_Init(i32* %9)
%15 = load i32*, i32** %5
%16 = load i64, i64* %6
%17 = call i32 @MD5_Update(i32* %9, i32* %15, i64 %16)
%18 = call i32 @MD5_Final(i32* %13, i32* %9)
%19 = load i32*, i32** %4
%20 = load i32, i32* @MD5_DIGEST_LENGTH
%21 = call i32 @memcmp(i32* %13, i32* %19, i32 %20)
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
%24 = zext i1 %23 to i32
%25 = load i8*, i8** %7
ret i32 %24
}

LLVM IR (-O2):
@MD5_DIGEST_LENGTH = global i32 0
define i32 @verify(i32* %0, i32* %1, i64 %2) {
%4 = alloca i32
%5 = load i32, i32* @MD5_DIGEST_LENGTH
%6 = zext i32 %5 to i64
%7 = alloca i32, i64 %6
%8 = bitcast i32* %4 to i8*
%9 = call i32 @MD5_Init(i32* %4)
%10 = call i32 @MD5_Update(i32* %4, i32* %1, i64 %2)
%11 = call i32 @MD5_Final(i32* %7, i32* %4)
%12 = load i32, i32* @MD5_DIGEST_LENGTH
%13 = call i32 @memcmp(i32* %7, i32* %0, i32 %12)
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
ret i32 %15
}