#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 EINVAL;
int ENOMEM;
int /*<<< orphan*/ aes_add_round_key(unsigned char *, unsigned char *);
int aes_get_num_rounds(int const);
int /*<<< orphan*/ aes_key_expand(unsigned char *, unsigned char *, int const,
                                  unsigned char *, int);
int /*<<< orphan*/ aes_mix_columns(unsigned char *);
int /*<<< orphan*/ aes_shift_rows(unsigned char *);
int /*<<< orphan*/ aes_sub_bytes(unsigned char *);
int /*<<< orphan*/ free(unsigned char *);
scalar_t__ malloc(int const);
int /*<<< orphan*/ printf(char *);
int aes_encrypt_block(const unsigned char *plain_text, const unsigned char *key,
                      const int key_len, unsigned char *cipher_text) {
  int num_rounds = aes_get_num_rounds(key_len);
  if (num_rounds < 0) {
    printf("ERROR: aes_get_num_rounds() failed\n");
    return -EINVAL;
  }
  unsigned char rcon;
  unsigned char state[16];
  unsigned char round_key[16];
  unsigned char *full_key =
      (unsigned char *)malloc(key_len * sizeof(unsigned char));
  if (full_key == NULL) {
    printf("ERROR: malloc() failed\n");
    return -ENOMEM;
  }
  for (int i = 0; i < 16; i++) {
    state[i] = plain_text[i];
  }
  for (int i = 0; i < key_len; i++) {
    full_key[i] = key[i];
  }
  for (int i = 0; i < 16; i++) {
    round_key[i] = full_key[i];
  }
  rcon = 0;
  aes_add_round_key(state, round_key);
  for (int j = 0; j < num_rounds; j++) {
    aes_sub_bytes(state);
    aes_shift_rows(state);
    if (j < (num_rounds - 1)) {
      aes_mix_columns(state);
    }
    aes_key_expand(round_key, full_key, key_len, &rcon, j);
    aes_add_round_key(state, round_key);
  }
  for (int i = 0; i < 16; i++) {
    cipher_text[i] = state[i];
  }
  free(full_key);
  return 0;
}


x86 assembly (clang, -O0):
<aes_encrypt_block>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
call   1090 <aes_get_num_rounds@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    11db <aes_encrypt_block+0x4b>
lea    0xe3d(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    0x2e07(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1378 <aes_encrypt_block+0x1e8>
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1218 <aes_encrypt_block+0x88>
lea    0xe24(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    0x2dd2(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1378 <aes_encrypt_block+0x1e8>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x10,-0x5c(%rbp)
jge    124a <aes_encrypt_block+0xba>
mov    -0x10(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x5c(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    121f <aes_encrypt_block+0x8f>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1281 <aes_encrypt_block+0xf1>
mov    -0x18(%rbp),%rax
movslq -0x60(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x58(%rbp),%rax
movslq -0x60(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1251 <aes_encrypt_block+0xc1>
movl   $0x0,-0x64(%rbp)
cmpl   $0x10,-0x64(%rbp)
jge    12b3 <aes_encrypt_block+0x123>
mov    -0x58(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x64(%rbp),%rax
mov    %cl,-0x50(%rbp,%rax,1)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1288 <aes_encrypt_block+0xf8>
movb   $0x0,-0x2d(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <aes_add_round_key@plt>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1336 <aes_encrypt_block+0x1a6>
lea    -0x40(%rbp),%rdi
call   10b0 <aes_sub_bytes@plt>
lea    -0x40(%rbp),%rdi
call   10a0 <aes_shift_rows@plt>
mov    -0x68(%rbp),%eax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1303 <aes_encrypt_block+0x173>
lea    -0x40(%rbp),%rdi
call   1080 <aes_mix_columns@plt>
lea    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x68(%rbp),%r8d
lea    -0x2d(%rbp),%rcx
call   1040 <aes_key_expand@plt>
lea    -0x40(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <aes_add_round_key@plt>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    12cb <aes_encrypt_block+0x13b>
movl   $0x0,-0x6c(%rbp)
cmpl   $0x10,-0x6c(%rbp)
jge    1368 <aes_encrypt_block+0x1d8>
movslq -0x6c(%rbp),%rax
mov    -0x40(%rbp,%rax,1),%dl
mov    -0x28(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    133d <aes_encrypt_block+0x1ad>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aes_encrypt_block>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,%r14
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %edx,%edi
call   1090 <aes_get_num_rounds@plt>
mov    %rax,0x8(%rsp)
test   %eax,%eax
js     1312 <aes_encrypt_block+0x182>
mov    %r15d,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     1327 <aes_encrypt_block+0x197>
mov    %rax,%r13
mov    %r14,0x28(%rsp)
movups (%rbx),%xmm0
movaps %xmm0,0x10(%rsp)
test   %r15d,%r15d
jle    1271 <aes_encrypt_block+0xe1>
mov    %r15d,%eax
cmp    $0x8,%r15d
jb     120b <aes_encrypt_block+0x7b>
lea    (%rax,%rbp,1),%rcx
cmp    %r13,%rcx
jbe    134d <aes_encrypt_block+0x1bd>
lea    (%rax,%r13,1),%rcx
cmp    %rbp,%rcx
jbe    134d <aes_encrypt_block+0x1bd>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
add    %rax,%rdx
mov    %rax,%rsi
and    $0x3,%rsi
je     1234 <aes_encrypt_block+0xa4>
nop
movzbl 0x0(%rbp,%rcx,1),%ebx
mov    %bl,0x0(%r13,%rcx,1)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rsi
jne    1220 <aes_encrypt_block+0x90>
cmp    $0x3,%rdx
jb     1271 <aes_encrypt_block+0xe1>
nopw   0x0(%rax,%rax,1)
movzbl 0x0(%rbp,%rcx,1),%edx
mov    %dl,0x0(%r13,%rcx,1)
movzbl 0x1(%rbp,%rcx,1),%edx
mov    %dl,0x1(%r13,%rcx,1)
movzbl 0x2(%rbp,%rcx,1),%edx
mov    %dl,0x2(%r13,%rcx,1)
movzbl 0x3(%rbp,%rcx,1),%edx
mov    %dl,0x3(%r13,%rcx,1)
add    $0x4,%rcx
cmp    %rcx,%rax
jne    1240 <aes_encrypt_block+0xb0>
movups 0x0(%r13),%xmm0
movaps %xmm0,0x30(%rsp)
movb   $0x0,0x7(%rsp)
lea    0x10(%rsp),%rdi
lea    0x30(%rsp),%rsi
call   1060 <aes_add_round_key@plt>
cmpl   $0x0,0x8(%rsp)
jle    12f9 <aes_encrypt_block+0x169>
mov    0x8(%rsp),%rax
lea    -0x1(%rax),%r12d
xor    %ebp,%ebp
lea    0x10(%rsp),%rbx
lea    0x30(%rsp),%r14
jmp    12da <aes_encrypt_block+0x14a>
nopl   (%rax)
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15d,%edx
lea    0x7(%rsp),%rcx
mov    %ebp,%r8d
call   1040 <aes_key_expand@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <aes_add_round_key@plt>
add    $0x1,%ebp
cmp    %ebp,0x8(%rsp)
je     12f9 <aes_encrypt_block+0x169>
mov    %rbx,%rdi
call   10b0 <aes_sub_bytes@plt>
mov    %rbx,%rdi
call   10a0 <aes_shift_rows@plt>
cmp    %r12d,%ebp
jge    12b0 <aes_encrypt_block+0x120>
mov    %rbx,%rdi
call   1080 <aes_mix_columns@plt>
jmp    12b0 <aes_encrypt_block+0x120>
movaps 0x10(%rsp),%xmm0
mov    0x28(%rsp),%rax
movups %xmm0,(%rax)
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    133e <aes_encrypt_block+0x1ae>
lea    0xcfe(%rip),%rdi
call   1050 <puts@plt>
mov    0x2cb3(%rip),%rcx
jmp    133a <aes_encrypt_block+0x1aa>
lea    0xcd2(%rip),%rdi
call   1050 <puts@plt>
mov    0x2ca6(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x20,%r15d
jae    135a <aes_encrypt_block+0x1ca>
xor    %ecx,%ecx
jmp    143c <aes_encrypt_block+0x2ac>
mov    %eax,%ecx
and    $0xffffffe0,%ecx
lea    -0x20(%rcx),%rdi
mov    %rdi,%rsi
shr    $0x5,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x3,%edx
cmp    $0x60,%rdi
jae    137d <aes_encrypt_block+0x1ed>
xor    %edi,%edi
jmp    13f2 <aes_encrypt_block+0x262>
and    $0xfffffffffffffffc,%rsi
xor    %edi,%edi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movups 0x0(%rbp,%rdi,1),%xmm0
movups 0x10(%rbp,%rdi,1),%xmm1
movups %xmm0,0x0(%r13,%rdi,1)
movups %xmm1,0x10(%r13,%rdi,1)
movups 0x20(%rbp,%rdi,1),%xmm0
movups 0x30(%rbp,%rdi,1),%xmm1
movups %xmm0,0x20(%r13,%rdi,1)
movups %xmm1,0x30(%r13,%rdi,1)
movups 0x40(%rbp,%rdi,1),%xmm0
movups 0x50(%rbp,%rdi,1),%xmm1
movups %xmm0,0x40(%r13,%rdi,1)
movups %xmm1,0x50(%r13,%rdi,1)
movups 0x60(%rbp,%rdi,1),%xmm0
movups 0x70(%rbp,%rdi,1),%xmm1
movups %xmm0,0x60(%r13,%rdi,1)
movups %xmm1,0x70(%r13,%rdi,1)
sub    $0xffffffffffffff80,%rdi
add    $0xfffffffffffffffc,%rsi
jne    1390 <aes_encrypt_block+0x200>
test   %rdx,%rdx
je     142b <aes_encrypt_block+0x29b>
lea    (%rdi,%r13,1),%rsi
add    $0x10,%rsi
add    %rbp,%rdi
add    $0x10,%rdi
shl    $0x5,%rdx
xor    %ebx,%ebx
nopl   0x0(%rax)
movups -0x10(%rdi,%rbx,1),%xmm0
movups (%rdi,%rbx,1),%xmm1
movups %xmm0,-0x10(%rsi,%rbx,1)
movups %xmm1,(%rsi,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%rdx
jne    1410 <aes_encrypt_block+0x280>
cmp    %rax,%rcx
je     1271 <aes_encrypt_block+0xe1>
test   $0x18,%al
je     120d <aes_encrypt_block+0x7d>
mov    %rcx,%rdx
mov    %eax,%ecx
and    $0xfffffff8,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x0(%rbp,%rdx,1),%rsi
mov    %rsi,0x0(%r13,%rdx,1)
add    $0x8,%rdx
cmp    %rdx,%rcx
jne    1450 <aes_encrypt_block+0x2c0>
cmp    %rax,%rcx
je     1271 <aes_encrypt_block+0xe1>
jmp    120d <aes_encrypt_block+0x7d>

LLVM IR (-O0):
@.str = [36 x i8] c"ERROR: aes_get_num_rounds() failed\0A\00"
@EINVAL = global i32 0
@.str.1 = [24 x i8] c"ERROR: malloc() failed\0A\00"
@ENOMEM = global i32 0
define i32 @aes_encrypt_block(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8
%12 = alloca [16 x i8]
%13 = alloca [16 x i8]
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
%20 = load i32, i32* %8
%21 = call i32 @aes_get_num_rounds(i32 %20)
store i32 %21, i32* %10
%22 = load i32, i32* %10
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %4
%25 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%26 = load i32, i32* @EINVAL
%27 = sub nsw i32 0, %26
store i32 %27, i32* %5
br label %142
28: ; preds = %4
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = mul i64 %30, 1
%32 = trunc i64 %31 to i32
%33 = call i64 @malloc(i32 %32)
%34 = inttoptr i64 %33 to i8*
store i8* %34, i8** %14
%35 = load i8*, i8** %14
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %41
37: ; preds = %28
%38 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32, i32* @ENOMEM
%40 = sub nsw i32 0, %39
store i32 %40, i32* %5
br label %142
41: ; preds = %28
store i32 0, i32* %15
br label %42
42: ; preds = %54, %41
%43 = load i32, i32* %15
%44 = icmp slt i32 %43, 16
br i1 %44, label %45, label %57
45: ; preds = %42
%46 = load i8*, i8** %6
%47 = load i32, i32* %15
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = load i32, i32* %15
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 %52
store i8 %50, i8* %53
br label %54
54: ; preds = %45
%55 = load i32, i32* %15
%56 = add nsw i32 %55, 1
store i32 %56, i32* %15
br label %42
57: ; preds = %42
store i32 0, i32* %16
br label %58
58: ; preds = %72, %57
%59 = load i32, i32* %16
%60 = load i32, i32* %8
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %75
62: ; preds = %58
%63 = load i8*, i8** %7
%64 = load i32, i32* %16
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = load i8, i8* %66
%68 = load i8*, i8** %14
%69 = load i32, i32* %16
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
store i8 %67, i8* %71
br label %72
72: ; preds = %62
%73 = load i32, i32* %16
%74 = add nsw i32 %73, 1
store i32 %74, i32* %16
br label %58
75: ; preds = %58
store i32 0, i32* %17
br label %76
76: ; preds = %88, %75
%77 = load i32, i32* %17
%78 = icmp slt i32 %77, 16
br i1 %78, label %79, label %91
79: ; preds = %76
%80 = load i8*, i8** %14
%81 = load i32, i32* %17
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8, i8* %80, i64 %82
%84 = load i8, i8* %83
%85 = load i32, i32* %17
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 %86
store i8 %84, i8* %87
br label %88
88: ; preds = %79
%89 = load i32, i32* %17
%90 = add nsw i32 %89, 1
store i32 %90, i32* %17
br label %76
91: ; preds = %76
store i8 0, i8* %11
%92 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%93 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%94 = call i32 @aes_add_round_key(i8* %92, i8* %93)
store i32 0, i32* %18
br label %95
95: ; preds = %120, %91
%96 = load i32, i32* %18
%97 = load i32, i32* %10
%98 = icmp slt i32 %96, %97
br i1 %98, label %99, label %123
99: ; preds = %95
%100 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%101 = call i32 @aes_sub_bytes(i8* %100)
%102 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%103 = call i32 @aes_shift_rows(i8* %102)
%104 = load i32, i32* %18
%105 = load i32, i32* %10
%106 = sub nsw i32 %105, 1
%107 = icmp slt i32 %104, %106
br i1 %107, label %108, label %111
108: ; preds = %99
%109 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%110 = call i32 @aes_mix_columns(i8* %109)
br label %111
111: ; preds = %108, %99
%112 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%113 = load i8*, i8** %14
%114 = load i32, i32* %8
%115 = load i32, i32* %18
%116 = call i32 @aes_key_expand(i8* %112, i8* %113, i32 %114, i8* %11, i32 %115)
%117 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%118 = getelementptr inbounds [16 x i8], [16 x i8]* %13, i64 0, i64 0
%119 = call i32 @aes_add_round_key(i8* %117, i8* %118)
br label %120
120: ; preds = %111
%121 = load i32, i32* %18
%122 = add nsw i32 %121, 1
store i32 %122, i32* %18
br label %95
123: ; preds = %95
store i32 0, i32* %19
br label %124
124: ; preds = %136, %123
%125 = load i32, i32* %19
%126 = icmp slt i32 %125, 16
br i1 %126, label %127, label %139
127: ; preds = %124
%128 = load i32, i32* %19
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 %129
%131 = load i8, i8* %130
%132 = load i8*, i8** %9
%133 = load i32, i32* %19
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i8, i8* %132, i64 %134
store i8 %131, i8* %135
br label %136
136: ; preds = %127
%137 = load i32, i32* %19
%138 = add nsw i32 %137, 1
store i32 %138, i32* %19
br label %124
139: ; preds = %124
%140 = load i8*, i8** %14
%141 = call i32 @free(i8* %140)
store i32 0, i32* %5
br label %142
142: ; preds = %139, %37, %24
%143 = load i32, i32* %5
ret i32 %143
}

LLVM IR (-O2):
@EINVAL = global i32 0
@ENOMEM = global i32 0
@str = [23 x i8] c"ERROR: malloc() failed\00"
@str.2 = [35 x i8] c"ERROR: aes_get_num_rounds() failed\00"
define i32 @aes_encrypt_block(i8* nocapture %0, i8* nocapture %1, i32 %2, i8* nocapture writeonly %3) {
%5 = alloca i8
%6 = alloca [16 x i8]
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%8 = alloca <16 x i8>
%9 = tail call i32 @aes_get_num_rounds(i32 %2)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.2, i64 0, i64 0))
%13 = load i32, i32* @EINVAL
%14 = sub nsw i32 0, %13
br label %194
15: ; preds = %4
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%17 = getelementptr inbounds <16 x i8>, <16 x i8>* %8, i64 0, i64 0
%18 = tail call i64 @malloc(i32 %2)
%19 = inttoptr i64 %18 to i8*
%20 = icmp eq i64 %18, 0
br i1 %20, label %23, label %21
21: ; preds = %15
%22 = icmp sgt i32 %2, 0
br i1 %22, label %27, label %152
23: ; preds = %15
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%25 = load i32, i32* @ENOMEM
%26 = sub nsw i32 0, %25
br label %192
27: ; preds = %21
%28 = zext i32 %2 to i64
%29 = icmp ult i32 %2, 8
br i1 %29, label %134, label %30
30: ; preds = %27
%31 = getelementptr i8, i8* %19, i64 %28
%32 = getelementptr i8, i8* %1, i64 %28
%33 = icmp ugt i8* %32, %19
%34 = icmp ugt i8* %31, %1
%35 = and i1 %33, %34
br i1 %35, label %134, label %36
36: ; preds = %30
%37 = icmp ult i32 %2, 32
br i1 %37, label %120, label %38
38: ; preds = %36
%39 = and i64 %28, 4294967264
%40 = add nsw i64 %39, -32
%41 = lshr exact i64 %40, 5
%42 = add nuw nsw i64 %41, 1
%43 = and i64 %42, 3
%44 = icmp ult i64 %40, 96
br i1 %44, label %96, label %45
45: ; preds = %38
%46 = and i64 %42, 1152921504606846972
br label %47
47: ; preds = %47, %45
%48 = phi i64 [ 0, %45 ], [ %93, %47 ]
%49 = phi i64 [ 0, %45 ], [ %94, %47 ]
%50 = getelementptr inbounds i8, i8* %1, i64 %48
%51 = bitcast i8* %50 to <16 x i8>*
%52 = load <16 x i8>, <16 x i8>* %51
%53 = getelementptr inbounds i8, i8* %50, i64 16
%54 = bitcast i8* %53 to <16 x i8>*
%55 = load <16 x i8>, <16 x i8>* %54
%56 = getelementptr inbounds i8, i8* %19, i64 %48
%57 = bitcast i8* %56 to <16 x i8>*
store <16 x i8> %52, <16 x i8>* %57
%58 = getelementptr inbounds i8, i8* %56, i64 16
%59 = bitcast i8* %58 to <16 x i8>*
store <16 x i8> %55, <16 x i8>* %59
%60 = or i64 %48, 32
%61 = getelementptr inbounds i8, i8* %1, i64 %60
%62 = bitcast i8* %61 to <16 x i8>*
%63 = load <16 x i8>, <16 x i8>* %62
%64 = getelementptr inbounds i8, i8* %61, i64 16
%65 = bitcast i8* %64 to <16 x i8>*
%66 = load <16 x i8>, <16 x i8>* %65
%67 = getelementptr inbounds i8, i8* %19, i64 %60
%68 = bitcast i8* %67 to <16 x i8>*
store <16 x i8> %63, <16 x i8>* %68
%69 = getelementptr inbounds i8, i8* %67, i64 16
%70 = bitcast i8* %69 to <16 x i8>*
store <16 x i8> %66, <16 x i8>* %70
%71 = or i64 %48, 64
%72 = getelementptr inbounds i8, i8* %1, i64 %71
%73 = bitcast i8* %72 to <16 x i8>*
%74 = load <16 x i8>, <16 x i8>* %73
%75 = getelementptr inbounds i8, i8* %72, i64 16
%76 = bitcast i8* %75 to <16 x i8>*
%77 = load <16 x i8>, <16 x i8>* %76
%78 = getelementptr inbounds i8, i8* %19, i64 %71
%79 = bitcast i8* %78 to <16 x i8>*
store <16 x i8> %74, <16 x i8>* %79
%80 = getelementptr inbounds i8, i8* %78, i64 16
%81 = bitcast i8* %80 to <16 x i8>*
store <16 x i8> %77, <16 x i8>* %81
%82 = or i64 %48, 96
%83 = getelementptr inbounds i8, i8* %1, i64 %82
%84 = bitcast i8* %83 to <16 x i8>*
%85 = load <16 x i8>, <16 x i8>* %84
%86 = getelementptr inbounds i8, i8* %83, i64 16
%87 = bitcast i8* %86 to <16 x i8>*
%88 = load <16 x i8>, <16 x i8>* %87
%89 = getelementptr inbounds i8, i8* %19, i64 %82
%90 = bitcast i8* %89 to <16 x i8>*
store <16 x i8> %85, <16 x i8>* %90
%91 = getelementptr inbounds i8, i8* %89, i64 16
%92 = bitcast i8* %91 to <16 x i8>*
store <16 x i8> %88, <16 x i8>* %92
%93 = add nuw i64 %48, 128
%94 = add i64 %49, 4
%95 = icmp eq i64 %94, %46
br i1 %95, label %96, label %47
96: ; preds = %47, %38
%97 = phi i64 [ 0, %38 ], [ %93, %47 ]
%98 = icmp eq i64 %43, 0
br i1 %98, label %115, label %99
99: ; preds = %96, %99
%100 = phi i64 [ %112, %99 ], [ %97, %96 ]
%101 = phi i64 [ %113, %99 ], [ 0, %96 ]
%102 = getelementptr inbounds i8, i8* %1, i64 %100
%103 = bitcast i8* %102 to <16 x i8>*
%104 = load <16 x i8>, <16 x i8>* %103
%105 = getelementptr inbounds i8, i8* %102, i64 16
%106 = bitcast i8* %105 to <16 x i8>*
%107 = load <16 x i8>, <16 x i8>* %106
%108 = getelementptr inbounds i8, i8* %19, i64 %100
%109 = bitcast i8* %108 to <16 x i8>*
store <16 x i8> %104, <16 x i8>* %109
%110 = getelementptr inbounds i8, i8* %108, i64 16
%111 = bitcast i8* %110 to <16 x i8>*
store <16 x i8> %107, <16 x i8>* %111
%112 = add nuw i64 %100, 32
%113 = add i64 %101, 1
%114 = icmp eq i64 %113, %43
br i1 %114, label %115, label %99
115: ; preds = %99, %96
%116 = icmp eq i64 %39, %28
br i1 %116, label %152, label %117
117: ; preds = %115
%118 = and i64 %28, 24
%119 = icmp eq i64 %118, 0
br i1 %119, label %134, label %120
120: ; preds = %36, %117
%121 = phi i64 [ %39, %117 ], [ 0, %36 ]
%122 = and i64 %28, 4294967288
br label %123
123: ; preds = %123, %120
%124 = phi i64 [ %121, %120 ], [ %130, %123 ]
%125 = getelementptr inbounds i8, i8* %1, i64 %124
%126 = bitcast i8* %125 to <8 x i8>*
%127 = load <8 x i8>, <8 x i8>* %126
%128 = getelementptr inbounds i8, i8* %19, i64 %124
%129 = bitcast i8* %128 to <8 x i8>*
store <8 x i8> %127, <8 x i8>* %129
%130 = add nuw i64 %124, 8
%131 = icmp eq i64 %130, %122
br i1 %131, label %132, label %123
132: ; preds = %123
%133 = icmp eq i64 %122, %28
br i1 %133, label %152, label %134
134: ; preds = %30, %27, %117, %132
%135 = phi i64 [ 0, %27 ], [ 0, %30 ], [ %39, %117 ], [ %122, %132 ]
%136 = xor i64 %135, -1
%137 = add nsw i64 %136, %28
%138 = and i64 %28, 3
%139 = icmp eq i64 %138, 0
br i1 %139, label %149, label %140
140: ; preds = %134, %140
%141 = phi i64 [ %146, %140 ], [ %135, %134 ]
%142 = phi i64 [ %147, %140 ], [ 0, %134 ]
%143 = getelementptr inbounds i8, i8* %1, i64 %141
%144 = load i8, i8* %143
%145 = getelementptr inbounds i8, i8* %19, i64 %141
store i8 %144, i8* %145
%146 = add nuw nsw i64 %141, 1
%147 = add i64 %142, 1
%148 = icmp eq i64 %147, %138
br i1 %148, label %149, label %140
149: ; preds = %140, %134
%150 = phi i64 [ %135, %134 ], [ %146, %140 ]
%151 = icmp ult i64 %137, 3
br i1 %151, label %152, label %157
152: ; preds = %149, %157, %115, %132, %21
%153 = inttoptr i64 %18 to <16 x i8>*
%154 = load <16 x i8>, <16 x i8>* %153
store <16 x i8> %154, <16 x i8>* %8
store i8 0, i8* %5
%155 = call i32 @aes_add_round_key(i8* %16, i8* %17)
%156 = icmp sgt i32 %9, 0
br i1 %156, label %176, label %178
157: ; preds = %149, %157
%158 = phi i64 [ %174, %157 ], [ %150, %149 ]
%159 = getelementptr inbounds i8, i8* %1, i64 %158
%160 = load i8, i8* %159
%161 = getelementptr inbounds i8, i8* %19, i64 %158
store i8 %160, i8* %161
%162 = add nuw nsw i64 %158, 1
%163 = getelementptr inbounds i8, i8* %1, i64 %162
%164 = load i8, i8* %163
%165 = getelementptr inbounds i8, i8* %19, i64 %162
store i8 %164, i8* %165
%166 = add nuw nsw i64 %158, 2
%167 = getelementptr inbounds i8, i8* %1, i64 %166
%168 = load i8, i8* %167
%169 = getelementptr inbounds i8, i8* %19, i64 %166
store i8 %168, i8* %169
%170 = add nuw nsw i64 %158, 3
%171 = getelementptr inbounds i8, i8* %1, i64 %170
%172 = load i8, i8* %171
%173 = getelementptr inbounds i8, i8* %19, i64 %170
store i8 %172, i8* %173
%174 = add nuw nsw i64 %158, 4
%175 = icmp eq i64 %174, %28
br i1 %175, label %152, label %157
176: ; preds = %152
%177 = add nsw i32 %9, -1
br label %180
178: ; preds = %187, %152
%179 = call i32 @free(i8* %19)
br label %192
180: ; preds = %176, %187
%181 = phi i32 [ 0, %176 ], [ %190, %187 ]
%182 = call i32 @aes_sub_bytes(i8* %16)
%183 = call i32 @aes_shift_rows(i8* %16)
%184 = icmp slt i32 %181, %177
br i1 %184, label %185, label %187
185: ; preds = %180
%186 = call i32 @aes_mix_columns(i8* %16)
br label %187
187: ; preds = %185, %180
%188 = call i32 @aes_key_expand(i8* %17, i8* %19, i32 %2, i8* %5, i32 %181)
%189 = call i32 @aes_add_round_key(i8* %16, i8* %17)
%190 = add nuw nsw i32 %181, 1
%191 = icmp eq i32 %190, %9
br i1 %191, label %178, label %180
192: ; preds = %178, %23
%193 = phi i32 [ %26, %23 ], [ 0, %178 ]
br label %194
194: ; preds = %192, %11
%195 = phi i32 [ %14, %11 ], [ %193, %192 ]
ret i32 %195
}