#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*/ hex;
typedef int /*<<< orphan*/ buff;

/* Variables and functions */
int /*<<< orphan*/ hmac_md5(char *, int, char *, int, char *, int);
int /*<<< orphan*/ printf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ tohex(char *, int, char *, int);
void check(char *k, int klen, char *text, int textlen, char *digst) {
  char buff[16];
  char hex[33];
  hmac_md5(k, klen, text, textlen, buff, sizeof(buff));
  tohex(buff, sizeof(buff), hex, sizeof(hex));
  hex[32] = '\0';
  if (strcmp(digst, hex) != 0) {
    printf("md5 cannot pass digst: %s, md5: %s\n", digst, hex);
    return;
  }
  printf("md5 pass digst: %s, md5: %s\n", digst, hex);
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    -0x40(%rbp),%r8
mov    $0x10,%r9d
call   1030 <hmac_md5@plt>
lea    -0x40(%rbp),%rdi
lea    -0x70(%rbp),%rdx
mov    $0x10,%esi
mov    $0x21,%ecx
call   1060 <tohex@plt>
movb   $0x0,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     11c2 <check+0x82>
mov    -0x28(%rbp),%rsi
lea    -0x70(%rbp),%rdx
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
jmp    11d6 <check+0x96>
mov    -0x28(%rbp),%rsi
lea    -0x70(%rbp),%rdx
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %r8,%rbx
mov    %rsp,%r14
mov    %r14,%r8
mov    $0x10,%r9d
call   1030 <hmac_md5@plt>
lea    0x10(%rsp),%r15
mov    %r14,%rdi
mov    $0x10,%esi
mov    %r15,%rdx
mov    $0x21,%ecx
call   1060 <tohex@plt>
movb   $0x0,0x30(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
lea    0xe93(%rip),%rax
lea    0xe68(%rip),%rdi
cmove  %rax,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [36 x i8] c"md5 cannot pass digst: %s, md5: %s\0A\00"
@.str.1 = [29 x i8] c"md5 pass digst: %s, md5: %s\0A\00"
define void @check(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca [16 x i8]
%12 = alloca [33 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%13 = load i8*, i8** %6
%14 = load i32, i32* %7
%15 = load i8*, i8** %8
%16 = load i32, i32* %9
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%18 = call i32 @hmac_md5(i8* %13, i32 %14, i8* %15, i32 %16, i8* %17, i32 16)
%19 = getelementptr inbounds [16 x i8], [16 x i8]* %11, i64 0, i64 0
%20 = getelementptr inbounds [33 x i8], [33 x i8]* %12, i64 0, i64 0
%21 = call i32 @tohex(i8* %19, i32 16, i8* %20, i32 33)
%22 = getelementptr inbounds [33 x i8], [33 x i8]* %12, i64 0, i64 32
store i8 0, i8* %22
%23 = load i8*, i8** %10
%24 = getelementptr inbounds [33 x i8], [33 x i8]* %12, i64 0, i64 0
%25 = call i64 @strcmp(i8* %23, i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %5
%28 = load i8*, i8** %10
%29 = getelementptr inbounds [33 x i8], [33 x i8]* %12, i64 0, i64 0
%30 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %28, i8* %29)
br label %35
31: ; preds = %5
%32 = load i8*, i8** %10
%33 = getelementptr inbounds [33 x i8], [33 x i8]* %12, i64 0, i64 0
%34 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %32, i8* %33)
br label %35
35: ; preds = %31, %27
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"md5 cannot pass digst: %s, md5: %s\0A\00"
@.str.1 = [29 x i8] c"md5 pass digst: %s, md5: %s\0A\00"
define void @check(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4) {
%6 = alloca [16 x i8]
%7 = alloca [33 x i8]
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%9 = getelementptr inbounds [33 x i8], [33 x i8]* %7, i64 0, i64 0
%10 = call i32 @hmac_md5(i8* %0, i32 %1, i8* %2, i32 %3, i8* %8, i32 16)
%11 = call i32 @tohex(i8* %8, i32 16, i8* %9, i32 33)
%12 = getelementptr inbounds [33 x i8], [33 x i8]* %7, i64 0, i64 32
store i8 0, i8* %12
%13 = call i64 @strcmp(i8* %4, i8* %9)
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0)
%16 = call i32 @printf(i8* %15, i8* %4, i8* %9)
ret void
}