#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 *, unsigned long *);
int /*<<< orphan*/ MixColumns(unsigned char *);
int /*<<< orphan*/ ShiftRows(unsigned char *);
int /*<<< orphan*/ SubBytes(unsigned char *);
void AES(unsigned char in[16], unsigned char out[16], unsigned long w[44]) {
  unsigned char state[16];
  unsigned long temp[4];
  int i, j, k;
  for (i = 0; i < 16; i++) {
    state[i] = in[i];
  }
  for (i = 0; i < 4; i++) {
    temp[i] = w[i];
  }
  AddRoundKey(state, temp);
  for (j = 1; j < 10; j++) {
    SubBytes(state);
    ShiftRows(state);
    MixColumns(state);
    for (k = 0; k < 4; k++) {
      temp[k] = w[j * 4 + k];
    }
    AddRoundKey(state, temp);
  }
  SubBytes(state);
  ShiftRows(state);
  for (k = 0; k < 4; k++) {
    temp[k] = w[40 + k];
  }
  AddRoundKey(state, temp);
  for (i = 0; i < 16; i++) {
    out[i] = state[i];
  }
}


x86 assembly (clang, -O0):
<AES>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x10,-0x54(%rbp)
jge    1186 <AES+0x46>
mov    -0x8(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x54(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    115b <AES+0x1b>
movl   $0x0,-0x54(%rbp)
cmpl   $0x4,-0x54(%rbp)
jge    11ba <AES+0x7a>
mov    -0x18(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
movslq -0x54(%rbp),%rax
mov    %rcx,-0x50(%rbp,%rax,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    118d <AES+0x4d>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <AddRoundKey@plt>
movl   $0x1,-0x58(%rbp)
cmpl   $0xa,-0x58(%rbp)
jge    124a <AES+0x10a>
lea    -0x30(%rbp),%rdi
call   1050 <SubBytes@plt>
lea    -0x30(%rbp),%rdi
call   1030 <ShiftRows@plt>
lea    -0x30(%rbp),%rdi
call   1060 <MixColumns@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jge    122f <AES+0xef>
mov    -0x18(%rbp),%rax
mov    -0x58(%rbp),%ecx
shl    $0x2,%ecx
add    -0x5c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
movslq -0x5c(%rbp),%rax
mov    %rcx,-0x50(%rbp,%rax,8)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    11fa <AES+0xba>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <AddRoundKey@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11ce <AES+0x8e>
lea    -0x30(%rbp),%rdi
call   1050 <SubBytes@plt>
lea    -0x30(%rbp),%rdi
call   1030 <ShiftRows@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x4,-0x5c(%rbp)
jge    1295 <AES+0x155>
mov    -0x18(%rbp),%rax
mov    -0x5c(%rbp),%ecx
add    $0x28,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
movslq -0x5c(%rbp),%rax
mov    %rcx,-0x50(%rbp,%rax,8)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1263 <AES+0x123>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1040 <AddRoundKey@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x10,-0x54(%rbp)
jge    12d4 <AES+0x194>
movslq -0x54(%rbp),%rax
mov    -0x30(%rbp,%rax,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    12a9 <AES+0x169>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AES>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
movups (%rdi),%xmm0
movaps %xmm0,0x20(%rsp)
movups (%rdx),%xmm0
movups 0x10(%rdx),%xmm1
movaps %xmm0,(%rsp)
movaps %xmm1,0x10(%rsp)
lea    0x20(%rsp),%r15
mov    %rsp,%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <AddRoundKey@plt>
mov    %r15,%rdi
call   1050 <SubBytes@plt>
mov    %r15,%rdi
call   1030 <ShiftRows@plt>
mov    %r15,%rdi
call   1060 <MixColumns@plt>
movups 0x20(%rbx),%xmm0
movups 0x30(%rbx),%xmm1
movaps %xmm0,(%rsp)
movaps %xmm1,0x10(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <AddRoundKey@plt>
mov    %r15,%rdi
call   1050 <SubBytes@plt>
mov    %r15,%rdi
call   1030 <ShiftRows@plt>
mov    %r15,%rdi
call   1060 <MixColumns@plt>
movups 0x40(%rbx),%xmm0
movups 0x50(%rbx),%xmm1
movaps %xmm0,(%rsp)
movaps %xmm1,0x10(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <AddRoundKey@plt>
mov    %r15,%rdi
call   1050 <SubBytes@plt>
mov    %r15,%rdi
call   1030 <ShiftRows@plt>
mov    %r15,%rdi
call   1060 <MixColumns@plt>
movups 0x60(%rbx),%xmm0
movups 0x70(%rbx),%xmm1
movaps %xmm0,(%rsp)
movaps %xmm1,0x10(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <AddRoundKey@plt>
mov    %r15,%rdi
call   1050 <SubBytes@plt>
mov    %r15,%rdi
call   1030 <ShiftRows@plt>
mov    %r15,%rdi
call   1060 <MixColumns@plt>
movups 0x80(%rbx),%xmm0
movups 0x90(%rbx),%xmm1
movaps %xmm0,(%rsp)
movaps %xmm1,0x10(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <AddRoundKey@plt>
mov    %r15,%rdi
call   1050 <SubBytes@plt>
mov    %r15,%rdi
call   1030 <ShiftRows@plt>
mov    %r15,%rdi
call   1060 <MixColumns@plt>
movups 0xa0(%rbx),%xmm0
movups 0xb0(%rbx),%xmm1
movaps %xmm0,(%rsp)
movaps %xmm1,0x10(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <AddRoundKey@plt>
mov    %r15,%rdi
call   1050 <SubBytes@plt>
mov    %r15,%rdi
call   1030 <ShiftRows@plt>
mov    %r15,%rdi
call   1060 <MixColumns@plt>
movups 0xc0(%rbx),%xmm0
movups 0xd0(%rbx),%xmm1
movaps %xmm0,(%rsp)
movaps %xmm1,0x10(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <AddRoundKey@plt>
mov    %r15,%rdi
call   1050 <SubBytes@plt>
mov    %r15,%rdi
call   1030 <ShiftRows@plt>
mov    %r15,%rdi
call   1060 <MixColumns@plt>
movups 0xe0(%rbx),%xmm0
movups 0xf0(%rbx),%xmm1
movaps %xmm0,(%rsp)
movaps %xmm1,0x10(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <AddRoundKey@plt>
mov    %r15,%rdi
call   1050 <SubBytes@plt>
mov    %r15,%rdi
call   1030 <ShiftRows@plt>
mov    %r15,%rdi
call   1060 <MixColumns@plt>
movups 0x100(%rbx),%xmm0
movups 0x110(%rbx),%xmm1
movaps %xmm0,(%rsp)
movaps %xmm1,0x10(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <AddRoundKey@plt>
mov    %r15,%rdi
call   1050 <SubBytes@plt>
mov    %r15,%rdi
call   1030 <ShiftRows@plt>
mov    %r15,%rdi
call   1060 <MixColumns@plt>
movups 0x120(%rbx),%xmm0
movups 0x130(%rbx),%xmm1
movaps %xmm0,(%rsp)
movaps %xmm1,0x10(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <AddRoundKey@plt>
mov    %r15,%rdi
call   1050 <SubBytes@plt>
mov    %r15,%rdi
call   1030 <ShiftRows@plt>
movups 0x140(%rbx),%xmm0
movups 0x150(%rbx),%xmm1
movaps %xmm0,(%rsp)
movaps %xmm1,0x10(%rsp)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <AddRoundKey@plt>
movaps 0x20(%rsp),%xmm0
movups %xmm0,(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @AES(i8* %0, i8* %1, i64* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64*
%7 = alloca [16 x i8]
%8 = alloca [4 x i64]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64* %2, i64** %6
store i32 0, i32* %9
br label %12
12: ; preds = %24, %3
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 16
br i1 %14, label %15, label %27
15: ; preds = %12
%16 = load i8*, i8** %4
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %22
store i8 %20, i8* %23
br label %24
24: ; preds = %15
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
br label %12
27: ; preds = %12
store i32 0, i32* %9
br label %28
28: ; preds = %40, %27
%29 = load i32, i32* %9
%30 = icmp slt i32 %29, 4
br i1 %30, label %31, label %43
31: ; preds = %28
%32 = load i64*, i64** %6
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i64, i64* %32, i64 %34
%36 = load i64, i64* %35
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [4 x i64], [4 x i64]* %8, i64 0, i64 %38
store i64 %36, i64* %39
br label %40
40: ; preds = %31
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 1
store i32 %42, i32* %9
br label %28
43: ; preds = %28
%44 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%45 = getelementptr inbounds [4 x i64], [4 x i64]* %8, i64 0, i64 0
%46 = call i32 @AddRoundKey(i8* %44, i64* %45)
store i32 1, i32* %10
br label %47
47: ; preds = %79, %43
%48 = load i32, i32* %10
%49 = icmp slt i32 %48, 10
br i1 %49, label %50, label %82
50: ; preds = %47
%51 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%52 = call i32 @SubBytes(i8* %51)
%53 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%54 = call i32 @ShiftRows(i8* %53)
%55 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%56 = call i32 @MixColumns(i8* %55)
store i32 0, i32* %11
br label %57
57: ; preds = %72, %50
%58 = load i32, i32* %11
%59 = icmp slt i32 %58, 4
br i1 %59, label %60, label %75
60: ; preds = %57
%61 = load i64*, i64** %6
%62 = load i32, i32* %10
%63 = mul nsw i32 %62, 4
%64 = load i32, i32* %11
%65 = add nsw i32 %63, %64
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i64, i64* %61, i64 %66
%68 = load i64, i64* %67
%69 = load i32, i32* %11
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [4 x i64], [4 x i64]* %8, i64 0, i64 %70
store i64 %68, i64* %71
br label %72
72: ; preds = %60
%73 = load i32, i32* %11
%74 = add nsw i32 %73, 1
store i32 %74, i32* %11
br label %57
75: ; preds = %57
%76 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%77 = getelementptr inbounds [4 x i64], [4 x i64]* %8, i64 0, i64 0
%78 = call i32 @AddRoundKey(i8* %76, i64* %77)
br label %79
79: ; preds = %75
%80 = load i32, i32* %10
%81 = add nsw i32 %80, 1
store i32 %81, i32* %10
br label %47
82: ; preds = %47
%83 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%84 = call i32 @SubBytes(i8* %83)
%85 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%86 = call i32 @ShiftRows(i8* %85)
store i32 0, i32* %11
br label %87
87: ; preds = %100, %82
%88 = load i32, i32* %11
%89 = icmp slt i32 %88, 4
br i1 %89, label %90, label %103
90: ; preds = %87
%91 = load i64*, i64** %6
%92 = load i32, i32* %11
%93 = add nsw i32 40, %92
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i64, i64* %91, i64 %94
%96 = load i64, i64* %95
%97 = load i32, i32* %11
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [4 x i64], [4 x i64]* %8, i64 0, i64 %98
store i64 %96, i64* %99
br label %100
100: ; preds = %90
%101 = load i32, i32* %11
%102 = add nsw i32 %101, 1
store i32 %102, i32* %11
br label %87
103: ; preds = %87
%104 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%105 = getelementptr inbounds [4 x i64], [4 x i64]* %8, i64 0, i64 0
%106 = call i32 @AddRoundKey(i8* %104, i64* %105)
store i32 0, i32* %9
br label %107
107: ; preds = %119, %103
%108 = load i32, i32* %9
%109 = icmp slt i32 %108, 16
br i1 %109, label %110, label %122
110: ; preds = %107
%111 = load i32, i32* %9
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %112
%114 = load i8, i8* %113
%115 = load i8*, i8** %5
%116 = load i32, i32* %9
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8, i8* %115, i64 %117
store i8 %114, i8* %118
br label %119
119: ; preds = %110
%120 = load i32, i32* %9
%121 = add nsw i32 %120, 1
store i32 %121, i32* %9
br label %107
122: ; preds = %107
ret void
}

LLVM IR (-O2):
define void @AES(i8* nocapture %0, i8* nocapture writeonly %1, i64* nocapture %2) {
%4 = bitcast i64* %2 to i8*
%5 = alloca [16 x i8]
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%7 = alloca [4 x i64]
%8 = bitcast [4 x i64]* %7 to i8*
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [4 x i64], [4 x i64]* %7, i64 0, i64 0
%11 = call i32 @AddRoundKey(i8* %9, i64* %10)
%12 = getelementptr i64, i64* %2, i64 4
%13 = bitcast i64* %12 to i8*
%14 = call i32 @SubBytes(i8* %9)
%15 = call i32 @ShiftRows(i8* %9)
%16 = call i32 @MixColumns(i8* %9)
%17 = call i32 @AddRoundKey(i8* %9, i64* %10)
%18 = getelementptr i64, i64* %2, i64 8
%19 = bitcast i64* %18 to i8*
%20 = call i32 @SubBytes(i8* %9)
%21 = call i32 @ShiftRows(i8* %9)
%22 = call i32 @MixColumns(i8* %9)
%23 = call i32 @AddRoundKey(i8* %9, i64* %10)
%24 = getelementptr i64, i64* %2, i64 12
%25 = bitcast i64* %24 to i8*
%26 = call i32 @SubBytes(i8* %9)
%27 = call i32 @ShiftRows(i8* %9)
%28 = call i32 @MixColumns(i8* %9)
%29 = call i32 @AddRoundKey(i8* %9, i64* %10)
%30 = getelementptr i64, i64* %2, i64 16
%31 = bitcast i64* %30 to i8*
%32 = call i32 @SubBytes(i8* %9)
%33 = call i32 @ShiftRows(i8* %9)
%34 = call i32 @MixColumns(i8* %9)
%35 = call i32 @AddRoundKey(i8* %9, i64* %10)
%36 = getelementptr i64, i64* %2, i64 20
%37 = bitcast i64* %36 to i8*
%38 = call i32 @SubBytes(i8* %9)
%39 = call i32 @ShiftRows(i8* %9)
%40 = call i32 @MixColumns(i8* %9)
%41 = call i32 @AddRoundKey(i8* %9, i64* %10)
%42 = getelementptr i64, i64* %2, i64 24
%43 = bitcast i64* %42 to i8*
%44 = call i32 @SubBytes(i8* %9)
%45 = call i32 @ShiftRows(i8* %9)
%46 = call i32 @MixColumns(i8* %9)
%47 = call i32 @AddRoundKey(i8* %9, i64* %10)
%48 = getelementptr i64, i64* %2, i64 28
%49 = bitcast i64* %48 to i8*
%50 = call i32 @SubBytes(i8* %9)
%51 = call i32 @ShiftRows(i8* %9)
%52 = call i32 @MixColumns(i8* %9)
%53 = call i32 @AddRoundKey(i8* %9, i64* %10)
%54 = getelementptr i64, i64* %2, i64 32
%55 = bitcast i64* %54 to i8*
%56 = call i32 @SubBytes(i8* %9)
%57 = call i32 @ShiftRows(i8* %9)
%58 = call i32 @MixColumns(i8* %9)
%59 = call i32 @AddRoundKey(i8* %9, i64* %10)
%60 = getelementptr i64, i64* %2, i64 36
%61 = bitcast i64* %60 to i8*
%62 = call i32 @SubBytes(i8* %9)
%63 = call i32 @ShiftRows(i8* %9)
%64 = call i32 @MixColumns(i8* %9)
%65 = call i32 @AddRoundKey(i8* %9, i64* %10)
%66 = call i32 @SubBytes(i8* %9)
%67 = call i32 @ShiftRows(i8* %9)
%68 = getelementptr i64, i64* %2, i64 40
%69 = bitcast i64* %68 to i8*
%70 = call i32 @AddRoundKey(i8* %9, i64* %10)
ret void
}