#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*/ add_round_key(unsigned char **, unsigned char **);
int /*<<< orphan*/ compute_key_schedule(unsigned char const *, int,
                                        unsigned char **);
int /*<<< orphan*/ inversion_mix_columns(unsigned char **);
int /*<<< orphan*/ inversion_shift_rows(unsigned char **);
int /*<<< orphan*/ inversion_subsitution_bytes(unsigned char **);
void aes_block_decrypt(const unsigned char *input_block,
                       unsigned char *output_block, const unsigned char *key,
                       int key_size) {
  int i;
  int j;
  int ronde;
  int number;
  unsigned char state[4][4];
  unsigned char w[60][4];
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      state[i][j] = input_block[i + (j * 4)];
    }
  }
  number = (key_size >> 2) + 6;
  compute_key_schedule(key, key_size, w);
  add_round_key(state, &w[number * 4]);
  for (ronde = number; ronde > 0; ronde--) {
    inversion_shift_rows(state);
    inversion_subsitution_bytes(state);
    add_round_key(state, &w[(ronde - 1) * 4]);
    if (ronde > 1) {
      inversion_mix_columns(state);
    }
  }
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      output_block[i + (4 * j)] = state[i][j];
    }
  }
}


x86 assembly (clang, -O0):
<aes_block_decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    11d8 <aes_block_decrypt+0x88>
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    11c5 <aes_block_decrypt+0x75>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%edx
shl    $0x2,%edx
add    %edx,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
movslq -0x20(%rbp),%rcx
lea    -0x40(%rbp),%rax
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1182 <aes_block_decrypt+0x32>
jmp    11ca <aes_block_decrypt+0x7a>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1171 <aes_block_decrypt+0x21>
mov    -0x1c(%rbp),%eax
sar    $0x2,%eax
add    $0x6,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x130(%rbp),%rdx
call   1040 <compute_key_schedule@plt>
lea    -0x40(%rbp),%rdi
mov    -0x2c(%rbp),%eax
shl    $0x2,%eax
cltq
lea    -0x130(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
call   1070 <add_round_key@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jle    1280 <aes_block_decrypt+0x130>
lea    -0x40(%rbp),%rdi
call   1060 <inversion_shift_rows@plt>
lea    -0x40(%rbp),%rdi
call   1030 <inversion_subsitution_bytes@plt>
lea    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
shl    $0x2,%eax
cltq
lea    -0x130(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
call   1070 <add_round_key@plt>
cmpl   $0x1,-0x28(%rbp)
jle    126d <aes_block_decrypt+0x11d>
lea    -0x40(%rbp),%rdi
call   1050 <inversion_mix_columns@plt>
jmp    1272 <aes_block_decrypt+0x122>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    121c <aes_block_decrypt+0xcc>
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    12ee <aes_block_decrypt+0x19e>
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    12db <aes_block_decrypt+0x18b>
movslq -0x20(%rbp),%rcx
lea    -0x40(%rbp),%rax
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%esi
shl    $0x2,%esi
add    %esi,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1298 <aes_block_decrypt+0x148>
jmp    12e0 <aes_block_decrypt+0x190>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1287 <aes_block_decrypt+0x137>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aes_block_decrypt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %ecx,%r12d
mov    %rdx,%rax
mov    %rsi,%r14
movdqu (%rdi),%xmm0
pxor   %xmm3,%xmm3
movdqa %xmm0,%xmm1
punpckhbw %xmm3,%xmm1
pshufd $0xe7,%xmm1,%xmm2
pshuflw $0x72,%xmm2,%xmm2
punpcklbw %xmm3,%xmm0
pshufd $0xe7,%xmm0,%xmm3
pshuflw $0x72,%xmm3,%xmm3
punpckldq %xmm2,%xmm3
pshufd $0xe8,%xmm1,%xmm1
pshuflw $0xd8,%xmm1,%xmm1
pshufd $0xe8,%xmm0,%xmm0
pshuflw $0xd8,%xmm0,%xmm0
punpckldq %xmm1,%xmm0
packuswb %xmm3,%xmm0
movdqa %xmm0,(%rsp)
lea    0x10(%rsp),%rdx
mov    %rax,%rdi
mov    %ecx,%esi
call   1040 <compute_key_schedule@plt>
lea    0x18(%r12),%eax
and    $0xfffffffc,%eax
cltq
lea    (%rsp,%rax,4),%rsi
add    $0x10,%rsi
mov    %rsp,%rdi
call   1070 <add_round_key@plt>
cmp    $0xffffffec,%r12d
jl     1274 <aes_block_decrypt+0x124>
sar    $0x2,%r12d
lea    0x6(%r12),%ebx
mov    %rsp,%r15
mov    %r15,%rdi
call   1060 <inversion_shift_rows@plt>
mov    %r15,%rdi
call   1030 <inversion_subsitution_bytes@plt>
lea    0x14(,%r12,4),%eax
cltq
lea    (%rsp,%rax,4),%rsi
add    $0x10,%rsi
mov    %r15,%rdi
call   1070 <add_round_key@plt>
cmp    $0x1,%ebx
je     1274 <aes_block_decrypt+0x124>
mov    %ebx,%r13d
lea    0x10(,%r12,4),%ebx
add    $0xffffffffffffffff,%r13
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1050 <inversion_mix_columns@plt>
mov    %r15,%rdi
call   1060 <inversion_shift_rows@plt>
mov    %r15,%rdi
call   1030 <inversion_subsitution_bytes@plt>
movslq %ebx,%rbx
lea    (%rsp,%rbx,4),%rsi
add    $0x10,%rsi
mov    %r15,%rdi
call   1070 <add_round_key@plt>
add    $0xfffffffc,%ebx
add    $0xffffffffffffffff,%r13
jne    1240 <aes_block_decrypt+0xf0>
movdqa (%rsp),%xmm0
movdqa %xmm0,%xmm1
pxor   %xmm3,%xmm3
punpckhbw %xmm3,%xmm1
pshufd $0xe7,%xmm1,%xmm2
pshuflw $0x72,%xmm2,%xmm2
punpcklbw %xmm3,%xmm0
pshufd $0xe7,%xmm0,%xmm3
pshuflw $0x72,%xmm3,%xmm3
punpckldq %xmm2,%xmm3
pshufd $0xe8,%xmm1,%xmm1
pshuflw $0xd8,%xmm1,%xmm1
pshufd $0xe8,%xmm0,%xmm0
pshuflw $0xd8,%xmm0,%xmm0
punpckldq %xmm1,%xmm0
packuswb %xmm3,%xmm0
movdqu %xmm0,(%r14)
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @aes_block_decrypt(i8* nocapture %0, i8* nocapture writeonly %1, i8* %2, i32 %3) {
%5 = alloca <16 x i8>
%6 = alloca [60 x [4 x i8]]
%7 = getelementptr inbounds <16 x i8>, <16 x i8>* %5, i64 0, i64 0
%8 = getelementptr inbounds [60 x [4 x i8]], [60 x [4 x i8]]* %6, i64 0, i64 0, i64 0
%9 = bitcast i8* %0 to <16 x i8>*
%10 = load <16 x i8>, <16 x i8>* %9
%11 = shufflevector <16 x i8> %10, <16 x i8> poison, <16 x i32> <i32 0, i32 4, i32 8, i32 12, i32 1, i32 5, i32 9, i32 13, i32 2, i32 6, i32 10, i32 14, i32 3, i32 7, i32 11, i32 15>
store <16 x i8> %11, <16 x i8>* %5
%12 = bitcast [60 x [4 x i8]]* %6 to i8**
%13 = call i32 @compute_key_schedule(i8* %2, i32 %3, i8** %12)
%14 = bitcast <16 x i8>* %5 to i8**
%15 = add i32 %3, 24
%16 = and i32 %15, -4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [60 x [4 x i8]], [60 x [4 x i8]]* %6, i64 0, i64 %17
%19 = bitcast [4 x i8]* %18 to i8**
%20 = call i32 @add_round_key(i8** %14, i8** %19)
%21 = icmp sgt i32 %3, -21
br i1 %21, label %22, label %36
22: ; preds = %4
%23 = ashr i32 %3, 2
%24 = add nsw i32 %23, 6
%25 = call i32 @inversion_shift_rows(i8** %14)
%26 = call i32 @inversion_subsitution_bytes(i8** %14)
%27 = shl i32 %24, 2
%28 = add i32 %27, -4
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [60 x [4 x i8]], [60 x [4 x i8]]* %6, i64 0, i64 %29
%31 = bitcast [4 x i8]* %30 to i8**
%32 = call i32 @add_round_key(i8** %14, i8** %31)
%33 = icmp eq i32 %24, 1
br i1 %33, label %36, label %34
34: ; preds = %22
%35 = zext i32 %24 to i64
br label %40
36: ; preds = %40, %22, %4
%37 = load <16 x i8>, <16 x i8>* %5
%38 = shufflevector <16 x i8> %37, <16 x i8> poison, <16 x i32> <i32 0, i32 4, i32 8, i32 12, i32 1, i32 5, i32 9, i32 13, i32 2, i32 6, i32 10, i32 14, i32 3, i32 7, i32 11, i32 15>
%39 = bitcast i8* %1 to <16 x i8>*
store <16 x i8> %38, <16 x i8>* %39
ret void
40: ; preds = %34, %40
%41 = phi i64 [ %35, %34 ], [ %43, %40 ]
%42 = call i32 @inversion_mix_columns(i8** %14)
%43 = add nsw i64 %41, -1
%44 = call i32 @inversion_shift_rows(i8** %14)
%45 = call i32 @inversion_subsitution_bytes(i8** %14)
%46 = trunc i64 %43 to i32
%47 = shl i32 %46, 2
%48 = add i32 %47, -4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [60 x [4 x i8]], [60 x [4 x i8]]* %6, i64 0, i64 %49
%51 = bitcast [4 x i8]* %50 to i8**
%52 = call i32 @add_round_key(i8** %14, i8** %51)
%53 = icmp eq i64 %43, 1
br i1 %53, label %36, label %40
}