#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*/ aes_add_round_key(char **, char **);
int /*<<< orphan*/ aes_inv_final_round(char **, char **);
int /*<<< orphan*/ aes_inv_round(char **, char **);
int /*<<< orphan*/ aes_inv_round_get_key(char **, char **, int);
int /*<<< orphan*/ aes_key_expansion(char **, char **);
int aes_inv_cipher(char state[][4], char key[][4]) {
  int r;
  char expanded_key[4][4 * (10 + 1)];
  char tmp_key[4][4];
  aes_key_expansion(key, expanded_key);
  aes_inv_round_get_key(expanded_key, tmp_key, 0);
  aes_add_round_key(state, tmp_key);
  for (r = 1; r < 10; r++) {
    aes_inv_round_get_key(expanded_key, tmp_key, r);
    aes_inv_round(state, tmp_key);
  }
  aes_inv_round_get_key(expanded_key, tmp_key, r);
  aes_inv_final_round(state, tmp_key);
  return 0;
}


x86 assembly (clang, -O0):
<aes_inv_cipher>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
call   1070 <aes_key_expansion@plt>
lea    -0xd0(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
xor    %edx,%edx
call   1060 <aes_inv_round_get_key@plt>
mov    -0x8(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1040 <aes_add_round_key@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11dd <aes_inv_cipher+0x8d>
lea    -0xd0(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <aes_inv_round_get_key@plt>
mov    -0x8(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1050 <aes_inv_round@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119f <aes_inv_cipher+0x4f>
lea    -0xd0(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <aes_inv_round_get_key@plt>
mov    -0x8(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1030 <aes_inv_final_round@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aes_inv_cipher>:
push   %r15
push   %r14
push   %rbx
sub    $0xc0,%rsp
mov    %rdi,%r14
lea    0x10(%rsp),%r15
mov    %rsi,%rdi
mov    %r15,%rsi
call   1070 <aes_key_expansion@plt>
mov    %rsp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1060 <aes_inv_round_get_key@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <aes_add_round_key@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1060 <aes_inv_round_get_key@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <aes_inv_round@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1060 <aes_inv_round_get_key@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <aes_inv_round@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x3,%edx
call   1060 <aes_inv_round_get_key@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <aes_inv_round@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1060 <aes_inv_round_get_key@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <aes_inv_round@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1060 <aes_inv_round_get_key@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <aes_inv_round@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1060 <aes_inv_round_get_key@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <aes_inv_round@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1060 <aes_inv_round_get_key@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <aes_inv_round@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1060 <aes_inv_round_get_key@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <aes_inv_round@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x9,%edx
call   1060 <aes_inv_round_get_key@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <aes_inv_round@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1060 <aes_inv_round_get_key@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <aes_inv_final_round@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @aes_inv_cipher([4 x i8]* %0, [4 x i8]* %1) {
%3 = alloca [4 x i8]*
%4 = alloca [4 x i8]*
%5 = alloca i32
%6 = alloca [4 x [44 x i8]]
%7 = alloca [4 x [4 x i8]]
store [4 x i8]* %0, [4 x i8]** %3
store [4 x i8]* %1, [4 x i8]** %4
%8 = load [4 x i8]*, [4 x i8]** %4
%9 = bitcast [4 x i8]* %8 to i8**
%10 = getelementptr inbounds [4 x [44 x i8]], [4 x [44 x i8]]* %6, i64 0, i64 0
%11 = bitcast [44 x i8]* %10 to i8**
%12 = call i32 @aes_key_expansion(i8** %9, i8** %11)
%13 = getelementptr inbounds [4 x [44 x i8]], [4 x [44 x i8]]* %6, i64 0, i64 0
%14 = bitcast [44 x i8]* %13 to i8**
%15 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %7, i64 0, i64 0
%16 = bitcast [4 x i8]* %15 to i8**
%17 = call i32 @aes_inv_round_get_key(i8** %14, i8** %16, i32 0)
%18 = load [4 x i8]*, [4 x i8]** %3
%19 = bitcast [4 x i8]* %18 to i8**
%20 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %7, i64 0, i64 0
%21 = bitcast [4 x i8]* %20 to i8**
%22 = call i32 @aes_add_round_key(i8** %19, i8** %21)
store i32 1, i32* %5
br label %23
23: ; preds = %38, %2
%24 = load i32, i32* %5
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %41
26: ; preds = %23
%27 = getelementptr inbounds [4 x [44 x i8]], [4 x [44 x i8]]* %6, i64 0, i64 0
%28 = bitcast [44 x i8]* %27 to i8**
%29 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %7, i64 0, i64 0
%30 = bitcast [4 x i8]* %29 to i8**
%31 = load i32, i32* %5
%32 = call i32 @aes_inv_round_get_key(i8** %28, i8** %30, i32 %31)
%33 = load [4 x i8]*, [4 x i8]** %3
%34 = bitcast [4 x i8]* %33 to i8**
%35 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %7, i64 0, i64 0
%36 = bitcast [4 x i8]* %35 to i8**
%37 = call i32 @aes_inv_round(i8** %34, i8** %36)
br label %38
38: ; preds = %26
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %23
41: ; preds = %23
%42 = getelementptr inbounds [4 x [44 x i8]], [4 x [44 x i8]]* %6, i64 0, i64 0
%43 = bitcast [44 x i8]* %42 to i8**
%44 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %7, i64 0, i64 0
%45 = bitcast [4 x i8]* %44 to i8**
%46 = load i32, i32* %5
%47 = call i32 @aes_inv_round_get_key(i8** %43, i8** %45, i32 %46)
%48 = load [4 x i8]*, [4 x i8]** %3
%49 = bitcast [4 x i8]* %48 to i8**
%50 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %7, i64 0, i64 0
%51 = bitcast [4 x i8]* %50 to i8**
%52 = call i32 @aes_inv_final_round(i8** %49, i8** %51)
ret i32 0
}

LLVM IR (-O2):
define i32 @aes_inv_cipher([4 x i8]* %0, [4 x i8]* %1) {
%3 = alloca [4 x [44 x i8]]
%4 = alloca [4 x [4 x i8]]
%5 = getelementptr inbounds [4 x [44 x i8]], [4 x [44 x i8]]* %3, i64 0, i64 0, i64 0
%6 = getelementptr inbounds [4 x [4 x i8]], [4 x [4 x i8]]* %4, i64 0, i64 0, i64 0
%7 = bitcast [4 x i8]* %1 to i8**
%8 = bitcast [4 x [44 x i8]]* %3 to i8**
%9 = call i32 @aes_key_expansion(i8** %7, i8** %8)
%10 = bitcast [4 x [4 x i8]]* %4 to i8**
%11 = call i32 @aes_inv_round_get_key(i8** %8, i8** %10, i32 0)
%12 = bitcast [4 x i8]* %0 to i8**
%13 = call i32 @aes_add_round_key(i8** %12, i8** %10)
%14 = call i32 @aes_inv_round_get_key(i8** %8, i8** %10, i32 1)
%15 = call i32 @aes_inv_round(i8** %12, i8** %10)
%16 = call i32 @aes_inv_round_get_key(i8** %8, i8** %10, i32 2)
%17 = call i32 @aes_inv_round(i8** %12, i8** %10)
%18 = call i32 @aes_inv_round_get_key(i8** %8, i8** %10, i32 3)
%19 = call i32 @aes_inv_round(i8** %12, i8** %10)
%20 = call i32 @aes_inv_round_get_key(i8** %8, i8** %10, i32 4)
%21 = call i32 @aes_inv_round(i8** %12, i8** %10)
%22 = call i32 @aes_inv_round_get_key(i8** %8, i8** %10, i32 5)
%23 = call i32 @aes_inv_round(i8** %12, i8** %10)
%24 = call i32 @aes_inv_round_get_key(i8** %8, i8** %10, i32 6)
%25 = call i32 @aes_inv_round(i8** %12, i8** %10)
%26 = call i32 @aes_inv_round_get_key(i8** %8, i8** %10, i32 7)
%27 = call i32 @aes_inv_round(i8** %12, i8** %10)
%28 = call i32 @aes_inv_round_get_key(i8** %8, i8** %10, i32 8)
%29 = call i32 @aes_inv_round(i8** %12, i8** %10)
%30 = call i32 @aes_inv_round_get_key(i8** %8, i8** %10, i32 9)
%31 = call i32 @aes_inv_round(i8** %12, i8** %10)
%32 = call i32 @aes_inv_round_get_key(i8** %8, i8** %10, i32 10)
%33 = call i32 @aes_inv_final_round(i8** %12, i8** %10)
ret i32 0
}