#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;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ sha512_Raw(int /*<<< orphan*/ const *, int,
                              int /*<<< orphan*/ *);
int /*<<< orphan*/ utils_zero(int /*<<< orphan*/ *, int);
void cipher_derive_hmac_keys(const uint8_t *secret, uint8_t *encryption_key,
                             uint8_t *authentication_key) {
  uint8_t hash[64];
  sha512_Raw(secret, 32, hash);
  int KEY_SIZE = 64 / 2;
  memcpy(encryption_key, hash, KEY_SIZE);
  memcpy(authentication_key, hash + KEY_SIZE, KEY_SIZE);
  utils_zero(hash, 64);
}


x86 assembly (clang, -O0):
<cipher_derive_hmac_keys>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x120(%rbp),%rdx
mov    $0x20,%esi
call   1050 <sha512_Raw@plt>
movl   $0x20,-0x124(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    -0x124(%rbp),%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rdi
lea    -0x120(%rbp),%rsi
movslq -0x124(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x124(%rbp),%edx
call   1040 <memcpy@plt>
lea    -0x120(%rbp),%rdi
mov    $0x40,%esi
call   1030 <utils_zero@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cipher_derive_hmac_keys>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rsp,%r15
mov    $0x20,%esi
mov    %r15,%rdx
call   1050 <sha512_Raw@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x20,%edx
call   1040 <memcpy@plt>
lea    0x80(%rsp),%rsi
mov    %r14,%rdi
mov    $0x20,%edx
call   1040 <memcpy@plt>
mov    %r15,%rdi
mov    $0x40,%esi
call   1030 <utils_zero@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @cipher_derive_hmac_keys(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca [64 x i32]
%8 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%9 = load i32*, i32** %4
%10 = getelementptr inbounds [64 x i32], [64 x i32]* %7, i64 0, i64 0
%11 = call i32 @sha512_Raw(i32* %9, i32 32, i32* %10)
store i32 32, i32* %8
%12 = load i32*, i32** %5
%13 = getelementptr inbounds [64 x i32], [64 x i32]* %7, i64 0, i64 0
%14 = load i32, i32* %8
%15 = call i32 @memcpy(i32* %12, i32* %13, i32 %14)
%16 = load i32*, i32** %6
%17 = getelementptr inbounds [64 x i32], [64 x i32]* %7, i64 0, i64 0
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %8
%22 = call i32 @memcpy(i32* %16, i32* %20, i32 %21)
%23 = getelementptr inbounds [64 x i32], [64 x i32]* %7, i64 0, i64 0
%24 = call i32 @utils_zero(i32* %23, i32 64)
ret void
}

LLVM IR (-O2):
define void @cipher_derive_hmac_keys(i32* %0, i32* %1, i32* %2) {
%4 = alloca [64 x i32]
%5 = bitcast [64 x i32]* %4 to i8*
%6 = getelementptr inbounds [64 x i32], [64 x i32]* %4, i64 0, i64 0
%7 = call i32 @sha512_Raw(i32* %0, i32 32, i32* %6)
%8 = call i32 @memcpy(i32* %1, i32* %6, i32 32)
%9 = getelementptr inbounds [64 x i32], [64 x i32]* %4, i64 0, i64 32
%10 = call i32 @memcpy(i32* %2, i32* %9, i32 32)
%11 = call i32 @utils_zero(i32* %6, i32 64)
ret void
}