#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 */
char _aes_sub_bytes(int const **, char);
int aes_sub_bytes(const int box[][16], char state[][4]) {
  int i;
  int j;
  for (i = 0; i < 4; i++)
    for (j = 0; j < 4; j++)
      state[i][j] = _aes_sub_bytes(box, state[i][j]);
  return 0;
}


x86 assembly (clang, -O0):
<aes_sub_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    119b <aes_sub_bytes+0x8b>
movl   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    1188 <aes_sub_bytes+0x78>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1030 <_aes_sub_bytes@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1138 <aes_sub_bytes+0x28>
jmp    118d <aes_sub_bytes+0x7d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <aes_sub_bytes+0x17>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aes_sub_bytes>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
movsbl (%rsi),%esi
call   1030 <_aes_sub_bytes@plt>
mov    %al,(%rbx)
movsbl 0x1(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0x1(%rbx)
movsbl 0x2(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0x2(%rbx)
movsbl 0x3(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0x3(%rbx)
movsbl 0x4(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0x4(%rbx)
movsbl 0x5(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0x5(%rbx)
movsbl 0x6(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0x6(%rbx)
movsbl 0x7(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0x7(%rbx)
movsbl 0x8(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0x8(%rbx)
movsbl 0x9(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0x9(%rbx)
movsbl 0xa(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0xa(%rbx)
movsbl 0xb(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0xb(%rbx)
movsbl 0xc(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0xc(%rbx)
movsbl 0xd(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0xd(%rbx)
movsbl 0xe(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0xe(%rbx)
movsbl 0xf(%rbx),%esi
mov    %r14,%rdi
call   1030 <_aes_sub_bytes@plt>
mov    %al,0xf(%rbx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @aes_sub_bytes([16 x i32]* %0, [4 x i8]* %1) {
%3 = alloca [16 x i32]*
%4 = alloca [4 x i8]*
%5 = alloca i32
%6 = alloca i32
store [16 x i32]* %0, [16 x i32]** %3
store [4 x i8]* %1, [4 x i8]** %4
store i32 0, i32* %5
br label %7
7: ; preds = %37, %2
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %40
10: ; preds = %7
store i32 0, i32* %6
br label %11
11: ; preds = %33, %10
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %36
14: ; preds = %11
%15 = load [16 x i32]*, [16 x i32]** %3
%16 = bitcast [16 x i32]* %15 to i32**
%17 = load [4 x i8]*, [4 x i8]** %4
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %17, i64 %19
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %20, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = call signext i8 @_aes_sub_bytes(i32** %16, i8 signext %24)
%26 = load [4 x i8]*, [4 x i8]** %4
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [4 x i8], [4 x i8]* %26, i64 %28
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %29, i64 0, i64 %31
store i8 %25, i8* %32
br label %33
33: ; preds = %14
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %11
36: ; preds = %11
br label %37
37: ; preds = %36
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %7
40: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
define i32 @aes_sub_bytes([16 x i32]* %0, [4 x i8]* nocapture %1) {
%3 = bitcast [16 x i32]* %0 to i32**
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
%5 = load i8, i8* %4
%6 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %5)
store i8 %6, i8* %4
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 1
%8 = load i8, i8* %7
%9 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %8)
store i8 %9, i8* %7
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 2
%11 = load i8, i8* %10
%12 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %11)
store i8 %12, i8* %10
%13 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 3
%14 = load i8, i8* %13
%15 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %14)
store i8 %15, i8* %13
%16 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 1, i64 0
%17 = load i8, i8* %16
%18 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %17)
store i8 %18, i8* %16
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 1, i64 1
%20 = load i8, i8* %19
%21 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %20)
store i8 %21, i8* %19
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 1, i64 2
%23 = load i8, i8* %22
%24 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %23)
store i8 %24, i8* %22
%25 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 1, i64 3
%26 = load i8, i8* %25
%27 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %26)
store i8 %27, i8* %25
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 2, i64 0
%29 = load i8, i8* %28
%30 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %29)
store i8 %30, i8* %28
%31 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 2, i64 1
%32 = load i8, i8* %31
%33 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %32)
store i8 %33, i8* %31
%34 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 2, i64 2
%35 = load i8, i8* %34
%36 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %35)
store i8 %36, i8* %34
%37 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 2, i64 3
%38 = load i8, i8* %37
%39 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %38)
store i8 %39, i8* %37
%40 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 3, i64 0
%41 = load i8, i8* %40
%42 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %41)
store i8 %42, i8* %40
%43 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 3, i64 1
%44 = load i8, i8* %43
%45 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %44)
store i8 %45, i8* %43
%46 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 3, i64 2
%47 = load i8, i8* %46
%48 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %47)
store i8 %48, i8* %46
%49 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 3, i64 3
%50 = load i8, i8* %49
%51 = tail call signext i8 @_aes_sub_bytes(i32** %3, i8 signext %50)
store i8 %51, i8* %49
ret i32 0
}