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

/* Variables and functions */
int /*<<< orphan*/ ASN1_OBJECT_free(int /*<<< orphan*/ *);
int EVP_CIPHER_nid(int /*<<< orphan*/ const *);
#define NID_aes_128_cfb1 147
#define NID_aes_128_cfb128 146
#define NID_aes_128_cfb8 145
#define NID_aes_192_cfb1 144
#define NID_aes_192_cfb128 143
#define NID_aes_192_cfb8 142
#define NID_aes_256_cfb1 141
#define NID_aes_256_cfb128 140
#define NID_aes_256_cfb8 139
#define NID_des_cfb1 138
#define NID_des_cfb64 137
#define NID_des_cfb8 136
#define NID_des_ede3_cfb1 135
#define NID_des_ede3_cfb64 134
#define NID_des_ede3_cfb8 133
#define NID_rc2_40_cbc 132
#define NID_rc2_64_cbc 131
#define NID_rc2_cbc 130
#define NID_rc4 129
#define NID_rc4_40 128
int NID_undef;
int /*<<< orphan*/ *OBJ_get0_data(int /*<<< orphan*/ *);
int /*<<< orphan*/ *OBJ_nid2obj(int);
int EVP_CIPHER_type(const EVP_CIPHER *ctx) {
  int nid;
  ASN1_OBJECT *otmp;
  nid = EVP_CIPHER_nid(ctx);
  switch (nid) {
  case NID_rc2_cbc:
  case NID_rc2_64_cbc:
  case NID_rc2_40_cbc:
    return NID_rc2_cbc;
  case NID_rc4:
  case NID_rc4_40:
    return NID_rc4;
  case NID_aes_128_cfb128:
  case NID_aes_128_cfb8:
  case NID_aes_128_cfb1:
    return NID_aes_128_cfb128;
  case NID_aes_192_cfb128:
  case NID_aes_192_cfb8:
  case NID_aes_192_cfb1:
    return NID_aes_192_cfb128;
  case NID_aes_256_cfb128:
  case NID_aes_256_cfb8:
  case NID_aes_256_cfb1:
    return NID_aes_256_cfb128;
  case NID_des_cfb64:
  case NID_des_cfb8:
  case NID_des_cfb1:
    return NID_des_cfb64;
  case NID_des_ede3_cfb64:
  case NID_des_ede3_cfb8:
  case NID_des_ede3_cfb1:
    return NID_des_cfb64;
  default:
    otmp = OBJ_nid2obj(nid);
    if (OBJ_get0_data(otmp) == NULL)
      nid = NID_undef;
    ASN1_OBJECT_free(otmp);
    return nid;
  }
}


x86 assembly (clang, -O0):
<EVP_CIPHER_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <EVP_CIPHER_nid@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x13,%eax
ja     11d5 <EVP_CIPHER_type+0x95>
mov    -0x28(%rbp),%rax
lea    0xe88(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x82,-0x4(%rbp)
jmp    120f <EVP_CIPHER_type+0xcf>
movl   $0x81,-0x4(%rbp)
jmp    120f <EVP_CIPHER_type+0xcf>
movl   $0x92,-0x4(%rbp)
jmp    120f <EVP_CIPHER_type+0xcf>
movl   $0x8f,-0x4(%rbp)
jmp    120f <EVP_CIPHER_type+0xcf>
movl   $0x8c,-0x4(%rbp)
jmp    120f <EVP_CIPHER_type+0xcf>
movl   $0x89,-0x4(%rbp)
jmp    120f <EVP_CIPHER_type+0xcf>
movl   $0x89,-0x4(%rbp)
jmp    120f <EVP_CIPHER_type+0xcf>
mov    -0x14(%rbp),%edi
call   1040 <OBJ_nid2obj@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <OBJ_get0_data@plt>
cmp    $0x0,%rax
jne    1200 <EVP_CIPHER_type+0xc0>
mov    0x2de5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <ASN1_OBJECT_free@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EVP_CIPHER_type>:
push   %r14
push   %rbx
push   %rax
call   1030 <EVP_CIPHER_nid@plt>
mov    %eax,%ebx
lea    -0x80(%rbx),%eax
cmp    $0x14,%eax
jae    1161 <EVP_CIPHER_type+0x21>
cltq
lea    0xea4(%rip),%rcx
mov    (%rcx,%rax,4),%ebx
jmp    1189 <EVP_CIPHER_type+0x49>
mov    %ebx,%edi
call   1040 <OBJ_nid2obj@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1060 <OBJ_get0_data@plt>
test   %rax,%rax
jne    1181 <EVP_CIPHER_type+0x41>
mov    0x2e61(%rip),%rax
mov    (%rax),%ebx
mov    %r14,%rdi
call   1050 <ASN1_OBJECT_free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@NID_undef = global i32 0
define i32 @EVP_CIPHER_type(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 @EVP_CIPHER_nid(i32* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
switch i32 %8, label %16 [
i32 130, label %9
i32 131, label %9
i32 132, label %9
i32 129, label %10
i32 128, label %10
i32 146, label %11
i32 145, label %11
i32 147, label %11
i32 143, label %12
i32 142, label %12
i32 144, label %12
i32 140, label %13
i32 139, label %13
i32 141, label %13
i32 137, label %14
i32 136, label %14
i32 138, label %14
i32 134, label %15
i32 133, label %15
i32 135, label %15
]
9: ; preds = %1, %1, %1
store i32 130, i32* %2
br label %28
10: ; preds = %1, %1
store i32 129, i32* %2
br label %28
11: ; preds = %1, %1, %1
store i32 146, i32* %2
br label %28
12: ; preds = %1, %1, %1
store i32 143, i32* %2
br label %28
13: ; preds = %1, %1, %1
store i32 140, i32* %2
br label %28
14: ; preds = %1, %1, %1
store i32 137, i32* %2
br label %28
15: ; preds = %1, %1, %1
store i32 137, i32* %2
br label %28
16: ; preds = %1
%17 = load i32, i32* %4
%18 = call i32* @OBJ_nid2obj(i32 %17)
store i32* %18, i32** %5
%19 = load i32*, i32** %5
%20 = call i32* @OBJ_get0_data(i32* %19)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %16
%23 = load i32, i32* @NID_undef
store i32 %23, i32* %4
br label %24
24: ; preds = %22, %16
%25 = load i32*, i32** %5
%26 = call i32 @ASN1_OBJECT_free(i32* %25)
%27 = load i32, i32* %4
store i32 %27, i32* %2
br label %28
28: ; preds = %24, %15, %14, %13, %12, %11, %10, %9
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@NID_undef = global i32 0
@switch.table.EVP_CIPHER_type = [20 x i32] [i32 129, i32 129, i32 130, i32 130, i32 130, i32 137, i32 137, i32 137, i32 137, i32 137, i32 137, i32 140, i32 140, i32 140, i32 143, i32 143, i32 143, i32 146, i32 146, i32 146]
define i32 @EVP_CIPHER_type(i32* %0) {
%2 = tail call i32 @EVP_CIPHER_nid(i32* %0)
%3 = add i32 %2, -128
%4 = icmp ult i32 %3, 20
br i1 %4, label %12, label %5
5: ; preds = %1
%6 = tail call i32* @OBJ_nid2obj(i32 %2)
%7 = tail call i32* @OBJ_get0_data(i32* %6)
%8 = icmp eq i32* %7, null
%9 = load i32, i32* @NID_undef
%10 = select i1 %8, i32 %9, i32 %2
%11 = tail call i32 @ASN1_OBJECT_free(i32* %6)
br label %16
12: ; preds = %1
%13 = sext i32 %3 to i64
%14 = getelementptr inbounds [20 x i32], [20 x i32]* @switch.table.EVP_CIPHER_type, i64 0, i64 %13
%15 = load i32, i32* %14
br label %16
16: ; preds = %12, %5
%17 = phi i32 [ %10, %5 ], [ %15, %12 ]
ret i32 %17
}