#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*/ inv_byte_substitution(unsigned char *);
int /*<<< orphan*/ inv_mix_column(unsigned char *);
int /*<<< orphan*/ inv_shift_row(unsigned char *);
int /*<<< orphan*/ key_addition_dec(unsigned char *, int);
int /*<<< orphan*/ key_schedule(unsigned char *);
void aes_128_dec(unsigned char *input, unsigned char *key) {
  key_schedule(key);
  key_addition_dec(input, 0);
  inv_shift_row(input);
  inv_byte_substitution(input);
  for (int rnd = 1; rnd < 10; rnd++) {
    key_addition_dec(input, rnd);
    inv_mix_column(input);
    inv_shift_row(input);
    inv_byte_substitution(input);
  }
  key_addition_dec(input, 10);
}


x86 assembly (clang, -O0):
<aes_128_dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <key_schedule@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <key_addition_dec@plt>
mov    -0x8(%rbp),%rdi
call   1070 <inv_shift_row@plt>
mov    -0x8(%rbp),%rdi
call   1060 <inv_byte_substitution@plt>
movl   $0x1,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    11cc <aes_128_dec+0x7c>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <key_addition_dec@plt>
mov    -0x8(%rbp),%rdi
call   1030 <inv_mix_column@plt>
mov    -0x8(%rbp),%rdi
call   1070 <inv_shift_row@plt>
mov    -0x8(%rbp),%rdi
call   1060 <inv_byte_substitution@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118d <aes_128_dec+0x3d>
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1040 <key_addition_dec@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aes_128_dec>:
push   %rbx
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1050 <key_schedule@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <key_addition_dec@plt>
mov    %rbx,%rdi
call   1070 <inv_shift_row@plt>
mov    %rbx,%rdi
call   1060 <inv_byte_substitution@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <key_addition_dec@plt>
mov    %rbx,%rdi
call   1030 <inv_mix_column@plt>
mov    %rbx,%rdi
call   1070 <inv_shift_row@plt>
mov    %rbx,%rdi
call   1060 <inv_byte_substitution@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <key_addition_dec@plt>
mov    %rbx,%rdi
call   1030 <inv_mix_column@plt>
mov    %rbx,%rdi
call   1070 <inv_shift_row@plt>
mov    %rbx,%rdi
call   1060 <inv_byte_substitution@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <key_addition_dec@plt>
mov    %rbx,%rdi
call   1030 <inv_mix_column@plt>
mov    %rbx,%rdi
call   1070 <inv_shift_row@plt>
mov    %rbx,%rdi
call   1060 <inv_byte_substitution@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <key_addition_dec@plt>
mov    %rbx,%rdi
call   1030 <inv_mix_column@plt>
mov    %rbx,%rdi
call   1070 <inv_shift_row@plt>
mov    %rbx,%rdi
call   1060 <inv_byte_substitution@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <key_addition_dec@plt>
mov    %rbx,%rdi
call   1030 <inv_mix_column@plt>
mov    %rbx,%rdi
call   1070 <inv_shift_row@plt>
mov    %rbx,%rdi
call   1060 <inv_byte_substitution@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1040 <key_addition_dec@plt>
mov    %rbx,%rdi
call   1030 <inv_mix_column@plt>
mov    %rbx,%rdi
call   1070 <inv_shift_row@plt>
mov    %rbx,%rdi
call   1060 <inv_byte_substitution@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1040 <key_addition_dec@plt>
mov    %rbx,%rdi
call   1030 <inv_mix_column@plt>
mov    %rbx,%rdi
call   1070 <inv_shift_row@plt>
mov    %rbx,%rdi
call   1060 <inv_byte_substitution@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1040 <key_addition_dec@plt>
mov    %rbx,%rdi
call   1030 <inv_mix_column@plt>
mov    %rbx,%rdi
call   1070 <inv_shift_row@plt>
mov    %rbx,%rdi
call   1060 <inv_byte_substitution@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1040 <key_addition_dec@plt>
mov    %rbx,%rdi
call   1030 <inv_mix_column@plt>
mov    %rbx,%rdi
call   1070 <inv_shift_row@plt>
mov    %rbx,%rdi
call   1060 <inv_byte_substitution@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
pop    %rbx
jmp    1040 <key_addition_dec@plt>

LLVM IR (-O0):
define void @aes_128_dec(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i32 @key_schedule(i8* %6)
%8 = load i8*, i8** %3
%9 = call i32 @key_addition_dec(i8* %8, i32 0)
%10 = load i8*, i8** %3
%11 = call i32 @inv_shift_row(i8* %10)
%12 = load i8*, i8** %3
%13 = call i32 @inv_byte_substitution(i8* %12)
store i32 1, i32* %5
br label %14
14: ; preds = %27, %2
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 10
br i1 %16, label %17, label %30
17: ; preds = %14
%18 = load i8*, i8** %3
%19 = load i32, i32* %5
%20 = call i32 @key_addition_dec(i8* %18, i32 %19)
%21 = load i8*, i8** %3
%22 = call i32 @inv_mix_column(i8* %21)
%23 = load i8*, i8** %3
%24 = call i32 @inv_shift_row(i8* %23)
%25 = load i8*, i8** %3
%26 = call i32 @inv_byte_substitution(i8* %25)
br label %27
27: ; preds = %17
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %14
30: ; preds = %14
%31 = load i8*, i8** %3
%32 = call i32 @key_addition_dec(i8* %31, i32 10)
ret void
}

LLVM IR (-O2):
define void @aes_128_dec(i8* %0, i8* %1) {
%3 = tail call i32 @key_schedule(i8* %1)
%4 = tail call i32 @key_addition_dec(i8* %0, i32 0)
%5 = tail call i32 @inv_shift_row(i8* %0)
%6 = tail call i32 @inv_byte_substitution(i8* %0)
%7 = tail call i32 @key_addition_dec(i8* %0, i32 1)
%8 = tail call i32 @inv_mix_column(i8* %0)
%9 = tail call i32 @inv_shift_row(i8* %0)
%10 = tail call i32 @inv_byte_substitution(i8* %0)
%11 = tail call i32 @key_addition_dec(i8* %0, i32 2)
%12 = tail call i32 @inv_mix_column(i8* %0)
%13 = tail call i32 @inv_shift_row(i8* %0)
%14 = tail call i32 @inv_byte_substitution(i8* %0)
%15 = tail call i32 @key_addition_dec(i8* %0, i32 3)
%16 = tail call i32 @inv_mix_column(i8* %0)
%17 = tail call i32 @inv_shift_row(i8* %0)
%18 = tail call i32 @inv_byte_substitution(i8* %0)
%19 = tail call i32 @key_addition_dec(i8* %0, i32 4)
%20 = tail call i32 @inv_mix_column(i8* %0)
%21 = tail call i32 @inv_shift_row(i8* %0)
%22 = tail call i32 @inv_byte_substitution(i8* %0)
%23 = tail call i32 @key_addition_dec(i8* %0, i32 5)
%24 = tail call i32 @inv_mix_column(i8* %0)
%25 = tail call i32 @inv_shift_row(i8* %0)
%26 = tail call i32 @inv_byte_substitution(i8* %0)
%27 = tail call i32 @key_addition_dec(i8* %0, i32 6)
%28 = tail call i32 @inv_mix_column(i8* %0)
%29 = tail call i32 @inv_shift_row(i8* %0)
%30 = tail call i32 @inv_byte_substitution(i8* %0)
%31 = tail call i32 @key_addition_dec(i8* %0, i32 7)
%32 = tail call i32 @inv_mix_column(i8* %0)
%33 = tail call i32 @inv_shift_row(i8* %0)
%34 = tail call i32 @inv_byte_substitution(i8* %0)
%35 = tail call i32 @key_addition_dec(i8* %0, i32 8)
%36 = tail call i32 @inv_mix_column(i8* %0)
%37 = tail call i32 @inv_shift_row(i8* %0)
%38 = tail call i32 @inv_byte_substitution(i8* %0)
%39 = tail call i32 @key_addition_dec(i8* %0, i32 9)
%40 = tail call i32 @inv_mix_column(i8* %0)
%41 = tail call i32 @inv_shift_row(i8* %0)
%42 = tail call i32 @inv_byte_substitution(i8* %0)
%43 = tail call i32 @key_addition_dec(i8* %0, i32 10)
ret void
}