#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 */
size_t aes_calclength(char *, size_t const);
int /*<<< orphan*/ aes_invcipher(int const, char const *, char const *, char *);
size_t aes_ecbdec(const int bits, const char *in, const size_t length,
                  const char *key, char *out) {
  for (size_t d = 0; d + 15 < length; d += 16) {
    aes_invcipher(bits, in + d, key, out + d);
  }
  return aes_calclength(out, length);
}


x86 assembly (clang, -O0):
<aes_ecbdec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0xf,%rax
cmp    -0x18(%rbp),%rax
jae    1182 <aes_ecbdec+0x62>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
add    -0x30(%rbp),%rcx
call   1030 <aes_invcipher@plt>
mov    -0x30(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x30(%rbp)
jmp    1143 <aes_ecbdec+0x23>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <aes_calclength@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aes_ecbdec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,(%rsp)
mov    %rdx,%r12
cmp    $0x10,%rdx
jb     1172 <aes_ecbdec+0x52>
mov    %rcx,%r15
mov    %rsi,%rbx
mov    %edi,%r13d
mov    $0xf,%r14d
mov    (%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %rbp,%rcx
call   1030 <aes_invcipher@plt>
add    $0x10,%rbx
add    $0x10,%rbp
add    $0x10,%r14
cmp    %r12,%r14
jb     1150 <aes_ecbdec+0x30>
mov    (%rsp),%rdi
mov    %r12,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <aes_calclength@plt>

LLVM IR (-O0):
define i64 @aes_ecbdec(i32 %0, i8* %1, i64 %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
store i32 %0, i32* %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i8* %4, i8** %10
store i64 0, i64* %11
br label %12
12: ; preds = %27, %5
%13 = load i64, i64* %11
%14 = add i64 %13, 15
%15 = load i64, i64* %8
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %30
17: ; preds = %12
%18 = load i32, i32* %6
%19 = load i8*, i8** %7
%20 = load i64, i64* %11
%21 = getelementptr inbounds i8, i8* %19, i64 %20
%22 = load i8*, i8** %9
%23 = load i8*, i8** %10
%24 = load i64, i64* %11
%25 = getelementptr inbounds i8, i8* %23, i64 %24
%26 = call i32 @aes_invcipher(i32 %18, i8* %21, i8* %22, i8* %25)
br label %27
27: ; preds = %17
%28 = load i64, i64* %11
%29 = add i64 %28, 16
store i64 %29, i64* %11
br label %12
30: ; preds = %12
%31 = load i8*, i8** %10
%32 = load i64, i64* %8
%33 = call i64 @aes_calclength(i8* %31, i64 %32)
ret i64 %33
}

LLVM IR (-O2):
define i64 @aes_ecbdec(i32 %0, i8* %1, i64 %2, i8* %3, i8* %4) {
%6 = icmp ugt i64 %2, 15
br i1 %6, label %9, label %7
7: ; preds = %9, %5
%8 = tail call i64 @aes_calclength(i8* %4, i64 %2)
ret i64 %8
9: ; preds = %5, %9
%10 = phi i64 [ %14, %9 ], [ 0, %5 ]
%11 = getelementptr inbounds i8, i8* %1, i64 %10
%12 = getelementptr inbounds i8, i8* %4, i64 %10
%13 = tail call i32 @aes_invcipher(i32 %0, i8* %11, i8* %3, i8* %12)
%14 = add i64 %10, 16
%15 = or i64 %14, 15
%16 = icmp ult i64 %15, %2
br i1 %16, label %9, label %7
}