#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);
int /*<<< orphan*/ strncpy(char *, char *, int);
int wordToBuffer(char **at, char output[]) {
  char *start = *at;
  while (**at && !isspace(**at)) {
    ++(*at);
  }
  char *end = *at;
  int size = end - start;
  strncpy(output, start, size);
  output[size] = '\0';
  return size;
}


x86 assembly (clang, -O0):
<wordToBuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x25(%rbp)
je     116d <wordToBuffer+0x4d>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    117d <wordToBuffer+0x5d>
jmp    1190 <wordToBuffer+0x70>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
jmp    113b <wordToBuffer+0x1b>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wordToBuffer>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    (%rdi),%r15
mov    (%r15),%al
mov    %r15,%rbx
test   %al,%al
je     1165 <wordToBuffer+0x45>
mov    %rdi,%r12
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <isspace@plt>
mov    (%r12),%rcx
test   %eax,%eax
jne    1162 <wordToBuffer+0x42>
lea    0x1(%rcx),%rbx
mov    %rbx,(%r12)
movzbl 0x1(%rcx),%eax
test   %al,%al
jne    1140 <wordToBuffer+0x20>
jmp    1165 <wordToBuffer+0x45>
mov    %rcx,%rbx
sub    %r15,%rbx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
movslq %ebx,%rax
movb   $0x0,(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @wordToBuffer(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8** %0, i8*** %3
store i8* %1, i8** %4
%8 = load i8**, i8*** %3
%9 = load i8*, i8** %8
store i8* %9, i8** %5
br label %10
10: ; preds = %25, %2
%11 = load i8**, i8*** %3
%12 = load i8*, i8** %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %10
%17 = load i8**, i8*** %3
%18 = load i8*, i8** %17
%19 = load i8, i8* %18
%20 = call i32 @isspace(i8 signext %19)
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
br label %23
23: ; preds = %16, %10
%24 = phi i1 [ false, %10 ], [ %22, %16 ]
br i1 %24, label %25, label %29
25: ; preds = %23
%26 = load i8**, i8*** %3
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %26
br label %10
29: ; preds = %23
%30 = load i8**, i8*** %3
%31 = load i8*, i8** %30
store i8* %31, i8** %6
%32 = load i8*, i8** %6
%33 = load i8*, i8** %5
%34 = ptrtoint i8* %32 to i64
%35 = ptrtoint i8* %33 to i64
%36 = sub i64 %34, %35
%37 = trunc i64 %36 to i32
store i32 %37, i32* %7
%38 = load i8*, i8** %4
%39 = load i8*, i8** %5
%40 = load i32, i32* %7
%41 = call i32 @strncpy(i8* %38, i8* %39, i32 %40)
%42 = load i8*, i8** %4
%43 = load i32, i32* %7
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8 0, i8* %45
%46 = load i32, i32* %7
ret i32 %46
}

LLVM IR (-O2):
define i32 @wordToBuffer(i8** nocapture %0, i8* %1) {
%3 = load i8*, i8** %0
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %2, %11
%7 = phi i8 [ %13, %11 ], [ %4, %2 ]
%8 = tail call i32 @isspace(i8 signext %7)
%9 = icmp eq i32 %8, 0
%10 = load i8*, i8** %0
br i1 %9, label %11, label %17
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %10, i64 1
store i8* %12, i8** %0
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %6
15: ; preds = %11
%16 = getelementptr inbounds i8, i8* %10, i64 1
br label %17
17: ; preds = %6, %15, %2
%18 = phi i8* [ %3, %2 ], [ %16, %15 ], [ %10, %6 ]
%19 = ptrtoint i8* %18 to i64
%20 = ptrtoint i8* %3 to i64
%21 = sub i64 %19, %20
%22 = trunc i64 %21 to i32
%23 = tail call i32 @strncpy(i8* %1, i8* %3, i32 %22)
%24 = shl i64 %21, 32
%25 = ashr exact i64 %24, 32
%26 = getelementptr inbounds i8, i8* %1, i64 %25
store i8 0, i8* %26
ret i32 %22
}