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

/* Variables and functions */
int UINT64_C(int);
int prince_core(int const, int const);
int prince_k0_to_k0_prime(int const);
uint64_t prince_enc_dec_uint64(const uint64_t input, const uint64_t enc_k0,
                               const uint64_t enc_k1, int decrypt) {
  const uint64_t prince_alpha = UINT64_C(0xc0ac29b7c97c50dd);
  const uint64_t k1 = enc_k1 ^ (decrypt ? prince_alpha : 0);
  const uint64_t enc_k0_prime = prince_k0_to_k0_prime(enc_k0);
  const uint64_t k0 = decrypt ? enc_k0_prime : enc_k0;
  const uint64_t k0_prime = decrypt ? enc_k0 : enc_k0_prime;
  do {
  } while (0);
  do {
  } while (0);
  const uint64_t core_input = input ^ k0;
  const uint64_t core_output = prince_core(core_input, k1);
  const uint64_t output = core_output ^ k0_prime;
  do {
  } while (0);
  do {
  } while (0);
  return output;
}


x86 assembly (clang, -O0):
<prince_enc_dec_uint64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    $0xc97c50dd,%edi
call   1030 <UINT64_C@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     116c <prince_enc_dec_uint64+0x3c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    1176 <prince_enc_dec_uint64+0x46>
xor    %eax,%eax
mov    %eax,-0x38(%rbp)
jmp    1176 <prince_enc_dec_uint64+0x46>
mov    -0x34(%rbp),%eax
mov    -0x38(%rbp),%ecx
xor    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <prince_k0_to_k0_prime@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11a1 <prince_enc_dec_uint64+0x71>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    11a7 <prince_enc_dec_uint64+0x77>
mov    -0x8(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11c2 <prince_enc_dec_uint64+0x92>
mov    -0x8(%rbp),%eax
mov    %eax,-0x40(%rbp)
jmp    11c8 <prince_enc_dec_uint64+0x98>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11d3 <prince_enc_dec_uint64+0xa3>
jmp    11d8 <prince_enc_dec_uint64+0xa8>
jmp    11dd <prince_enc_dec_uint64+0xad>
mov    -0x4(%rbp),%eax
xor    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <prince_core@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
xor    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    1202 <prince_enc_dec_uint64+0xd2>
jmp    1207 <prince_enc_dec_uint64+0xd7>
jmp    120c <prince_enc_dec_uint64+0xdc>
mov    -0x30(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prince_enc_dec_uint64>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %edx,%r14d
mov    %esi,%r13d
mov    %edi,%r15d
mov    $0xc97c50dd,%edi
call   1030 <UINT64_C@plt>
mov    %eax,%ebx
mov    %r13d,%edi
call   1050 <prince_k0_to_k0_prime@plt>
mov    %eax,%ebp
test   %r12d,%r12d
cmove  %r12d,%ebx
mov    %eax,%edi
cmove  %r13d,%edi
cmovne %r13d,%ebp
xor    %r14d,%ebx
xor    %r15d,%edi
mov    %ebx,%esi
call   1040 <prince_core@plt>
xor    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @prince_enc_dec_uint64(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
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%17 = call i32 @UINT64_C(i32 -914599715)
store i32 %17, i32* %9
%18 = load i32, i32* %7
%19 = load i32, i32* %8
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %4
%22 = load i32, i32* %9
br label %24
23: ; preds = %4
br label %24
24: ; preds = %23, %21
%25 = phi i32 [ %22, %21 ], [ 0, %23 ]
%26 = xor i32 %18, %25
store i32 %26, i32* %10
%27 = load i32, i32* %6
%28 = call i32 @prince_k0_to_k0_prime(i32 %27)
store i32 %28, i32* %11
%29 = load i32, i32* %8
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = load i32, i32* %11
br label %35
33: ; preds = %24
%34 = load i32, i32* %6
br label %35
35: ; preds = %33, %31
%36 = phi i32 [ %32, %31 ], [ %34, %33 ]
store i32 %36, i32* %12
%37 = load i32, i32* %8
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = load i32, i32* %6
br label %43
41: ; preds = %35
%42 = load i32, i32* %11
br label %43
43: ; preds = %41, %39
%44 = phi i32 [ %40, %39 ], [ %42, %41 ]
store i32 %44, i32* %13
br label %45
45: ; preds = %43
br label %46
46: ; preds = %45
br label %47
47: ; preds = %46
br label %48
48: ; preds = %47
%49 = load i32, i32* %5
%50 = load i32, i32* %12
%51 = xor i32 %49, %50
store i32 %51, i32* %14
%52 = load i32, i32* %14
%53 = load i32, i32* %10
%54 = call i32 @prince_core(i32 %52, i32 %53)
store i32 %54, i32* %15
%55 = load i32, i32* %15
%56 = load i32, i32* %13
%57 = xor i32 %55, %56
store i32 %57, i32* %16
br label %58
58: ; preds = %48
br label %59
59: ; preds = %58
br label %60
60: ; preds = %59
br label %61
61: ; preds = %60
%62 = load i32, i32* %16
ret i32 %62
}

LLVM IR (-O2):
define i32 @prince_enc_dec_uint64(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @UINT64_C(i32 -914599715)
%6 = icmp eq i32 %3, 0
%7 = select i1 %6, i32 0, i32 %5
%8 = xor i32 %7, %2
%9 = tail call i32 @prince_k0_to_k0_prime(i32 %1)
%10 = select i1 %6, i32 %1, i32 %9
%11 = select i1 %6, i32 %9, i32 %1
%12 = xor i32 %10, %0
%13 = tail call i32 @prince_core(i32 %12, i32 %8)
%14 = xor i32 %13, %11
ret i32 %14
}