#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 *);
void getStringArray(char *line, char **array, char *comp) {
  int i = 0;
  char *token;
  token = strtok(line, comp);
  while (token != NULL) {
    array[i++] = token;
    token = (char *)strtok(NULL, comp);
  }
  array[i] = NULL;
}


x86 assembly (clang, -O0):
<getStringArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1177 <getStringArray+0x67>
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1030 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    113c <getStringArray+0x2c>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getStringArray>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdx,%rsi
call   1030 <strtok@plt>
test   %rax,%rax
je     114b <getStringArray+0x3b>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %rax,(%r14,%rbx,8)
add    $0x1,%rbx
xor    %edi,%edi
mov    %r15,%rsi
call   1030 <strtok@plt>
test   %rax,%rax
jne    1130 <getStringArray+0x20>
mov    %ebx,%eax
jmp    114d <getStringArray+0x3d>
xor    %eax,%eax
movq   $0x0,(%r14,%rax,8)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @getStringArray(i8* %0, i8** %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8* %2, i8** %6
store i32 0, i32* %7
%9 = load i8*, i8** %4
%10 = load i8*, i8** %6
%11 = call i8* @strtok(i8* %9, i8* %10)
store i8* %11, i8** %8
br label %12
12: ; preds = %15, %3
%13 = load i8*, i8** %8
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load i8*, i8** %8
%17 = load i8**, i8*** %5
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1
store i32 %19, i32* %7
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8*, i8** %17, i64 %20
store i8* %16, i8** %21
%22 = load i8*, i8** %6
%23 = call i8* @strtok(i8* null, i8* %22)
store i8* %23, i8** %8
br label %12
24: ; preds = %12
%25 = load i8**, i8*** %5
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
store i8* null, i8** %28
ret void
}

LLVM IR (-O2):
define void @getStringArray(i8* %0, i8** nocapture writeonly %1, i8* nocapture %2) {
%4 = tail call i8* @strtok(i8* %0, i8* %2)
%5 = icmp eq i8* %4, null
br i1 %5, label %15, label %6
6: ; preds = %3, %6
%7 = phi i64 [ %9, %6 ], [ 0, %3 ]
%8 = phi i8* [ %11, %6 ], [ %4, %3 ]
%9 = add nuw i64 %7, 1
%10 = getelementptr inbounds i8*, i8** %1, i64 %7
store i8* %8, i8** %10
%11 = tail call i8* @strtok(i8* null, i8* %2)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %6
13: ; preds = %6
%14 = and i64 %9, 4294967295
br label %15
15: ; preds = %13, %3
%16 = phi i64 [ 0, %3 ], [ %14, %13 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
store i8* null, i8** %17
ret void
}