#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 */
char getchar();
int /*<<< orphan*/ putchar(char);
main() {
  int nb = 0;
  char c;
  while ((c = getchar()) != '\n') {
    while (c == ' ') {
      c = getchar();
      nb = 1;
    }
    if (nb > 0) {
      putchar(' ');
      nb = 0;
    }
    putchar(c);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x9(%rbp)
movsbl %al,%eax
cmp    $0xa,%eax
je     119d <main+0x7d>
jmp    1151 <main+0x31>
movsbl -0x9(%rbp),%eax
cmp    $0x20,%eax
jne    1174 <main+0x54>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x9(%rbp)
movl   $0x1,-0x8(%rbp)
jmp    1151 <main+0x31>
cmpl   $0x0,-0x8(%rbp)
jle    118f <main+0x6f>
mov    $0x20,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x8(%rbp)
movsbl -0x9(%rbp),%edi
call   1030 <putchar@plt>
jmp    1136 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
jne    1137 <main+0x17>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %eax,%ebp
jmp    1157 <main+0x37>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%ebx
movsbl %bl,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebp
cmp    $0xa,%al
je     112e <main+0xe>
cmp    $0x20,%bpl
jne    1140 <main+0x20>
nopl   (%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x20,%al
je     1160 <main+0x40>
mov    %eax,%ebx
cmp    $0x20,%bpl
jne    1142 <main+0x22>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1142 <main+0x22>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %20, %0
%5 = call signext i8 (...) @getchar()
store i8 %5, i8* %3
%6 = sext i8 %5 to i32
%7 = icmp ne i32 %6, 10
br i1 %7, label %8, label %23
8: ; preds = %4
br label %9
9: ; preds = %13, %8
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 32
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call signext i8 (...) @getchar()
store i8 %14, i8* %3
store i32 1, i32* %2
br label %9
15: ; preds = %9
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @putchar(i8 signext 32)
store i32 0, i32* %2
br label %20
20: ; preds = %18, %15
%21 = load i8, i8* %3
%22 = call i32 @putchar(i8 signext %21)
br label %4
23: ; preds = %4
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = icmp eq i8 %1, 10
br i1 %2, label %17, label %3
3: ; preds = %0, %12
%4 = phi i8 [ %15, %12 ], [ %1, %0 ]
%5 = icmp eq i8 %4, 32
br i1 %5, label %6, label %12
6: ; preds = %3, %6
%7 = tail call signext i8 (...) @getchar()
%8 = icmp eq i8 %7, 32
br i1 %8, label %6, label %9
9: ; preds = %6
br i1 %5, label %10, label %12
10: ; preds = %9
%11 = tail call i32 @putchar(i8 signext 32)
br label %12
12: ; preds = %3, %10, %9
%13 = phi i8 [ %7, %10 ], [ %7, %9 ], [ %4, %3 ]
%14 = tail call i32 @putchar(i8 signext %13)
%15 = tail call signext i8 (...) @getchar()
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %3
17: ; preds = %12, %0
ret i32 0
}