#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 char *,
                               unsigned short);
int /*<<< orphan*/ genericround(unsigned char *, unsigned char *,
                                unsigned short);
int /*<<< orphan*/ lastround(unsigned char *, unsigned char *, unsigned short);
void AES_encrypt(unsigned char *state, unsigned char *key) {
  unsigned short int Round = 0;
  addroundkey(state, key, Round);
  Round++;
  for (unsigned short int i = 1; i <= 9; ++i) {
    genericround(state, key, Round);
    Round++;
  }
  lastround(state, key, Round);
}


x86 assembly (clang, -O0):
<AES_encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movw   $0x0,-0x12(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movzwl -0x12(%rbp),%edx
call   1050 <addroundkey@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
movw   $0x1,-0x14(%rbp)
movzwl -0x14(%rbp),%eax
cmp    $0x9,%eax
jg     11a4 <AES_encrypt+0x74>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movzwl -0x12(%rbp),%edx
call   1030 <genericround@plt>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
mov    -0x14(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x14(%rbp)
jmp    1169 <AES_encrypt+0x39>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movzwl -0x12(%rbp),%edx
call   1040 <lastround@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AES_encrypt>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edx,%edx
call   1050 <addroundkey@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <genericround@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <genericround@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1030 <genericround@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <genericround@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <genericround@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <genericround@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1030 <genericround@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
call   1030 <genericround@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x9,%edx
call   1030 <genericround@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <lastround@plt>

LLVM IR (-O0):
define void @AES_encrypt(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i16
%6 = alloca i16
store i8* %0, i8** %3
store i8* %1, i8** %4
store i16 0, i16* %5
%7 = load i8*, i8** %3
%8 = load i8*, i8** %4
%9 = load i16, i16* %5
%10 = call i32 @addroundkey(i8* %7, i8* %8, i16 zeroext %9)
%11 = load i16, i16* %5
%12 = add i16 %11, 1
store i16 %12, i16* %5
store i16 1, i16* %6
br label %13
13: ; preds = %24, %2
%14 = load i16, i16* %6
%15 = zext i16 %14 to i32
%16 = icmp sle i32 %15, 9
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = load i8*, i8** %4
%20 = load i16, i16* %5
%21 = call i32 @genericround(i8* %18, i8* %19, i16 zeroext %20)
%22 = load i16, i16* %5
%23 = add i16 %22, 1
store i16 %23, i16* %5
br label %24
24: ; preds = %17
%25 = load i16, i16* %6
%26 = add i16 %25, 1
store i16 %26, i16* %6
br label %13
27: ; preds = %13
%28 = load i8*, i8** %3
%29 = load i8*, i8** %4
%30 = load i16, i16* %5
%31 = call i32 @lastround(i8* %28, i8* %29, i16 zeroext %30)
ret void
}

LLVM IR (-O2):
define void @AES_encrypt(i8* %0, i8* %1) {
%3 = tail call i32 @addroundkey(i8* %0, i8* %1, i16 zeroext 0)
%4 = tail call i32 @genericround(i8* %0, i8* %1, i16 zeroext 1)
%5 = tail call i32 @genericround(i8* %0, i8* %1, i16 zeroext 2)
%6 = tail call i32 @genericround(i8* %0, i8* %1, i16 zeroext 3)
%7 = tail call i32 @genericround(i8* %0, i8* %1, i16 zeroext 4)
%8 = tail call i32 @genericround(i8* %0, i8* %1, i16 zeroext 5)
%9 = tail call i32 @genericround(i8* %0, i8* %1, i16 zeroext 6)
%10 = tail call i32 @genericround(i8* %0, i8* %1, i16 zeroext 7)
%11 = tail call i32 @genericround(i8* %0, i8* %1, i16 zeroext 8)
%12 = tail call i32 @genericround(i8* %0, i8* %1, i16 zeroext 9)
%13 = tail call i32 @lastround(i8* %0, i8* %1, i16 zeroext 10)
ret void
}