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

/* Variables and functions */
int /*<<< orphan*/ bytes_to_uint64(int /*<<< orphan*/ const *);
int /*<<< orphan*/ prince_enc_dec_uint64(int /*<<< orphan*/ const,
                                         int /*<<< orphan*/ const,
                                         int /*<<< orphan*/ const, int);
int /*<<< orphan*/ uint64_to_bytes(int /*<<< orphan*/ const,
                                   int /*<<< orphan*/ *);
void prince_enc_dec(const uint8_t in_bytes[8], const uint8_t key_bytes[16],
                    uint8_t out_bytes[8], int decrypt) {
  const uint64_t input = bytes_to_uint64(in_bytes);
  const uint64_t enc_k0 = bytes_to_uint64(key_bytes);
  const uint64_t enc_k1 = bytes_to_uint64(key_bytes + 8);
  const uint64_t output = prince_enc_dec_uint64(input, enc_k0, enc_k1, decrypt);
  uint64_to_bytes(output, out_bytes);
}


x86 assembly (clang, -O0):
<prince_enc_dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <bytes_to_uint64@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <bytes_to_uint64@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x20,%rdi
call   1030 <bytes_to_uint64@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1050 <prince_enc_dec_uint64@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <uint64_to_bytes@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prince_enc_dec>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r15d
mov    %rdx,%r14
mov    %rsi,%rbx
call   1030 <bytes_to_uint64@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1030 <bytes_to_uint64@plt>
mov    %eax,%ebp
add    $0x20,%rbx
mov    %rbx,%rdi
call   1030 <bytes_to_uint64@plt>
mov    %r12d,%edi
mov    %ebp,%esi
mov    %eax,%edx
mov    %r15d,%ecx
call   1050 <prince_enc_dec_uint64@plt>
mov    %eax,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <uint64_to_bytes@plt>

LLVM IR (-O0):
define void @prince_enc_dec(i32* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%13 = load i32*, i32** %5
%14 = call i32 @bytes_to_uint64(i32* %13)
store i32 %14, i32* %9
%15 = load i32*, i32** %6
%16 = call i32 @bytes_to_uint64(i32* %15)
store i32 %16, i32* %10
%17 = load i32*, i32** %6
%18 = getelementptr inbounds i32, i32* %17, i64 8
%19 = call i32 @bytes_to_uint64(i32* %18)
store i32 %19, i32* %11
%20 = load i32, i32* %9
%21 = load i32, i32* %10
%22 = load i32, i32* %11
%23 = load i32, i32* %8
%24 = call i32 @prince_enc_dec_uint64(i32 %20, i32 %21, i32 %22, i32 %23)
store i32 %24, i32* %12
%25 = load i32, i32* %12
%26 = load i32*, i32** %7
%27 = call i32 @uint64_to_bytes(i32 %25, i32* %26)
ret void
}

LLVM IR (-O2):
define void @prince_enc_dec(i32* %0, i32* %1, i32* %2, i32 %3) {
%5 = tail call i32 @bytes_to_uint64(i32* %0)
%6 = tail call i32 @bytes_to_uint64(i32* %1)
%7 = getelementptr inbounds i32, i32* %1, i64 8
%8 = tail call i32 @bytes_to_uint64(i32* %7)
%9 = tail call i32 @prince_enc_dec_uint64(i32 %5, i32 %6, i32 %8, i32 %3)
%10 = tail call i32 @uint64_to_bytes(i32 %9, i32* %2)
ret void
}