#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 /*<<< orphan*/ MD5_Final(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Update(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                              size_t);
void md5_mac(uint8_t *key, size_t key_len, uint8_t *data, size_t data_len,
             uint8_t *mac) {
  MD5_CTX context;
  MD5_Init(&context);
  MD5_Update(&context, key, key_len);
  MD5_Update(&context, data, data_len);
  MD5_Update(&context, key, key_len);
  MD5_Final(mac, &context);
}


x86 assembly (clang, -O0):
<md5_mac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x2c(%rbp),%rdi
call   1040 <MD5_Init@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    -0x2c(%rbp),%rdi
call   1050 <MD5_Update@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    -0x2c(%rbp),%rdi
call   1050 <MD5_Update@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    -0x2c(%rbp),%rdi
call   1050 <MD5_Update@plt>
mov    -0x28(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
call   1030 <MD5_Final@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md5_mac>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
lea    0x4(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <MD5_Init@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1050 <MD5_Update@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
call   1050 <MD5_Update@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1050 <MD5_Update@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1030 <MD5_Final@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @md5_mac(i32* %0, i64 %1, i32* %2, i64 %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i32*
%11 = alloca i32
store i32* %0, i32** %6
store i64 %1, i64* %7
store i32* %2, i32** %8
store i64 %3, i64* %9
store i32* %4, i32** %10
%12 = call i32 @MD5_Init(i32* %11)
%13 = load i32*, i32** %6
%14 = load i64, i64* %7
%15 = call i32 @MD5_Update(i32* %11, i32* %13, i64 %14)
%16 = load i32*, i32** %8
%17 = load i64, i64* %9
%18 = call i32 @MD5_Update(i32* %11, i32* %16, i64 %17)
%19 = load i32*, i32** %6
%20 = load i64, i64* %7
%21 = call i32 @MD5_Update(i32* %11, i32* %19, i64 %20)
%22 = load i32*, i32** %10
%23 = call i32 @MD5_Final(i32* %22, i32* %11)
ret void
}

LLVM IR (-O2):
define void @md5_mac(i32* %0, i64 %1, i32* %2, i64 %3, i32* %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
%8 = call i32 @MD5_Init(i32* %6)
%9 = call i32 @MD5_Update(i32* %6, i32* %0, i64 %1)
%10 = call i32 @MD5_Update(i32* %6, i32* %2, i64 %3)
%11 = call i32 @MD5_Update(i32* %6, i32* %0, i64 %1)
%12 = call i32 @MD5_Final(i32* %4, i32* %6)
ret void
}