#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 uint64_t;
typedef scalar_t__ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
size_t strlen(char const *);
int strtoul(char const *, char **, int);
void hex_string_to_bytes(const char *src, uint32_t array[2]) {
  const size_t string_len = strlen(src);
  if (string_len > 16) {
    fprintf(stderr, "Error: Input string longer than expected\n");
    return;
  }
  char **end_ptr = NULL;
  const uint64_t value_as_uint64 = strtoul(src, end_ptr, 16);
  array[0] = (uint32_t)((value_as_uint64 >> 32) & 0xFFFFFFFF);
  array[1] = (uint32_t)(value_as_uint64 & 0xFFFFFFFF);
}


x86 assembly (clang, -O0):
<hex_string_to_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x10,-0x18(%rbp)
jbe    1172 <hex_string_to_bytes+0x42>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11b9 <hex_string_to_bytes+0x89>
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1050 <strtoul@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
and    $0xffffffff,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x24(%rbp),%eax
and    $0xffffffff,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_string_to_bytes>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0x11,%rax
jb     1161 <hex_string_to_bytes+0x31>
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
lea    0xeab(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fprintf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <strtoul@plt>
mov    %eax,%eax
mov    %rax,0x8(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [42 x i8] c"Error: Input string longer than expected\0A\00"
define void @hex_string_to_bytes(i8* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i64*
%5 = alloca i64
%6 = alloca i8**
%7 = alloca i32
store i8* %0, i8** %3
store i64* %1, i64** %4
%8 = load i8*, i8** %3
%9 = call i64 @strlen(i8* %8)
store i64 %9, i64* %5
%10 = load i64, i64* %5
%11 = icmp ugt i64 %10, 16
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %30
15: ; preds = %2
store i8** null, i8*** %6
%16 = load i8*, i8** %3
%17 = load i8**, i8*** %6
%18 = call i32 @strtoul(i8* %16, i8** %17, i32 16)
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = ashr i32 %19, 32
%21 = and i32 %20, -1
%22 = zext i32 %21 to i64
%23 = load i64*, i64** %4
%24 = getelementptr inbounds i64, i64* %23, i64 0
store i64 %22, i64* %24
%25 = load i32, i32* %7
%26 = and i32 %25, -1
%27 = zext i32 %26 to i64
%28 = load i64*, i64** %4
%29 = getelementptr inbounds i64, i64* %28, i64 1
store i64 %27, i64* %29
br label %30
30: ; preds = %15, %12
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [42 x i8] c"Error: Input string longer than expected\0A\00"
define void @hex_string_to_bytes(i8* nocapture %0, i64* nocapture writeonly %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = icmp ugt i64 %3, 16
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %12
8: ; preds = %2
%9 = tail call i32 @strtoul(i8* nocapture %0, i8** null, i32 16)
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i64, i64* %1, i64 1
store i64 %10, i64* %11
br label %12
12: ; preds = %8, %5
ret void
}