#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 main(void) {
  char c[500], tempChar;
  unsigned int wordsNum, linesNum, charsNum;
  unsigned int i;
  wordsNum = 1;
  linesNum = 1;
  charsNum = 0;
  i = 0;
  printf("Input your chars please:\n");
  while ((tempChar = getchar()) != EOF) {
    c[i] = tempChar;
    i++;
    switch (tempChar) {
    case '\n':
      linesNum++;
    case ' ':
      wordsNum++;
      break;
    default:
      charsNum++;
    }
    if (i == 20) {
      printf("your char array is full\n");
      c[i] = '\0';
      printf("%s \n", c);
      break;
    }
  }
  printf("Your've input %d chars.\n", charsNum);
  printf("Your've input %d words.\n", wordsNum);
  printf("Your've input %d lines.\n", linesNum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x208(%rbp)
movl   $0x1,-0x20c(%rbp)
movl   $0x0,-0x210(%rbp)
movl   $0x0,-0x214(%rbp)
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x201(%rbp)
movsbl %al,%eax
mov    0x2e69(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1255 <main+0x135>
mov    -0x201(%rbp),%cl
mov    -0x214(%rbp),%eax
mov    %cl,-0x200(%rbp,%rax,1)
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
movsbl -0x201(%rbp),%eax
mov    %eax,-0x218(%rbp)
sub    $0xa,%eax
je     11db <main+0xbb>
jmp    11c7 <main+0xa7>
mov    -0x218(%rbp),%eax
sub    $0x20,%eax
je     11ea <main+0xca>
jmp    11fe <main+0xde>
mov    -0x20c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20c(%rbp)
mov    -0x208(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x208(%rbp)
jmp    120d <main+0xed>
mov    -0x210(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x210(%rbp)
cmpl   $0x14,-0x214(%rbp)
jne    1250 <main+0x130>
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x214(%rbp),%eax
movb   $0x0,-0x200(%rbp,%rax,1)
lea    -0x200(%rbp),%rsi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1255 <main+0x135>
jmp    1168 <main+0x48>
mov    -0x210(%rbp),%esi
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x208(%rbp),%esi
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20c(%rbp),%esi
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
lea    0xf0a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
mov    0x2e91(%rip),%r15
xor    %ebx,%ebx
mov    $0x1,%r14d
xor    %r12d,%r12d
jmp    117a <main+0x4a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r12d
cmp    $0x14,%rbx
je     11a7 <main+0x77>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r15),%al
je     11c9 <main+0x99>
movsbl %al,%ecx
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x20,%ecx
je     119e <main+0x6e>
cmp    $0xa,%ecx
jne    1170 <main+0x40>
add    $0x1,%r14d
add    $0x1,%ebp
cmp    $0x14,%rbx
jne    117a <main+0x4a>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
movb   $0x0,0x14(%rsp)
lea    0xe41(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe35(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe3d(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe46(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Input your chars please:\0A\00"
@EOF = global i8 0
@.str.1 = [25 x i8] c"your char array is full\0A\00"
@.str.2 = [5 x i8] c"%s \0A\00"
@.str.3 = [25 x i8] c"Your've input %d chars.\0A\00"
@.str.4 = [25 x i8] c"Your've input %d words.\0A\00"
@.str.5 = [25 x i8] c"Your've input %d lines.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [500 x i8]
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
store i32 1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %43, %0
%10 = call signext i8 (...) @getchar()
store i8 %10, i8* %3
%11 = sext i8 %10 to i32
%12 = load i8, i8* @EOF
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %11, %13
br i1 %14, label %15, label %44
15: ; preds = %9
%16 = load i8, i8* %3
%17 = load i32, i32* %7
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %18
store i8 %16, i8* %19
%20 = load i32, i32* %7
%21 = add i32 %20, 1
store i32 %21, i32* %7
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
switch i32 %23, label %30 [
i32 10, label %24
i32 32, label %27
]
24: ; preds = %15
%25 = load i32, i32* %5
%26 = add i32 %25, 1
store i32 %26, i32* %5
br label %27
27: ; preds = %15, %24
%28 = load i32, i32* %4
%29 = add i32 %28, 1
store i32 %29, i32* %4
br label %33
30: ; preds = %15
%31 = load i32, i32* %6
%32 = add i32 %31, 1
store i32 %32, i32* %6
br label %33
33: ; preds = %30, %27
%34 = load i32, i32* %7
%35 = icmp eq i32 %34, 20
br i1 %35, label %36, label %43
36: ; preds = %33
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%38 = load i32, i32* %7
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %39
store i8 0, i8* %40
%41 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %41)
br label %44
43: ; preds = %33
br label %9
44: ; preds = %36, %9
%45 = load i32, i32* %6
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = load i32, i32* %4
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %5
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %49)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
@.str.2 = [5 x i8] c"%s \0A\00"
@.str.3 = [25 x i8] c"Your've input %d chars.\0A\00"
@.str.4 = [25 x i8] c"Your've input %d words.\0A\00"
@.str.5 = [25 x i8] c"Your've input %d lines.\0A\00"
@str = [25 x i8] c"Input your chars please:\00"
@str.6 = [24 x i8] c"your char array is full\00"
define i32 @main() {
%1 = alloca [500 x i8]
%2 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %4
4: ; preds = %23, %0
%5 = phi i64 [ %15, %23 ], [ 0, %0 ]
%6 = phi i32 [ %24, %23 ], [ 1, %0 ]
%7 = phi i32 [ %25, %23 ], [ 1, %0 ]
%8 = phi i32 [ %26, %23 ], [ 0, %0 ]
%9 = tail call signext i8 (...) @getchar()
%10 = load i8, i8* @EOF
%11 = icmp eq i8 %9, %10
br i1 %11, label %32, label %12
12: ; preds = %4
%13 = sext i8 %9 to i32
%14 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %5
store i8 %9, i8* %14
%15 = add nuw nsw i64 %5, 1
switch i32 %13, label %21 [
i32 10, label %16
i32 32, label %18
]
16: ; preds = %12
%17 = add i32 %7, 1
br label %18
18: ; preds = %12, %16
%19 = phi i32 [ %7, %12 ], [ %17, %16 ]
%20 = add i32 %6, 1
br label %23
21: ; preds = %12
%22 = add i32 %8, 1
br label %23
23: ; preds = %21, %18
%24 = phi i32 [ %6, %21 ], [ %20, %18 ]
%25 = phi i32 [ %7, %21 ], [ %19, %18 ]
%26 = phi i32 [ %22, %21 ], [ %8, %18 ]
%27 = icmp eq i64 %15, 20
br i1 %27, label %28, label %4
28: ; preds = %23
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.6, i64 0, i64 0))
%30 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 20
store i8 0, i8* %30
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %2)
br label %32
32: ; preds = %4, %28
%33 = phi i32 [ %24, %28 ], [ %6, %4 ]
%34 = phi i32 [ %25, %28 ], [ %7, %4 ]
%35 = phi i32 [ %26, %28 ], [ %8, %4 ]
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %35)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %34)
ret i32 0
}