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

/* Variables and functions */
int /*<<< orphan*/ ASN1_OBJECT_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ ERR_asprintf_error_data(char *, char const *);
int /*<<< orphan*/ *OBJ_txt2obj(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ *X509_NAME_ENTRY_create_by_OBJ(int /*<<< orphan*/ **,
                                                  int /*<<< orphan*/ *, int,
                                                  unsigned char const *, int);
int /*<<< orphan*/ X509_R_INVALID_FIELD_NAME;
int /*<<< orphan*/ X509error(int /*<<< orphan*/);
X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
                                               const char *field, int type,
                                               const unsigned char *bytes,
                                               int len) {
  ASN1_OBJECT *obj;
  X509_NAME_ENTRY *nentry;
  obj = OBJ_txt2obj(field, 0);
  if (obj == NULL) {
    X509error(X509_R_INVALID_FIELD_NAME);
    ERR_asprintf_error_data("name=%s", field);
    return (NULL);
  }
  nentry = X509_NAME_ENTRY_create_by_OBJ(ne, obj, type, bytes, len);
  ASN1_OBJECT_free(obj);
  return nentry;
}


x86 assembly (clang, -O0):
<X509_NAME_ENTRY_create_by_txt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1040 <OBJ_txt2obj@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11b0 <X509_NAME_ENTRY_create_by_txt+0x60>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
call   1050 <X509error@plt>
mov    -0x18(%rbp),%rsi
lea    0xe62(%rip),%rdi
call   1030 <ERR_asprintf_error_data@plt>
movq   $0x0,-0x8(%rbp)
jmp    11dd <X509_NAME_ENTRY_create_by_txt+0x8d>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
call   1070 <X509_NAME_ENTRY_create_by_OBJ@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <ASN1_OBJECT_free@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<X509_NAME_ENTRY_create_by_txt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %edx,%r12d
mov    %rsi,%rbx
mov    %rdi,%r13
mov    %rsi,%rdi
xor    %esi,%esi
call   1040 <OBJ_txt2obj@plt>
test   %rax,%rax
je     11a0 <X509_NAME_ENTRY_create_by_txt+0x50>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %rax,%rsi
mov    %r12d,%edx
mov    %r15,%rcx
mov    %r14d,%r8d
call   1070 <X509_NAME_ENTRY_create_by_OBJ@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1060 <ASN1_OBJECT_free@plt>
mov    %rbx,%rax
jmp    11bf <X509_NAME_ENTRY_create_by_txt+0x6f>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1050 <X509error@plt>
lea    0xe4b(%rip),%rdi
mov    %rbx,%rsi
call   1030 <ERR_asprintf_error_data@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@X509_R_INVALID_FIELD_NAME = global i32 0
@.str = [8 x i8] c"name=%s\00"
define i32* @X509_NAME_ENTRY_create_by_txt(i32** %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32**
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
store i32** %0, i32*** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%14 = load i8*, i8** %8
%15 = call i32* @OBJ_txt2obj(i8* %14, i32 0)
store i32* %15, i32** %12
%16 = load i32*, i32** %12
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %23
18: ; preds = %5
%19 = load i32, i32* @X509_R_INVALID_FIELD_NAME
%20 = call i32 @X509error(i32 %19)
%21 = load i8*, i8** %8
%22 = call i32 @ERR_asprintf_error_data(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %21)
store i32* null, i32** %6
br label %33
23: ; preds = %5
%24 = load i32**, i32*** %7
%25 = load i32*, i32** %12
%26 = load i32, i32* %9
%27 = load i8*, i8** %10
%28 = load i32, i32* %11
%29 = call i32* @X509_NAME_ENTRY_create_by_OBJ(i32** %24, i32* %25, i32 %26, i8* %27, i32 %28)
store i32* %29, i32** %13
%30 = load i32*, i32** %12
%31 = call i32 @ASN1_OBJECT_free(i32* %30)
%32 = load i32*, i32** %13
store i32* %32, i32** %6
br label %33
33: ; preds = %23, %18
%34 = load i32*, i32** %6
ret i32* %34
}

LLVM IR (-O2):
@X509_R_INVALID_FIELD_NAME = global i32 0
@.str = [8 x i8] c"name=%s\00"
define i32* @X509_NAME_ENTRY_create_by_txt(i32** %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = tail call i32* @OBJ_txt2obj(i8* %1, i32 0)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %5
%9 = load i32, i32* @X509_R_INVALID_FIELD_NAME
%10 = tail call i32 @X509error(i32 %9)
%11 = tail call i32 @ERR_asprintf_error_data(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %15
12: ; preds = %5
%13 = tail call i32* @X509_NAME_ENTRY_create_by_OBJ(i32** %0, i32* %6, i32 %2, i8* %3, i32 %4)
%14 = tail call i32 @ASN1_OBJECT_free(i32* %6)
br label %15
15: ; preds = %12, %8
%16 = phi i32* [ null, %8 ], [ %13, %12 ]
ret i32* %16
}