#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_punctuation(char);
scalar_t__ is_separator(char);
char *parser_get_next_word(char **sp) {
  static char buffer[512];
  char *s = *sp, *p = buffer;
  while (is_separator(*s))
    ++s;
  if (*s == '\0')
    goto done;
  if (is_punctuation(*s)) {
    *p++ = *s++;
    goto done;
  }
  while (*s && !is_separator(*s) && !is_punctuation(*s))
    *p++ = *s++;
done:
  *p++ = '\0';
  *sp = s;
  return buffer[0] ? buffer : NULL;
}


x86 assembly (clang, -O0):
<parser_get_next_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
lea    0x2f02(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <is_separator@plt>
cmp    $0x0,%rax
je     1169 <parser_get_next_word+0x49>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1142 <parser_get_next_word+0x22>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    117e <parser_get_next_word+0x5e>
jmp    1247 <parser_get_next_word+0x127>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <is_punctuation@plt>
cmp    $0x0,%rax
je     11bb <parser_get_next_word+0x9b>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1247 <parser_get_next_word+0x127>
jmp    11c0 <parser_get_next_word+0xa0>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     120b <parser_get_next_word+0xeb>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <is_separator@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x19(%rbp)
jne    120b <parser_get_next_word+0xeb>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <is_punctuation@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    121b <parser_get_next_word+0xfb>
jmp    1242 <parser_get_next_word+0x122>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    11c0 <parser_get_next_word+0xa0>
jmp    1247 <parser_get_next_word+0x127>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
movsbl 0x2dd5(%rip),%edx
xor    %eax,%eax
lea    0x2dcc(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parser_get_next_word>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
mov    (%rdi),%rbx
nop
movsbl (%rbx),%edi
call   1030 <is_separator@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1130 <parser_get_next_word+0x10>
lea    -0x1(%rbx),%r12
mov    -0x1(%rbx),%al
lea    0x2ef1(%rip),%r15
test   %al,%al
je     11bd <parser_get_next_word+0x9d>
movsbl %al,%edi
call   1040 <is_punctuation@plt>
mov    (%r12),%cl
test   %rax,%rax
je     1173 <parser_get_next_word+0x53>
mov    %cl,0x2ed6(%rip)
lea    0x2ed0(%rip),%r13
jmp    11c3 <parser_get_next_word+0xa3>
test   %cl,%cl
je     11bd <parser_get_next_word+0x9d>
lea    0x2ec2(%rip),%r13
xchg   %ax,%ax
movsbl %cl,%edi
call   1030 <is_separator@plt>
test   %rax,%rax
jne    11e5 <parser_get_next_word+0xc5>
movsbl (%r12),%edi
call   1040 <is_punctuation@plt>
test   %rax,%rax
jne    11e5 <parser_get_next_word+0xc5>
lea    0x1(%r12),%rbx
movzbl (%r12),%eax
mov    %al,0x0(%r13)
add    $0x1,%r13
movzbl 0x1(%r12),%ecx
mov    %rbx,%r12
test   %cl,%cl
jne    1180 <parser_get_next_word+0x60>
jmp    11c3 <parser_get_next_word+0xa3>
mov    %r12,%rbx
mov    %r15,%r13
movb   $0x0,0x0(%r13)
mov    %rbx,(%r14)
xor    %eax,%eax
cmpb   $0x0,0x2e6c(%rip)
cmove  %rax,%r15
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %r12,%rbx
jmp    11c3 <parser_get_next_word+0xa3>

LLVM IR (-O0):
@parser_get_next_word.buffer = internal global [512 x i8] zeroinitializer
define i8* @parser_get_next_word(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
%4 = alloca i8*
store i8** %0, i8*** %2
%5 = load i8**, i8*** %2
%6 = load i8*, i8** %5
store i8* %6, i8** %3
store i8* getelementptr inbounds ([512 x i8], [512 x i8]* @parser_get_next_word.buffer, i64 0, i64 0), i8** %4
br label %7
7: ; preds = %12, %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = call i64 @is_separator(i8 signext %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %3
br label %7
15: ; preds = %7
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
br label %58
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = call i64 @is_punctuation(i8 signext %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %21
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %3
%29 = load i8, i8* %27
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %4
store i8 %29, i8* %30
br label %58
32: ; preds = %21
br label %33
33: ; preds = %51, %32
%34 = load i8*, i8** %3
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %49
38: ; preds = %33
%39 = load i8*, i8** %3
%40 = load i8, i8* %39
%41 = call i64 @is_separator(i8 signext %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %49, label %43
43: ; preds = %38
%44 = load i8*, i8** %3
%45 = load i8, i8* %44
%46 = call i64 @is_punctuation(i8 signext %45)
%47 = icmp ne i64 %46, 0
%48 = xor i1 %47, true
br label %49
49: ; preds = %43, %38, %33
%50 = phi i1 [ false, %38 ], [ false, %33 ], [ %48, %43 ]
br i1 %50, label %51, label %57
51: ; preds = %49
%52 = load i8*, i8** %3
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %3
%54 = load i8, i8* %52
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i32 1
store i8* %56, i8** %4
store i8 %54, i8* %55
br label %33
57: ; preds = %49
br label %58
58: ; preds = %57, %26, %20
%59 = load i8*, i8** %4
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %4
store i8 0, i8* %59
%61 = load i8*, i8** %3
%62 = load i8**, i8*** %2
store i8* %61, i8** %62
%63 = load i8, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @parser_get_next_word.buffer, i64 0, i64 0)
%64 = sext i8 %63 to i32
%65 = icmp ne i32 %64, 0
%66 = zext i1 %65 to i64
%67 = select i1 %65, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @parser_get_next_word.buffer, i64 0, i64 0), i8* null
ret i8* %67
}

LLVM IR (-O2):
@parser_get_next_word.buffer = internal global [512 x i8] zeroinitializer
define i8* @parser_get_next_word(i8** nocapture %0) {
%2 = load i8*, i8** %0
br label %3
3: ; preds = %3, %1
%4 = phi i8* [ %2, %1 ], [ %8, %3 ]
%5 = load i8, i8* %4
%6 = tail call i64 @is_separator(i8 signext %5)
%7 = icmp eq i64 %6, 0
%8 = getelementptr inbounds i8, i8* %4, i64 1
br i1 %7, label %9, label %3
9: ; preds = %3
%10 = load i8, i8* %4
%11 = icmp eq i8 %10, 0
br i1 %11, label %35, label %12
12: ; preds = %9
%13 = tail call i64 @is_punctuation(i8 signext %10)
%14 = icmp eq i64 %13, 0
%15 = load i8, i8* %4
br i1 %14, label %16, label %18
16: ; preds = %12
%17 = icmp eq i8 %15, 0
br i1 %17, label %35, label %19
18: ; preds = %12
store i8 %15, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @parser_get_next_word.buffer, i64 0, i64 0)
br label %35
19: ; preds = %16, %29
%20 = phi i8 [ %33, %29 ], [ %15, %16 ]
%21 = phi i8* [ %32, %29 ], [ getelementptr inbounds ([512 x i8], [512 x i8]* @parser_get_next_word.buffer, i64 0, i64 0), %16 ]
%22 = phi i8* [ %30, %29 ], [ %4, %16 ]
%23 = tail call i64 @is_separator(i8 signext %20)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %35
25: ; preds = %19
%26 = load i8, i8* %22
%27 = tail call i64 @is_punctuation(i8 signext %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = getelementptr inbounds i8, i8* %22, i64 1
%31 = load i8, i8* %22
%32 = getelementptr inbounds i8, i8* %21, i64 1
store i8 %31, i8* %21
%33 = load i8, i8* %30
%34 = icmp eq i8 %33, 0
br i1 %34, label %35, label %19
35: ; preds = %29, %19, %25, %16, %9, %18
%36 = phi i8* [ %4, %9 ], [ %8, %18 ], [ %4, %16 ], [ %30, %29 ], [ %22, %19 ], [ %22, %25 ]
%37 = phi i8* [ getelementptr inbounds ([512 x i8], [512 x i8]* @parser_get_next_word.buffer, i64 0, i64 0), %9 ], [ getelementptr inbounds ([512 x i8], [512 x i8]* @parser_get_next_word.buffer, i64 0, i64 1), %18 ], [ getelementptr inbounds ([512 x i8], [512 x i8]* @parser_get_next_word.buffer, i64 0, i64 0), %16 ], [ %32, %29 ], [ %21, %19 ], [ %21, %25 ]
store i8 0, i8* %37
store i8* %36, i8** %0
%38 = load i8, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @parser_get_next_word.buffer, i64 0, i64 0)
%39 = icmp eq i8 %38, 0
%40 = select i1 %39, i8* null, i8* getelementptr inbounds ([512 x i8], [512 x i8]* @parser_get_next_word.buffer, i64 0, i64 0)
ret i8* %40
}