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

/* Variables and functions */
int /*<<< orphan*/ SHA256(unsigned char *, int, unsigned char *);
int /*<<< orphan*/ addr_to_bytes(unsigned char *, int /*<<< orphan*/ const *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
void prf_addr(unsigned char *out, const unsigned char *key,
              const uint32_t addr[8]) {
  unsigned char buf[64 + 32];
  unsigned char outbuf[32];
  memcpy(buf, key, 16);
  memset(buf + 16, 0, 64 - 16);
  addr_to_bytes(buf + 64, addr);
  SHA256(buf, 64 + 32, outbuf);
  memcpy(out, outbuf, 16);
}


x86 assembly (clang, -O0):
<prf_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x10,%edx
call   1060 <memcpy@plt>
lea    -0x80(%rbp),%rdi
add    $0x10,%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
lea    -0x80(%rbp),%rdi
add    $0x40,%rdi
mov    -0x18(%rbp),%rsi
call   1050 <addr_to_bytes@plt>
lea    -0x80(%rbp),%rdi
lea    -0xa0(%rbp),%rdx
mov    $0x60,%esi
call   1030 <SHA256@plt>
mov    -0x8(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    $0x10,%edx
call   1060 <memcpy@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prf_addr>:
push   %r15
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rdx,%rbx
mov    %rdi,%r14
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    $0x10,%edx
call   1060 <memcpy@plt>
lea    0x30(%rsp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
lea    0x60(%rsp),%rdi
mov    %rbx,%rsi
call   1050 <addr_to_bytes@plt>
mov    %rsp,%rbx
mov    %r15,%rdi
mov    $0x60,%esi
mov    %rbx,%rdx
call   1030 <SHA256@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1060 <memcpy@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @prf_addr(i8* %0, i8* %1, i32* %2) {
%4 = alloca [96 x i8]
%5 = alloca [32 x i8]
%6 = getelementptr inbounds [96 x i8], [96 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%8 = call i32 @memcpy(i8* %6, i8* %1, i32 16)
%9 = getelementptr inbounds [96 x i8], [96 x i8]* %4, i64 0, i64 16
%10 = call i32 @memset(i8* %9, i32 0, i32 48)
%11 = getelementptr inbounds [96 x i8], [96 x i8]* %4, i64 0, i64 64
%12 = call i32 @addr_to_bytes(i8* %11, i32* %2)
%13 = call i32 @SHA256(i8* %6, i32 96, i8* %7)
%14 = call i32 @memcpy(i8* %0, i8* %7, i32 16)
ret void
}