#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 in;
  int sp = 0;
  int tc = 0;
  while (in = getchar()) {
    if (in != 10) {
      tc += 1;
      sp += (in == 32) ? 1 : 0;
    } else {
      break;
    }
  }
  printf("%d\n", tc - sp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
cmp    $0x0,%al
je     118b <main+0x6b>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
je     1181 <main+0x61>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movsbl -0x5(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x20,%edx
cmove  %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1186 <main+0x66>
jmp    118b <main+0x6b>
jmp    113d <main+0x1d>
mov    -0x10(%rbp),%esi
sub    -0xc(%rbp),%esi
lea    0xe68(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
test   %al,%al
je     114d <main+0x2d>
cmp    $0xa,%al
je     114d <main+0x2d>
add    $0x1,%ebx
xor    %ecx,%ecx
cmp    $0x20,%al
sete   %cl
add    %ecx,%ebp
jmp    1130 <main+0x10>
sub    %ebp,%ebx
lea    0xeaa(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %23, %0
%6 = call signext i8 (...) @getchar()
store i8 %6, i8* %2
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
store i32 %14, i32* %4
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 32
%18 = zext i1 %17 to i64
%19 = select i1 %17, i32 1, i32 0
%20 = load i32, i32* %3
%21 = add nsw i32 %20, %19
store i32 %21, i32* %3
br label %23
22: ; preds = %8
br label %24
23: ; preds = %12
br label %5
24: ; preds = %22, %5
%25 = load i32, i32* %4
%26 = load i32, i32* %3
%27 = sub nsw i32 %25, %26
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %5, %0
%2 = phi i32 [ 0, %0 ], [ %9, %5 ]
%3 = phi i32 [ 0, %0 ], [ %6, %5 ]
%4 = tail call signext i8 (...) @getchar()
switch i8 %4, label %5 [
i8 10, label %10
i8 0, label %10
]
5: ; preds = %1
%6 = add nuw nsw i32 %3, 1
%7 = icmp eq i8 %4, 32
%8 = zext i1 %7 to i32
%9 = add nuw nsw i32 %2, %8
br label %1
10: ; preds = %1, %1
%11 = sub nsw i32 %3, %2
%12 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
ret i32 0
}