#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 */
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
scalar_t__ aes128_detect_decB(int, int /*<<< orphan*/ const *, void *);
scalar_t__ aes128_detect_decF(int, int /*<<< orphan*/ const *, void *);
scalar_t__ aes192_detect_decB(int, int /*<<< orphan*/ const *, void *);
scalar_t__ aes192_detect_decF(int, int /*<<< orphan*/ const *, void *);
scalar_t__ aes256_detect_decB(int, int /*<<< orphan*/ const *, void *);
scalar_t__ aes256_detect_decF(int, int /*<<< orphan*/ const *, void *);
unsigned int aes_detect_dec_with_rev(bool reversed, const uint32_t *ctx,
                                     void *key) {
  if (aes128_detect_decF(reversed, ctx, key) ||
      aes128_detect_decB(reversed, ctx, key))
    return 16;
  if (aes192_detect_decF(reversed, ctx, key) ||
      aes192_detect_decB(reversed, ctx, key))
    return 24;
  if (aes256_detect_decF(reversed, ctx, key) ||
      aes256_detect_decB(reversed, ctx, key))
    return 32;
  return 0;
}


x86 assembly (clang, -O0):
<aes_detect_dec_with_rev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <aes128_detect_decF@plt>
cmp    $0x0,%rax
jne    11a7 <aes_detect_dec_with_rev+0x47>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <aes128_detect_decB@plt>
cmp    $0x0,%rax
je     11b3 <aes_detect_dec_with_rev+0x53>
movl   $0x10,-0x4(%rbp)
jmp    123a <aes_detect_dec_with_rev+0xda>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1080 <aes192_detect_decF@plt>
cmp    $0x0,%rax
jne    11e7 <aes_detect_dec_with_rev+0x87>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <aes192_detect_decB@plt>
cmp    $0x0,%rax
je     11f3 <aes_detect_dec_with_rev+0x93>
movl   $0x18,-0x4(%rbp)
jmp    123a <aes_detect_dec_with_rev+0xda>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <aes256_detect_decF@plt>
cmp    $0x0,%rax
jne    1227 <aes_detect_dec_with_rev+0xc7>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <aes256_detect_decB@plt>
cmp    $0x0,%rax
je     1233 <aes_detect_dec_with_rev+0xd3>
movl   $0x20,-0x4(%rbp)
jmp    123a <aes_detect_dec_with_rev+0xda>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aes_detect_dec_with_rev>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
call   1030 <aes128_detect_decF@plt>
mov    $0x10,%r15d
test   %rax,%rax
jne    11ee <aes_detect_dec_with_rev+0x8e>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <aes128_detect_decB@plt>
test   %rax,%rax
jne    11ee <aes_detect_dec_with_rev+0x8e>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <aes192_detect_decF@plt>
mov    $0x18,%r15d
test   %rax,%rax
jne    11ee <aes_detect_dec_with_rev+0x8e>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <aes192_detect_decB@plt>
test   %rax,%rax
jne    11ee <aes_detect_dec_with_rev+0x8e>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <aes256_detect_decF@plt>
mov    $0x20,%r15d
test   %rax,%rax
jne    11ee <aes_detect_dec_with_rev+0x8e>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1060 <aes256_detect_decB@plt>
xor    %r15d,%r15d
test   %rax,%rax
setne  %r15b
shl    $0x5,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @aes_detect_dec_with_rev(i32 %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8*
store i32 %0, i32* %5
store i32* %1, i32** %6
store i8* %2, i8** %7
%8 = load i32, i32* %5
%9 = load i32*, i32** %6
%10 = load i8*, i8** %7
%11 = call i64 @aes128_detect_decF(i32 %8, i32* %9, i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %3
%14 = load i32, i32* %5
%15 = load i32*, i32** %6
%16 = load i8*, i8** %7
%17 = call i64 @aes128_detect_decB(i32 %14, i32* %15, i8* %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %13, %3
store i32 16, i32* %4
br label %47
20: ; preds = %13
%21 = load i32, i32* %5
%22 = load i32*, i32** %6
%23 = load i8*, i8** %7
%24 = call i64 @aes192_detect_decF(i32 %21, i32* %22, i8* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %20
%27 = load i32, i32* %5
%28 = load i32*, i32** %6
%29 = load i8*, i8** %7
%30 = call i64 @aes192_detect_decB(i32 %27, i32* %28, i8* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %26, %20
store i32 24, i32* %4
br label %47
33: ; preds = %26
%34 = load i32, i32* %5
%35 = load i32*, i32** %6
%36 = load i8*, i8** %7
%37 = call i64 @aes256_detect_decF(i32 %34, i32* %35, i8* %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %45, label %39
39: ; preds = %33
%40 = load i32, i32* %5
%41 = load i32*, i32** %6
%42 = load i8*, i8** %7
%43 = call i64 @aes256_detect_decB(i32 %40, i32* %41, i8* %42)
%44 = icmp ne i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %39, %33
store i32 32, i32* %4
br label %47
46: ; preds = %39
store i32 0, i32* %4
br label %47
47: ; preds = %46, %45, %32, %19
%48 = load i32, i32* %4
ret i32 %48
}

LLVM IR (-O2):
define i32 @aes_detect_dec_with_rev(i32 %0, i32* %1, i8* %2) {
%4 = tail call i64 @aes128_detect_decF(i32 %0, i32* %1, i8* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %22
6: ; preds = %3
%7 = tail call i64 @aes128_detect_decB(i32 %0, i32* %1, i8* %2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = tail call i64 @aes192_detect_decF(i32 %0, i32* %1, i8* %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = tail call i64 @aes192_detect_decB(i32 %0, i32* %1, i8* %2)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = tail call i64 @aes256_detect_decF(i32 %0, i32* %1, i8* %2)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = tail call i64 @aes256_detect_decB(i32 %0, i32* %1, i8* %2)
%20 = icmp eq i64 %19, 0
%21 = select i1 %20, i32 0, i32 32
br label %22
22: ; preds = %18, %15, %9, %12, %3, %6
%23 = phi i32 [ 16, %6 ], [ 16, %3 ], [ 24, %12 ], [ 24, %9 ], [ 32, %15 ], [ %21, %18 ]
ret i32 %23
}