#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*/ printf(char *, int);
int main() {
  int last_character, space_count;
  while ((last_character = getchar()) != EOF) {
    if (isspace(last_character)) {
      ++space_count;
    }
  }
  printf("There was found %d spaces in input\n", space_count);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e98(%rip),%rcx
cmp    (%rcx),%eax
je     1178 <main+0x48>
mov    -0x8(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1173 <main+0x43>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113f <main+0xf>
mov    -0xc(%rbp),%esi
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2ea6(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%edi
call   1040 <isspace@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebx
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%eax
jne    1150 <main+0x20>
lea    0xe8f(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [36 x i8] c"There was found %d spaces in input\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %15, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %16
8: ; preds = %4
%9 = load i32, i32* %2
%10 = call i64 @isspace(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %15
15: ; preds = %12, %8
br label %4
16: ; preds = %4
%17 = load i32, i32* %3
%18 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [36 x i8] c"There was found %d spaces in input\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp ne i32 %1, %2
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ %11, %4 ], [ %1, %0 ]
%6 = phi i32 [ %10, %4 ], [ undef, %0 ]
%7 = tail call i64 @isspace(i32 %5)
%8 = icmp ne i64 %7, 0
%9 = zext i1 %8 to i32
%10 = add nsw i32 %6, %9
%11 = tail call i32 (...) @getchar()
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %4
14: ; preds = %4
%15 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %10)
ret i32 0
}