#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*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ *realloc(int /*<<< orphan*/ *, int);
int script_unhexlify(int /*<<< orphan*/ *, int, char const *);
int strlen(char const *);
int parse_opt_u8(const char *src, uint8_t **dst) {
  int len = strlen(src);
  *dst = realloc(*dst, len / 2);
  if (!*dst)
    return -1;
  return script_unhexlify(*dst, len, src);
}


x86 assembly (clang, -O0):
<parse_opt_u8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1189 <parse_opt_u8+0x59>
movl   $0xffffffff,-0x4(%rbp)
jmp    119f <parse_opt_u8+0x6f>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1040 <script_unhexlify@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_opt_u8>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %eax,%ebp
mov    (%rbx),%rdi
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
call   1050 <realloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     116b <parse_opt_u8+0x3b>
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <script_unhexlify@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @parse_opt_u8(i8* %0, i32** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32**
%6 = alloca i32
store i8* %0, i8** %4
store i32** %1, i32*** %5
%7 = load i8*, i8** %4
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %6
%9 = load i32**, i32*** %5
%10 = load i32*, i32** %9
%11 = load i32, i32* %6
%12 = sdiv i32 %11, 2
%13 = call i32* @realloc(i32* %10, i32 %12)
%14 = load i32**, i32*** %5
store i32* %13, i32** %14
%15 = load i32**, i32*** %5
%16 = load i32*, i32** %15
%17 = icmp ne i32* %16, null
br i1 %17, label %19, label %18
18: ; preds = %2
store i32 -1, i32* %3
br label %25
19: ; preds = %2
%20 = load i32**, i32*** %5
%21 = load i32*, i32** %20
%22 = load i32, i32* %6
%23 = load i8*, i8** %4
%24 = call i32 @script_unhexlify(i32* %21, i32 %22, i8* %23)
store i32 %24, i32* %3
br label %25
25: ; preds = %19, %18
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @parse_opt_u8(i8* %0, i32** nocapture %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = load i32*, i32** %1
%5 = sdiv i32 %3, 2
%6 = tail call i32* @realloc(i32* %4, i32 %5)
store i32* %6, i32** %1
%7 = icmp eq i32* %6, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @script_unhexlify(i32* %6, i32 %3, i8* %0)
br label %10
10: ; preds = %2, %8
%11 = phi i32 [ %9, %8 ], [ -1, %2 ]
ret i32 %11
}