#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 /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ close(int);
int lseek(int, int, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, char *, int);
int main(int argc, char *argv[]) {
  int fd, count = 0, len, wCount = 0, lCount = 0, f = 0;
  char buffer, flag = 'y';
  fd = open(argv[1], O_RDWR);
  if (fd != -1) {
    len = lseek(fd, 0L, 2);
    while (lseek(fd, count, 0) < len) {
      count++;
      read(fd, &buffer, sizeof(char));
      if ((char)buffer == ' ' || (char)buffer == '\t')
        f = 0;
      else if ((char)buffer == '\n') {
        lCount++;
        f = 0;
      } else if (f == 0) {
        f = 1;
        wCount++;
      }
    }
    printf("No of Lines= %d", lCount);
    printf("\nNo of Words= %d", wCount);
    printf("\nNo of Characters= %d\n", len);
  } else
    printf("\nFile not found\n");
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movb   $0x79,-0x2a(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
je     1294 <main+0x144>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <lseek@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
xor    %edx,%edx
call   1040 <lseek@plt>
cmp    -0x1c(%rbp),%eax
jge    125c <main+0x10c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x29(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
movsbl -0x29(%rbp),%eax
cmp    $0x20,%eax
je     1205 <main+0xb5>
movsbl -0x29(%rbp),%eax
cmp    $0x9,%eax
jne    1211 <main+0xc1>
movl   $0x0,-0x28(%rbp)
jmp    1257 <main+0x107>
movsbl -0x29(%rbp),%eax
cmp    $0xa,%eax
jne    1233 <main+0xe3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
jmp    1252 <main+0x102>
cmpl   $0x0,-0x28(%rbp)
jne    124d <main+0xfd>
movl   $0x1,-0x28(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1252 <main+0x102>
jmp    1257 <main+0x107>
jmp    11bb <main+0x6b>
mov    -0x24(%rbp),%esi
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xd99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a2 <main+0x152>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1261 <main+0x101>
movl   $0x0,0x4(%rsp)
mov    %ebx,%edi
xor    %esi,%esi
mov    $0x2,%edx
call   1050 <lseek@plt>
mov    %eax,%r12d
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <lseek@plt>
mov    $0x0,%r15d
cmp    %r12d,%eax
jge    122b <main+0xcb>
xor    %r14d,%r14d
mov    $0x1,%ebp
lea    0x3(%rsp),%r13
xor    %r15d,%r15d
movl   $0x0,0x4(%rsp)
jmp    11fa <main+0x9a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
xor    %r14d,%r14d
mov    %ebx,%edi
mov    %ebp,%esi
xor    %edx,%edx
call   1050 <lseek@plt>
add    $0x1,%ebp
cmp    %r12d,%eax
jge    122b <main+0xcb>
mov    %ebx,%edi
mov    %r13,%rsi
mov    $0x1,%edx
call   1070 <read@plt>
movzbl 0x3(%rsp),%eax
cmp    $0x9,%al
je     11e4 <main+0x84>
cmp    $0x20,%al
je     11e4 <main+0x84>
cmp    $0xa,%al
je     11e0 <main+0x80>
cmp    $0x1,%r14d
adcl   $0x0,0x4(%rsp)
mov    $0x1,%r14d
jmp    11e7 <main+0x87>
lea    0xdce(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdcd(%rip),%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdcc(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    126d <main+0x10d>
lea    0xdd0(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDWR = global i32 0
@.str = [16 x i8] c"No of Lines= %d\00"
@.str.1 = [17 x i8] c"\0ANo of Words= %d\00"
@.str.2 = [23 x i8] c"\0ANo of Characters= %d\0A\00"
@.str.3 = [17 x i8] c"\0AFile not found\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
%13 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i8 121, i8* %13
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i32, i32* @O_RDWR
%18 = call i32 @open(i8* %16, i32 %17)
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp ne i32 %19, -1
br i1 %20, label %21, label %66
21: ; preds = %2
%22 = load i32, i32* %6
%23 = call i32 @lseek(i32 %22, i32 0, i32 2)
store i32 %23, i32* %8
br label %24
24: ; preds = %58, %21
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = call i32 @lseek(i32 %25, i32 %26, i32 0)
%28 = load i32, i32* %8
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %59
30: ; preds = %24
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
%33 = load i32, i32* %6
%34 = call i32 @read(i32 %33, i8* %12, i32 1)
%35 = load i8, i8* %12
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 32
br i1 %37, label %42, label %38
38: ; preds = %30
%39 = load i8, i8* %12
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 9
br i1 %41, label %42, label %43
42: ; preds = %38, %30
store i32 0, i32* %11
br label %58
43: ; preds = %38
%44 = load i8, i8* %12
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 10
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load i32, i32* %10
%49 = add nsw i32 %48, 1
store i32 %49, i32* %10
store i32 0, i32* %11
br label %57
50: ; preds = %43
%51 = load i32, i32* %11
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %50
store i32 1, i32* %11
%54 = load i32, i32* %9
%55 = add nsw i32 %54, 1
store i32 %55, i32* %9
br label %56
56: ; preds = %53, %50
br label %57
57: ; preds = %56, %47
br label %58
58: ; preds = %57, %42
br label %24
59: ; preds = %24
%60 = load i32, i32* %10
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %60)
%62 = load i32, i32* %9
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %62)
%64 = load i32, i32* %8
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %64)
br label %68
66: ; preds = %2
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
br label %68
68: ; preds = %66, %59
%69 = load i32, i32* %6
%70 = call i32 @close(i32 %69)
ret i32 0
}

LLVM IR (-O2):
@O_RDWR = global i32 0
@.str = [16 x i8] c"No of Lines= %d\00"
@.str.1 = [17 x i8] c"\0ANo of Words= %d\00"
@.str.2 = [23 x i8] c"\0ANo of Characters= %d\0A\00"
@str = [16 x i8] c"\0AFile not found\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = load i32, i32* @O_RDWR
%7 = tail call i32 @open(i8* %5, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %39, label %9
9: ; preds = %2
%10 = tail call i32 @lseek(i32 %7, i32 0, i32 2)
%11 = tail call i32 @lseek(i32 %7, i32 0, i32 0)
%12 = icmp slt i32 %11, %10
br i1 %12, label %13, label %33
13: ; preds = %9, %27
%14 = phi i32 [ %30, %27 ], [ 0, %9 ]
%15 = phi i32 [ %29, %27 ], [ 0, %9 ]
%16 = phi i32 [ %28, %27 ], [ 0, %9 ]
%17 = phi i32 [ %18, %27 ], [ 0, %9 ]
%18 = add nuw nsw i32 %17, 1
%19 = call i32 @read(i32 %7, i8* %3, i32 1)
%20 = load i8, i8* %3
switch i8 %20, label %23 [
i8 32, label %27
i8 9, label %27
i8 10, label %21
]
21: ; preds = %13
%22 = add nsw i32 %15, 1
br label %27
23: ; preds = %13
%24 = icmp eq i32 %14, 0
%25 = zext i1 %24 to i32
%26 = add nsw i32 %16, %25
br label %27
27: ; preds = %23, %13, %13, %21
%28 = phi i32 [ %16, %21 ], [ %16, %13 ], [ %16, %13 ], [ %26, %23 ]
%29 = phi i32 [ %22, %21 ], [ %15, %13 ], [ %15, %13 ], [ %15, %23 ]
%30 = phi i32 [ 0, %21 ], [ 0, %13 ], [ 0, %13 ], [ 1, %23 ]
%31 = tail call i32 @lseek(i32 %7, i32 %18, i32 0)
%32 = icmp slt i32 %31, %10
br i1 %32, label %13, label %33
33: ; preds = %27, %9
%34 = phi i32 [ 0, %9 ], [ %28, %27 ]
%35 = phi i32 [ 0, %9 ], [ %29, %27 ]
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %10)
br label %41
39: ; preds = %2
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %41
41: ; preds = %39, %33
%42 = tail call i32 @close(i32 %7)
ret i32 0
}