#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__ xisblack(char);
scalar_t__ xiswhite(char);
char *xstripall(char *str) {
  char *s = str;
  char *d = str;
  while (xiswhite(*s)) {
    ++s;
  }
  for (;;) {
    while (xisblack(*s)) {
      *d++ = *s++;
    }
    while (xiswhite(*s)) {
      ++s;
    }
    if (*s == 0) {
      *d = 0;
      return str;
    }
    *d++ = ' ';
  }
}


x86 assembly (clang, -O0):
<xstripall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <xiswhite@plt>
cmp    $0x0,%rax
je     1163 <xstripall+0x43>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113c <xstripall+0x1c>
jmp    1168 <xstripall+0x48>
jmp    116d <xstripall+0x4d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <xisblack@plt>
cmp    $0x0,%rax
je     11aa <xstripall+0x8a>
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    116d <xstripall+0x4d>
jmp    11af <xstripall+0x8f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <xiswhite@plt>
cmp    $0x0,%rax
je     11d6 <xstripall+0xb6>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11af <xstripall+0x8f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11f7 <xstripall+0xd7>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x20,(%rax)
jmp    1168 <xstripall+0x48>

x86 assembly (clang, -O2):
<xstripall>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    -0x1(%rdi),%rbx
nop
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1040 <xiswhite@plt>
test   %rax,%rax
jne    1130 <xstripall+0x10>
mov    %r14,%r15
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%rbx),%edi
call   1030 <xisblack@plt>
test   %rax,%rax
je     117f <xstripall+0x5f>
nopl   (%rax)
lea    0x1(%rbx),%r12
movzbl (%rbx),%eax
mov    %al,(%r15)
add    $0x1,%r15
movsbl 0x1(%rbx),%edi
call   1030 <xisblack@plt>
mov    %r12,%rbx
test   %rax,%rax
jne    1160 <xstripall+0x40>
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1040 <xiswhite@plt>
test   %rax,%rax
jne    1190 <xstripall+0x70>
cmpb   $0x0,(%rbx)
je     11b1 <xstripall+0x91>
movb   $0x20,(%r15)
add    $0x1,%r15
jmp    1150 <xstripall+0x30>
movb   $0x0,(%r15)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @xstripall(i8* returned %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %7, %2 ]
%4 = load i8, i8* %3
%5 = tail call i64 @xiswhite(i8 signext %4)
%6 = icmp eq i64 %5, 0
%7 = getelementptr inbounds i8, i8* %3, i64 1
br i1 %6, label %8, label %2
8: ; preds = %2, %36
%9 = phi i8* [ %27, %36 ], [ %3, %2 ]
%10 = phi i8* [ %37, %36 ], [ %0, %2 ]
%11 = load i8, i8* %9
%12 = tail call i64 @xisblack(i8 signext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %17, %8
%15 = phi i8* [ %9, %8 ], [ %20, %17 ]
%16 = phi i8* [ %10, %8 ], [ %22, %17 ]
br label %26
17: ; preds = %8, %17
%18 = phi i8* [ %22, %17 ], [ %10, %8 ]
%19 = phi i8* [ %20, %17 ], [ %9, %8 ]
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %19
%22 = getelementptr inbounds i8, i8* %18, i64 1
store i8 %21, i8* %18
%23 = load i8, i8* %20
%24 = tail call i64 @xisblack(i8 signext %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %14, label %17
26: ; preds = %26, %14
%27 = phi i8* [ %31, %26 ], [ %15, %14 ]
%28 = load i8, i8* %27
%29 = tail call i64 @xiswhite(i8 signext %28)
%30 = icmp eq i64 %29, 0
%31 = getelementptr inbounds i8, i8* %27, i64 1
br i1 %30, label %32, label %26
32: ; preds = %26
%33 = load i8, i8* %27
%34 = icmp eq i8 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32
store i8 0, i8* %16
ret i8* %0
36: ; preds = %32
%37 = getelementptr inbounds i8, i8* %16, i64 1
store i8 32, i8* %16
br label %8
}