#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_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int flags;
  int enc_offset;
};
struct TYPE_4__ {
  TYPE_2__ *funcs;
};
typedef int /*<<< orphan*/ ASN1_VALUE;
typedef TYPE_1__ ASN1_ITEM;
typedef void ASN1_ENCODING;
typedef TYPE_2__ ASN1_AUX;

/* Variables and functions */
int ASN1_AFLG_ENCODING;
ASN1_ENCODING *asn1_get_enc_ptr(ASN1_VALUE **pval, const ASN1_ITEM *it) {
  const ASN1_AUX *aux;
  if (!pval || !*pval)
    return NULL;
  aux = it->funcs;
  if (!aux || !(aux->flags & ASN1_AFLG_ENCODING))
    return NULL;
  return (void *)(((char *)*pval) + aux->enc_offset);
}


x86 assembly (clang, -O0):
<asn1_get_enc_ptr>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1125 <asn1_get_enc_ptr+0x25>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1132 <asn1_get_enc_ptr+0x32>
movq   $0x0,-0x8(%rbp)
jmp    1183 <asn1_get_enc_ptr+0x83>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1160 <asn1_get_enc_ptr+0x60>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    0x2e93(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    116d <asn1_get_enc_ptr+0x6d>
movq   $0x0,-0x8(%rbp)
jmp    1183 <asn1_get_enc_ptr+0x83>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
movslq 0x4(%rcx),%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<asn1_get_enc_ptr>:
test   %rdi,%rdi
je     112a <asn1_get_enc_ptr+0x2a>
mov    (%rdi),%rax
test   %rax,%rax
je     112a <asn1_get_enc_ptr+0x2a>
mov    (%rsi),%rcx
test   %rcx,%rcx
je     112a <asn1_get_enc_ptr+0x2a>
mov    0x2ecc(%rip),%rdx
mov    (%rdx),%edx
test   %edx,(%rcx)
je     112a <asn1_get_enc_ptr+0x2a>
movslq 0x4(%rcx),%rcx
add    %rcx,%rax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i32, i32 }
@ASN1_AFLG_ENCODING = global i32 0
define i8* @asn1_get_enc_ptr(i32** %0, %struct.TYPE_4__* %1) {
%3 = alloca i8*
%4 = alloca i32**
%5 = alloca %struct.TYPE_4__*
%6 = alloca %struct.TYPE_5__*
store i32** %0, i32*** %4
store %struct.TYPE_4__* %1, %struct.TYPE_4__** %5
%7 = load i32**, i32*** %4
%8 = icmp ne i32** %7, null
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32**, i32*** %4
%11 = load i32*, i32** %10
%12 = icmp ne i32* %11, null
br i1 %12, label %14, label %13
13: ; preds = %9, %2
store i8* null, i8** %3
br label %37
14: ; preds = %9
%15 = load %struct.TYPE_4__*, %struct.TYPE_4__** %5
%16 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %15, i32 0, i32 0
%17 = load %struct.TYPE_5__*, %struct.TYPE_5__** %16
store %struct.TYPE_5__* %17, %struct.TYPE_5__** %6
%18 = load %struct.TYPE_5__*, %struct.TYPE_5__** %6
%19 = icmp ne %struct.TYPE_5__* %18, null
br i1 %19, label %20, label %27
20: ; preds = %14
%21 = load %struct.TYPE_5__*, %struct.TYPE_5__** %6
%22 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = load i32, i32* @ASN1_AFLG_ENCODING
%25 = and i32 %23, %24
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %20, %14
store i8* null, i8** %3
br label %37
28: ; preds = %20
%29 = load i32**, i32*** %4
%30 = load i32*, i32** %29
%31 = bitcast i32* %30 to i8*
%32 = load %struct.TYPE_5__*, %struct.TYPE_5__** %6
%33 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %32, i32 0, i32 1
%34 = load i32, i32* %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %31, i64 %35
store i8* %36, i8** %3
br label %37
37: ; preds = %28, %27, %13
%38 = load i8*, i8** %3
ret i8* %38
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i32, i32 }
@ASN1_AFLG_ENCODING = global i32 0
define i8* @asn1_get_enc_ptr(i32** %0, %struct.TYPE_4__* nocapture %1) {
%3 = icmp eq i32** %0, null
br i1 %3, label %23, label %4
4: ; preds = %2
%5 = load i32*, i32** %0
%6 = icmp eq i32* %5, null
br i1 %6, label %23, label %7
7: ; preds = %4
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 0
%9 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%10 = icmp eq %struct.TYPE_5__* %9, null
br i1 %10, label %23, label %11
11: ; preds = %7
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i64 0, i32 0
%13 = load i32, i32* %12
%14 = load i32, i32* @ASN1_AFLG_ENCODING
%15 = and i32 %14, %13
%16 = icmp eq i32 %15, 0
br i1 %16, label %23, label %17
17: ; preds = %11
%18 = bitcast i32* %5 to i8*
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i64 0, i32 1
%20 = load i32, i32* %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %18, i64 %21
br label %23
23: ; preds = %7, %11, %2, %4, %17
%24 = phi i8* [ %22, %17 ], [ null, %4 ], [ null, %2 ], [ null, %11 ], [ null, %7 ]
ret i8* %24
}