#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 unsigned int uint64_t;

/* Variables and functions */
unsigned int prince_sbox(unsigned int const);
uint64_t prince_s_layer(const uint64_t s_in) {
  uint64_t s_out = 0;
  for (unsigned int i = 0; i < 16; i++) {
    const unsigned int shift = i * 4;
    const unsigned int sbox_in = s_in >> shift;
    const uint64_t sbox_out = prince_sbox(sbox_in);
    s_out |= sbox_out << shift;
  }
  return s_out;
}


x86 assembly (clang, -O0):
<prince_s_layer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jae    116e <prince_s_layer+0x5e>
mov    -0xc(%rbp),%eax
shl    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x10(%rbp),%ecx
shr    %cl,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <prince_sbox@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    %cl,%eax
or     -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1129 <prince_s_layer+0x19>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prince_s_layer>:
push   %rbx
mov    %edi,%ebx
call   1030 <prince_sbox@plt>
mov    %ebx,%edi
shr    $0x4,%edi
call   1030 <prince_sbox@plt>
mov    %ebx,%edi
shr    $0x8,%edi
call   1030 <prince_sbox@plt>
mov    %ebx,%edi
shr    $0xc,%edi
call   1030 <prince_sbox@plt>
mov    %ebx,%edi
shr    $0x10,%edi
call   1030 <prince_sbox@plt>
mov    %ebx,%edi
shr    $0x14,%edi
call   1030 <prince_sbox@plt>
mov    %ebx,%edi
shr    $0x18,%edi
call   1030 <prince_sbox@plt>
shr    $0x1c,%ebx
mov    %ebx,%edi
call   1030 <prince_sbox@plt>
call   1030 <prince_sbox@plt>
call   1030 <prince_sbox@plt>
call   1030 <prince_sbox@plt>
call   1030 <prince_sbox@plt>
call   1030 <prince_sbox@plt>
call   1030 <prince_sbox@plt>
call   1030 <prince_sbox@plt>
pop    %rbx
jmp    1030 <prince_sbox@plt>

LLVM IR (-O0):
define i32 @prince_s_layer(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %8
8: ; preds = %24, %1
%9 = load i32, i32* %4
%10 = icmp ult i32 %9, 16
br i1 %10, label %11, label %27
11: ; preds = %8
%12 = load i32, i32* %4
%13 = mul i32 %12, 4
store i32 %13, i32* %5
%14 = load i32, i32* %2
%15 = load i32, i32* %5
%16 = lshr i32 %14, %15
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = call i32 @prince_sbox(i32 %17)
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = load i32, i32* %5
%21 = shl i32 %19, %20
%22 = load i32, i32* %3
%23 = or i32 %22, %21
store i32 %23, i32* %3
br label %24
24: ; preds = %11
%25 = load i32, i32* %4
%26 = add i32 %25, 1
store i32 %26, i32* %4
br label %8
27: ; preds = %8
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @prince_s_layer(i32 %0) {
%2 = tail call i32 @prince_sbox(i32 %0)
%3 = lshr i32 %0, 4
%4 = tail call i32 @prince_sbox(i32 %3)
%5 = lshr i32 %0, 8
%6 = tail call i32 @prince_sbox(i32 %5)
%7 = lshr i32 %0, 12
%8 = tail call i32 @prince_sbox(i32 %7)
%9 = lshr i32 %0, 16
%10 = tail call i32 @prince_sbox(i32 %9)
%11 = lshr i32 %0, 20
%12 = tail call i32 @prince_sbox(i32 %11)
%13 = lshr i32 %0, 24
%14 = tail call i32 @prince_sbox(i32 %13)
%15 = lshr i32 %0, 28
%16 = tail call i32 @prince_sbox(i32 %15)
%17 = tail call i32 @prince_sbox(i32 poison)
%18 = tail call i32 @prince_sbox(i32 poison)
%19 = tail call i32 @prince_sbox(i32 poison)
%20 = tail call i32 @prince_sbox(i32 poison)
%21 = tail call i32 @prince_sbox(i32 poison)
%22 = tail call i32 @prince_sbox(i32 poison)
%23 = tail call i32 @prince_sbox(i32 poison)
%24 = tail call i32 @prince_sbox(i32 poison)
ret i32 poison
}