#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 *, char);
main() {
  char c;
  while ((c = getchar()) != EOF) {
    if (c != ' ') {
      printf("%c", c);
    } else {
      printf("%c", c);
      while ((c = getchar()) == ' ') {
      }
      printf("%c", c);
    }
  }
}


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     11b0 <main+0x90>
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
je     1170 <main+0x50>
lea    0xe9e(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
jmp    11ab <main+0x8b>
lea    0xe89(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x20,%eax
jne    119b <main+0x7b>
jmp    1180 <main+0x60>
lea    0xe5e(%rip),%rdi
movsbl -0x5(%rbp),%esi
call   1030 <printf@plt>
jmp    112f <main+0xf>
mov    -0x4(%rbp),%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
lea    0xeb8(%rip),%rbx
jmp    1167 <main+0x47>
nopw   0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%al
je     1137 <main+0x17>
cmp    $0x20,%al
jne    1150 <main+0x30>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1030 <printf@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x20,%al
je     1180 <main+0x60>
jmp    1150 <main+0x30>

LLVM IR (-O0):
@EOF = global i8 0
@.str = [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 = %27, %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 %28
9: ; preds = %3
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 32
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i8, i8* %2
%15 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %14)
br label %27
16: ; preds = %9
%17 = load i8, i8* %2
%18 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %17)
br label %19
19: ; preds = %23, %16
%20 = call signext i8 (...) @getchar()
store i8 %20, i8* %2
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 32
br i1 %22, label %23, label %24
23: ; preds = %19
br label %19
24: ; preds = %19
%25 = load i8, i8* %2
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %25)
br label %27
27: ; preds = %24, %13
br label %3
28: ; preds = %3
%29 = load i32, i32* %1
ret i32 %29
}

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