#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*/ printf(char *);
int /*<<< orphan*/ putchar(int);
int main(int argc, char const *argv[]) {
  int c;
  int isspace;
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      if (isspace == 0) {
        isspace = 1;
        putchar(c);
      }
    } else {
      isspace = 0;
      putchar(c);
    }
  }
  printf("\n");
  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)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%eax
je     119b <main+0x6b>
cmpl   $0x20,-0x14(%rbp)
jne    1187 <main+0x57>
cmpl   $0x0,-0x18(%rbp)
jne    1182 <main+0x52>
movl   $0x1,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
jmp    1196 <main+0x66>
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
jmp    1146 <main+0x16>
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
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    1148 <main+0x28>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
jmp    1164 <main+0x44>
nopw   0x0(%rax,%rax,1)
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebp,%ecx
cmp    (%rbx),%eax
je     1135 <main+0x15>
mov    $0x0,%ebp
cmp    $0x20,%eax
jne    1150 <main+0x30>
mov    $0x1,%ebp
test   %ecx,%ecx
jne    1157 <main+0x37>
mov    $0x20,%eax
jmp    1150 <main+0x30>

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