#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(void) {
  int ret = 0;
  int toput = 0;
  int c = 0;
  printf("This program replaces the strings that contain more than 1 blanks by "
         "a single blank\n");
  while ((c = getchar()) != EOF) {
    if (c == ' ') {
      if (toput == 1) {
        putchar(c);
        toput = 0;
      }
    } else {
      putchar(c);
      toput = 1;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%eax
je     11b5 <main+0x85>
cmpl   $0x20,-0x10(%rbp)
jne    11a1 <main+0x71>
cmpl   $0x1,-0xc(%rbp)
jne    119c <main+0x6c>
mov    -0x10(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x0,-0xc(%rbp)
jmp    11b0 <main+0x80>
mov    -0x10(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x1,-0xc(%rbp)
jmp    1160 <main+0x30>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9a(%rip),%r14
cmp    (%r14),%eax
jne    115a <main+0x2a>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %ebx,%ebx
jmp    1175 <main+0x45>
xchg   %ax,%ax
mov    %eax,%edi
call   1030 <putchar@plt>
mov    %ebp,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%eax
je     1153 <main+0x23>
mov    $0x1,%ebp
cmp    $0x20,%eax
jne    1160 <main+0x30>
xor    %ebp,%ebp
mov    $0x20,%eax
cmp    $0x1,%ebx
mov    $0x0,%ebx
je     1160 <main+0x30>
jmp    1169 <main+0x39>

LLVM IR (-O0):
@.str = [85 x i8] c"This program replaces the strings that contain more than 1 blanks by a single blank\0A\00"
@EOF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([85 x i8], [85 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %23, %0
%7 = call i32 (...) @getchar()
store i32 %7, i32* %4
%8 = load i32, i32* @EOF
%9 = icmp ne i32 %7, %8
br i1 %9, label %10, label %24
10: ; preds = %6
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 32
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %4
%18 = call i32 @putchar(i32 %17)
store i32 0, i32* %3
br label %19
19: ; preds = %16, %13
br label %23
20: ; preds = %10
%21 = load i32, i32* %4
%22 = call i32 @putchar(i32 %21)
store i32 1, i32* %3
br label %23
23: ; preds = %20, %19
br label %6
24: ; preds = %6
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@EOF = global i32 0
@str = [84 x i8] c"This program replaces the strings that contain more than 1 blanks by a single blank\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([84 x i8], [84 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @getchar()
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %20, label %5
5: ; preds = %0, %15
%6 = phi i32 [ %17, %15 ], [ %2, %0 ]
%7 = phi i32 [ %16, %15 ], [ 0, %0 ]
%8 = icmp eq i32 %6, 32
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = icmp eq i32 %7, 1
br i1 %10, label %11, label %15
11: ; preds = %5, %9
%12 = phi i32 [ 32, %9 ], [ %6, %5 ]
%13 = phi i32 [ 0, %9 ], [ 1, %5 ]
%14 = tail call i32 @putchar(i32 %12)
br label %15
15: ; preds = %11, %9
%16 = phi i32 [ 0, %9 ], [ %13, %11 ]
%17 = tail call i32 (...) @getchar()
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %5
20: ; preds = %15, %0
ret i32 0
}