#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*/ aes256_add_round_key(unsigned char *, unsigned char *);
int /*<<< orphan*/ aes256_final_round(unsigned char *, unsigned char *);
int /*<<< orphan*/ aes256_full_round(unsigned char *, unsigned char *);
int /*<<< orphan*/ aes256_key_schedule(unsigned char const *, unsigned char *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, int);
void aes256_encrypt_block(const unsigned char *state, const unsigned char *key,
                          unsigned char *out) {
  int i;
  unsigned char key_schedule[240];
  memcpy(out, state, 16);
  aes256_key_schedule(key, key_schedule);
  aes256_add_round_key(out, key_schedule);
  for (i = 1; i < 14; i++) {
    aes256_full_round(out, key_schedule + (16 * i));
  }
  aes256_final_round(out, key_schedule + 224);
}


x86 assembly (clang, -O0):
<aes256_encrypt_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
mov    -0x10(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1040 <aes256_key_schedule@plt>
mov    -0x18(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1030 <aes256_add_round_key@plt>
movl   $0x1,-0x1c(%rbp)
cmpl   $0xe,-0x1c(%rbp)
jge    11d3 <aes256_encrypt_block+0x83>
mov    -0x18(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    -0x1c(%rbp),%eax
shl    $0x4,%eax
cltq
add    %rax,%rsi
call   1070 <aes256_full_round@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a0 <aes256_encrypt_block+0x50>
mov    -0x18(%rbp),%rdi
lea    -0x110(%rbp),%rsi
add    $0xe0,%rsi
call   1060 <aes256_final_round@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aes256_encrypt_block>:
push   %r15
push   %r14
push   %rbx
sub    $0xf0,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%rsi
mov    %rdx,%rdi
mov    $0x10,%edx
call   1050 <memcpy@plt>
mov    %rsp,%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <aes256_key_schedule@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <aes256_add_round_key@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <aes256_full_round@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <aes256_full_round@plt>
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <aes256_full_round@plt>
lea    0x40(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <aes256_full_round@plt>
lea    0x50(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <aes256_full_round@plt>
lea    0x60(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <aes256_full_round@plt>
lea    0x70(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <aes256_full_round@plt>
lea    0x80(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <aes256_full_round@plt>
lea    0x90(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <aes256_full_round@plt>
lea    0xa0(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <aes256_full_round@plt>
lea    0xb0(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <aes256_full_round@plt>
lea    0xc0(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <aes256_full_round@plt>
lea    0xd0(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <aes256_full_round@plt>
lea    0xe0(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <aes256_final_round@plt>
add    $0xf0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @aes256_encrypt_block(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca [240 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i8*, i8** %6
%10 = load i8*, i8** %4
%11 = call i32 @memcpy(i8* %9, i8* %10, i32 16)
%12 = load i8*, i8** %5
%13 = getelementptr inbounds [240 x i8], [240 x i8]* %8, i64 0, i64 0
%14 = call i32 @aes256_key_schedule(i8* %12, i8* %13)
%15 = load i8*, i8** %6
%16 = getelementptr inbounds [240 x i8], [240 x i8]* %8, i64 0, i64 0
%17 = call i32 @aes256_add_round_key(i8* %15, i8* %16)
store i32 1, i32* %7
br label %18
18: ; preds = %29, %3
%19 = load i32, i32* %7
%20 = icmp slt i32 %19, 14
br i1 %20, label %21, label %32
21: ; preds = %18
%22 = load i8*, i8** %6
%23 = getelementptr inbounds [240 x i8], [240 x i8]* %8, i64 0, i64 0
%24 = load i32, i32* %7
%25 = mul nsw i32 16, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
%28 = call i32 @aes256_full_round(i8* %22, i8* %27)
br label %29
29: ; preds = %21
%30 = load i32, i32* %7
%31 = add nsw i32 %30, 1
store i32 %31, i32* %7
br label %18
32: ; preds = %18
%33 = load i8*, i8** %6
%34 = getelementptr inbounds [240 x i8], [240 x i8]* %8, i64 0, i64 0
%35 = getelementptr inbounds i8, i8* %34, i64 224
%36 = call i32 @aes256_final_round(i8* %33, i8* %35)
ret void
}

LLVM IR (-O2):
define void @aes256_encrypt_block(i8* %0, i8* %1, i8* %2) {
%4 = alloca [240 x i8]
%5 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @memcpy(i8* %2, i8* %0, i32 16)
%7 = call i32 @aes256_key_schedule(i8* %1, i8* %5)
%8 = call i32 @aes256_add_round_key(i8* %2, i8* %5)
%9 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 16
%10 = call i32 @aes256_full_round(i8* %2, i8* %9)
%11 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 32
%12 = call i32 @aes256_full_round(i8* %2, i8* %11)
%13 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 48
%14 = call i32 @aes256_full_round(i8* %2, i8* %13)
%15 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 64
%16 = call i32 @aes256_full_round(i8* %2, i8* %15)
%17 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 80
%18 = call i32 @aes256_full_round(i8* %2, i8* %17)
%19 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 96
%20 = call i32 @aes256_full_round(i8* %2, i8* %19)
%21 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 112
%22 = call i32 @aes256_full_round(i8* %2, i8* %21)
%23 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 128
%24 = call i32 @aes256_full_round(i8* %2, i8* %23)
%25 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 144
%26 = call i32 @aes256_full_round(i8* %2, i8* %25)
%27 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 160
%28 = call i32 @aes256_full_round(i8* %2, i8* %27)
%29 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 176
%30 = call i32 @aes256_full_round(i8* %2, i8* %29)
%31 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 192
%32 = call i32 @aes256_full_round(i8* %2, i8* %31)
%33 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 208
%34 = call i32 @aes256_full_round(i8* %2, i8* %33)
%35 = getelementptr inbounds [240 x i8], [240 x i8]* %4, i64 0, i64 224
%36 = call i32 @aes256_final_round(i8* %2, i8* %35)
ret void
}