#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_isubbyte_ishiftrows_imixcols(int /*<<< orphan*/ *);
int /*<<< orphan*/ aes_isubbytes_ishiftrows(int /*<<< orphan*/ *);
int /*<<< orphan*/ aes_last_addroundkey(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ const *);
void aesc_decrypt(const uint8_t cipher_text[], uint8_t plain_text[],
                  const uint8_t key_sched[]) {
  uint8_t state[16];
  unsigned int i;
  aes_first_addroundkey(state, cipher_text, key_sched + 10 * 16);
  aes_isubbytes_ishiftrows(state);
  for (i = 9; i > 0; --i) {
    aes_addroundkey(state, key_sched + i * 16);
    aes_isubbyte_ishiftrows_imixcols(state);
  }
  aes_last_addroundkey(plain_text, state, key_sched);
}


x86 assembly (clang, -O0):
<aesc_decrypt>:
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
add    $0x280,%rdx
call   1060 <aes_first_addroundkey@plt>
lea    -0x60(%rbp),%rdi
call   1050 <aes_isubbytes_ishiftrows@plt>
movl   $0x9,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jbe    11c9 <aesc_decrypt+0x79>
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>
lea    -0x60(%rbp),%rdi
call   1070 <aes_isubbyte_ishiftrows_imixcols@plt>
mov    -0x64(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x64(%rbp)
jmp    118c <aesc_decrypt+0x3c>
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <aes_last_addroundkey@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aesc_decrypt>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%rsi
add    $0x280,%rdx
mov    %rsp,%r15
mov    %r15,%rdi
call   1060 <aes_first_addroundkey@plt>
mov    %r15,%rdi
call   1050 <aes_isubbytes_ishiftrows@plt>
lea    0x240(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1070 <aes_isubbyte_ishiftrows_imixcols@plt>
lea    0x200(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1070 <aes_isubbyte_ishiftrows_imixcols@plt>
lea    0x1c0(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1070 <aes_isubbyte_ishiftrows_imixcols@plt>
lea    0x180(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1070 <aes_isubbyte_ishiftrows_imixcols@plt>
lea    0x140(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1070 <aes_isubbyte_ishiftrows_imixcols@plt>
lea    0x100(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1070 <aes_isubbyte_ishiftrows_imixcols@plt>
lea    0xc0(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1070 <aes_isubbyte_ishiftrows_imixcols@plt>
lea    0x80(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1070 <aes_isubbyte_ishiftrows_imixcols@plt>
lea    0x40(%rbx),%rsi
mov    %r15,%rdi
call   1040 <aes_addroundkey@plt>
mov    %r15,%rdi
call   1070 <aes_isubbyte_ishiftrows_imixcols@plt>
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_decrypt(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 = getelementptr inbounds i32, i32* %11, i64 160
%13 = call i32 @aes_first_addroundkey(i32* %9, i32* %10, i32* %12)
%14 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 0
%15 = call i32 @aes_isubbytes_ishiftrows(i32* %14)
store i32 9, i32* %8
br label %16
16: ; preds = %29, %3
%17 = load i32, i32* %8
%18 = icmp ugt i32 %17, 0
br i1 %18, label %19, label %32
19: ; preds = %16
%20 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 0
%21 = load i32*, i32** %6
%22 = load i32, i32* %8
%23 = mul i32 %22, 16
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %21, i64 %24
%26 = call i32 @aes_addroundkey(i32* %20, i32* %25)
%27 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 0
%28 = call i32 @aes_isubbyte_ishiftrows_imixcols(i32* %27)
br label %29
29: ; preds = %19
%30 = load i32, i32* %8
%31 = add i32 %30, -1
store i32 %31, i32* %8
br label %16
32: ; preds = %16
%33 = load i32*, i32** %5
%34 = getelementptr inbounds [16 x i32], [16 x i32]* %7, i64 0, i64 0
%35 = load i32*, i32** %6
%36 = call i32 @aes_last_addroundkey(i32* %33, i32* %34, i32* %35)
ret void
}

LLVM IR (-O2):
define void @aesc_decrypt(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 = getelementptr inbounds i32, i32* %2, i64 160
%8 = call i32 @aes_first_addroundkey(i32* %6, i32* %0, i32* %7)
%9 = call i32 @aes_isubbytes_ishiftrows(i32* %6)
%10 = getelementptr inbounds i32, i32* %2, i64 144
%11 = call i32 @aes_addroundkey(i32* %6, i32* %10)
%12 = call i32 @aes_isubbyte_ishiftrows_imixcols(i32* %6)
%13 = getelementptr inbounds i32, i32* %2, i64 128
%14 = call i32 @aes_addroundkey(i32* %6, i32* %13)
%15 = call i32 @aes_isubbyte_ishiftrows_imixcols(i32* %6)
%16 = getelementptr inbounds i32, i32* %2, i64 112
%17 = call i32 @aes_addroundkey(i32* %6, i32* %16)
%18 = call i32 @aes_isubbyte_ishiftrows_imixcols(i32* %6)
%19 = getelementptr inbounds i32, i32* %2, i64 96
%20 = call i32 @aes_addroundkey(i32* %6, i32* %19)
%21 = call i32 @aes_isubbyte_ishiftrows_imixcols(i32* %6)
%22 = getelementptr inbounds i32, i32* %2, i64 80
%23 = call i32 @aes_addroundkey(i32* %6, i32* %22)
%24 = call i32 @aes_isubbyte_ishiftrows_imixcols(i32* %6)
%25 = getelementptr inbounds i32, i32* %2, i64 64
%26 = call i32 @aes_addroundkey(i32* %6, i32* %25)
%27 = call i32 @aes_isubbyte_ishiftrows_imixcols(i32* %6)
%28 = getelementptr inbounds i32, i32* %2, i64 48
%29 = call i32 @aes_addroundkey(i32* %6, i32* %28)
%30 = call i32 @aes_isubbyte_ishiftrows_imixcols(i32* %6)
%31 = getelementptr inbounds i32, i32* %2, i64 32
%32 = call i32 @aes_addroundkey(i32* %6, i32* %31)
%33 = call i32 @aes_isubbyte_ishiftrows_imixcols(i32* %6)
%34 = getelementptr inbounds i32, i32* %2, i64 16
%35 = call i32 @aes_addroundkey(i32* %6, i32* %34)
%36 = call i32 @aes_isubbyte_ishiftrows_imixcols(i32* %6)
%37 = call i32 @aes_last_addroundkey(i32* %1, i32* %6, i32* %2)
ret void
}