#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);
int /*<<< orphan*/ strcpy(char *, char *);
int getwordandskipspace(char **q, char *j) {
  char *p, *r, c;
  p = *q;
  r = p;
  while (!isspace(*p))
    p++;
  c = *p;
  *p = ('\0');
  strcpy(j, r);
  *p = c;
  while (isspace(*p))
    p++;
  *q = p;
  return 1;
}


x86 assembly (clang, -O0):
<getwordandskipspace>:
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    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1165 <getwordandskipspace+0x45>
jmp    1176 <getwordandskipspace+0x56>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1143 <getwordandskipspace+0x23>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x21(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x21(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11c3 <getwordandskipspace+0xa3>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    119c <getwordandskipspace+0x7c>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getwordandskipspace>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    (%rdi),%r12
lea    -0x1(%r12),%rbx
cs nopw 0x0(%rax,%rax,1)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1040 <isspace@plt>
test   %rax,%rax
je     1140 <getwordandskipspace+0x20>
movsbl (%rbx),%ebp
movb   $0x0,(%rbx)
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %bpl,(%rbx)
mov    %ebp,%edi
nopl   0x0(%rax,%rax,1)
call   1040 <isspace@plt>
test   %rax,%rax
je     1184 <getwordandskipspace+0x64>
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
jmp    1170 <getwordandskipspace+0x50>
mov    %rbx,(%r14)
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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