#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) {
  int iLineNum = 0;
  char cCharA = 0;
  while ((cCharA = getchar()) != EOF) {
    if (cCharA == '\n') {
      iLineNum++;
    }
  }
  printf("Number of Line is %d\n", iLineNum);
  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   $0x0,-0x14(%rbp)
movb   $0x0,-0x15(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%eax
mov    0x2e93(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     117b <main+0x5b>
movsbl -0x15(%rbp),%eax
cmp    $0xa,%eax
jne    1176 <main+0x56>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1141 <main+0x21>
mov    -0x14(%rbp),%esi
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb4(%rip),%r14
cmp    (%r14),%al
je     1155 <main+0x35>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %ecx,%ecx
cmp    $0xa,%al
sete   %cl
add    %ecx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%al
jne    1140 <main+0x20>
lea    0xea4(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i8 0
@.str = [22 x i8] c"Number of Line is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8 0, i8* %7
br label %8
8: ; preds = %21, %2
%9 = call signext i8 (...) @getchar()
store i8 %9, i8* %7
%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 %22
14: ; preds = %8
%15 = load i8, i8* %7
%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* %6
%20 = add nsw i32 %19, 1
store i32 %20, i32* %6
br label %21
21: ; preds = %18, %14
br label %8
22: ; preds = %8
%23 = load i32, i32* %6
%24 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %23)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [22 x i8] c"Number of Line is %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 %15, label %6
6: ; preds = %2, %6
%7 = phi i8 [ %12, %6 ], [ %3, %2 ]
%8 = phi i32 [ %11, %6 ], [ 0, %2 ]
%9 = icmp eq i8 %7, 10
%10 = zext i1 %9 to i32
%11 = add nuw nsw i32 %8, %10
%12 = tail call signext i8 (...) @getchar()
%13 = load i8, i8* @EOF
%14 = icmp eq i8 %12, %13
br i1 %14, label %15, label %6
15: ; preds = %6, %2
%16 = phi i32 [ 0, %2 ], [ %11, %6 ]
%17 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %16)
ret i32 0
}