#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 */
scalar_t__ is_space(char);
char *getNextString(char *buffer) {
  if (buffer == 0)
    return 0;
  while (!is_space(*buffer) && *buffer != '\0')
    buffer++;
  if (*buffer == '\0')
    return 0;
  *buffer++ = '\0';
  while (is_space(*buffer))
    buffer++;
  if (*buffer == '\0')
    return 0;
  return buffer;
}


x86 assembly (clang, -O0):
<getNextString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1134 <getNextString+0x24>
movq   $0x0,-0x8(%rbp)
jmp    1203 <getNextString+0xf3>
jmp    1139 <getNextString+0x29>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <is_space@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
jne    1167 <getNextString+0x57>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1177 <getNextString+0x67>
jmp    1188 <getNextString+0x78>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1139 <getNextString+0x29>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11a5 <getNextString+0x95>
movq   $0x0,-0x8(%rbp)
jmp    1203 <getNextString+0xf3>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <is_space@plt>
cmp    $0x0,%rax
je     11de <getNextString+0xce>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11b7 <getNextString+0xa7>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11fb <getNextString+0xeb>
movq   $0x0,-0x8(%rbp)
jmp    1203 <getNextString+0xf3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNextString>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     116e <getNextString+0x5e>
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <is_space@plt>
test   %rax,%rax
jne    1147 <getNextString+0x37>
xor    %r14d,%r14d
nopl   0x0(%rax)
cmpb   $0x0,(%rbx)
je     1171 <getNextString+0x61>
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <is_space@plt>
test   %rax,%rax
je     1130 <getNextString+0x20>
cmpb   $0x0,(%rbx)
je     116e <getNextString+0x5e>
movb   $0x0,(%rbx)
nop
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <is_space@plt>
test   %rax,%rax
jne    1150 <getNextString+0x40>
xor    %r14d,%r14d
cmpb   $0x0,(%rbx)
cmovne %rbx,%r14
jmp    1171 <getNextString+0x61>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @getNextString(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %1
store i8* null, i8** %2
br label %48
7: ; preds = %1
br label %8
8: ; preds = %20, %7
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = call i64 @is_space(i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br label %18
18: ; preds = %13, %8
%19 = phi i1 [ false, %8 ], [ %17, %13 ]
br i1 %19, label %20, label %23
20: ; preds = %18
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
br label %8
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
store i8* null, i8** %2
br label %48
29: ; preds = %23
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %3
store i8 0, i8* %30
br label %32
32: ; preds = %37, %29
%33 = load i8*, i8** %3
%34 = load i8, i8* %33
%35 = call i64 @is_space(i8 signext %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %3
br label %32
40: ; preds = %32
%41 = load i8*, i8** %3
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %40
store i8* null, i8** %2
br label %48
46: ; preds = %40
%47 = load i8*, i8** %3
store i8* %47, i8** %2
br label %48
48: ; preds = %46, %45, %28, %6
%49 = load i8*, i8** %2
ret i8* %49
}

LLVM IR (-O2):
define i8* @getNextString(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %31, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = tail call i64 @is_space(i8 signext %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %3, %11
%8 = phi i8* [ %12, %11 ], [ %0, %3 ]
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %31, label %11
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %8, i64 1
%13 = load i8, i8* %12
%14 = tail call i64 @is_space(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %7, label %16
16: ; preds = %11, %3
%17 = phi i8* [ %0, %3 ], [ %12, %11 ]
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %31, label %20
20: ; preds = %16
store i8 0, i8* %17
br label %21
21: ; preds = %21, %20
%22 = phi i8* [ %17, %20 ], [ %23, %21 ]
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = load i8, i8* %23
%25 = tail call i64 @is_space(i8 signext %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %21
27: ; preds = %21
%28 = load i8, i8* %23
%29 = icmp eq i8 %28, 0
%30 = select i1 %29, i8* null, i8* %23
br label %31
31: ; preds = %7, %27, %16, %1
%32 = phi i8* [ null, %1 ], [ null, %16 ], [ %30, %27 ], [ null, %7 ]
ret i8* %32
}