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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eb2(%rip),%rax
mov    (%rax),%al
mov    %al,-0x5(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e99(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ac <main+0x8c>
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
jne    1195 <main+0x75>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x20,%eax
jne    1190 <main+0x70>
jmp    1175 <main+0x55>
jmp    1195 <main+0x75>
movsbl -0x5(%rbp),%esi
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    113b <main+0x1b>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb9(%rip),%rbx
jmp    114f <main+0x2f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%al
je     117d <main+0x5d>
cmp    $0x20,%al
jne    1140 <main+0x20>
mov    $0x20,%edi
call   1030 <putchar@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0x20,%al
je     1170 <main+0x50>
jmp    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
ret

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

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
%8 = tail call i32 @putchar(i32 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 = 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
}