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

/* Variables and functions */
int /*<<< orphan*/ *X509_NAME_ENTRY_create_by_NID(int /*<<< orphan*/ *, int,
                                                  int, unsigned char const *,
                                                  int);
int /*<<< orphan*/ X509_NAME_ENTRY_free(int /*<<< orphan*/ *);
int X509_NAME_add_entry(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int, int);
int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type,
                               const unsigned char *bytes, int len, int loc,
                               int set) {
  X509_NAME_ENTRY *ne;
  int ret;
  ne = X509_NAME_ENTRY_create_by_NID(NULL, nid, type, bytes, len);
  if (!ne)
    return 0;
  ret = X509_NAME_add_entry(name, ne, loc, set);
  X509_NAME_ENTRY_free(ne);
  return ret;
}


x86 assembly (clang, -O0):
<X509_NAME_add_entry_by_NID>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
call   1040 <X509_NAME_ENTRY_create_by_NID@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1183 <X509_NAME_add_entry_by_NID+0x53>
movl   $0x0,-0x4(%rbp)
jmp    11a8 <X509_NAME_add_entry_by_NID+0x78>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%edx
mov    0x10(%rbp),%ecx
call   1030 <X509_NAME_add_entry@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <X509_NAME_ENTRY_free@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<X509_NAME_add_entry_by_NID>:
push   %rbp
push   %r14
push   %rbx
mov    %r9d,%r14d
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <X509_NAME_ENTRY_create_by_NID@plt>
test   %rax,%rax
je     1169 <X509_NAME_add_entry_by_NID+0x39>
mov    %rax,%rbp
mov    0x20(%rsp),%ecx
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r14d,%edx
call   1030 <X509_NAME_add_entry@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1050 <X509_NAME_ENTRY_free@plt>
mov    %ebx,%eax
jmp    116b <X509_NAME_add_entry_by_NID+0x3b>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @X509_NAME_add_entry_by_NID(i32* %0, i32 %1, i32 %2, i8* %3, i32 %4, i32 %5, i32 %6) {
%8 = tail call i32* @X509_NAME_ENTRY_create_by_NID(i32* null, i32 %1, i32 %2, i8* %3, i32 %4)
%9 = icmp eq i32* %8, null
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i32 @X509_NAME_add_entry(i32* %0, i32* %8, i32 %5, i32 %6)
%12 = tail call i32 @X509_NAME_ENTRY_free(i32* %8)
br label %13
13: ; preds = %7, %10
%14 = phi i32 [ %11, %10 ], [ 0, %7 ]
ret i32 %14
}