#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_r(char *, char *, char **);
scalar_t__ strtol(char *, char **, int);
int stringToChars(char *valueBuffer, char *data, int nvalues) {
  int i = 0;
  char *delim = " ";
  char *token = NULL;
  char *brkt;
  for (token = strtok_r(valueBuffer, delim, &brkt); token != NULL;
       token = strtok_r(NULL, delim, &brkt)) {
    char *unconverted;
    data[i] = (char)strtol(token, &unconverted, 10);
    i++;
  }
  if (i < nvalues - 1) {
    return 0;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<stringToChars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xebf(%rip),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11af <stringToChars+0x8f>
mov    -0x30(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x38(%rbp),%rdx
call   1030 <strtok_r@plt>
mov    %rax,-0x30(%rbp)
jmp    1162 <stringToChars+0x42>
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11cc <stringToChars+0xac>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <stringToChars+0xb3>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stringToChars>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r14d
mov    %rsi,%rbx
lea    0xec5(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1030 <strtok_r@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1189 <stringToChars+0x69>
lea    0x10(%rsp),%r15
lea    0xea8(%rip),%r12
lea    0x8(%rsp),%r13
nopl   (%rax)
mov    %rax,%rdi
mov    %r15,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %al,(%rbx,%rbp,1)
add    $0x1,%rbp
xor    %edi,%edi
mov    %r12,%rsi
mov    %r13,%rdx
call   1030 <strtok_r@plt>
test   %rax,%rax
jne    1160 <stringToChars+0x40>
add    $0xffffffff,%r14d
xor    %eax,%eax
cmp    %r14d,%ebp
setge  %al
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i32 @stringToChars(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 0, i32* %8
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %9
store i8* null, i8** %10
%13 = load i8*, i8** %5
%14 = load i8*, i8** %9
%15 = call i8* @strtok_r(i8* %13, i8* %14, i8** %11)
store i8* %15, i8** %10
br label %16
16: ; preds = %29, %3
%17 = load i8*, i8** %10
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %32
19: ; preds = %16
%20 = load i8*, i8** %10
%21 = call i64 @strtol(i8* %20, i8** %12, i32 10)
%22 = trunc i64 %21 to i8
%23 = load i8*, i8** %6
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 %22, i8* %26
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %29
29: ; preds = %19
%30 = load i8*, i8** %9
%31 = call i8* @strtok_r(i8* null, i8* %30, i8** %11)
store i8* %31, i8** %10
br label %16
32: ; preds = %16
%33 = load i32, i32* %8
%34 = load i32, i32* %7
%35 = sub nsw i32 %34, 1
%36 = icmp slt i32 %33, %35
br i1 %36, label %37, label %38
37: ; preds = %32
store i32 0, i32* %4
br label %39
38: ; preds = %32
store i32 1, i32* %4
br label %39
39: ; preds = %38, %37
%40 = load i32, i32* %4
ret i32 %40
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i32 @stringToChars(i8* %0, i8* nocapture writeonly %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = bitcast i8** %4 to i8*
%7 = call i8* @strtok_r(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4)
%8 = icmp eq i8* %7, null
br i1 %8, label %22, label %9
9: ; preds = %3
%10 = bitcast i8** %5 to i8*
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %17, %11 ]
%13 = phi i8* [ %7, %9 ], [ %18, %11 ]
%14 = call i64 @strtol(i8* %13, i8** %5, i32 10)
%15 = trunc i64 %14 to i8
%16 = getelementptr inbounds i8, i8* %1, i64 %12
store i8 %15, i8* %16
%17 = add nuw i64 %12, 1
%18 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %4)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %11
20: ; preds = %11
%21 = trunc i64 %17 to i32
br label %22
22: ; preds = %20, %3
%23 = phi i32 [ 0, %3 ], [ %21, %20 ]
%24 = add nsw i32 %2, -1
%25 = icmp sge i32 %23, %24
%26 = zext i1 %25 to i32
ret i32 %26
}