#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();
scalar_t__ isspace(int);
int /*<<< orphan*/ putchar(int);
void squeeze_spaces(void) {
  int character;
  int space = 0;
  while ((character = getchar()) != EOF) {
    if (!isspace(character)) {
      putchar(character);
      space = 0;
    } else if (isspace(character) && space == 0) {
      putchar(character);
      space = 1;
    }
  }
}


x86 assembly (clang, -O0):
<squeeze_spaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e98(%rip),%rcx
cmp    (%rcx),%eax
je     11b3 <squeeze_spaces+0x83>
mov    -0x4(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
jne    117e <squeeze_spaces+0x4e>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x0,-0x8(%rbp)
jmp    11ae <squeeze_spaces+0x7e>
mov    -0x4(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11a9 <squeeze_spaces+0x79>
cmpl   $0x0,-0x8(%rbp)
jne    11a9 <squeeze_spaces+0x79>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x1,-0x8(%rbp)
jmp    11ae <squeeze_spaces+0x7e>
jmp    113f <squeeze_spaces+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<squeeze_spaces>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2ea3(%rip),%r14
cmp    (%r14),%eax
jne    1155 <squeeze_spaces+0x25>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
xor    %r15d,%r15d
jmp    117a <squeeze_spaces+0x4a>
nopl   0x0(%rax)
xor    %ebp,%ebp
mov    %ebx,%edi
call   1030 <putchar@plt>
mov    %ebp,%r15d
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
cmp    (%r14),%eax
je     114a <squeeze_spaces+0x1a>
mov    %ebx,%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     1160 <squeeze_spaces+0x30>
mov    %ebx,%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     116c <squeeze_spaces+0x3c>
mov    $0x1,%ebp
test   %r15d,%r15d
je     1162 <squeeze_spaces+0x32>
jmp    116c <squeeze_spaces+0x3c>

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

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