#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) {
    print_usage();
    return -EINVAL;
  }
  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 (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>
mov    $0x0,%al
call   1080 <print_usage@plt>
xor    %eax,%eax
mov    0x2e2b(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1354 <main+0x1f4>
jmp    11b4 <main+0x54>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
lea    0xe3b(%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    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1354 <main+0x1f4>
xor    %eax,%eax
mov    0x2d7f(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1354 <main+0x1f4>
jmp    11b4 <main+0x54>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xda1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x28(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    12c1 <main+0x161>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
mov    0x2d21(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1354 <main+0x1f4>
jmp    12c6 <main+0x166>
mov    -0x28(%rbp),%rcx
lea    -0x29(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
cmp    $0x1,%eax
jne    1344 <main+0x1e4>
cmpl   $0x0,-0x20(%rbp)
je     1319 <main+0x1b9>
cmpl   $0x0,-0x18(%rbp)
je     1319 <main+0x1b9>
mov    -0x1c(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movsbl -0x29(%rbp),%edx
lea    0xd22(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    132b <main+0x1cb>
movsbl -0x29(%rbp),%esi
lea    0xd0f(%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    12c6 <main+0x166>
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    1197 <main+0x27>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <print_usage@plt>
mov    0x2e40(%rip),%rax
sub    (%rax),%ebx
jmp    12ca <main+0x15a>
mov    %rsi,%r15
mov    %edi,%ebp
add    $0xffffffff,%ebp
xor    %ecx,%ecx
lea    0xe58(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %ecx,%ebx
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
call   1080 <getopt@plt>
mov    $0x1,%cl
cmp    $0x6e,%eax
je     11b0 <main+0x40>
cmp    $0xffffffff,%eax
je     11fe <main+0x8e>
cmp    $0x68,%eax
je     11f0 <main+0x80>
cmp    $0x3f,%eax
jne    12b2 <main+0x142>
mov    0x2e08(%rip),%rax
mov    (%rax),%esi
lea    0xe1a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <print_usage@plt>
jmp    12ca <main+0x15a>
movslq %ebp,%rbp
mov    (%r15,%rbp,8),%rdi
lea    0xe0d(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     12db <main+0x16b>
mov    %rax,%r12
lea    0x7(%rsp),%rdi
mov    $0x1,%ebp
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    12c0 <main+0x150>
not    %bl
lea    0x7(%rsp),%r15
xor    %r13d,%r13d
jmp    1283 <main+0x113>
xchg   %ax,%ax
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   1040 <fread@plt>
cmp    $0x1,%eax
jne    12c0 <main+0x150>
test   %ebp,%ebp
sete   %al
or     %bl,%al
test   $0x1,%al
jne    1250 <main+0xe0>
lea    0x1(%r13),%ebp
movzbl 0x7(%rsp),%r14d
movsbl %r14b,%edx
lea    0xd8c(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebp,%r13d
jmp    125f <main+0xef>
mov    0x2d17(%rip),%rax
xor    %ebx,%ebx
jmp    1190 <main+0x20>
mov    %r12,%rdi
call   1050 <fclose@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r15,%rbp,8),%rsi
lea    0xd35(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2ce2(%rip),%rax
jmp    1190 <main+0x20>

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

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