#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;
int getchar();
int /*<<< orphan*/ putchar(int);
int main(int argc, char **argv) {
  char space = 0;
  int c;
  while ((c = getchar()) != EOF) {
    switch (c) {
    case ' ':
      if (!space) {
        putchar(' ');
        space = 1;
      }
      break;
    default:
      space = 0;
      putchar(c);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e9d(%rip),%rcx
cmp    (%rcx),%eax
je     1192 <main+0x72>
mov    -0x18(%rbp),%eax
sub    $0x20,%eax
jne    1181 <main+0x61>
jmp    1164 <main+0x44>
cmpb   $0x0,-0x11(%rbp)
jne    117c <main+0x5c>
mov    $0x20,%edi
call   1030 <putchar@plt>
movb   $0x1,-0x11(%rbp)
jmp    118d <main+0x6d>
movb   $0x0,-0x11(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <putchar@plt>
jmp    113a <main+0x1a>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb7(%rip),%rbx
cmp    (%rbx),%eax
jne    113e <main+0x1e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %ecx,%ecx
jmp    1166 <main+0x46>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ebp,%ebp
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebp,%ecx
cmp    (%rbx),%eax
je     1135 <main+0x15>
cmp    $0x20,%eax
jne    1150 <main+0x30>
mov    $0x1,%bpl
test   %cl,%cl
jne    1159 <main+0x39>
mov    $0x20,%eax
jmp    1152 <main+0x32>

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

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