#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*/ addroundkey(unsigned char *, unsigned char *,
                               unsigned short);
int /*<<< orphan*/ decrypt_generic_round(unsigned char *, unsigned char *,
                                         unsigned short);
int /*<<< orphan*/ decrypt_lastround(unsigned char *, unsigned char *,
                                     unsigned short);
void AES_decrypt(unsigned char *ciphertext, unsigned char *key, int length) {
  unsigned short int Round = 10;
  addroundkey(ciphertext, key, Round);
  Round--;
  for (; Round >= 1; Round--)
    decrypt_generic_round(ciphertext, key, Round);
  decrypt_lastround(ciphertext, key, Round);
}


x86 assembly (clang, -O0):
<AES_decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movw   $0xa,-0x16(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movzwl -0x16(%rbp),%edx
call   1040 <addroundkey@plt>
mov    -0x16(%rbp),%ax
add    $0xffff,%ax
mov    %ax,-0x16(%rbp)
movzwl -0x16(%rbp),%eax
cmp    $0x1,%eax
jl     1195 <AES_decrypt+0x65>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movzwl -0x16(%rbp),%edx
call   1030 <decrypt_generic_round@plt>
mov    -0x16(%rbp),%ax
add    $0xffff,%ax
mov    %ax,-0x16(%rbp)
jmp    1166 <AES_decrypt+0x36>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movzwl -0x16(%rbp),%edx
call   1050 <decrypt_lastround@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AES_decrypt>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0xa,%edx
call   1040 <addroundkey@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x9,%edx
call   1030 <decrypt_generic_round@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
call   1030 <decrypt_generic_round@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
call   1030 <decrypt_generic_round@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1030 <decrypt_generic_round@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
call   1030 <decrypt_generic_round@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <decrypt_generic_round@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
call   1030 <decrypt_generic_round@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1030 <decrypt_generic_round@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <decrypt_generic_round@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <decrypt_lastround@plt>

LLVM IR (-O0):
define void @AES_decrypt(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i16
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i16 10, i16* %7
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = load i16, i16* %7
%11 = call i32 @addroundkey(i8* %8, i8* %9, i16 zeroext %10)
%12 = load i16, i16* %7
%13 = add i16 %12, -1
store i16 %13, i16* %7
br label %14
14: ; preds = %23, %3
%15 = load i16, i16* %7
%16 = zext i16 %15 to i32
%17 = icmp sge i32 %16, 1
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i8*, i8** %4
%20 = load i8*, i8** %5
%21 = load i16, i16* %7
%22 = call i32 @decrypt_generic_round(i8* %19, i8* %20, i16 zeroext %21)
br label %23
23: ; preds = %18
%24 = load i16, i16* %7
%25 = add i16 %24, -1
store i16 %25, i16* %7
br label %14
26: ; preds = %14
%27 = load i8*, i8** %4
%28 = load i8*, i8** %5
%29 = load i16, i16* %7
%30 = call i32 @decrypt_lastround(i8* %27, i8* %28, i16 zeroext %29)
ret void
}

LLVM IR (-O2):
define void @AES_decrypt(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @addroundkey(i8* %0, i8* %1, i16 zeroext 10)
%5 = tail call i32 @decrypt_generic_round(i8* %0, i8* %1, i16 zeroext 9)
%6 = tail call i32 @decrypt_generic_round(i8* %0, i8* %1, i16 zeroext 8)
%7 = tail call i32 @decrypt_generic_round(i8* %0, i8* %1, i16 zeroext 7)
%8 = tail call i32 @decrypt_generic_round(i8* %0, i8* %1, i16 zeroext 6)
%9 = tail call i32 @decrypt_generic_round(i8* %0, i8* %1, i16 zeroext 5)
%10 = tail call i32 @decrypt_generic_round(i8* %0, i8* %1, i16 zeroext 4)
%11 = tail call i32 @decrypt_generic_round(i8* %0, i8* %1, i16 zeroext 3)
%12 = tail call i32 @decrypt_generic_round(i8* %0, i8* %1, i16 zeroext 2)
%13 = tail call i32 @decrypt_generic_round(i8* %0, i8* %1, i16 zeroext 1)
%14 = tail call i32 @decrypt_lastround(i8* %0, i8* %1, i16 zeroext 0)
ret void
}