#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 EOF;
scalar_t__ isspace(int);
int /*<<< orphan*/ printwhite();
int readchar();
int /*<<< orphan*/ savewhite(int, int);
int /*<<< orphan*/ writechar(char);
int main(void) {
  int c;
  bool leading = true;
  while ((c = readchar()) != EOF) {
    if (isspace(c))
      savewhite(c, leading);
    else {
      printwhite();
      writechar(c);
      leading = false;
    }
  }
  if (!leading)
    writechar('\n');
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
mov    $0x0,%al
call   1030 <readchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e71(%rip),%rcx
cmp    (%rcx),%eax
je     11bf <main+0x6f>
mov    -0x8(%rbp),%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
je     11a1 <main+0x51>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <savewhite@plt>
jmp    11ba <main+0x6a>
mov    $0x0,%al
call   1050 <printwhite@plt>
mov    -0x8(%rbp),%eax
movsbl %al,%edi
call   1040 <writechar@plt>
movl   $0x0,-0xc(%rbp)
jmp    1166 <main+0x16>
cmpl   $0x0,-0xc(%rbp)
jne    11d3 <main+0x83>
mov    $0xa,%edi
call   1040 <writechar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <readchar@plt>
mov    0x2e86(%rip),%r14
cmp    (%r14),%eax
je     11b5 <main+0x65>
mov    %eax,%ebp
mov    $0x1,%ebx
jmp    1190 <main+0x40>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printwhite@plt>
movsbl %bpl,%edi
call   1040 <writechar@plt>
xor    %eax,%eax
call   1030 <readchar@plt>
mov    %eax,%ebp
cmp    (%r14),%eax
je     11a7 <main+0x57>
mov    %ebp,%edi
call   1070 <isspace@plt>
test   %rax,%rax
je     1170 <main+0x20>
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <savewhite@plt>
jmp    1182 <main+0x32>
test   %ebx,%ebx
jne    11b5 <main+0x65>
mov    $0xa,%edi
call   1040 <writechar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %3
br label %4
4: ; preds = %21, %0
%5 = call i32 (...) @readchar()
store i32 %5, i32* %2
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %22
8: ; preds = %4
%9 = load i32, i32* %2
%10 = call i64 @isspace(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = call i32 @savewhite(i32 %13, i32 %14)
br label %21
16: ; preds = %8
%17 = call i32 (...) @printwhite()
%18 = load i32, i32* %2
%19 = trunc i32 %18 to i8
%20 = call i32 @writechar(i8 signext %19)
store i32 0, i32* %3
br label %21
21: ; preds = %16, %12
br label %4
22: ; preds = %4
%23 = load i32, i32* %3
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = call i32 @writechar(i8 signext 10)
br label %27
27: ; preds = %25, %22
ret i32 0
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @readchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %24, label %4
4: ; preds = %0, %15
%5 = phi i32 [ %17, %15 ], [ %1, %0 ]
%6 = phi i32 [ %16, %15 ], [ 1, %0 ]
%7 = tail call i64 @isspace(i32 %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = tail call i32 @savewhite(i32 %5, i32 %6)
br label %15
11: ; preds = %4
%12 = tail call i32 (...) @printwhite()
%13 = trunc i32 %5 to i8
%14 = tail call i32 @writechar(i8 signext %13)
br label %15
15: ; preds = %11, %9
%16 = phi i32 [ %6, %9 ], [ 0, %11 ]
%17 = tail call i32 (...) @readchar()
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %4
20: ; preds = %15
%21 = icmp eq i32 %16, 0
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = tail call i32 @writechar(i8 signext 10)
br label %24
24: ; preds = %0, %22, %20
ret i32 0
}