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

/* Variables and functions */
int /*<<< orphan*/ const *EVP_aes_128_gcm();
int /*<<< orphan*/ const *EVP_aes_192_gcm();
int /*<<< orphan*/ const *EVP_aes_256_gcm();
const EVP_CIPHER *algid_to_evp_aead(uint32_t alg) {
  switch (alg & (0xf0000000 | 0x000f0000 | 0x00000fff)) {
  case 0x40010000 | 0x00000100:
    return EVP_aes_256_gcm();
  case 0x40010000 | 0x000000c0:
    return EVP_aes_192_gcm();
  case 0x40010000 | 0x00000080:
    return EVP_aes_128_gcm();
  }
  return NULL;
}


x86 assembly (clang, -O0):
<algid_to_evp_aead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xf00f0fff,%eax
mov    %eax,-0x10(%rbp)
sub    $0x40010080,%eax
je     119c <algid_to_evp_aead+0x6c>
jmp    1156 <algid_to_evp_aead+0x26>
mov    -0x10(%rbp),%eax
sub    $0x400100c0,%eax
je     118c <algid_to_evp_aead+0x5c>
jmp    1169 <algid_to_evp_aead+0x39>
mov    -0x10(%rbp),%eax
sub    $0x40010100,%eax
jne    11ac <algid_to_evp_aead+0x7c>
jmp    117c <algid_to_evp_aead+0x4c>
mov    $0x0,%al
call   1050 <EVP_aes_256_gcm@plt>
mov    %rax,-0x8(%rbp)
jmp    11b4 <algid_to_evp_aead+0x84>
mov    $0x0,%al
call   1040 <EVP_aes_192_gcm@plt>
mov    %rax,-0x8(%rbp)
jmp    11b4 <algid_to_evp_aead+0x84>
mov    $0x0,%al
call   1030 <EVP_aes_128_gcm@plt>
mov    %rax,-0x8(%rbp)
jmp    11b4 <algid_to_evp_aead+0x84>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<algid_to_evp_aead>:
and    $0xf00f0fff,%edi
cmp    $0x40010080,%edi
je     1155 <algid_to_evp_aead+0x25>
cmp    $0x400100c0,%edi
je     115c <algid_to_evp_aead+0x2c>
cmp    $0x40010100,%edi
jne    1163 <algid_to_evp_aead+0x33>
xor    %eax,%eax
jmp    1050 <EVP_aes_256_gcm@plt>
xor    %eax,%eax
jmp    1030 <EVP_aes_128_gcm@plt>
xor    %eax,%eax
jmp    1040 <EVP_aes_192_gcm@plt>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32* @algid_to_evp_aead(i32 %0) {
%2 = alloca i32*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = and i32 %4, -267448321
switch i32 %5, label %12 [
i32 1073807616, label %6
i32 1073807552, label %8
i32 1073807488, label %10
]
6: ; preds = %1
%7 = call i32* (...) @EVP_aes_256_gcm()
store i32* %7, i32** %2
br label %13
8: ; preds = %1
%9 = call i32* (...) @EVP_aes_192_gcm()
store i32* %9, i32** %2
br label %13
10: ; preds = %1
%11 = call i32* (...) @EVP_aes_128_gcm()
store i32* %11, i32** %2
br label %13
12: ; preds = %1
store i32* null, i32** %2
br label %13
13: ; preds = %12, %10, %8, %6
%14 = load i32*, i32** %2
ret i32* %14
}

LLVM IR (-O2):
define i32* @algid_to_evp_aead(i32 %0) {
%2 = and i32 %0, -267448321
switch i32 %2, label %9 [
i32 1073807616, label %3
i32 1073807552, label %5
i32 1073807488, label %7
]
3: ; preds = %1
%4 = tail call i32* (...) @EVP_aes_256_gcm()
br label %9
5: ; preds = %1
%6 = tail call i32* (...) @EVP_aes_192_gcm()
br label %9
7: ; preds = %1
%8 = tail call i32* (...) @EVP_aes_128_gcm()
br label %9
9: ; preds = %1, %7, %5, %3
%10 = phi i32* [ %8, %7 ], [ %6, %5 ], [ %4, %3 ], [ null, %1 ]
ret i32* %10
}