#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 int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ aes_addroundkey(int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ const *);
int /*<<< orphan*/ aes_first_addroundkey(int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ const *,
                                         int /*<<< orphan*/ const *);
int /*<<< orphan*/ aes_last_addroundkey(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ const *);
int /*<<< orphan*/ aes_subbyte_shiftrows_mixcols(int /*<<< orphan*/ *);
int /*<<< orphan*/ aes_subbytes_shiftrows(int /*<<< orphan*/ *);
void aesc_encrypt(const uint8_t plain_text[], uint8_t cipher_text[],
                  const uint8_t key_sched[]) {
  uint8_t state[16];
  unsigned int i;
  aes_first_addroundkey(state, plain_text, key_sched);
  for (i = 1; i < 10; ++i) {
    aes_subbyte_shiftrows_mixcols(state);
    aes_addroundkey(state, key_sched + i * 16);
  }
  aes_subbytes_shiftrows(state);
  aes_last_addroundkey(cipher_text, state, key_sched + 10 * 16);
}


x86 assembly (clang, -O0):
<aesc_encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <aes_first_addroundkey@plt>
movl   $0x1,-0x64(%rbp)
cmpl   $0xa,-0x64(%rbp)
jae    11b9 <aesc_encrypt+0x69>
lea    -0x60(%rbp),%rdi
call   1060 <aes_subbyte_shiftrows_mixcols@plt>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x64(%rbp),%eax
shl    $0x4,%eax
mov    %eax,%eax
shl    $0x2,%rax
add    %rax,%rsi
call   1040 <aes_addroundkey@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    117c <aesc_encrypt+0x2c>
lea    -0x60(%rbp),%rdi
call   1050 <aes_subbytes_shiftrows@plt>
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x18(%rbp),%rdx
add    $0x280,%rdx
call   1030 <aes_last_addroundkey@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aesc_encrypt>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1070 <aes_first_addroundkey@plt>
mov    %r15,%rdi
call   1060 <aes_subbyte_shiftrows_mixcols@plt>
lea    0x40(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1060 <aes_subbyte_shiftrows_mixcols@plt>
lea    0x80(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1060 <aes_subbyte_shiftrows_mixcols@plt>
lea    0xc0(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1060 <aes_subbyte_shiftrows_mixcols@plt>
lea    0x100(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1060 <aes_subbyte_shiftrows_mixcols@plt>
lea    0x140(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1060 <aes_subbyte_shiftrows_mixcols@plt>
lea    0x180(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1060 <aes_subbyte_shiftrows_mixcols@plt>
lea    0x1c0(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1060 <aes_subbyte_shiftrows_mixcols@plt>
lea    0x200(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1060 <aes_subbyte_shiftrows_mixcols@plt>
lea    0x240(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1050 <aes_subbytes_shiftrows@plt>
add    $0x280,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <aes_last_addroundkey@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @aesc_encrypt(i32* %0, i32* %1, i32* %2) {
%4 = alloca [16 x i32]
%5 = bitcast [16 x i32]* %4 to i8*
%6 = getelementptr inbounds [16 x i32], [16 x i32]* %4, i64 0, i64 0
%7 = call i32 @aes_first_addroundkey(i32* %6, i32* %0, i32* %2)
%8 = call i32 @aes_subbyte_shiftrows_mixcols(i32* %6)
%9 = getelementptr inbounds i32, i32* %2, i64 16
%10 = call i32 @aes_addroundkey(i32* %6, i32* %9)
%11 = call i32 @aes_subbyte_shiftrows_mixcols(i32* %6)
%12 = getelementptr inbounds i32, i32* %2, i64 32
%13 = call i32 @aes_addroundkey(i32* %6, i32* %12)
%14 = call i32 @aes_subbyte_shiftrows_mixcols(i32* %6)
%15 = getelementptr inbounds i32, i32* %2, i64 48
%16 = call i32 @aes_addroundkey(i32* %6, i32* %15)
%17 = call i32 @aes_subbyte_shiftrows_mixcols(i32* %6)
%18 = getelementptr inbounds i32, i32* %2, i64 64
%19 = call i32 @aes_addroundkey(i32* %6, i32* %18)
%20 = call i32 @aes_subbyte_shiftrows_mixcols(i32* %6)
%21 = getelementptr inbounds i32, i32* %2, i64 80
%22 = call i32 @aes_addroundkey(i32* %6, i32* %21)
%23 = call i32 @aes_subbyte_shiftrows_mixcols(i32* %6)
%24 = getelementptr inbounds i32, i32* %2, i64 96
%25 = call i32 @aes_addroundkey(i32* %6, i32* %24)
%26 = call i32 @aes_subbyte_shiftrows_mixcols(i32* %6)
%27 = getelementptr inbounds i32, i32* %2, i64 112
%28 = call i32 @aes_addroundkey(i32* %6, i32* %27)
%29 = call i32 @aes_subbyte_shiftrows_mixcols(i32* %6)
%30 = getelementptr inbounds i32, i32* %2, i64 128
%31 = call i32 @aes_addroundkey(i32* %6, i32* %30)
%32 = call i32 @aes_subbyte_shiftrows_mixcols(i32* %6)
%33 = getelementptr inbounds i32, i32* %2, i64 144
%34 = call i32 @aes_addroundkey(i32* %6, i32* %33)
%35 = call i32 @aes_subbytes_shiftrows(i32* %6)
%36 = getelementptr inbounds i32, i32* %2, i64 160
%37 = call i32 @aes_last_addroundkey(i32* %1, i32* %6, i32* %36)
ret void
}