#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*/ EVP_md5();
int /*<<< orphan*/ *HMAC(int /*<<< orphan*/, unsigned char const *, int,
                         unsigned char const *, size_t, unsigned char *,
                         unsigned int *);
unsigned int MD5_DIGEST_LENGTH;
int /*<<< orphan*/ assert(int);
int saslc__crypto_hmac_md5_hash(const unsigned char *key, size_t keylen,
                                const unsigned char *in, size_t inlen,
                                unsigned char *hmac) {
  unsigned int hmac_len;
  assert(hmac != NULL);
  if (hmac == NULL ||
      HMAC(EVP_md5(), key, (int)keylen, in, inlen, hmac, &hmac_len) == NULL)
    return -1;
  assert(hmac_len == MD5_DIGEST_LENGTH);
  return 0;
}


x86 assembly (clang, -O0):
<saslc__crypto_hmac_md5_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x30(%rbp)
je     119f <saslc__crypto_hmac_md5_hash+0x6f>
mov    $0x0,%al
call   1030 <EVP_md5@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    %eax,%edx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
lea    -0x34(%rbp),%rax
mov    %rax,(%rsp)
call   1050 <HMAC@plt>
cmp    $0x0,%rax
jne    11ab <saslc__crypto_hmac_md5_hash+0x7b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11cb <saslc__crypto_hmac_md5_hash+0x9b>
mov    -0x34(%rbp),%eax
mov    0x2e2b(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saslc__crypto_hmac_md5_hash>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
xor    %edi,%edi
test   %r8,%r8
setne  %dil
call   1040 <assert@plt>
mov    $0xffffffff,%ebp
test   %rbx,%rbx
je     11aa <saslc__crypto_hmac_md5_hash+0x7a>
xor    %eax,%eax
call   1030 <EVP_md5@plt>
lea    0x14(%rsp),%rcx
mov    %rcx,(%rsp)
mov    %eax,%edi
mov    %r13,%rsi
mov    %r12d,%edx
mov    %r15,%rcx
mov    %r14,%r8
mov    %rbx,%r9
call   1050 <HMAC@plt>
test   %rax,%rax
je     11aa <saslc__crypto_hmac_md5_hash+0x7a>
mov    0x14(%rsp),%eax
mov    0x2e45(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%eax
sete   %dil
call   1040 <assert@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%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 @saslc__crypto_hmac_md5_hash(i8* %0, i64 %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i32
store i8* %0, i8** %7
store i64 %1, i64* %8
store i8* %2, i8** %9
store i64 %3, i64* %10
store i8* %4, i8** %11
%13 = load i8*, i8** %11
%14 = icmp ne i8* %13, null
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i8*, i8** %11
%18 = icmp eq i8* %17, null
br i1 %18, label %29, label %19
19: ; preds = %5
%20 = call i32 (...) @EVP_md5()
%21 = load i8*, i8** %7
%22 = load i64, i64* %8
%23 = trunc i64 %22 to i32
%24 = load i8*, i8** %9
%25 = load i64, i64* %10
%26 = load i8*, i8** %11
%27 = call i32* @HMAC(i32 %20, i8* %21, i32 %23, i8* %24, i64 %25, i8* %26, i32* %12)
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %30
29: ; preds = %19, %5
store i32 -1, i32* %6
br label %36
30: ; preds = %19
%31 = load i32, i32* %12
%32 = load i32, i32* @MD5_DIGEST_LENGTH
%33 = icmp eq i32 %31, %32
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
store i32 0, i32* %6
br label %36
36: ; preds = %30, %29
%37 = load i32, i32* %6
ret i32 %37
}

LLVM IR (-O2):
@MD5_DIGEST_LENGTH = global i32 0
define i32 @saslc__crypto_hmac_md5_hash(i8* %0, i64 %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
%8 = icmp ne i8* %4, null
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = icmp eq i8* %4, null
br i1 %11, label %23, label %12
12: ; preds = %5
%13 = tail call i32 (...) @EVP_md5()
%14 = trunc i64 %1 to i32
%15 = call i32* @HMAC(i32 %13, i8* %0, i32 %14, i8* %2, i64 %3, i8* %4, i32* %6)
%16 = icmp eq i32* %15, null
br i1 %16, label %23, label %17
17: ; preds = %12
%18 = load i32, i32* %6
%19 = load i32, i32* @MD5_DIGEST_LENGTH
%20 = icmp eq i32 %18, %19
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
br label %23
23: ; preds = %5, %12, %17
%24 = phi i32 [ 0, %17 ], [ -1, %12 ], [ -1, %5 ]
ret i32 %24
}