#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 strlen(char *);
char *nextToken(char *in) {
  int i;
  for (i = 0; i < strlen(in); i++) {
    if (in[i] == ' ') {
      in[i] = 0x0;
      return (&in[i + 1]);
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<nextToken>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    118c <nextToken+0x7c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1179 <nextToken+0x69>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1194 <nextToken+0x84>
jmp    117e <nextToken+0x6e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <nextToken+0x13>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nextToken>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
call   1030 <strlen@plt>
xor    %r14d,%r14d
test   %eax,%eax
jle    1159 <nextToken+0x49>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x20,(%r15,%rbx,1)
je     114c <nextToken+0x3c>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1130 <nextToken+0x20>
jmp    1159 <nextToken+0x49>
movb   $0x0,(%r15,%rbx,1)
lea    (%r15,%rbx,1),%r14
add    $0x1,%r14
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @nextToken(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %20
4: ; preds = %1, %15
%5 = phi i64 [ %16, %15 ], [ 0, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 32
br i1 %8, label %9, label %15
9: ; preds = %4
%10 = and i64 %5, 4294967295
%11 = getelementptr inbounds i8, i8* %0, i64 %10
store i8 0, i8* %11
%12 = add nuw nsw i64 %5, 1
%13 = and i64 %12, 4294967295
%14 = getelementptr inbounds i8, i8* %0, i64 %13
br label %20
15: ; preds = %4
%16 = add nuw nsw i64 %5, 1
%17 = tail call i32 @strlen(i8* %0)
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %4, label %20
20: ; preds = %15, %1, %9
%21 = phi i8* [ %14, %9 ], [ null, %1 ], [ null, %15 ]
ret i8* %21
}