#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__ isspace(char);
char *strchr(char *, char);
const char *first_word(char *msg_in, char **msg_out) {
  while (isspace(*msg_in))
    msg_in++;
  *msg_out = strchr(msg_in, ' ');
  if (!*msg_out)
    return msg_in;
  **msg_out = 0;
  do {
    ++*msg_out;
  } while (isspace(**msg_out));
  return msg_in;
}


x86 assembly (clang, -O0):
<first_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1157 <first_word+0x37>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1130 <first_word+0x10>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
jne    118a <first_word+0x6a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <first_word+0xa3>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
jne    1194 <first_word+0x74>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<first_word>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0xffffffffffffffff,%rbx
xchg   %ax,%ax
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1040 <isspace@plt>
test   %rax,%rax
jne    1130 <first_word+0x10>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     1178 <first_word+0x58>
movb   $0x0,(%rax)
nopw   0x0(%rax,%rax,1)
mov    (%r14),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%r14)
movsbl 0x1(%rax),%edi
call   1040 <isspace@plt>
test   %rax,%rax
jne    1160 <first_word+0x40>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @first_word(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8**
store i8* %0, i8** %4
store i8** %1, i8*** %5
br label %6
6: ; preds = %11, %2
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = call i64 @isspace(i8 signext %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %4
br label %6
14: ; preds = %6
%15 = load i8*, i8** %4
%16 = call i8* @strchr(i8* %15, i8 signext 32)
%17 = load i8**, i8*** %5
store i8* %16, i8** %17
%18 = load i8**, i8*** %5
%19 = load i8*, i8** %18
%20 = icmp ne i8* %19, null
br i1 %20, label %23, label %21
21: ; preds = %14
%22 = load i8*, i8** %4
store i8* %22, i8** %3
br label %38
23: ; preds = %14
%24 = load i8**, i8*** %5
%25 = load i8*, i8** %24
store i8 0, i8* %25
br label %26
26: ; preds = %30, %23
%27 = load i8**, i8*** %5
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %27
br label %30
30: ; preds = %26
%31 = load i8**, i8*** %5
%32 = load i8*, i8** %31
%33 = load i8, i8* %32
%34 = call i64 @isspace(i8 signext %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %26, label %36
36: ; preds = %30
%37 = load i8*, i8** %4
store i8* %37, i8** %3
br label %38
38: ; preds = %36, %21
%39 = load i8*, i8** %3
ret i8* %39
}

LLVM IR (-O2):
define i8* @first_word(i8* %0, i8** nocapture %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i8* [ %0, %2 ], [ %8, %3 ]
%5 = load i8, i8* %4
%6 = tail call i64 @isspace(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 = tail call i8* @strchr(i8* %4, i8 signext 32)
store i8* %10, i8** %1
%11 = icmp eq i8* %10, null
br i1 %11, label %19, label %12
12: ; preds = %9
store i8 0, i8* %10
br label %13
13: ; preds = %13, %12
%14 = load i8*, i8** %1
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8* %15, i8** %1
%16 = load i8, i8* %15
%17 = tail call i64 @isspace(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %13
19: ; preds = %13, %9
ret i8* %4
}