#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 */
int EOF;
int getchar();
int /*<<< orphan*/ printf(char *, ...);
main() {
  int c, nc, nl, nw, P = 0, cl = 1;
  printf("I will count your characters, words, and lines.\n");
  while (cl == 1) {
    nc = 0;
    nl = 0;
    nw = 0;
    printf("Type below, ctrl+d to stop\n");
    while ((c = getchar()) != EOF) {
      ++nc;
      if (c == '\n')
        ++nl;
      if (c == ' ' || c == '\t' || c == '\n')
        P = 0;
      else if (P == 0) {
        P = 1;
        ++nw;
      }
      if (nl == 0 && nc > 0)
        nl++;
    }
    printf("\nFound: %d lines, %d words, %d Characters\n", nl, nw, nc);
    printf("Try again? (Y or N)\n");
    cl = -1;
    while (cl == -1) {
      c = getchar();
      if (c == 'n' || c == 'N')
        cl = 0;
      else if (c == 'y' || c == 'Y')
        cl = 1;
      else if (c != '\n')
        printf("Y or N please.\n");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    12c4 <main+0x1a4>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e5f(%rip),%rcx
cmp    (%rcx),%eax
je     1218 <main+0xf8>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0x8(%rbp)
jne    11ad <main+0x8d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x20,-0x8(%rbp)
je     11cb <main+0xab>
cmpl   $0x9,-0x8(%rbp)
je     11cb <main+0xab>
cmpl   $0xa,-0x8(%rbp)
jne    11d7 <main+0xb7>
movl   $0x0,-0x18(%rbp)
jmp    11f6 <main+0xd6>
cmpl   $0x0,-0x18(%rbp)
jne    11f1 <main+0xd1>
movl   $0x1,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f6 <main+0xd6>
cmpl   $0x0,-0x10(%rbp)
jne    1213 <main+0xf3>
cmpl   $0x0,-0xc(%rbp)
jle    1213 <main+0xf3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1178 <main+0x58>
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    12bf <main+0x19f>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x6e,-0x8(%rbp)
je     126c <main+0x14c>
cmpl   $0x4e,-0x8(%rbp)
jne    1278 <main+0x158>
movl   $0x0,-0x1c(%rbp)
jmp    12ba <main+0x19a>
cmpl   $0x79,-0x8(%rbp)
je     128c <main+0x16c>
cmpl   $0x59,-0x8(%rbp)
jne    1298 <main+0x178>
movl   $0x1,-0x1c(%rbp)
jmp    12b5 <main+0x195>
cmpl   $0xa,-0x8(%rbp)
je     12b0 <main+0x190>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b5 <main+0x195>
jmp    12ba <main+0x19a>
jmp    1244 <main+0x124>
jmp    114b <main+0x2b>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0d(%rip),%rdi
mov    0x2e93(%rip),%r13
mov    $0x1,%r15d
xor    %r14d,%r14d
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    0x0(%r13),%eax
jne    11d0 <main+0xa0>
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r12d,%r12d
lea    0xe82(%rip),%rdi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee3(%rip),%rdi
call   1030 <puts@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ecx
and    $0xffffffdf,%ecx
cmp    $0x4e,%ecx
je     124c <main+0x11c>
cmp    $0x59,%ecx
je     1240 <main+0x110>
cmp    $0xa,%eax
je     11a0 <main+0x70>
lea    0xec0(%rip),%rdi
jmp    1193 <main+0x63>
nopl   0x0(%rax)
xor    %r12d,%r12d
xor    %ecx,%ecx
xor    %ebx,%ebx
jmp    120a <main+0xda>
nopl   0x0(%rax)
cmp    $0x1,%r14d
adc    $0x0,%r12d
mov    $0x1,%r14d
test   %ebp,%ebp
cmove  %r15d,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0x1,%ebx
mov    %ebp,%ecx
cmp    0x0(%r13),%eax
je     1177 <main+0x47>
xor    %ebp,%ebp
cmp    $0xa,%eax
sete   %bpl
add    %ecx,%ebp
cmp    $0x20,%eax
ja     11e0 <main+0xb0>
mov    %eax,%eax
movabs $0x100000600,%rcx
bt     %rax,%rcx
jae    11e0 <main+0xb0>
xor    %r14d,%r14d
jmp    11ee <main+0xbe>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe14(%rip),%rdi
jmp    115e <main+0x2e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"I will count your characters, words, and lines.\0A\00"
@.str.1 = [28 x i8] c"Type below, ctrl+d to stop\0A\00"
@EOF = global i32 0
@.str.2 = [43 x i8] c"\0AFound: %d lines, %d words, %d Characters\0A\00"
@.str.3 = [21 x i8] c"Try again? (Y or N)\0A\00"
@.str.4 = [16 x i8] c"Y or N please.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
store i32 1, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %85, %0
%10 = load i32, i32* %7
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %86
12: ; preds = %9
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %52, %12
%15 = call i32 (...) @getchar()
store i32 %15, i32* %2
%16 = load i32, i32* @EOF
%17 = icmp ne i32 %15, %16
br i1 %17, label %18, label %53
18: ; preds = %14
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 10
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %26
26: ; preds = %23, %18
%27 = load i32, i32* %2
%28 = icmp eq i32 %27, 32
br i1 %28, label %35, label %29
29: ; preds = %26
%30 = load i32, i32* %2
%31 = icmp eq i32 %30, 9
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = load i32, i32* %2
%34 = icmp eq i32 %33, 10
br i1 %34, label %35, label %36
35: ; preds = %32, %29, %26
store i32 0, i32* %6
br label %43
36: ; preds = %32
%37 = load i32, i32* %6
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %42
39: ; preds = %36
store i32 1, i32* %6
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 1
store i32 %41, i32* %5
br label %42
42: ; preds = %39, %36
br label %43
43: ; preds = %42, %35
%44 = load i32, i32* %4
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %52
46: ; preds = %43
%47 = load i32, i32* %3
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %46
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %52
52: ; preds = %49, %46, %43
br label %14
53: ; preds = %14
%54 = load i32, i32* %4
%55 = load i32, i32* %5
%56 = load i32, i32* %3
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %54, i32 %55, i32 %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %7
br label %59
59: ; preds = %84, %53
%60 = load i32, i32* %7
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %85
62: ; preds = %59
%63 = call i32 (...) @getchar()
store i32 %63, i32* %2
%64 = load i32, i32* %2
%65 = icmp eq i32 %64, 110
br i1 %65, label %69, label %66
66: ; preds = %62
%67 = load i32, i32* %2
%68 = icmp eq i32 %67, 78
br i1 %68, label %69, label %70
69: ; preds = %66, %62
store i32 0, i32* %7
br label %84
70: ; preds = %66
%71 = load i32, i32* %2
%72 = icmp eq i32 %71, 121
br i1 %72, label %76, label %73
73: ; preds = %70
%74 = load i32, i32* %2
%75 = icmp eq i32 %74, 89
br i1 %75, label %76, label %77
76: ; preds = %73, %70
store i32 1, i32* %7
br label %83
77: ; preds = %73
%78 = load i32, i32* %2
%79 = icmp ne i32 %78, 10
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %82
82: ; preds = %80, %77
br label %83
83: ; preds = %82, %76
br label %84
84: ; preds = %83, %69
br label %59
85: ; preds = %59
br label %9
86: ; preds = %9
%87 = load i32, i32* %1
ret i32 %87
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.2 = [43 x i8] c"\0AFound: %d lines, %d words, %d Characters\0A\00"
@str = [48 x i8] c"I will count your characters, words, and lines.\00"
@str.5 = [27 x i8] c"Type below, ctrl+d to stop\00"
@str.6 = [20 x i8] c"Try again? (Y or N)\00"
@str.7 = [15 x i8] c"Y or N please.\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %39, %0
%3 = phi i32 [ 0, %0 ], [ %34, %39 ]
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.5, i64 0, i64 0))
%5 = tail call i32 (...) @getchar()
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %30, label %8
8: ; preds = %2, %22
%9 = phi i32 [ %27, %22 ], [ %5, %2 ]
%10 = phi i32 [ %24, %22 ], [ %3, %2 ]
%11 = phi i32 [ %23, %22 ], [ 0, %2 ]
%12 = phi i32 [ %26, %22 ], [ 0, %2 ]
%13 = phi i32 [ %14, %22 ], [ 0, %2 ]
%14 = add nuw nsw i32 %13, 1
%15 = icmp eq i32 %9, 10
%16 = zext i1 %15 to i32
%17 = add nsw i32 %12, %16
switch i32 %9, label %18 [
i32 32, label %22
i32 10, label %22
i32 9, label %22
]
18: ; preds = %8
%19 = icmp eq i32 %10, 0
%20 = zext i1 %19 to i32
%21 = add nsw i32 %11, %20
br label %22
22: ; preds = %18, %8, %8, %8
%23 = phi i32 [ %11, %8 ], [ %21, %18 ], [ %11, %8 ], [ %11, %8 ]
%24 = phi i32 [ 0, %8 ], [ 1, %18 ], [ 0, %8 ], [ 0, %8 ]
%25 = icmp eq i32 %17, 0
%26 = select i1 %25, i32 1, i32 %17
%27 = tail call i32 (...) @getchar()
%28 = load i32, i32* @EOF
%29 = icmp eq i32 %27, %28
br i1 %29, label %30, label %8
30: ; preds = %22, %2
%31 = phi i32 [ 0, %2 ], [ %14, %22 ]
%32 = phi i32 [ 0, %2 ], [ %26, %22 ]
%33 = phi i32 [ 0, %2 ], [ %23, %22 ]
%34 = phi i32 [ %3, %2 ], [ %24, %22 ]
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %32, i32 %33, i32 %31)
br label %36
36: ; preds = %42, %30
%37 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.6, i64 0, i64 0), %30 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.7, i64 0, i64 0), %42 ]
%38 = tail call i32 @puts(i8* dereferenceable(1) %37)
br label %39
39: ; preds = %36, %42
%40 = tail call i32 (...) @getchar()
%41 = and i32 %40, -33
switch i32 %41, label %42 [
i32 78, label %44
i32 89, label %2
]
42: ; preds = %39
%43 = icmp eq i32 %40, 10
br i1 %43, label %39, label %36
44: ; preds = %39
ret i32 0
}