#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_1__;

/* Type definitions */
typedef int /*<<< orphan*/ X509V3_EXT_METHOD;
typedef int /*<<< orphan*/ X509V3_CTX;
struct TYPE_5__ {
  long length;
  int /*<<< orphan*/ data;
};
typedef TYPE_1__ ASN1_OCTET_STRING;

/* Variables and functions */
int /*<<< orphan*/ ASN1_OCTET_STRING_free(TYPE_1__ *);
TYPE_1__ *ASN1_OCTET_STRING_new();
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int /*<<< orphan*/ X509V3error(int /*<<< orphan*/);
int /*<<< orphan*/ string_to_hex(char const *, long *);
ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method,
                                         X509V3_CTX *ctx, const char *str) {
  ASN1_OCTET_STRING *oct;
  long length;
  if (!(oct = ASN1_OCTET_STRING_new())) {
    X509V3error(ERR_R_MALLOC_FAILURE);
    return NULL;
  }
  if (!(oct->data = string_to_hex(str, &length))) {
    ASN1_OCTET_STRING_free(oct);
    return NULL;
  }
  oct->length = length;
  return oct;
}


x86 assembly (clang, -O0):
<s2i_ASN1_OCTET_STRING>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    $0x0,%al
call   1030 <ASN1_OCTET_STRING_new@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1184 <s2i_ASN1_OCTET_STRING+0x44>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1050 <X509V3error@plt>
movq   $0x0,-0x8(%rbp)
jmp    11ca <s2i_ASN1_OCTET_STRING+0x8a>
mov    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <string_to_hex@plt>
mov    -0x28(%rbp),%rcx
mov    %eax,0x8(%rcx)
cmp    $0x0,%eax
jne    11b7 <s2i_ASN1_OCTET_STRING+0x77>
mov    -0x28(%rbp),%rdi
call   1040 <ASN1_OCTET_STRING_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11ca <s2i_ASN1_OCTET_STRING+0x8a>
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<s2i_ASN1_OCTET_STRING>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
xor    %eax,%eax
call   1030 <ASN1_OCTET_STRING_new@plt>
test   %rax,%rax
je     1171 <s2i_ASN1_OCTET_STRING+0x31>
mov    %rax,%rbx
mov    %rsp,%rsi
mov    %r14,%rdi
call   1060 <string_to_hex@plt>
mov    %eax,0x8(%rbx)
test   %eax,%eax
je     1181 <s2i_ASN1_OCTET_STRING+0x41>
mov    (%rsp),%rax
mov    %rax,(%rbx)
jmp    118b <s2i_ASN1_OCTET_STRING+0x4b>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
call   1050 <X509V3error@plt>
jmp    1189 <s2i_ASN1_OCTET_STRING+0x49>
mov    %rbx,%rdi
call   1040 <ASN1_OCTET_STRING_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i64, i32 }
@ERR_R_MALLOC_FAILURE = global i32 0
define %struct.TYPE_5__* @s2i_ASN1_OCTET_STRING(i32* %0, i32* %1, i8* %2) {
%4 = alloca %struct.TYPE_5__*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca %struct.TYPE_5__*
%9 = alloca i64
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
%10 = call %struct.TYPE_5__* (...) @ASN1_OCTET_STRING_new()
store %struct.TYPE_5__* %10, %struct.TYPE_5__** %8
%11 = icmp ne %struct.TYPE_5__* %10, null
br i1 %11, label %15, label %12
12: ; preds = %3
%13 = load i32, i32* @ERR_R_MALLOC_FAILURE
%14 = call i32 @X509V3error(i32 %13)
store %struct.TYPE_5__* null, %struct.TYPE_5__** %4
br label %29
15: ; preds = %3
%16 = load i8*, i8** %7
%17 = call i32 @string_to_hex(i8* %16, i64* %9)
%18 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %18, i32 0, i32 1
store i32 %17, i32* %19
%20 = icmp ne i32 %17, 0
br i1 %20, label %24, label %21
21: ; preds = %15
%22 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%23 = call i32 @ASN1_OCTET_STRING_free(%struct.TYPE_5__* %22)
store %struct.TYPE_5__* null, %struct.TYPE_5__** %4
br label %29
24: ; preds = %15
%25 = load i64, i64* %9
%26 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%27 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %26, i32 0, i32 0
store i64 %25, i64* %27
%28 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
store %struct.TYPE_5__* %28, %struct.TYPE_5__** %4
br label %29
29: ; preds = %24, %21, %12
%30 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
ret %struct.TYPE_5__* %30
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i64, i32 }
@ERR_R_MALLOC_FAILURE = global i32 0
define %struct.TYPE_5__* @s2i_ASN1_OCTET_STRING(i32* nocapture readnone %0, i32* nocapture readnone %1, i8* %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
%6 = tail call %struct.TYPE_5__* (...) @ASN1_OCTET_STRING_new()
%7 = icmp eq %struct.TYPE_5__* %6, null
br i1 %7, label %8, label %11
8: ; preds = %3
%9 = load i32, i32* @ERR_R_MALLOC_FAILURE
%10 = tail call i32 @X509V3error(i32 %9)
br label %20
11: ; preds = %3
%12 = call i32 @string_to_hex(i8* %2, i64* %4)
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 1
store i32 %12, i32* %13
%14 = icmp eq i32 %12, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @ASN1_OCTET_STRING_free(%struct.TYPE_5__* %6)
br label %20
17: ; preds = %11
%18 = load i64, i64* %4
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 0
store i64 %18, i64* %19
br label %20
20: ; preds = %17, %15, %8
%21 = phi %struct.TYPE_5__* [ %6, %17 ], [ null, %15 ], [ null, %8 ]
ret %struct.TYPE_5__* %21
}