#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;
  while ('\n' != (array[i] = getchar())) {
    i++;
  }
  i = 0;
  while (' ' != array[i]) {
    i++;
  }
  printf("%d", i + 1);
  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)
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     1198 <main+0x68>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    115f <main+0x2f>
movl   $0x0,-0x414(%rbp)
movslq -0x414(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%ecx
ff
mov    $0x20,%eax
cmp    %ecx,%eax
je     11d2 <main+0xa2>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    11a2 <main+0x72>
mov    -0x414(%rbp),%esi
add    $0x1,%esi
lea    0xe1e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x400,%rsp
mov    %rsp,%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
cmp    $0xa,%al
jne    1150 <main+0x20>
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpb   $0x20,(%rsp,%rsi,1)
lea    0x1(%rsi),%rsi
jne    1170 <main+0x40>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
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
store i32 0, i32* %1
%4 = bitcast [1024 x i8]* %2 to i8*
store i32 0, i32* %3
br label %5
5: ; preds = %12, %0
%6 = call signext i8 (...) @getchar()
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %8
store i8 %6, i8* %9
%10 = sext i8 %6 to i32
%11 = icmp ne i32 10, %10
br i1 %11, label %12, label %15
12: ; preds = %5
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %5
15: ; preds = %5
store i32 0, i32* %3
br label %16
16: ; preds = %23, %15
%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
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 32, %21
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %16
26: ; preds = %16
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
%29 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %28)
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, %9
%10 = phi i64 [ %14, %9 ], [ 0, %3 ]
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 32
%14 = add nuw i64 %10, 1
br i1 %13, label %15, label %9
15: ; preds = %9
%16 = trunc i64 %10 to i32
%17 = add nuw nsw i32 %16, 1
%18 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %17)
ret i32 0
}