#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EINVAL;
int errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int getopt(int, char **, char *);
int optopt;
int /*<<< orphan*/ print_usage();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int opt;
  int number = 0, line = 0, new_line = 1;
  FILE *fd;
  char buff;
  if (argc < 2) {
    printf("Please enter correct file name\n");
    return 0;
  }
  while (-1 != (opt = getopt(argc - 1, argv, "nh"))) {
    switch (opt) {
    case 'n':
      number = 1;
      break;
    case '?':
      printf("Invalid option `-%c'\n", optopt);
    case 'h':
      print_usage();
      return 0;
    default:
      return -EINVAL;
    }
  }
  if (argc < 2) {
    print_usage();
    return 0;
  }
  if (NULL == (fd = fopen(argv[argc - 1], "r"))) {
    printf("Can't open file %s\n", argv[argc - 1]);
    return -errno;
  }
  while (fread(&buff, 1, 1, fd) == 1) {
    if (new_line && number) {
      printf("\t%d %c", line++, buff);
    } else {
      printf("%c", buff);
    }
    new_line = (buff == '\n') ? 1 : 0;
  }
  fclose(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,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11af <main+0x4f>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1371 <main+0x211>
jmp    11b4 <main+0x54>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
lea    0xe5b(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
je     1260 <main+0x100>
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
sub    $0x3f,%eax
je     121e <main+0xbe>
jmp    11f0 <main+0x90>
mov    -0x30(%rbp),%eax
sub    $0x68,%eax
je     1235 <main+0xd5>
jmp    1201 <main+0xa1>
mov    -0x30(%rbp),%eax
sub    $0x6e,%eax
jne    1248 <main+0xe8>
jmp    1212 <main+0xb2>
movl   $0x1,-0x18(%rbp)
jmp    125b <main+0xfb>
mov    0x2dc3(%rip),%rax
mov    (%rax),%esi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1371 <main+0x211>
xor    %eax,%eax
mov    0x2d7f(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1371 <main+0x211>
jmp    11b4 <main+0x54>
cmpl   $0x2,-0x8(%rbp)
jge    127d <main+0x11d>
mov    $0x0,%al
call   1080 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1371 <main+0x211>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xda4(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x28(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    12de <main+0x17e>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    0x2d04(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1371 <main+0x211>
jmp    12e3 <main+0x183>
mov    -0x28(%rbp),%rcx
lea    -0x29(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1361 <main+0x201>
cmpl   $0x0,-0x20(%rbp)
je     1336 <main+0x1d6>
cmpl   $0x0,-0x18(%rbp)
je     1336 <main+0x1d6>
mov    -0x1c(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsbl -0x29(%rbp),%edx
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1348 <main+0x1e8>
movsbl -0x29(%rbp),%esi
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsbl -0x29(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0xa,%edx
cmove  %ecx,%eax
mov    %eax,-0x20(%rbp)
jmp    12e3 <main+0x183>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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
cmp    $0x2,%edi
jge    11a3 <main+0x23>
lea    0xe9f(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
jmp    12f7 <main+0x177>
mov    %rsi,%r15
mov    %edi,%ebp
add    $0xffffffff,%ebp
xor    %ecx,%ecx
lea    0xe4c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ecx,%ebx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
call   1090 <getopt@plt>
mov    $0x1,%cl
cmp    $0x6e,%eax
je     11c0 <main+0x40>
cmp    $0xffffffff,%eax
je     120e <main+0x8e>
cmp    $0x68,%eax
je     1200 <main+0x80>
cmp    $0x3f,%eax
jne    12c2 <main+0x142>
mov    0x2df8(%rip),%rax
mov    (%rax),%esi
lea    0xe0a(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <print_usage@plt>
jmp    12f7 <main+0x177>
mov    %ebp,%ebp
mov    (%r15,%rbp,8),%rdi
lea    0xdfe(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     12da <main+0x15a>
mov    %rax,%r12
lea    0x7(%rsp),%rdi
mov    $0x1,%ebp
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1050 <fread@plt>
cmp    $0x1,%eax
jne    12cd <main+0x14d>
not    %bl
lea    0x7(%rsp),%r15
xor    %r13d,%r13d
jmp    1293 <main+0x113>
nopl   (%rax)
movzbl 0x7(%rsp),%r14d
movsbl %r14b,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
cmp    $0xa,%r14b
sete   %bpl
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1050 <fread@plt>
cmp    $0x1,%eax
jne    12cd <main+0x14d>
test   %ebp,%ebp
sete   %al
or     %bl,%al
test   $0x1,%al
jne    1260 <main+0xe0>
lea    0x1(%r13),%ebp
movzbl 0x7(%rsp),%r14d
movsbl %r14b,%edx
lea    0xd7c(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebp,%r13d
jmp    126f <main+0xef>
mov    0x2d07(%rip),%rax
xor    %ebx,%ebx
jmp    12f5 <main+0x175>
mov    %r12,%rdi
call   1060 <fclose@plt>
jmp    119c <main+0x1c>
mov    (%r15,%rbp,8),%rsi
lea    0xd36(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2ce3(%rip),%rax
sub    (%rax),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Please enter correct file name\0A\00"
@.str.1 = [3 x i8] c"nh\00"
@.str.2 = [22 x i8] c"Invalid option `-%c'\0A\00"
@optopt = global i32 0
@EINVAL = global i32 0
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [20 x i8] c"Can't open file %s\0A\00"
@errno = global i32 0
@.str.5 = [7 x i8] c"\09%d %c\00"
@.str.6 = [3 x i8] c"%c\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 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* %8
store i32 1, i32* %9
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %89
16: ; preds = %2
br label %17
17: ; preds = %34, %16
%18 = load i32, i32* %4
%19 = sub nsw i32 %18, 1
%20 = load i8**, i8*** %5
%21 = call i32 @getopt(i32 %19, i8** %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 %21, i32* %6
%22 = icmp ne i32 -1, %21
br i1 %22, label %23, label %35
23: ; preds = %17
%24 = load i32, i32* %6
switch i32 %24, label %31 [
i32 110, label %25
i32 63, label %26
i32 104, label %29
]
25: ; preds = %23
store i32 1, i32* %7
br label %34
26: ; preds = %23
%27 = load i32, i32* @optopt
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %23, %26
%30 = call i32 (...) @print_usage()
store i32 0, i32* %3
br label %89
31: ; preds = %23
%32 = load i32, i32* @EINVAL
%33 = sub nsw i32 0, %32
store i32 %33, i32* %3
br label %89
34: ; preds = %25
br label %17
35: ; preds = %17
%36 = load i32, i32* %4
%37 = icmp slt i32 %36, 2
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 (...) @print_usage()
store i32 0, i32* %3
br label %89
40: ; preds = %35
%41 = load i8**, i8*** %5
%42 = load i32, i32* %4
%43 = sub nsw i32 %42, 1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %41, i64 %44
%46 = load i8*, i8** %45
%47 = call i32* @fopen(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %47, i32** %10
%48 = icmp eq i32* null, %47
br i1 %48, label %49, label %59
49: ; preds = %40
%50 = load i8**, i8*** %5
%51 = load i32, i32* %4
%52 = sub nsw i32 %51, 1
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %50, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %55)
%57 = load i32, i32* @errno
%58 = sub nsw i32 0, %57
store i32 %58, i32* %3
br label %89
59: ; preds = %40
br label %60
60: ; preds = %80, %59
%61 = load i32*, i32** %10
%62 = call i32 @fread(i8* %11, i32 1, i32 1, i32* %61)
%63 = icmp eq i32 %62, 1
br i1 %63, label %64, label %86
64: ; preds = %60
%65 = load i32, i32* %9
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %76
67: ; preds = %64
%68 = load i32, i32* %7
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %76
70: ; preds = %67
%71 = load i32, i32* %8
%72 = add nsw i32 %71, 1
store i32 %72, i32* %8
%73 = load i8, i8* %11
%74 = sext i8 %73 to i32
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %71, i32 %74)
br label %80
76: ; preds = %67, %64
%77 = load i8, i8* %11
%78 = sext i8 %77 to i32
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %78)
br label %80
80: ; preds = %76, %70
%81 = load i8, i8* %11
%82 = sext i8 %81 to i32
%83 = icmp eq i32 %82, 10
%84 = zext i1 %83 to i64
%85 = select i1 %83, i32 1, i32 0
store i32 %85, i32* %9
br label %60
86: ; preds = %60
%87 = load i32*, i32** %10
%88 = call i32 @fclose(i32* %87)
store i32 0, i32* %3
br label %89
89: ; preds = %86, %49, %38, %31, %29, %14
%90 = load i32, i32* %3
ret i32 %90
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"nh\00"
@.str.2 = [22 x i8] c"Invalid option `-%c'\0A\00"
@optopt = global i32 0
@EINVAL = global i32 0
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [20 x i8] c"Can't open file %s\0A\00"
@errno = global i32 0
@.str.5 = [7 x i8] c"\09%d %c\00"
@str = [31 x i8] c"Please enter correct file name\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8
%4 = icmp slt i32 %0, 2
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = add nsw i32 %0, -1
br label %9
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %57
9: ; preds = %5, %9
%10 = phi i1 [ true, %9 ], [ false, %5 ]
%11 = tail call i32 @getopt(i32 %6, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
switch i32 %11, label %17 [
i32 -1, label %20
i32 110, label %9
i32 63, label %12
i32 104, label %15
]
12: ; preds = %9
%13 = load i32, i32* @optopt
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %9, %12
%16 = tail call i32 (...) @print_usage()
br label %57
17: ; preds = %9
%18 = load i32, i32* @EINVAL
%19 = sub nsw i32 0, %18
br label %57
20: ; preds = %9
%21 = zext i32 %6 to i64
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i8*, i8** %22
%24 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %29, label %26
26: ; preds = %20
%27 = call i32 @fread(i8* %3, i32 1, i32 1, i32* %24)
%28 = icmp eq i32 %27, 1
br i1 %28, label %34, label %55
29: ; preds = %20
%30 = load i8*, i8** %22
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @errno
%33 = sub nsw i32 0, %32
br label %57
34: ; preds = %26, %48
%35 = phi i32 [ %52, %48 ], [ 1, %26 ]
%36 = phi i32 [ %50, %48 ], [ 0, %26 ]
%37 = icmp ne i32 %35, 0
%38 = and i1 %10, %37
br i1 %38, label %39, label %44
39: ; preds = %34
%40 = add nsw i32 %36, 1
%41 = load i8, i8* %3
%42 = sext i8 %41 to i32
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %36, i32 %42)
br label %48
44: ; preds = %34
%45 = load i8, i8* %3
%46 = sext i8 %45 to i32
%47 = tail call i32 @putchar(i32 %46)
br label %48
48: ; preds = %44, %39
%49 = phi i8 [ %41, %39 ], [ %45, %44 ]
%50 = phi i32 [ %40, %39 ], [ %36, %44 ]
%51 = icmp eq i8 %49, 10
%52 = zext i1 %51 to i32
%53 = call i32 @fread(i8* %3, i32 1, i32 1, i32* %24)
%54 = icmp eq i32 %53, 1
br i1 %54, label %34, label %55
55: ; preds = %48, %26
%56 = tail call i32 @fclose(i32* %24)
br label %57
57: ; preds = %55, %29, %17, %15, %7
%58 = phi i32 [ 0, %7 ], [ %19, %17 ], [ 0, %15 ], [ %33, %29 ], [ 0, %55 ]
ret i32 %58
}