#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_enc(int, int /*<<< orphan*/ const *, void *);
scalar_t__ aes192_detect_enc(int, int /*<<< orphan*/ const *, void *);
scalar_t__ aes256_detect_enc(int, int /*<<< orphan*/ const *, void *);
unsigned int aes_detect_enc(const uint32_t *ctx, void *key) {
  if (aes128_detect_enc(true, ctx, key) || aes128_detect_enc(false, ctx, key))
    return 16;
  if (aes192_detect_enc(true, ctx, key) || aes192_detect_enc(false, ctx, key))
    return 24;
  if (aes256_detect_enc(true, ctx, key) || aes256_detect_enc(false, ctx, key))
    return 32;
  return 0;
}


x86 assembly (clang, -O0):
<aes_detect_enc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x1,%edi
call   1050 <aes128_detect_enc@plt>
cmp    $0x0,%rax
jne    1175 <aes_detect_enc+0x45>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
xor    %edi,%edi
call   1050 <aes128_detect_enc@plt>
cmp    $0x0,%rax
je     1181 <aes_detect_enc+0x51>
movl   $0x10,-0x4(%rbp)
jmp    120a <aes_detect_enc+0xda>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x1,%edi
call   1040 <aes192_detect_enc@plt>
cmp    $0x0,%rax
jne    11b6 <aes_detect_enc+0x86>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
xor    %edi,%edi
call   1040 <aes192_detect_enc@plt>
cmp    $0x0,%rax
je     11c2 <aes_detect_enc+0x92>
movl   $0x18,-0x4(%rbp)
jmp    120a <aes_detect_enc+0xda>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x1,%edi
call   1030 <aes256_detect_enc@plt>
cmp    $0x0,%rax
jne    11f7 <aes_detect_enc+0xc7>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
xor    %edi,%edi
call   1030 <aes256_detect_enc@plt>
cmp    $0x0,%rax
je     1203 <aes_detect_enc+0xd3>
movl   $0x20,-0x4(%rbp)
jmp    120a <aes_detect_enc+0xda>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aes_detect_enc>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <aes128_detect_enc@plt>
mov    $0x10,%ebp
test   %rax,%rax
jne    11c5 <aes_detect_enc+0x95>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <aes128_detect_enc@plt>
test   %rax,%rax
jne    11c5 <aes_detect_enc+0x95>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <aes192_detect_enc@plt>
mov    $0x18,%ebp
test   %rax,%rax
jne    11c5 <aes_detect_enc+0x95>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <aes192_detect_enc@plt>
test   %rax,%rax
jne    11c5 <aes_detect_enc+0x95>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <aes256_detect_enc@plt>
mov    $0x20,%ebp
test   %rax,%rax
jne    11c5 <aes_detect_enc+0x95>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <aes256_detect_enc@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
shl    $0x5,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @aes_detect_enc(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
%6 = load i32*, i32** %4
%7 = load i8*, i8** %5
%8 = call i64 @aes128_detect_enc(i32 1, i32* %6, i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %2
%11 = load i32*, i32** %4
%12 = load i8*, i8** %5
%13 = call i64 @aes128_detect_enc(i32 0, i32* %11, i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10, %2
store i32 16, i32* %3
br label %39
16: ; preds = %10
%17 = load i32*, i32** %4
%18 = load i8*, i8** %5
%19 = call i64 @aes192_detect_enc(i32 1, i32* %17, i8* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = load i32*, i32** %4
%23 = load i8*, i8** %5
%24 = call i64 @aes192_detect_enc(i32 0, i32* %22, i8* %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %21, %16
store i32 24, i32* %3
br label %39
27: ; preds = %21
%28 = load i32*, i32** %4
%29 = load i8*, i8** %5
%30 = call i64 @aes256_detect_enc(i32 1, i32* %28, i8* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %27
%33 = load i32*, i32** %4
%34 = load i8*, i8** %5
%35 = call i64 @aes256_detect_enc(i32 0, i32* %33, i8* %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %32, %27
store i32 32, i32* %3
br label %39
38: ; preds = %32
store i32 0, i32* %3
br label %39
39: ; preds = %38, %37, %26, %15
%40 = load i32, i32* %3
ret i32 %40
}

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