#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_EXTENSION;
typedef int /*<<< orphan*/ X509V3_EXT_METHOD;

/* Variables and functions */
int /*<<< orphan*/ *X509V3_EXT_get_nid(int);
int /*<<< orphan*/ X509V3_R_UNKNOWN_EXTENSION;
int /*<<< orphan*/ X509V3error(int /*<<< orphan*/);
int /*<<< orphan*/ *do_ext_i2d(int /*<<< orphan*/ const *, int, int, void *);
X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc) {
  const X509V3_EXT_METHOD *method;
  if (!(method = X509V3_EXT_get_nid(ext_nid))) {
    X509V3error(X509V3_R_UNKNOWN_EXTENSION);
    return NULL;
  }
  return do_ext_i2d(method, ext_nid, crit, ext_struc);
}


x86 assembly (clang, -O0):
<X509V3_EXT_i2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <X509V3_EXT_get_nid@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1173 <X509V3_EXT_i2d+0x43>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
call   1030 <X509V3error@plt>
movq   $0x0,-0x8(%rbp)
jmp    118a <X509V3_EXT_i2d+0x5a>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1040 <do_ext_i2d@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<X509V3_EXT_i2d>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %edi,%ebx
call   1050 <X509V3_EXT_get_nid@plt>
test   %rax,%rax
je     1158 <X509V3_EXT_i2d+0x28>
mov    %rax,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14,%rcx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <do_ext_i2d@plt>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
call   1030 <X509V3error@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@X509V3_R_UNKNOWN_EXTENSION = global i32 0
define i32* @X509V3_EXT_i2d(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%9 = load i32, i32* %5
%10 = call i32* @X509V3_EXT_get_nid(i32 %9)
store i32* %10, i32** %8
%11 = icmp ne i32* %10, null
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load i32, i32* @X509V3_R_UNKNOWN_EXTENSION
%14 = call i32 @X509V3error(i32 %13)
store i32* null, i32** %4
br label %21
15: ; preds = %3
%16 = load i32*, i32** %8
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = load i8*, i8** %7
%20 = call i32* @do_ext_i2d(i32* %16, i32 %17, i32 %18, i8* %19)
store i32* %20, i32** %4
br label %21
21: ; preds = %15, %12
%22 = load i32*, i32** %4
ret i32* %22
}

LLVM IR (-O2):
@X509V3_R_UNKNOWN_EXTENSION = global i32 0
define i32* @X509V3_EXT_i2d(i32 %0, i32 %1, i8* %2) {
%4 = tail call i32* @X509V3_EXT_get_nid(i32 %0)
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = load i32, i32* @X509V3_R_UNKNOWN_EXTENSION
%8 = tail call i32 @X509V3error(i32 %7)
br label %11
9: ; preds = %3
%10 = tail call i32* @do_ext_i2d(i32* %4, i32 %0, i32 %1, i8* %2)
br label %11
11: ; preds = %9, %6
%12 = phi i32* [ %10, %9 ], [ null, %6 ]
ret i32* %12
}