#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 EOF;
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char c;
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      while ((c = getchar()) == ' ')
        ;
      printf(" ");
    }
    printf("%c", c);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2ea5(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11a0 <main+0x80>
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
jne    1189 <main+0x69>
jmp    1160 <main+0x40>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x20,%eax
jne    117b <main+0x5b>
jmp    1160 <main+0x40>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x5(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb6(%rip),%r14
cmp    (%r14),%al
jne    1141 <main+0x21>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %eax,%ebx
jmp    1166 <main+0x46>
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %bl,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
cmp    (%r14),%al
je     1137 <main+0x17>
cmp    $0x20,%bl
jne    1150 <main+0x30>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x20,%al
je     1170 <main+0x50>
mov    %eax,%ebx
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    1150 <main+0x30>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %21, %0
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %2
%5 = sext i8 %4 to i32
%6 = load i8, i8* @EOF
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %5, %7
br i1 %8, label %9, label %25
9: ; preds = %3
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 32
br i1 %12, label %13, label %21
13: ; preds = %9
br label %14
14: ; preds = %18, %13
%15 = call signext i8 (...) @getchar()
store i8 %15, i8* %2
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 32
br i1 %17, label %18, label %19
18: ; preds = %14
br label %14
19: ; preds = %14
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %9
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %3
25: ; preds = %3
ret i32 0
}

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