#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_get_entry(int /*<<< orphan*/ *, long);
long X509_NAME_get_index_by_NID(int /*<<< orphan*/ *, unsigned long, long);
X509_NAME_ENTRY *req_GetNameENidI(X509_NAME *name, unsigned long nid,
                                  long offset) {
  long index;
  if (!name)
    return NULL;
  index = X509_NAME_get_index_by_NID(name, nid, offset);
  if (index < 0)
    return NULL;
  return X509_NAME_get_entry(name, index);
}


x86 assembly (clang, -O0):
<req_GetNameENidI>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114c <req_GetNameENidI+0x2c>
movq   $0x0,-0x8(%rbp)
jmp    118a <req_GetNameENidI+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <X509_NAME_get_index_by_NID@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    1179 <req_GetNameENidI+0x59>
movq   $0x0,-0x8(%rbp)
jmp    118a <req_GetNameENidI+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <X509_NAME_get_entry@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<req_GetNameENidI>:
push   %rbx
test   %rdi,%rdi
je     113f <req_GetNameENidI+0x1f>
mov    %rdi,%rbx
call   1040 <X509_NAME_get_index_by_NID@plt>
test   %rax,%rax
js     113f <req_GetNameENidI+0x1f>
mov    %rbx,%rdi
mov    %rax,%rsi
pop    %rbx
jmp    1030 <X509_NAME_get_entry@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32* @req_GetNameENidI(i32* %0, i64 %1, i64 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32* %0, i32** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%9 = load i32*, i32** %5
%10 = icmp ne i32* %9, null
br i1 %10, label %12, label %11
11: ; preds = %3
store i32* null, i32** %4
br label %24
12: ; preds = %3
%13 = load i32*, i32** %5
%14 = load i64, i64* %6
%15 = load i64, i64* %7
%16 = call i64 @X509_NAME_get_index_by_NID(i32* %13, i64 %14, i64 %15)
store i64 %16, i64* %8
%17 = load i64, i64* %8
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %12
store i32* null, i32** %4
br label %24
20: ; preds = %12
%21 = load i32*, i32** %5
%22 = load i64, i64* %8
%23 = call i32* @X509_NAME_get_entry(i32* %21, i64 %22)
store i32* %23, i32** %4
br label %24
24: ; preds = %20, %19, %11
%25 = load i32*, i32** %4
ret i32* %25
}

LLVM IR (-O2):
define i32* @req_GetNameENidI(i32* %0, i64 %1, i64 %2) {
%4 = icmp eq i32* %0, null
br i1 %4, label %10, label %5
5: ; preds = %3
%6 = tail call i64 @X509_NAME_get_index_by_NID(i32* %0, i64 %1, i64 %2)
%7 = icmp slt i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32* @X509_NAME_get_entry(i32* %0, i64 %6)
br label %10
10: ; preds = %5, %3, %8
%11 = phi i32* [ %9, %8 ], [ null, %3 ], [ null, %5 ]
ret i32* %11
}