#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 */
int /*<<< orphan*/ isspace(char const);
char *wordcpy(char *out, const char *s) {
  char *p = out;
  while (*s && !isspace(*s)) {
    *p++ = *s++;
  }
  *p++ = '\0';
  return out;
}


x86 assembly (clang, -O0):
<wordcpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     1154 <wordcpy+0x44>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1164 <wordcpy+0x54>
jmp    118b <wordcpy+0x7b>
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    1128 <wordcpy+0x18>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wordcpy>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    (%rsi),%al
mov    %rdi,%r15
test   %al,%al
je     1152 <wordcpy+0x42>
mov    %rsi,%rbx
add    $0x1,%rbx
mov    %r14,%r15
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <isspace@plt>
test   %eax,%eax
jne    1152 <wordcpy+0x42>
movzbl -0x1(%rbx),%eax
mov    %al,(%r15)
add    $0x1,%r15
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <wordcpy+0x20>
movb   $0x0,(%r15)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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