#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 */
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *strtok(int /*<<< orphan*/ *, char *);
char *get_token(int startover) {
  static char tmp[1024];
  static char *cont = NULL;
  char *insert, *start;
  char *k = strtok(NULL, " ");
  if (!k)
    return NULL;
  if (startover)
    start = tmp;
  else
    start = cont;
  strcpy(start, k);
  insert = start + strlen(start) - 1;
  while (*insert == '\\') {
    *insert++ = ' ';
    k = strtok(NULL, " ");
    if (!k)
      break;
    strcpy(insert, k);
    insert = start + strlen(start) - 1;
  }
  cont = start + strlen(start) + 1;
  return start;
}


x86 assembly (clang, -O0):
<get_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xeba(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1167 <get_token+0x37>
movq   $0x0,-0x8(%rbp)
jmp    126b <get_token+0x13b>
cmpl   $0x0,-0xc(%rbp)
je     1181 <get_token+0x51>
lea    0x2ed8(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    118c <get_token+0x5c>
mov    0x32c8(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    123b <get_token+0x10b>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x20,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe15(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1204 <get_token+0xd4>
jmp    123b <get_token+0x10b>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    11be <get_token+0x8e>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,0x31ed(%rip)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_token>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xebf(%rip),%rsi
xor    %r15d,%r15d
xor    %edi,%edi
call   1050 <strtok@plt>
test   %rax,%rax
je     11ef <get_token+0xbf>
test   %ebx,%ebx
jne    1161 <get_token+0x31>
mov    0x32f1(%rip),%r15
jmp    1168 <get_token+0x38>
lea    0x2ee8(%rip),%r15
mov    %r15,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x5c,-0x1(%r15,%rax,1)
jne    11d7 <get_token+0xa7>
lea    (%r15,%rax,1),%rbx
add    $0xffffffffffffffff,%rbx
lea    -0x1(%r15),%r12
lea    0xe68(%rip),%r14
nopl   0x0(%rax,%rax,1)
movb   $0x20,(%rbx)
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     11d7 <get_token+0xa7>
add    $0x1,%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
lea    (%r12,%rax,1),%rbx
cmpb   $0x5c,-0x1(%r15,%rax,1)
je     11a0 <get_token+0x70>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
add    %r15,%rax
add    $0x1,%rax
mov    %rax,0x3261(%rip)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@get_token.tmp = internal global [1024 x i8] zeroinitializer
@get_token.cont = internal global i8* null
@.str = [2 x i8] c" \00"
define i8* @get_token(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %3
%7 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %6
%8 = load i8*, i8** %6
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store i8* null, i8** %2
br label %57
11: ; preds = %1
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_token.tmp, i64 0, i64 0), i8** %5
br label %17
15: ; preds = %11
%16 = load i8*, i8** @get_token.cont
store i8* %16, i8** %5
br label %17
17: ; preds = %15, %14
%18 = load i8*, i8** %5
%19 = load i8*, i8** %6
%20 = call i32 @strcpy(i8* %18, i8* %19)
%21 = load i8*, i8** %5
%22 = load i8*, i8** %5
%23 = call i32 @strlen(i8* %22)
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %21, i64 %24
%26 = getelementptr inbounds i8, i8* %25, i64 -1
store i8* %26, i8** %4
br label %27
27: ; preds = %39, %17
%28 = load i8*, i8** %4
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 92
br i1 %31, label %32, label %49
32: ; preds = %27
%33 = load i8*, i8** %4
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %4
store i8 32, i8* %33
%35 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %35, i8** %6
%36 = load i8*, i8** %6
%37 = icmp ne i8* %36, null
br i1 %37, label %39, label %38
38: ; preds = %32
br label %49
39: ; preds = %32
%40 = load i8*, i8** %4
%41 = load i8*, i8** %6
%42 = call i32 @strcpy(i8* %40, i8* %41)
%43 = load i8*, i8** %5
%44 = load i8*, i8** %5
%45 = call i32 @strlen(i8* %44)
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %43, i64 %46
%48 = getelementptr inbounds i8, i8* %47, i64 -1
store i8* %48, i8** %4
br label %27
49: ; preds = %38, %27
%50 = load i8*, i8** %5
%51 = load i8*, i8** %5
%52 = call i32 @strlen(i8* %51)
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %50, i64 %53
%55 = getelementptr inbounds i8, i8* %54, i64 1
store i8* %55, i8** @get_token.cont
%56 = load i8*, i8** %5
store i8* %56, i8** %2
br label %57
57: ; preds = %49, %10
%58 = load i8*, i8** %2
ret i8* %58
}

LLVM IR (-O2):
@get_token.tmp = internal global [1024 x i8] zeroinitializer
@get_token.cont = internal unnamed_addr global i8* null
@.str = [2 x i8] c" \00"
define i8* @get_token(i32 %0) {
%2 = tail call i8* @strtok(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %34, label %4
4: ; preds = %1
%5 = icmp eq i32 %0, 0
%6 = load i8*, i8** @get_token.cont
%7 = select i1 %5, i8* %6, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @get_token.tmp, i64 0, i64 0)
%8 = tail call i32 @strcpy(i8* %7, i8* %2)
%9 = tail call i32 @strlen(i8* %7)
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
%12 = getelementptr inbounds i8, i8* %11, i64 -1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 92
br i1 %14, label %15, label %29
15: ; preds = %4
%16 = getelementptr inbounds i8, i8* %7, i64 -1
br label %17
17: ; preds = %15, %21
%18 = phi i8* [ %26, %21 ], [ %12, %15 ]
store i8 32, i8* %18
%19 = tail call i8* @strtok(i32* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i8* %19, null
br i1 %20, label %29, label %21
21: ; preds = %17
%22 = getelementptr inbounds i8, i8* %18, i64 1
%23 = tail call i32 @strcpy(i8* %22, i8* %19)
%24 = tail call i32 @strlen(i8* %7)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %16, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 92
br i1 %28, label %17, label %29
29: ; preds = %21, %17, %4
%30 = tail call i32 @strlen(i8* %7)
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %7, i64 %31
%33 = getelementptr inbounds i8, i8* %32, i64 1
store i8* %33, i8** @get_token.cont
br label %34
34: ; preds = %1, %29
%35 = phi i8* [ %7, %29 ], [ null, %1 ]
ret i8* %35
}