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

/* Variables and functions */
int /*<<< orphan*/ sbox_lookup(int const *, int *, int);
void sbox_transform(const bool input[48], bool output[32]) {
  int i;
  for (i = 0; i < 8; i++) {
    sbox_lookup(&input[6 * i], &output[4 * i], i);
  }
}


x86 assembly (clang, -O0):
<sbox_transform>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    116b <sbox_transform+0x5b>
mov    -0x8(%rbp),%rdi
imul   $0x6,-0x14(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
shl    $0x2,%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
call   1030 <sbox_lookup@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <sbox_transform+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sbox_transform>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edx,%edx
call   1030 <sbox_lookup@plt>
lea    0x18(%rbx),%rdi
lea    0x10(%r14),%rsi
mov    $0x1,%edx
call   1030 <sbox_lookup@plt>
lea    0x30(%rbx),%rdi
lea    0x20(%r14),%rsi
mov    $0x2,%edx
call   1030 <sbox_lookup@plt>
lea    0x48(%rbx),%rdi
lea    0x30(%r14),%rsi
mov    $0x3,%edx
call   1030 <sbox_lookup@plt>
lea    0x60(%rbx),%rdi
lea    0x40(%r14),%rsi
mov    $0x4,%edx
call   1030 <sbox_lookup@plt>
lea    0x78(%rbx),%rdi
lea    0x50(%r14),%rsi
mov    $0x5,%edx
call   1030 <sbox_lookup@plt>
lea    0x90(%rbx),%rdi
lea    0x60(%r14),%rsi
mov    $0x6,%edx
call   1030 <sbox_lookup@plt>
add    $0xa8,%rbx
add    $0x70,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <sbox_lookup@plt>

LLVM IR (-O0):
define void @sbox_transform(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %6
6: ; preds = %22, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 8
br i1 %8, label %9, label %25
9: ; preds = %6
%10 = load i32*, i32** %3
%11 = load i32, i32* %5
%12 = mul nsw i32 6, %11
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %10, i64 %13
%15 = load i32*, i32** %4
%16 = load i32, i32* %5
%17 = mul nsw i32 4, %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %15, i64 %18
%20 = load i32, i32* %5
%21 = call i32 @sbox_lookup(i32* %14, i32* %19, i32 %20)
br label %22
22: ; preds = %9
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %6
25: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @sbox_transform(i32* %0, i32* %1) {
%3 = tail call i32 @sbox_lookup(i32* %0, i32* %1, i32 0)
%4 = getelementptr inbounds i32, i32* %0, i64 6
%5 = getelementptr inbounds i32, i32* %1, i64 4
%6 = tail call i32 @sbox_lookup(i32* %4, i32* %5, i32 1)
%7 = getelementptr inbounds i32, i32* %0, i64 12
%8 = getelementptr inbounds i32, i32* %1, i64 8
%9 = tail call i32 @sbox_lookup(i32* %7, i32* %8, i32 2)
%10 = getelementptr inbounds i32, i32* %0, i64 18
%11 = getelementptr inbounds i32, i32* %1, i64 12
%12 = tail call i32 @sbox_lookup(i32* %10, i32* %11, i32 3)
%13 = getelementptr inbounds i32, i32* %0, i64 24
%14 = getelementptr inbounds i32, i32* %1, i64 16
%15 = tail call i32 @sbox_lookup(i32* %13, i32* %14, i32 4)
%16 = getelementptr inbounds i32, i32* %0, i64 30
%17 = getelementptr inbounds i32, i32* %1, i64 20
%18 = tail call i32 @sbox_lookup(i32* %16, i32* %17, i32 5)
%19 = getelementptr inbounds i32, i32* %0, i64 36
%20 = getelementptr inbounds i32, i32* %1, i64 24
%21 = tail call i32 @sbox_lookup(i32* %19, i32* %20, i32 6)
%22 = getelementptr inbounds i32, i32* %0, i64 42
%23 = getelementptr inbounds i32, i32* %1, i64 28
%24 = tail call i32 @sbox_lookup(i32* %22, i32* %23, i32 7)
ret void
}