#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*/ ASN1_OBJECT;

/* Variables and functions */
int ASN1_object_size(int /*<<< orphan*/, int, int /*<<< orphan*/);
int /*<<< orphan*/ ASN1_put_object(unsigned char **, int /*<<< orphan*/, int,
                                   int /*<<< orphan*/, int /*<<< orphan*/);
int NID_undef;
int OBJ_ln2nid(char const *);
int /*<<< orphan*/ *OBJ_nid2obj(int);
int OBJ_sn2nid(char const *);
int /*<<< orphan*/ V_ASN1_OBJECT;
int /*<<< orphan*/ V_ASN1_UNIVERSAL;
int a2d_ASN1_OBJECT(unsigned char *, int, char const *, int);
int /*<<< orphan*/ *d2i_ASN1_OBJECT(int /*<<< orphan*/ *,
                                    unsigned char const **, int);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *malloc(int);
ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name) {
  int nid = NID_undef;
  ASN1_OBJECT *op = NULL;
  unsigned char *buf;
  unsigned char *p;
  const unsigned char *cp;
  int i, j;
  if (!no_name) {
    if (((nid = OBJ_sn2nid(s)) != NID_undef) ||
        ((nid = OBJ_ln2nid(s)) != NID_undef))
      return OBJ_nid2obj(nid);
  }
  i = a2d_ASN1_OBJECT(NULL, 0, s, -1);
  if (i <= 0) {
    return NULL;
  }
  j = ASN1_object_size(0, i, V_ASN1_OBJECT);
  if ((buf = malloc(j)) == NULL)
    return NULL;
  p = buf;
  ASN1_put_object(&p, 0, i, V_ASN1_OBJECT, V_ASN1_UNIVERSAL);
  a2d_ASN1_OBJECT(p, i, s, -1);
  cp = buf;
  op = d2i_ASN1_OBJECT(NULL, &cp, j);
  free(buf);
  return op;
}


x86 assembly (clang, -O0):
<OBJ_txt2obj>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1209 <OBJ_txt2obj+0x79>
mov    -0x10(%rbp),%rdi
call   1040 <OBJ_sn2nid@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e00(%rip),%rcx
cmp    (%rcx),%eax
jne    11f3 <OBJ_txt2obj+0x63>
mov    -0x10(%rbp),%rdi
call   1080 <OBJ_ln2nid@plt>
mov    %eax,-0x18(%rbp)
mov    0x2de5(%rip),%rcx
cmp    (%rcx),%eax
je     1204 <OBJ_txt2obj+0x74>
mov    -0x18(%rbp),%edi
call   1050 <OBJ_nid2obj@plt>
mov    %rax,-0x8(%rbp)
jmp    12db <OBJ_txt2obj+0x14b>
jmp    1209 <OBJ_txt2obj+0x79>
mov    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%edi
xor    %esi,%esi
mov    $0xffffffff,%ecx
call   1060 <a2d_ASN1_OBJECT@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jg     1237 <OBJ_txt2obj+0xa7>
movq   $0x0,-0x8(%rbp)
jmp    12db <OBJ_txt2obj+0x14b>
mov    -0x3c(%rbp),%esi
mov    0x2da7(%rip),%rax
mov    (%rax),%edx
xor    %edi,%edi
call   10b0 <ASN1_object_size@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1270 <OBJ_txt2obj+0xe0>
movq   $0x0,-0x8(%rbp)
jmp    12db <OBJ_txt2obj+0x14b>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x3c(%rbp),%edx
mov    0x2d66(%rip),%rax
mov    (%rax),%ecx
mov    0x2d4d(%rip),%rax
mov    (%rax),%r8d
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
call   10a0 <ASN1_put_object@plt>
mov    -0x30(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    $0xffffffff,%ecx
call   1060 <a2d_ASN1_OBJECT@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
lea    -0x38(%rbp),%rsi
call   1070 <d2i_ASN1_OBJECT@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OBJ_txt2obj>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
test   %esi,%esi
je     1250 <OBJ_txt2obj+0xc0>
xor    %ebx,%ebx
xor    %edi,%edi
xor    %esi,%esi
mov    %r14,%rdx
mov    $0xffffffff,%ecx
call   1060 <a2d_ASN1_OBJECT@plt>
test   %eax,%eax
jle    123e <OBJ_txt2obj+0xae>
mov    %eax,%ebp
mov    0x2e1f(%rip),%r13
mov    0x0(%r13),%edx
xor    %ebx,%ebx
xor    %edi,%edi
mov    %eax,%esi
call   10b0 <ASN1_object_size@plt>
mov    %eax,%r12d
mov    %eax,%edi
call   1090 <malloc@plt>
test   %rax,%rax
je     123e <OBJ_txt2obj+0xae>
mov    %rax,%r15
mov    %rax,0x8(%rsp)
mov    0x0(%r13),%ecx
mov    0x2dde(%rip),%rax
mov    (%rax),%r8d
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   10a0 <ASN1_put_object@plt>
mov    0x8(%rsp),%rdi
mov    %ebp,%esi
mov    %r14,%rdx
mov    $0xffffffff,%ecx
call   1060 <a2d_ASN1_OBJECT@plt>
mov    %r15,0x10(%rsp)
lea    0x10(%rsp),%rsi
xor    %edi,%edi
mov    %r12d,%edx
call   1070 <d2i_ASN1_OBJECT@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14,%rdi
call   1040 <OBJ_sn2nid@plt>
mov    0x2d71(%rip),%rbx
cmp    (%rbx),%eax
jne    1273 <OBJ_txt2obj+0xe3>
mov    %r14,%rdi
call   1080 <OBJ_ln2nid@plt>
cmp    (%rbx),%eax
je     11a9 <OBJ_txt2obj+0x19>
mov    %eax,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <OBJ_nid2obj@plt>

LLVM IR (-O0):
@NID_undef = global i32 0
@V_ASN1_OBJECT = global i32 0
@V_ASN1_UNIVERSAL = global i32 0
define i32* @OBJ_txt2obj(i8* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%13 = load i32, i32* @NID_undef
store i32 %13, i32* %6
store i32* null, i32** %7
%14 = load i32, i32* %5
%15 = icmp ne i32 %14, 0
br i1 %15, label %30, label %16
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = call i32 @OBJ_sn2nid(i8* %17)
store i32 %18, i32* %6
%19 = load i32, i32* @NID_undef
%20 = icmp ne i32 %18, %19
br i1 %20, label %26, label %21
21: ; preds = %16
%22 = load i8*, i8** %4
%23 = call i32 @OBJ_ln2nid(i8* %22)
store i32 %23, i32* %6
%24 = load i32, i32* @NID_undef
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %21, %16
%27 = load i32, i32* %6
%28 = call i32* @OBJ_nid2obj(i32 %27)
store i32* %28, i32** %3
br label %60
29: ; preds = %21
br label %30
30: ; preds = %29, %2
%31 = load i8*, i8** %4
%32 = call i32 @a2d_ASN1_OBJECT(i8* null, i32 0, i8* %31, i32 -1)
store i32 %32, i32* %11
%33 = load i32, i32* %11
%34 = icmp sle i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
store i32* null, i32** %3
br label %60
36: ; preds = %30
%37 = load i32, i32* %11
%38 = load i32, i32* @V_ASN1_OBJECT
%39 = call i32 @ASN1_object_size(i32 0, i32 %37, i32 %38)
store i32 %39, i32* %12
%40 = load i32, i32* %12
%41 = call i8* @malloc(i32 %40)
store i8* %41, i8** %8
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %44
43: ; preds = %36
store i32* null, i32** %3
br label %60
44: ; preds = %36
%45 = load i8*, i8** %8
store i8* %45, i8** %9
%46 = load i32, i32* %11
%47 = load i32, i32* @V_ASN1_OBJECT
%48 = load i32, i32* @V_ASN1_UNIVERSAL
%49 = call i32 @ASN1_put_object(i8** %9, i32 0, i32 %46, i32 %47, i32 %48)
%50 = load i8*, i8** %9
%51 = load i32, i32* %11
%52 = load i8*, i8** %4
%53 = call i32 @a2d_ASN1_OBJECT(i8* %50, i32 %51, i8* %52, i32 -1)
%54 = load i8*, i8** %8
store i8* %54, i8** %10
%55 = load i32, i32* %12
%56 = call i32* @d2i_ASN1_OBJECT(i32* null, i8** %10, i32 %55)
store i32* %56, i32** %7
%57 = load i8*, i8** %8
%58 = call i32 @free(i8* %57)
%59 = load i32*, i32** %7
store i32* %59, i32** %3
br label %60
60: ; preds = %44, %43, %35, %26
%61 = load i32*, i32** %3
ret i32* %61
}

LLVM IR (-O2):
@NID_undef = global i32 0
@V_ASN1_OBJECT = global i32 0
@V_ASN1_UNIVERSAL = global i32 0
define i32* @OBJ_txt2obj(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i8** %3 to i8*
%6 = bitcast i8** %4 to i8*
%7 = icmp eq i32 %1, 0
br i1 %7, label %8, label %19
8: ; preds = %2
%9 = tail call i32 @OBJ_sn2nid(i8* %0)
%10 = load i32, i32* @NID_undef
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = tail call i32 @OBJ_ln2nid(i8* %0)
%14 = load i32, i32* @NID_undef
%15 = icmp eq i32 %13, %14
br i1 %15, label %19, label %16
16: ; preds = %12, %8
%17 = phi i32 [ %9, %8 ], [ %13, %12 ]
%18 = tail call i32* @OBJ_nid2obj(i32 %17)
br label %35
19: ; preds = %12, %2
%20 = tail call i32 @a2d_ASN1_OBJECT(i8* null, i32 0, i8* %0, i32 -1)
%21 = icmp slt i32 %20, 1
br i1 %21, label %35, label %22
22: ; preds = %19
%23 = load i32, i32* @V_ASN1_OBJECT
%24 = tail call i32 @ASN1_object_size(i32 0, i32 %20, i32 %23)
%25 = tail call i8* @malloc(i32 %24)
%26 = icmp eq i8* %25, null
br i1 %26, label %35, label %27
27: ; preds = %22
store i8* %25, i8** %3
%28 = load i32, i32* @V_ASN1_OBJECT
%29 = load i32, i32* @V_ASN1_UNIVERSAL
%30 = call i32 @ASN1_put_object(i8** %3, i32 0, i32 %20, i32 %28, i32 %29)
%31 = load i8*, i8** %3
%32 = call i32 @a2d_ASN1_OBJECT(i8* %31, i32 %20, i8* %0, i32 -1)
store i8* %25, i8** %4
%33 = call i32* @d2i_ASN1_OBJECT(i32* null, i8** %4, i32 %24)
%34 = call i32 @free(i8* %25)
br label %35
35: ; preds = %22, %19, %27, %16
%36 = phi i32* [ %33, %27 ], [ %18, %16 ], [ null, %19 ], [ null, %22 ]
ret i32* %36
}