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

/* Variables and functions */
char *strtok(char *, char *);
long strtol(char *, char **, int);
void parse_to_array(char *in, char *out) {
  char *ptr, *err;
  long num, i = 0;
  ptr = strtok(in, " ");
  while (ptr != NULL) {
    num = strtol(ptr, &err, 16);
    out[i++] = num;
    ptr = strtok(NULL, " ");
  }
}


x86 assembly (clang, -O0):
<parse_to_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xebd(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a2 <parse_to_array+0x82>
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x30(%rbp)
mov    %dl,(%rax,%rcx,1)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe6c(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
jmp    114c <parse_to_array+0x2c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_to_array>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0xecd(%rip),%rsi
call   1040 <strtok@plt>
test   %rax,%rax
je     1175 <parse_to_array+0x55>
lea    0x8(%rsp),%r14
lea    0xeb7(%rip),%r15
nopl   0x0(%rax)
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0x10,%edx
call   1030 <strtol@plt>
mov    %al,(%rbx)
xor    %edi,%edi
mov    %r15,%rsi
call   1040 <strtok@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1150 <parse_to_array+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define void @parse_to_array(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
store i64 0, i64* %8
%9 = load i8*, i8** %3
%10 = call i8* @strtok(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %5
br label %11
11: ; preds = %14, %2
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i8*, i8** %5
%16 = call i64 @strtol(i8* %15, i8** %6, i32 16)
store i64 %16, i64* %7
%17 = load i64, i64* %7
%18 = trunc i64 %17 to i8
%19 = load i8*, i8** %4
%20 = load i64, i64* %8
%21 = add nsw i64 %20, 1
store i64 %21, i64* %8
%22 = getelementptr inbounds i8, i8* %19, i64 %20
store i8 %18, i8* %22
%23 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %23, i8** %5
br label %11
24: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define void @parse_to_array(i8* %0, i8* nocapture writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %16, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %12, %7 ], [ 0, %2 ]
%9 = phi i8* [ %14, %7 ], [ %5, %2 ]
%10 = call i64 @strtol(i8* %9, i8** %3, i32 16)
%11 = trunc i64 %10 to i8
%12 = add nuw nsw i64 %8, 1
%13 = getelementptr inbounds i8, i8* %1, i64 %8
store i8 %11, i8* %13
%14 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %7
16: ; preds = %7, %2
ret void
}