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

/* Variables and functions */
int /*<<< orphan*/ HMAC_Final(int /*<<< orphan*/ *, unsigned char *, int *);
int /*<<< orphan*/ HMAC_Init_ex(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int,
                                int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ HMAC_Update(int /*<<< orphan*/ *, unsigned char *, int);
scalar_t__ malloc(int);
unsigned char *gen_hmac(HMAC_CTX *hmac, unsigned char *data, int *len) {
  unsigned char *result = (unsigned char *)malloc(sizeof(char) * 32);
  HMAC_Init_ex(hmac, NULL, (int)NULL, NULL, NULL);
  HMAC_Update(hmac, data, *len);
  HMAC_Final(hmac, result, len);
  return result;
}


x86 assembly (clang, -O0):
<gen_hmac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x20,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%r8d
xor    %edx,%edx
mov    %r8,%rsi
mov    %r8,%rcx
call   1060 <HMAC_Init_ex@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
call   1030 <HMAC_Update@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <HMAC_Final@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_hmac>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x20,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <HMAC_Init_ex@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <HMAC_Update@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1050 <HMAC_Final@plt>
mov    %r12,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @gen_hmac(i32* %0, i8* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%8 = call i64 @malloc(i32 32)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %7
%10 = load i32*, i32** %4
%11 = call i32 @HMAC_Init_ex(i32* %10, i32* null, i32 0, i32* null, i32* null)
%12 = load i32*, i32** %4
%13 = load i8*, i8** %5
%14 = load i32*, i32** %6
%15 = load i32, i32* %14
%16 = call i32 @HMAC_Update(i32* %12, i8* %13, i32 %15)
%17 = load i32*, i32** %4
%18 = load i8*, i8** %7
%19 = load i32*, i32** %6
%20 = call i32 @HMAC_Final(i32* %17, i8* %18, i32* %19)
%21 = load i8*, i8** %7
ret i8* %21
}

LLVM IR (-O2):
define i8* @gen_hmac(i32* %0, i8* %1, i32* %2) {
%4 = tail call i64 @malloc(i32 32)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @HMAC_Init_ex(i32* %0, i32* null, i32 0, i32* null, i32* null)
%7 = load i32, i32* %2
%8 = tail call i32 @HMAC_Update(i32* %0, i8* %1, i32 %7)
%9 = tail call i32 @HMAC_Final(i32* %0, i8* %5, i32* %2)
ret i8* %5
}