#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 *nasm_skip_spaces(char *);
char *nasm_skip_word(char *);
char *nasm_get_word(char *p, char **tail) {
  char *word = nasm_skip_spaces(p);
  char *next = nasm_skip_word(word);
  if (word && *word) {
    if (*next)
      *next++ = '\0';
  } else
    word = next = NULL;
  *tail = next;
  return word;
}


x86 assembly (clang, -O0):
<nasm_get_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <nasm_skip_spaces@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <nasm_skip_word@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1189 <nasm_get_word+0x69>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1189 <nasm_get_word+0x69>
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1184 <nasm_get_word+0x64>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
jmp    1199 <nasm_get_word+0x79>
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nasm_get_word>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
call   1040 <nasm_skip_spaces@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <nasm_skip_word@plt>
test   %rbx,%rbx
je     114f <nasm_get_word+0x2f>
cmpb   $0x0,(%rbx)
je     114f <nasm_get_word+0x2f>
cmpb   $0x0,(%rax)
je     1153 <nasm_get_word+0x33>
movb   $0x0,(%rax)
add    $0x1,%rax
jmp    1153 <nasm_get_word+0x33>
xor    %ebx,%ebx
xor    %eax,%eax
mov    %rax,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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