#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 EOF;
char getchar();
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char **argv) {
  register char c;
  register int n = 1;
  while ((c = getchar()) != EOF) {
    if (c == '\n') {
      printf("%d\n", n);
      n = 1;
    } else if (c == ' ') {
      n++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e97(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11a4 <main+0x84>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
jne    1184 <main+0x64>
mov    -0x18(%rbp),%esi
lea    0xe8d(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
jmp    119f <main+0x7f>
movsbl -0x11(%rbp),%eax
cmp    $0x20,%eax
jne    119a <main+0x7a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119f <main+0x7f>
jmp    113d <main+0x1d>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb6(%rip),%rbx
cmp    (%rbx),%al
jne    113d <main+0x1d>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x1,%ebp
lea    0xeb7(%rip),%r14
jmp    115e <main+0x3e>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%al
je     1136 <main+0x16>
cmp    $0x20,%al
je     1150 <main+0x30>
cmp    $0xa,%al
jne    1153 <main+0x33>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    $0x1,%ebp
jmp    1153 <main+0x33>

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

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