#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_F_X509V3_EXT_I2D;
int /*<<< orphan*/ X509V3_R_UNKNOWN_EXTENSION;
int /*<<< orphan*/ X509V3err(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ *do_ext_i2d(int /*<<< orphan*/ *, int, int, void *);
X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc) {
  X509V3_EXT_METHOD *method;
  if (!(method = X509V3_EXT_get_nid(ext_nid))) {
    X509V3err(X509V3_F_X509V3_EXT_I2D, 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   1040 <X509V3_EXT_get_nid@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    117c <X509V3_EXT_i2d+0x4c>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
call   1050 <X509V3err@plt>
movq   $0x0,-0x8(%rbp)
jmp    1193 <X509V3_EXT_i2d+0x63>
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1030 <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   1040 <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    1030 <do_ext_i2d@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
call   1050 <X509V3err@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@X509V3_F_X509V3_EXT_I2D = global i32 0
@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 %16, label %12
12: ; preds = %3
%13 = load i32, i32* @X509V3_F_X509V3_EXT_I2D
%14 = load i32, i32* @X509V3_R_UNKNOWN_EXTENSION
%15 = call i32 @X509V3err(i32 %13, i32 %14)
store i32* null, i32** %4
br label %22
16: ; preds = %3
%17 = load i32*, i32** %8
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = load i8*, i8** %7
%21 = call i32* @do_ext_i2d(i32* %17, i32 %18, i32 %19, i8* %20)
store i32* %21, i32** %4
br label %22
22: ; preds = %16, %12
%23 = load i32*, i32** %4
ret i32* %23
}

LLVM IR (-O2):
@X509V3_F_X509V3_EXT_I2D = global i32 0
@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 %10
6: ; preds = %3
%7 = load i32, i32* @X509V3_F_X509V3_EXT_I2D
%8 = load i32, i32* @X509V3_R_UNKNOWN_EXTENSION
%9 = tail call i32 @X509V3err(i32 %7, i32 %8)
br label %12
10: ; preds = %3
%11 = tail call i32* @do_ext_i2d(i32* %4, i32 %0, i32 %1, i8* %2)
br label %12
12: ; preds = %10, %6
%13 = phi i32* [ %11, %10 ], [ null, %6 ]
ret i32* %13
}