#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 */
char getchar();
int /*<<< orphan*/ printf(char *, int);
int main() {
  char array[1024] = {};
  int i = 0, count = 0;
  while ('\n' != (array[i] = getchar())) {
    i++;
  }
  array[i] = '\0';
  i = 0;
  for (i = 0; '\0' != array[i]; i++) {
    if (' ' == array[i])
      count += 1;
  }
  count += 1;
  printf("%d", count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
movl   $0x0,-0x414(%rbp)
movl   $0x0,-0x418(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
movslq -0x414(%rbp),%rcx
mov    %al,-0x410(%rbp,%rcx,1)
movsbl %al,%ecx
mov    $0xa,%eax
cmp    %ecx,%eax
je     11a2 <main+0x72>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1169 <main+0x39>
movslq -0x414(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
movl   $0x0,-0x414(%rbp)
movl   $0x0,-0x414(%rbp)
movslq -0x414(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%ecx
ff
xor    %eax,%eax
cmp    %ecx,%eax
je     1222 <main+0xf2>
movslq -0x414(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%ecx
ff
mov    $0x20,%eax
cmp    %ecx,%eax
jne    1209 <main+0xd9>
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
jmp    120e <main+0xde>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    11c5 <main+0x95>
mov    -0x418(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x418(%rbp)
mov    -0x418(%rbp),%esi
lea    0xdc2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%r14
mov    $0x400,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
mov    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,0x1(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0xa,%al
jne    1160 <main+0x30>
mov    %ebx,%eax
movb   $0x0,(%rsp,%rax,1)
xor    %esi,%esi
jmp    1187 <main+0x57>
nopl   (%rax)
add    $0x1,%esi
add    $0x1,%r14
movzbl (%r14),%eax
cmp    $0x20,%al
je     1180 <main+0x50>
test   %al,%al
jne    1183 <main+0x53>
add    $0x1,%esi
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [1024 x i8]* %2 to i8*
store i32 0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %13, %0
%7 = call signext i8 (...) @getchar()
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %9
store i8 %7, i8* %10
%11 = sext i8 %7 to i32
%12 = icmp ne i32 10, %11
br i1 %12, label %13, label %16
13: ; preds = %6
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %6
16: ; preds = %6
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %18
store i8 0, i8* %19
store i32 0, i32* %3
store i32 0, i32* %3
br label %20
20: ; preds = %38, %16
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 0, %25
br i1 %26, label %27, label %41
27: ; preds = %20
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 32, %32
br i1 %33, label %34, label %37
34: ; preds = %27
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %37
37: ; preds = %34, %27
br label %38
38: ; preds = %37
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %20
41: ; preds = %20
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
%44 = load i32, i32* %4
%45 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ %8, %3 ], [ 0, %0 ]
%5 = tail call signext i8 (...) @getchar()
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %4
store i8 %5, i8* %6
%7 = icmp eq i8 %5, 10
%8 = add nuw i64 %4, 1
br i1 %7, label %9, label %3
9: ; preds = %3
%10 = and i64 %4, 4294967295
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %10
store i8 0, i8* %11
br label %12
12: ; preds = %19, %9
%13 = phi i64 [ %21, %19 ], [ 0, %9 ]
%14 = phi i32 [ %20, %19 ], [ 0, %9 ]
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %13
%16 = load i8, i8* %15
switch i8 %16, label %19 [
i8 0, label %22
i8 32, label %17
]
17: ; preds = %12
%18 = add nsw i32 %14, 1
br label %19
19: ; preds = %12, %17
%20 = phi i32 [ %18, %17 ], [ %14, %12 ]
%21 = add nuw i64 %13, 1
br label %12
22: ; preds = %12
%23 = add nsw i32 %14, 1
%24 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %23)
ret i32 0
}