#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,
                                         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, int num_half_rounds,
                    int old_key_schedule) {
  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, num_half_rounds, old_key_schedule);
  uint64_to_bytes(output, out_bytes);
}


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

x86 assembly (clang, -O2):
<prince_enc_dec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r15d
mov    %r8d,%r12d
mov    %ecx,%r13d
mov    %rdx,(%rsp)
mov    %rsi,%rbx
call   1030 <bytes_to_uint64@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <bytes_to_uint64@plt>
mov    %eax,%r14d
add    $0x20,%rbx
mov    %rbx,%rdi
call   1030 <bytes_to_uint64@plt>
mov    %ebp,%edi
mov    %r14d,%esi
mov    %eax,%edx
mov    %r13d,%ecx
mov    %r12d,%r8d
mov    %r15d,%r9d
call   1050 <prince_enc_dec_uint64@plt>
mov    %eax,%edi
mov    (%rsp),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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, i32 %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%17 = load i32*, i32** %7
%18 = call i32 @bytes_to_uint64(i32* %17)
store i32 %18, i32* %13
%19 = load i32*, i32** %8
%20 = call i32 @bytes_to_uint64(i32* %19)
store i32 %20, i32* %14
%21 = load i32*, i32** %8
%22 = getelementptr inbounds i32, i32* %21, i64 8
%23 = call i32 @bytes_to_uint64(i32* %22)
store i32 %23, i32* %15
%24 = load i32, i32* %13
%25 = load i32, i32* %14
%26 = load i32, i32* %15
%27 = load i32, i32* %10
%28 = load i32, i32* %11
%29 = load i32, i32* %12
%30 = call i32 @prince_enc_dec_uint64(i32 %24, i32 %25, i32 %26, i32 %27, i32 %28, i32 %29)
store i32 %30, i32* %16
%31 = load i32, i32* %16
%32 = load i32*, i32** %9
%33 = call i32 @uint64_to_bytes(i32 %31, i32* %32)
ret void
}

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