#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 const, int);
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,
                               int num_half_rounds, int old_key_schedule) {
  const uint64_t prince_alpha = UINT64_C(0xc0ac29b7c97c50dd);
  const uint64_t k1 = enc_k1 ^ (decrypt ? prince_alpha : 0);
  const uint64_t k0_new =
      (old_key_schedule) ? k1 : enc_k0 ^ (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, k0_new, k1, num_half_rounds);
  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    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
mov    $0xc97c50dd,%edi
call   1030 <UINT64_C@plt>
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1174 <prince_enc_dec_uint64+0x44>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    117e <prince_enc_dec_uint64+0x4e>
xor    %eax,%eax
mov    %eax,-0x44(%rbp)
jmp    117e <prince_enc_dec_uint64+0x4e>
mov    -0x40(%rbp),%eax
mov    -0x44(%rbp),%ecx
xor    %ecx,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     119e <prince_enc_dec_uint64+0x6e>
mov    -0x20(%rbp),%eax
mov    %eax,-0x48(%rbp)
jmp    11ce <prince_enc_dec_uint64+0x9e>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11b9 <prince_enc_dec_uint64+0x89>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x50(%rbp)
jmp    11c3 <prince_enc_dec_uint64+0x93>
xor    %eax,%eax
mov    %eax,-0x50(%rbp)
jmp    11c3 <prince_enc_dec_uint64+0x93>
mov    -0x4c(%rbp),%eax
mov    -0x50(%rbp),%ecx
xor    %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <prince_k0_to_k0_prime@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11f4 <prince_enc_dec_uint64+0xc4>
mov    -0x28(%rbp),%eax
mov    %eax,-0x54(%rbp)
jmp    11fa <prince_enc_dec_uint64+0xca>
mov    -0x8(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1215 <prince_enc_dec_uint64+0xe5>
mov    -0x8(%rbp),%eax
mov    %eax,-0x58(%rbp)
jmp    121b <prince_enc_dec_uint64+0xeb>
mov    -0x28(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    1226 <prince_enc_dec_uint64+0xf6>
jmp    122b <prince_enc_dec_uint64+0xfb>
jmp    1230 <prince_enc_dec_uint64+0x100>
mov    -0x4(%rbp),%eax
xor    -0x2c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1040 <prince_core@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
xor    -0x30(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    125b <prince_enc_dec_uint64+0x12b>
jmp    1260 <prince_enc_dec_uint64+0x130>
jmp    1265 <prince_enc_dec_uint64+0x135>
mov    -0x3c(%rbp),%eax
add    $0x60,%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    %r9d,(%rsp)
mov    %r8d,0x4(%rsp)
mov    %ecx,%r12d
mov    %edx,%ebp
mov    %esi,%ebx
mov    %edi,%r13d
mov    $0xc97c50dd,%edi
call   1030 <UINT64_C@plt>
mov    %eax,%r14d
mov    %ebx,%edi
call   1050 <prince_k0_to_k0_prime@plt>
mov    %eax,%r15d
test   %r12d,%r12d
cmove  %r12d,%r14d
mov    %eax,%edi
cmove  %ebx,%edi
cmovne %ebx,%r15d
xor    %r14d,%ebp
xor    %ebx,%r14d
cmpl   $0x0,(%rsp)
cmovne %ebp,%r14d
xor    %r13d,%edi
mov    %r14d,%esi
mov    %ebp,%edx
mov    0x4(%rsp),%ecx
call   1040 <prince_core@plt>
xor    %r15d,%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, 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
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = 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
%22 = call i32 @UINT64_C(i32 -914599715)
store i32 %22, i32* %13
%23 = load i32, i32* %9
%24 = load i32, i32* %10
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %6
%27 = load i32, i32* %13
br label %29
28: ; preds = %6
br label %29
29: ; preds = %28, %26
%30 = phi i32 [ %27, %26 ], [ 0, %28 ]
%31 = xor i32 %23, %30
store i32 %31, i32* %14
%32 = load i32, i32* %12
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %29
%35 = load i32, i32* %14
br label %46
36: ; preds = %29
%37 = load i32, i32* %8
%38 = load i32, i32* %10
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = load i32, i32* %13
br label %43
42: ; preds = %36
br label %43
43: ; preds = %42, %40
%44 = phi i32 [ %41, %40 ], [ 0, %42 ]
%45 = xor i32 %37, %44
br label %46
46: ; preds = %43, %34
%47 = phi i32 [ %35, %34 ], [ %45, %43 ]
store i32 %47, i32* %15
%48 = load i32, i32* %8
%49 = call i32 @prince_k0_to_k0_prime(i32 %48)
store i32 %49, i32* %16
%50 = load i32, i32* %10
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %46
%53 = load i32, i32* %16
br label %56
54: ; preds = %46
%55 = load i32, i32* %8
br label %56
56: ; preds = %54, %52
%57 = phi i32 [ %53, %52 ], [ %55, %54 ]
store i32 %57, i32* %17
%58 = load i32, i32* %10
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = load i32, i32* %8
br label %64
62: ; preds = %56
%63 = load i32, i32* %16
br label %64
64: ; preds = %62, %60
%65 = phi i32 [ %61, %60 ], [ %63, %62 ]
store i32 %65, i32* %18
br label %66
66: ; preds = %64
br label %67
67: ; preds = %66
br label %68
68: ; preds = %67
br label %69
69: ; preds = %68
%70 = load i32, i32* %7
%71 = load i32, i32* %17
%72 = xor i32 %70, %71
store i32 %72, i32* %19
%73 = load i32, i32* %19
%74 = load i32, i32* %15
%75 = load i32, i32* %14
%76 = load i32, i32* %11
%77 = call i32 @prince_core(i32 %73, i32 %74, i32 %75, i32 %76)
store i32 %77, i32* %20
%78 = load i32, i32* %20
%79 = load i32, i32* %18
%80 = xor i32 %78, %79
store i32 %80, i32* %21
br label %81
81: ; preds = %69
br label %82
82: ; preds = %81
br label %83
83: ; preds = %82
br label %84
84: ; preds = %83
%85 = load i32, i32* %21
ret i32 %85
}

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