#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 debugger_tokenise(char *line, int *drgc, char *drgv[256]) {
  *drgc = 0;
  if (!line) {
    drgv[0] = NULL;
  } else {
    char *p = strtok(line, " ");
    while (p) {
      drgv[(*drgc)++] = p;
      p = strtok(NULL, " ");
    }
    drgv[*drgc] = NULL;
  }
}


x86 assembly (clang, -O0):
<debugger_tokenise>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
cmpq   $0x0,-0x8(%rbp)
jne    1149 <debugger_tokenise+0x39>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
jmp    11b0 <debugger_tokenise+0xa0>
mov    -0x8(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     119d <debugger_tokenise+0x8d>
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rsi
mov    (%rsi),%ecx
mov    %ecx,%edi
add    $0x1,%edi
mov    %edi,(%rsi)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe71(%rip),%rsi
call   1030 <strtok@plt>
mov    %rax,-0x20(%rbp)
jmp    115d <debugger_tokenise+0x4d>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debugger_tokenise>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
movl   $0x0,(%rsi)
test   %rdi,%rdi
je     1162 <debugger_tokenise+0x52>
mov    %rsi,%rbx
lea    0xed3(%rip),%rsi
call   1030 <strtok@plt>
test   %rax,%rax
je     115b <debugger_tokenise+0x4b>
lea    0xec2(%rip),%r15
xchg   %ax,%ax
movslq (%rbx),%rcx
lea    0x1(%rcx),%edx
mov    %edx,(%rbx)
mov    %rax,(%r14,%rcx,8)
xor    %edi,%edi
mov    %r15,%rsi
call   1030 <strtok@plt>
test   %rax,%rax
jne    1140 <debugger_tokenise+0x30>
movslq (%rbx),%rax
lea    (%r14,%rax,8),%r14
movq   $0x0,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define void @debugger_tokenise(i8* %0, i32* nocapture %1, i8** nocapture writeonly %2) {
store i32 0, i32* %1
%4 = icmp eq i8* %0, null
br i1 %4, label %20, label %5
5: ; preds = %3
%6 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %16, label %8
8: ; preds = %5, %8
%9 = phi i8* [ %14, %8 ], [ %6, %5 ]
%10 = load i32, i32* %1
%11 = add nsw i32 %10, 1
store i32 %11, i32* %1
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds i8*, i8** %2, i64 %12
store i8* %9, 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 %8
16: ; preds = %8, %5
%17 = load i32, i32* %1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %2, i64 %18
br label %20
20: ; preds = %3, %16
%21 = phi i8** [ %19, %16 ], [ %2, %3 ]
store i8* null, i8** %21
ret void
}