#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*/ AddRoundKey(unsigned char *, int, int);
int /*<<< orphan*/ MixColumns(unsigned char *);
int /*<<< orphan*/ ShiftRows(unsigned char *);
int /*<<< orphan*/ SubBytes(unsigned char *);
int /*<<< orphan*/ print16(unsigned char *, char *, int);
int /*<<< orphan*/ printKey(int, char *, int);
void AES_encrypt(unsigned char state[16]) {
  int round = 0;
  print16(state, ".input\0", round);
  AddRoundKey(state, round, 3);
  printKey(round, ".k_sch\0", 0);
  for (round = 1; round < 10; round++) {
    print16(state, ".start\0", round);
    SubBytes(state);
    print16(state, ".s_box\0", round);
    ShiftRows(state);
    print16(state, ".s_row\0", round);
    MixColumns(state);
    print16(state, ".m_col\0", round);
    AddRoundKey(state, round * 4, (round + 1) * 4 - 1);
    printKey(round, ".k_sch\0", round * 4);
  }
  print16(state, ".start\0", round);
  SubBytes(state);
  print16(state, ".s_box\0", round);
  ShiftRows(state);
  print16(state, ".s_row\0", round);
  AddRoundKey(state, 40, 43);
  printKey(round, ".k_sch\0", 40);
  print16(state, ".output\0", round);
}


x86 assembly (clang, -O0):
<AES_encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe7f(%rip),%rsi
call   1050 <print16@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x3,%edx
call   1040 <AddRoundKey@plt>
mov    -0xc(%rbp),%edi
lea    0xe67(%rip),%rsi
xor    %edx,%edx
call   1060 <printKey@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    125e <AES_encrypt+0xfe>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe49(%rip),%rsi
call   1050 <print16@plt>
mov    -0x8(%rbp),%rdi
call   1070 <SubBytes@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe35(%rip),%rsi
call   1050 <print16@plt>
mov    -0x8(%rbp),%rdi
call   1030 <ShiftRows@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe21(%rip),%rsi
call   1050 <print16@plt>
mov    -0x8(%rbp),%rdi
call   1080 <MixColumns@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe0d(%rip),%rsi
call   1050 <print16@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
shl    $0x2,%esi
mov    -0xc(%rbp),%edx
add    $0x1,%edx
shl    $0x2,%edx
sub    $0x1,%edx
call   1040 <AddRoundKey@plt>
mov    -0xc(%rbp),%edi
mov    -0xc(%rbp),%edx
shl    $0x2,%edx
lea    0xdbd(%rip),%rsi
call   1060 <printKey@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11af <AES_encrypt+0x4f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xda4(%rip),%rsi
call   1050 <print16@plt>
mov    -0x8(%rbp),%rdi
call   1070 <SubBytes@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xd90(%rip),%rsi
call   1050 <print16@plt>
mov    -0x8(%rbp),%rdi
call   1030 <ShiftRows@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xd7c(%rip),%rsi
call   1050 <print16@plt>
mov    -0x8(%rbp),%rdi
mov    $0x28,%esi
mov    $0x2b,%edx
call   1040 <AddRoundKey@plt>
mov    -0xc(%rbp),%edi
lea    0xd42(%rip),%rsi
mov    $0x28,%edx
call   1060 <printKey@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xd52(%rip),%rsi
call   1050 <print16@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AES_encrypt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
lea    0xe8b(%rip),%rsi
xor    %edx,%edx
call   1050 <print16@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1040 <AddRoundKey@plt>
lea    0xe76(%rip),%rsi
xor    %edi,%edi
xor    %edx,%edx
call   1060 <printKey@plt>
mov    $0x1,%r12d
mov    $0x7,%ebx
lea    0xe7b(%rip),%r14
nopl   (%rax)
mov    %r15,%rdi
lea    0xe56(%rip),%rsi
mov    %r12d,%edx
call   1050 <print16@plt>
mov    %r15,%rdi
call   1070 <SubBytes@plt>
mov    %r15,%rdi
lea    0xe44(%rip),%rsi
mov    %r12d,%edx
call   1050 <print16@plt>
mov    %r15,%rdi
call   1030 <ShiftRows@plt>
mov    %r15,%rdi
lea    0xe32(%rip),%rsi
mov    %r12d,%edx
call   1050 <print16@plt>
mov    %r15,%rdi
call   1080 <MixColumns@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1050 <print16@plt>
lea    0x1(%r12),%ebp
lea    -0x3(%rbx),%r13d
mov    %r15,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   1040 <AddRoundKey@plt>
mov    %r12d,%edi
lea    0xddc(%rip),%rsi
mov    %r13d,%edx
call   1060 <printKey@plt>
add    $0x4,%ebx
mov    %ebp,%r12d
cmp    $0xa,%ebp
jne    11b0 <AES_encrypt+0x50>
lea    0xdc6(%rip),%rsi
mov    %r15,%rdi
mov    $0xa,%edx
call   1050 <print16@plt>
mov    %r15,%rdi
call   1070 <SubBytes@plt>
lea    0xdb2(%rip),%rsi
mov    %r15,%rdi
mov    $0xa,%edx
call   1050 <print16@plt>
mov    %r15,%rdi
call   1030 <ShiftRows@plt>
lea    0xd9e(%rip),%rsi
mov    %r15,%rdi
mov    $0xa,%edx
call   1050 <print16@plt>
mov    %r15,%rdi
mov    $0x28,%esi
mov    $0x2b,%edx
call   1040 <AddRoundKey@plt>
lea    0xd60(%rip),%rsi
mov    $0xa,%edi
mov    $0x28,%edx
call   1060 <printKey@plt>
lea    0xd72(%rip),%rsi
mov    %r15,%rdi
mov    $0xa,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <print16@plt>

LLVM IR (-O0):
@.str = [8 x i8] c".input\00\00"
@.str.1 = [8 x i8] c".k_sch\00\00"
@.str.2 = [8 x i8] c".start\00\00"
@.str.3 = [8 x i8] c".s_box\00\00"
@.str.4 = [8 x i8] c".s_row\00\00"
@.str.5 = [8 x i8] c".m_col\00\00"
@.str.6 = [9 x i8] c".output\00\00"
define void @AES_encrypt(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i8*, i8** %2
%5 = load i32, i32* %3
%6 = call i32 @print16(i8* %4, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i8*, i8** %2
%8 = load i32, i32* %3
%9 = call i32 @AddRoundKey(i8* %7, i32 %8, i32 3)
%10 = load i32, i32* %3
%11 = call i32 @printKey(i32 %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 0)
store i32 1, i32* %3
br label %12
12: ; preds = %46, %1
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 10
br i1 %14, label %15, label %49
15: ; preds = %12
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = call i32 @print16(i8* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = load i8*, i8** %2
%20 = call i32 @SubBytes(i8* %19)
%21 = load i8*, i8** %2
%22 = load i32, i32* %3
%23 = call i32 @print16(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = load i8*, i8** %2
%25 = call i32 @ShiftRows(i8* %24)
%26 = load i8*, i8** %2
%27 = load i32, i32* %3
%28 = call i32 @print16(i8* %26, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %27)
%29 = load i8*, i8** %2
%30 = call i32 @MixColumns(i8* %29)
%31 = load i8*, i8** %2
%32 = load i32, i32* %3
%33 = call i32 @print16(i8* %31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %32)
%34 = load i8*, i8** %2
%35 = load i32, i32* %3
%36 = mul nsw i32 %35, 4
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
%39 = mul nsw i32 %38, 4
%40 = sub nsw i32 %39, 1
%41 = call i32 @AddRoundKey(i8* %34, i32 %36, i32 %40)
%42 = load i32, i32* %3
%43 = load i32, i32* %3
%44 = mul nsw i32 %43, 4
%45 = call i32 @printKey(i32 %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %15
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %12
49: ; preds = %12
%50 = load i8*, i8** %2
%51 = load i32, i32* %3
%52 = call i32 @print16(i8* %50, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %51)
%53 = load i8*, i8** %2
%54 = call i32 @SubBytes(i8* %53)
%55 = load i8*, i8** %2
%56 = load i32, i32* %3
%57 = call i32 @print16(i8* %55, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %56)
%58 = load i8*, i8** %2
%59 = call i32 @ShiftRows(i8* %58)
%60 = load i8*, i8** %2
%61 = load i32, i32* %3
%62 = call i32 @print16(i8* %60, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %61)
%63 = load i8*, i8** %2
%64 = call i32 @AddRoundKey(i8* %63, i32 40, i32 43)
%65 = load i32, i32* %3
%66 = call i32 @printKey(i32 %65, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 40)
%67 = load i8*, i8** %2
%68 = load i32, i32* %3
%69 = call i32 @print16(i8* %67, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %68)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c".input\00\00"
@.str.1 = [8 x i8] c".k_sch\00\00"
@.str.2 = [8 x i8] c".start\00\00"
@.str.3 = [8 x i8] c".s_box\00\00"
@.str.4 = [8 x i8] c".s_row\00\00"
@.str.5 = [8 x i8] c".m_col\00\00"
@.str.6 = [9 x i8] c".output\00\00"
define void @AES_encrypt(i8* %0) {
%2 = tail call i32 @print16(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 0)
%3 = tail call i32 @AddRoundKey(i8* %0, i32 0, i32 3)
%4 = tail call i32 @printKey(i32 0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %5
5: ; preds = %1, %5
%6 = phi i32 [ 1, %1 ], [ %15, %5 ]
%7 = tail call i32 @print16(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = tail call i32 @SubBytes(i8* %0)
%9 = tail call i32 @print16(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %6)
%10 = tail call i32 @ShiftRows(i8* %0)
%11 = tail call i32 @print16(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %6)
%12 = tail call i32 @MixColumns(i8* %0)
%13 = tail call i32 @print16(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %6)
%14 = shl nuw nsw i32 %6, 2
%15 = add nuw nsw i32 %6, 1
%16 = shl nuw nsw i32 %15, 2
%17 = add nsw i32 %16, -1
%18 = tail call i32 @AddRoundKey(i8* %0, i32 %14, i32 %17)
%19 = tail call i32 @printKey(i32 %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%20 = icmp eq i32 %15, 10
br i1 %20, label %21, label %5
21: ; preds = %5
%22 = tail call i32 @print16(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 10)
%23 = tail call i32 @SubBytes(i8* %0)
%24 = tail call i32 @print16(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 10)
%25 = tail call i32 @ShiftRows(i8* %0)
%26 = tail call i32 @print16(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 10)
%27 = tail call i32 @AddRoundKey(i8* %0, i32 40, i32 43)
%28 = tail call i32 @printKey(i32 10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 40)
%29 = tail call i32 @print16(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 10)
ret void
}