#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 */
struct TYPE_3__ {
  int /*<<< orphan*/ *sk;
};
typedef TYPE_1__ CRYPTO_EX_DATA;

/* Variables and functions */
int sk_void_num(int /*<<< orphan*/ *);
void *sk_void_value(int /*<<< orphan*/ *, int);
void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx) {
  if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
    return NULL;
  return sk_void_value(ad->sk, idx);
}


x86 assembly (clang, -O0):
<CRYPTO_get_ex_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     115c <CRYPTO_get_ex_data+0x3c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <sk_void_num@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jl     1169 <CRYPTO_get_ex_data+0x49>
movq   $0x0,-0x8(%rbp)
jmp    117c <CRYPTO_get_ex_data+0x5c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x14(%rbp),%esi
call   1030 <sk_void_value@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CRYPTO_get_ex_data>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1149 <CRYPTO_get_ex_data+0x29>
mov    %esi,%ebp
call   1040 <sk_void_num@plt>
cmp    %ebp,%eax
jle    1149 <CRYPTO_get_ex_data+0x29>
mov    (%rbx),%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <sk_void_value@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32* }
define i8* @CRYPTO_get_ex_data(%struct.TYPE_3__* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca %struct.TYPE_3__*
%5 = alloca i32
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %4
store i32 %1, i32* %5
%6 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 0
%8 = load i32*, i32** %7
%9 = icmp eq i32* %8, null
br i1 %9, label %17, label %10
10: ; preds = %2
%11 = load i32, i32* %5
%12 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 0
%14 = load i32*, i32** %13
%15 = call i32 @sk_void_num(i32* %14)
%16 = icmp sge i32 %11, %15
br i1 %16, label %17, label %18
17: ; preds = %10, %2
store i8* null, i8** %3
br label %24
18: ; preds = %10
%19 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %19, i32 0, i32 0
%21 = load i32*, i32** %20
%22 = load i32, i32* %5
%23 = call i8* @sk_void_value(i32* %21, i32 %22)
store i8* %23, i8** %3
br label %24
24: ; preds = %18, %17
%25 = load i8*, i8** %3
ret i8* %25
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32* }
define i8* @CRYPTO_get_ex_data(%struct.TYPE_3__* nocapture %0, i32 %1) {
%3 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%4 = load i32*, i32** %3
%5 = icmp eq i32* %4, null
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = tail call i32 @sk_void_num(i32* %4)
%8 = icmp sgt i32 %7, %1
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load i32*, i32** %3
%11 = tail call i8* @sk_void_value(i32* %10, i32 %1)
br label %12
12: ; preds = %2, %6, %9
%13 = phi i8* [ %11, %9 ], [ null, %6 ], [ null, %2 ]
ret i8* %13
}