#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 *skip_over_blank(char *);
char *skip_over_word(char *);
char *parse_word(char **buf) {
  char *word, *next;
  word = *buf;
  if (*word == 0)
    return 0;
  word = skip_over_blank(word);
  next = skip_over_word(word);
  if (*next)
    *next++ = 0;
  *buf = next;
  return word;
}


x86 assembly (clang, -O0):
<parse_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1154 <parse_word+0x34>
movq   $0x0,-0x8(%rbp)
jmp    11a0 <parse_word+0x80>
mov    -0x18(%rbp),%rdi
call   1040 <skip_over_blank@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <skip_over_word@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     118d <parse_word+0x6d>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_word>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%rdi
cmpb   $0x0,(%rdi)
je     1150 <parse_word+0x30>
call   1040 <skip_over_blank@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <skip_over_word@plt>
cmpb   $0x0,(%rax)
je     114b <parse_word+0x2b>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,(%r14)
jmp    1152 <parse_word+0x32>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @parse_word(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = load i8, i8* %2
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = tail call i8* @skip_over_blank(i8* %2)
%7 = tail call i8* @skip_over_word(i8* %6)
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %7, i64 1
store i8 0, i8* %7
br label %12
12: ; preds = %10, %5
%13 = phi i8* [ %11, %10 ], [ %7, %5 ]
store i8* %13, i8** %0
br label %14
14: ; preds = %1, %12
%15 = phi i8* [ %6, %12 ], [ null, %1 ]
ret i8* %15
}