#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);
ln_2(void) {
  int c, am_primit_deja_spatiu;
  am_primit_deja_spatiu = 0;
  printf("Input some characters, when you finishes, press Ctrl+D.\n");
  while ((c = getchar()) != EOF)
    if (c == ' ') {
      if (!am_primit_deja_spatiu) {
        am_primit_deja_spatiu = 1;
        putchar(c);
      }
    } else {
      am_primit_deja_spatiu = 0;
      putchar(c);
    }
}


x86 assembly (clang, -O0):
<ln_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0xc(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%eax
je     11a0 <ln_2+0x70>
cmpl   $0x20,-0x8(%rbp)
jne    118c <ln_2+0x5c>
cmpl   $0x0,-0xc(%rbp)
jne    1187 <ln_2+0x57>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    119b <ln_2+0x6b>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
jmp    114b <ln_2+0x1b>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ln_2>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e9b(%rip),%rbx
cmp    (%rbx),%eax
jne    1158 <ln_2+0x28>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %ecx,%ecx
jmp    1174 <ln_2+0x44>
nopl   0x0(%rax)
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %ebp,%ecx
cmp    (%rbx),%eax
je     1151 <ln_2+0x21>
xor    %ebp,%ebp
cmp    $0x20,%eax
jne    1160 <ln_2+0x30>
mov    $0x1,%ebp
test   %ecx,%ecx
jne    1167 <ln_2+0x37>
mov    $0x20,%eax
jmp    1160 <ln_2+0x30>

LLVM IR (-O0):
@.str = [57 x i8] c"Input some characters, when you finishes, press Ctrl+D.\0A\00"
@EOF = global i32 0
define i32 @ln_2() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %3
%4 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %22, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %2
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %23
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 32
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
store i32 1, i32* %3
%16 = load i32, i32* %2
%17 = call i32 @putchar(i32 %16)
br label %18
18: ; preds = %15, %12
br label %22
19: ; preds = %9
store i32 0, i32* %3
%20 = load i32, i32* %2
%21 = call i32 @putchar(i32 %20)
br label %22
22: ; preds = %19, %18
br label %5
23: ; preds = %5
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@EOF = global i32 0
@str = [56 x i8] c"Input some characters, when you finishes, press Ctrl+D.\00"
define i32 @ln_2() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 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, 0
br i1 %10, label %11, label %15
11: ; preds = %5, %9
%12 = phi i32 [ 32, %9 ], [ %6, %5 ]
%13 = phi i32 [ 1, %9 ], [ 0, %5 ]
%14 = tail call i32 @putchar(i32 %12)
br label %15
15: ; preds = %11, %9
%16 = phi i32 [ 1, %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 undef
}