#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ X509_EXTENSION;
typedef int /*<<< orphan*/ X509;
struct TYPE_3__ {
  int length;
  unsigned char const *data;
};
typedef TYPE_1__ ASN1_OCTET_STRING;

/* Variables and functions */
TYPE_1__ *X509_EXTENSION_get_data(int /*<<< orphan*/ *);
int /*<<< orphan*/ *X509_get_ext(int /*<<< orphan*/ *, int);
int X509_get_ext_by_NID(int /*<<< orphan*/ *, int, int);
const unsigned char *get_extention(X509 *x, int NID, int *data_len) {
  int loc;
  ASN1_OCTET_STRING *octet_str;
  long xlen;
  int tag, xclass;
  loc = X509_get_ext_by_NID(x, NID, -1);
  X509_EXTENSION *ex = X509_get_ext(x, loc);
  octet_str = X509_EXTENSION_get_data(ex);
  *data_len = octet_str->length;
  return octet_str->data;
}


x86 assembly (clang, -O0):
<get_extention>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0xffffffff,%edx
call   1040 <X509_get_ext_by_NID@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <X509_get_ext@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   1050 <X509_EXTENSION_get_data@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_extention>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
mov    $0xffffffff,%edx
call   1040 <X509_get_ext_by_NID@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <X509_get_ext@plt>
mov    %rax,%rdi
call   1050 <X509_EXTENSION_get_data@plt>
mov    (%rax),%ecx
mov    %ecx,(%r14)
mov    0x8(%rax),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i8* }
define i8* @get_extention(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca %struct.TYPE_3__*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%13 = load i32*, i32** %4
%14 = load i32, i32* %5
%15 = call i32 @X509_get_ext_by_NID(i32* %13, i32 %14, i32 -1)
store i32 %15, i32* %7
%16 = load i32*, i32** %4
%17 = load i32, i32* %7
%18 = call i32* @X509_get_ext(i32* %16, i32 %17)
store i32* %18, i32** %12
%19 = load i32*, i32** %12
%20 = call %struct.TYPE_3__* @X509_EXTENSION_get_data(i32* %19)
store %struct.TYPE_3__* %20, %struct.TYPE_3__** %8
%21 = load %struct.TYPE_3__*, %struct.TYPE_3__** %8
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = load i32*, i32** %6
store i32 %23, i32* %24
%25 = load %struct.TYPE_3__*, %struct.TYPE_3__** %8
%26 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %25, i32 0, i32 1
%27 = load i8*, i8** %26
ret i8* %27
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i8* }
define i8* @get_extention(i32* %0, i32 %1, i32* nocapture writeonly %2) {
%4 = tail call i32 @X509_get_ext_by_NID(i32* %0, i32 %1, i32 -1)
%5 = tail call i32* @X509_get_ext(i32* %0, i32 %4)
%6 = tail call %struct.TYPE_3__* @X509_EXTENSION_get_data(i32* %5)
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i64 0, i32 0
%8 = load i32, i32* %7
store i32 %8, i32* %2
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i64 0, i32 1
%10 = load i8*, i8** %9
ret i8* %10
}