#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 */
unsigned char getSBoxValue(unsigned char);
void SubBytes(unsigned char state[][4]) {
  int i, j;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      state[i][j] = getSBoxValue(state[i][j]);
    }
  }
  return;
}


x86 assembly (clang, -O0):
<SubBytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    1193 <SubBytes+0x83>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    1180 <SubBytes+0x70>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <getSBoxValue@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <SubBytes+0x24>
jmp    1185 <SubBytes+0x75>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <SubBytes+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SubBytes>:
push   %rbx
mov    %rdi,%rbx
movzbl (%rdi),%edi
call   1030 <getSBoxValue@plt>
mov    %al,(%rbx)
movzbl 0x1(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0x1(%rbx)
movzbl 0x2(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0x2(%rbx)
movzbl 0x3(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0x3(%rbx)
movzbl 0x4(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0x4(%rbx)
movzbl 0x5(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0x5(%rbx)
movzbl 0x6(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0x6(%rbx)
movzbl 0x7(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0x7(%rbx)
movzbl 0x8(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0x8(%rbx)
movzbl 0x9(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0x9(%rbx)
movzbl 0xa(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0xa(%rbx)
movzbl 0xb(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0xb(%rbx)
movzbl 0xc(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0xc(%rbx)
movzbl 0xd(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0xd(%rbx)
movzbl 0xe(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0xe(%rbx)
movzbl 0xf(%rbx),%edi
call   1030 <getSBoxValue@plt>
mov    %al,0xf(%rbx)
pop    %rbx
ret

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

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