#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 */
struct pollfd {
  int events;
  int revents;
  int /*<<< orphan*/ fd;
};

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDONLY;
int POLLIN;
int /*<<< orphan*/ PROT_READ;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
size_t lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
char *mmap(int /*<<< orphan*/, size_t, int /*<<< orphan*/, int /*<<< orphan*/,
           int, int /*<<< orphan*/);
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char const *);
int poll(struct pollfd *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  if (argc == 1) {
    perror("Not enough arguments");
    exit(1);
  }
  const char *filename = argv[1];
  int fd;
  int i, table_length = 1;
  char *table[101];
  if ((fd = open(filename, O_RDONLY)) == -1) {
    perror(filename);
    exit(1);
  }
  size_t size = lseek(fd, 0, SEEK_END);
  char *p = mmap(0, size, PROT_READ, MAP_SHARED, fd, 0);
  table[0] = p;
  for (i = 0; i < size; i++) {
    if (*(p + i) == '\n') {
      table[table_length++] = p + i;
    } else if (i == size - 1) {
      table[table_length++] = p + i + 1;
    }
  }
  struct pollfd fds[1];
  fds[0].fd = STDIN_FILENO;
  fds[0].events = POLLIN;
  int line_number;
  char *cp;
  while (1) {
    int count = poll(fds, 1, 5 * 1000);
    if (count == -1) {
      perror("poll failed");
      exit(1);
    }
    if (count == 0) {
      printf("No data for reading/writing\n");
    }
    if (fds[0].revents & POLLIN) {
      scanf("%d", &line_number);
      if (line_number < table_length && line_number > 0) {
        for (cp = table[line_number - 1] + 1; cp <= table[line_number] - 1;
             cp++) {
          printf("%c", *cp);
        }
        printf("\n");
      } else {
        printf("Maximum possible line is %d\n", table_length - 1);
      }
    } else {
      for (i = 0; i < size; i++) {
        printf("%c", *(p + i));
      }
      break;
    }
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x390,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11c9 <main+0x39>
lea    0xe46(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
jne    120d <main+0x7d>
mov    -0x18(%rbp),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    0x2dc1(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %rax,-0x358(%rbp)
mov    -0x358(%rbp),%rsi
mov    0x2dc3(%rip),%rax
mov    (%rax),%edx
mov    0x2daa(%rip),%rax
mov    (%rax),%ecx
mov    -0x1c(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x360(%rbp)
mov    -0x360(%rbp),%rax
mov    %rax,-0x350(%rbp)
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmp    -0x358(%rbp),%rax
jae    1313 <main+0x183>
mov    -0x360(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    12bc <main+0x12c>
mov    -0x360(%rbp),%rcx
movslq -0x20(%rbp),%rax
add    %rax,%rcx
mov    -0x24(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
cltq
mov    %rcx,-0x350(%rbp,%rax,8)
ff
jmp    1300 <main+0x170>
movslq -0x20(%rbp),%rax
mov    -0x358(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jne    12fb <main+0x16b>
mov    -0x360(%rbp),%rcx
movslq -0x20(%rbp),%rax
add    %rax,%rcx
add    $0x1,%rcx
mov    -0x24(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
cltq
mov    %rcx,-0x350(%rbp,%rax,8)
ff
jmp    1300 <main+0x170>
jmp    1305 <main+0x175>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    126b <main+0xdb>
mov    0x2c9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x368(%rbp)
mov    0x2c9f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x370(%rbp)
lea    -0x370(%rbp),%rdi
mov    $0x1,%esi
mov    $0x1388,%edx
call   1080 <poll@plt>
mov    %eax,-0x384(%rbp)
cmpl   $0xffffffff,-0x384(%rbp)
jne    1370 <main+0x1e0>
lea    0xcb4(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0x384(%rbp)
jne    138b <main+0x1fb>
lea    0xc9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x36c(%rbp),%eax
mov    0x2c30(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     146e <main+0x2de>
lea    0xc94(%rip),%rdi
lea    -0x374(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x374(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1455 <main+0x2c5>
cmpl   $0x0,-0x374(%rbp)
jle    1455 <main+0x2c5>
mov    -0x374(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x350(%rbp,%rax,8),%rax
ff
add    $0x1,%rax
mov    %rax,-0x380(%rbp)
mov    -0x380(%rbp),%rax
movslq -0x374(%rbp),%rcx
mov    -0x350(%rbp,%rcx,8),%rcx
ff
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rax
ja     1442 <main+0x2b2>
mov    -0x380(%rbp),%rax
movsbl (%rax),%esi
lea    0xc1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x380(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x380(%rbp)
jmp    13f0 <main+0x260>
lea    0xc16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1469 <main+0x2d9>
mov    -0x24(%rbp),%esi
sub    $0x1,%esi
lea    0xbe2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    14b6 <main+0x326>
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmp    -0x358(%rbp),%rax
jae    14b1 <main+0x321>
mov    -0x360(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xba5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1475 <main+0x2e5>
jmp    14bb <main+0x32b>
jmp    1331 <main+0x1a1>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x390,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x358,%rsp
cmp    $0x1,%edi
je     1456 <main+0x2a6>
mov    0x8(%rsi),%rbp
mov    0x2dfb(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
je     145f <main+0x2af>
mov    %eax,%ebx
mov    0x2de7(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1070 <lseek@plt>
mov    %rax,%r14
mov    0x2df2(%rip),%rax
mov    (%rax),%edx
mov    0x2dd9(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %r14,%rsi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,0x30(%rsp)
test   %r14,%r14
mov    %ebx,0x8(%rsp)
je     12b8 <main+0x108>
mov    %r14,%rbp
add    $0xffffffffffffffff,%rbp
je     12c0 <main+0x110>
mov    %r14,%rdx
and    $0xfffffffffffffffe,%rdx
lea    -0x2(%r14),%rsi
mov    $0x1,%r15d
xor    %ecx,%ecx
jmp    127d <main+0xcd>
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%rax,%rcx,1),%rdi
add    $0x1,%rdi
movslq %r15d,%rbx
add    $0x1,%r15d
mov    %rdi,0x30(%rsp,%rbx,8)
add    $0x2,%rcx
cmp    %rcx,%rdx
je     12c8 <main+0x118>
lea    (%rax,%rcx,1),%rdi
cmpb   $0xa,(%rax,%rcx,1)
je     1290 <main+0xe0>
cmp    %rcx,%rbp
jne    129c <main+0xec>
add    $0x1,%rdi
movslq %r15d,%rbx
add    $0x1,%r15d
mov    %rdi,0x30(%rsp,%rbx,8)
cmpb   $0xa,0x1(%rax,%rcx,1)
je     1260 <main+0xb0>
cmp    %rcx,%rsi
jne    1274 <main+0xc4>
mov    %rcx,%rdi
or     $0x1,%rdi
add    %rax,%rdi
add    $0x1,%rdi
jmp    1268 <main+0xb8>
mov    $0x1,%r15d
jmp    12ef <main+0x13f>
xor    %ecx,%ecx
mov    $0x1,%r15d
test   $0x1,%r14b
je     12ef <main+0x13f>
mov    %rax,%rdx
add    %rcx,%rdx
cmpb   $0xa,(%rax,%rcx,1)
je     12e3 <main+0x133>
cmp    %rcx,%rbp
jne    12ef <main+0x13f>
add    $0x1,%rdx
movslq %r15d,%rcx
add    $0x1,%r15d
mov    %rdx,0x30(%rsp,%rcx,8)
mov    %rax,0x20(%rsp)
mov    %r14,0x28(%rsp)
mov    0x2cb8(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    0x2cbb(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,0x10(%rsp)
lea    -0x1(%r15),%eax
mov    %eax,0xc(%rsp)
lea    0x10(%rsp),%r12
lea    0xcfa(%rip),%r13
lea    0x4(%rsp),%r14
jmp    1342 <main+0x192>
xchg   %ax,%ax
lea    0xced(%rip),%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1388,%edx
call   10a0 <poll@plt>
test   %eax,%eax
je     1370 <main+0x1c0>
cmp    $0xffffffff,%eax
jne    137c <main+0x1cc>
jmp    1440 <main+0x290>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xcca(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%eax
test   %eax,0x14(%rsp)
je     13f2 <main+0x242>
mov    %r13,%rdi
mov    %r14,%rsi
call   1090 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    %r15d,%eax
jge    1330 <main+0x180>
test   %eax,%eax
jle    1330 <main+0x180>
mov    %r12,%rbp
lea    -0x1(%rax),%ecx
mov    0x30(%rsp,%rcx,8),%r12
add    $0x1,%r12
nopl   0x0(%rax,%rax,1)
mov    0x30(%rsp,%rax,8),%rax
add    $0xffffffffffffffff,%rax
cmp    %rax,%r12
ja     13e0 <main+0x230>
movsbl (%r12),%edi
call   1030 <putchar@plt>
add    $0x1,%r12
movslq 0x4(%rsp),%rax
jmp    13b0 <main+0x200>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbp,%r12
jmp    1342 <main+0x192>
mov    0x28(%rsp),%rbp
test   %rbp,%rbp
mov    0x20(%rsp),%r14
je     1423 <main+0x273>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r14,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1410 <main+0x260>
mov    0x8(%rsp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x358,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbce(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xba3(%rip),%rdi
jmp    1447 <main+0x297>
mov    %rbp,%rdi
jmp    1447 <main+0x297>

LLVM IR (-O0):
%struct.pollfd = type { i32, i32, i32 }
@.str = [21 x i8] c"Not enough arguments\00"
@O_RDONLY = global i32 0
@SEEK_END = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@STDIN_FILENO = global i32 0
@POLLIN = global i32 0
@.str.1 = [12 x i8] c"poll failed\00"
@.str.2 = [29 x i8] c"No data for reading/writing\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [29 x i8] c"Maximum possible line is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [101 x i8*]
%11 = alloca i64
%12 = alloca i8*
%13 = alloca [1 x %struct.pollfd]
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %22
19: ; preds = %2
%20 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
store i8* %25, i8** %6
store i32 1, i32* %9
%26 = load i8*, i8** %6
%27 = load i32, i32* @O_RDONLY
%28 = call i32 @open(i8* %26, i32 %27)
store i32 %28, i32* %7
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %34
30: ; preds = %22
%31 = load i8*, i8** %6
%32 = call i32 @perror(i8* %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %22
%35 = load i32, i32* %7
%36 = load i32, i32* @SEEK_END
%37 = call i64 @lseek(i32 %35, i32 0, i32 %36)
store i64 %37, i64* %11
%38 = load i64, i64* %11
%39 = load i32, i32* @PROT_READ
%40 = load i32, i32* @MAP_SHARED
%41 = load i32, i32* %7
%42 = call i8* @mmap(i32 0, i64 %38, i32 %39, i32 %40, i32 %41, i32 0)
store i8* %42, i8** %12
%43 = load i8*, i8** %12
%44 = getelementptr inbounds [101 x i8*], [101 x i8*]* %10, i64 0, i64 0
store i8* %43, i8** %44
store i32 0, i32* %8
br label %45
45: ; preds = %85, %34
%46 = load i32, i32* %8
%47 = sext i32 %46 to i64
%48 = load i64, i64* %11
%49 = icmp ult i64 %47, %48
br i1 %49, label %50, label %88
50: ; preds = %45
%51 = load i8*, i8** %12
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 10
br i1 %57, label %58, label %67
58: ; preds = %50
%59 = load i8*, i8** %12
%60 = load i32, i32* %8
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
%63 = load i32, i32* %9
%64 = add nsw i32 %63, 1
store i32 %64, i32* %9
%65 = sext i32 %63 to i64
%66 = getelementptr inbounds [101 x i8*], [101 x i8*]* %10, i64 0, i64 %65
store i8* %62, i8** %66
br label %84
67: ; preds = %50
%68 = load i32, i32* %8
%69 = sext i32 %68 to i64
%70 = load i64, i64* %11
%71 = sub i64 %70, 1
%72 = icmp eq i64 %69, %71
br i1 %72, label %73, label %83
73: ; preds = %67
%74 = load i8*, i8** %12
%75 = load i32, i32* %8
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %74, i64 %76
%78 = getelementptr inbounds i8, i8* %77, i64 1
%79 = load i32, i32* %9
%80 = add nsw i32 %79, 1
store i32 %80, i32* %9
%81 = sext i32 %79 to i64
%82 = getelementptr inbounds [101 x i8*], [101 x i8*]* %10, i64 0, i64 %81
store i8* %78, i8** %82
br label %83
83: ; preds = %73, %67
br label %84
84: ; preds = %83, %58
br label %85
85: ; preds = %84
%86 = load i32, i32* %8
%87 = add nsw i32 %86, 1
store i32 %87, i32* %8
br label %45
88: ; preds = %45
%89 = load i32, i32* @STDIN_FILENO
%90 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %13, i64 0, i64 0
%91 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %90, i32 0, i32 2
store i32 %89, i32* %91
%92 = load i32, i32* @POLLIN
%93 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %13, i64 0, i64 0
%94 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %93, i32 0, i32 0
store i32 %92, i32* %94
br label %95
95: ; preds = %88, %171
%96 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %13, i64 0, i64 0
%97 = call i32 @poll(%struct.pollfd* %96, i32 1, i32 5000)
store i32 %97, i32* %16
%98 = load i32, i32* %16
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %103
100: ; preds = %95
%101 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%102 = call i32 @exit(i32 1)
unreachable
103: ; preds = %95
%104 = load i32, i32* %16
%105 = icmp eq i32 %104, 0
br i1 %105, label %106, label %108
106: ; preds = %103
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %108
108: ; preds = %106, %103
%109 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %13, i64 0, i64 0
%110 = getelementptr inbounds %struct.pollfd, %struct.pollfd* %109, i32 0, i32 1
%111 = load i32, i32* %110
%112 = load i32, i32* @POLLIN
%113 = and i32 %111, %112
%114 = icmp ne i32 %113, 0
br i1 %114, label %115, label %153
115: ; preds = %108
%116 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %14)
%117 = load i32, i32* %14
%118 = load i32, i32* %9
%119 = icmp slt i32 %117, %118
br i1 %119, label %120, label %148
120: ; preds = %115
%121 = load i32, i32* %14
%122 = icmp sgt i32 %121, 0
br i1 %122, label %123, label %148
123: ; preds = %120
%124 = load i32, i32* %14
%125 = sub nsw i32 %124, 1
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds [101 x i8*], [101 x i8*]* %10, i64 0, i64 %126
%128 = load i8*, i8** %127
%129 = getelementptr inbounds i8, i8* %128, i64 1
store i8* %129, i8** %15
br label %130
130: ; preds = %143, %123
%131 = load i8*, i8** %15
%132 = load i32, i32* %14
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds [101 x i8*], [101 x i8*]* %10, i64 0, i64 %133
%135 = load i8*, i8** %134
%136 = getelementptr inbounds i8, i8* %135, i64 -1
%137 = icmp ule i8* %131, %136
br i1 %137, label %138, label %146
138: ; preds = %130
%139 = load i8*, i8** %15
%140 = load i8, i8* %139
%141 = sext i8 %140 to i32
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %141)
br label %143
143: ; preds = %138
%144 = load i8*, i8** %15
%145 = getelementptr inbounds i8, i8* %144, i32 1
store i8* %145, i8** %15
br label %130
146: ; preds = %130
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %152
148: ; preds = %120, %115
%149 = load i32, i32* %9
%150 = sub nsw i32 %149, 1
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %150)
br label %152
152: ; preds = %148, %146
br label %171
153: ; preds = %108
store i32 0, i32* %8
br label %154
154: ; preds = %167, %153
%155 = load i32, i32* %8
%156 = sext i32 %155 to i64
%157 = load i64, i64* %11
%158 = icmp ult i64 %156, %157
br i1 %158, label %159, label %170
159: ; preds = %154
%160 = load i8*, i8** %12
%161 = load i32, i32* %8
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds i8, i8* %160, i64 %162
%164 = load i8, i8* %163
%165 = sext i8 %164 to i32
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %165)
br label %167
167: ; preds = %159
%168 = load i32, i32* %8
%169 = add nsw i32 %168, 1
store i32 %169, i32* %8
br label %154
170: ; preds = %154
br label %172
171: ; preds = %152
br label %95
172: ; preds = %170
%173 = load i32, i32* %7
%174 = call i32 @close(i32 %173)
ret i32 0
}

LLVM IR (-O2):
%struct.pollfd = type { i32, i32, i32 }
@.str = [21 x i8] c"Not enough arguments\00"
@O_RDONLY = global i32 0
@SEEK_END = global i32 0
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@STDIN_FILENO = global i32 0
@POLLIN = global i32 0
@.str.1 = [12 x i8] c"poll failed\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.6 = [29 x i8] c"Maximum possible line is %d\0A\00"
@str = [28 x i8] c"No data for reading/writing\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [101 x i8*]
%4 = alloca [1 x %struct.pollfd]
%5 = alloca i32
%6 = icmp eq i32 %0, 1
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = bitcast [101 x i8*]* %3 to i8*
%14 = load i32, i32* @O_RDONLY
%15 = tail call i32 @open(i8* %12, i32 %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = tail call i32 @perror(i8* %12)
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %10
%21 = load i32, i32* @SEEK_END
%22 = tail call i64 @lseek(i32 %15, i32 0, i32 %21)
%23 = load i32, i32* @PROT_READ
%24 = load i32, i32* @MAP_SHARED
%25 = tail call i8* @mmap(i32 0, i64 %22, i32 %23, i32 %24, i32 %15, i32 0)
%26 = getelementptr inbounds [101 x i8*], [101 x i8*]* %3, i64 0, i64 0
store i8* %25, i8** %26
%27 = icmp eq i64 %22, 0
br i1 %27, label %88, label %28
28: ; preds = %20
%29 = add i64 %22, -1
%30 = and i64 %22, 1
%31 = icmp eq i64 %29, 0
br i1 %31, label %70, label %32
32: ; preds = %28
%33 = and i64 %22, -2
br label %34
34: ; preds = %65, %32
%35 = phi i64 [ 0, %32 ], [ %67, %65 ]
%36 = phi i32 [ 1, %32 ], [ %66, %65 ]
%37 = phi i64 [ 0, %32 ], [ %68, %65 ]
%38 = getelementptr inbounds i8, i8* %25, i64 %35
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 10
br i1 %40, label %45, label %41
41: ; preds = %34
%42 = icmp eq i64 %29, %35
br i1 %42, label %43, label %50
43: ; preds = %41
%44 = getelementptr inbounds i8, i8* %38, i64 1
br label %45
45: ; preds = %34, %43
%46 = phi i8* [ %44, %43 ], [ %38, %34 ]
%47 = add nsw i32 %36, 1
%48 = sext i32 %36 to i64
%49 = getelementptr inbounds [101 x i8*], [101 x i8*]* %3, i64 0, i64 %48
store i8* %46, i8** %49
br label %50
50: ; preds = %45, %41
%51 = phi i32 [ %36, %41 ], [ %47, %45 ]
%52 = or i64 %35, 1
%53 = getelementptr inbounds i8, i8* %25, i64 %52
%54 = load i8, i8* %53
%55 = icmp eq i8 %54, 10
br i1 %55, label %60, label %56
56: ; preds = %50
%57 = icmp eq i64 %29, %52
br i1 %57, label %58, label %65
58: ; preds = %56
%59 = getelementptr inbounds i8, i8* %53, i64 1
br label %60
60: ; preds = %58, %50
%61 = phi i8* [ %59, %58 ], [ %53, %50 ]
%62 = add nsw i32 %51, 1
%63 = sext i32 %51 to i64
%64 = getelementptr inbounds [101 x i8*], [101 x i8*]* %3, i64 0, i64 %63
store i8* %61, i8** %64
br label %65
65: ; preds = %60, %56
%66 = phi i32 [ %51, %56 ], [ %62, %60 ]
%67 = add nuw nsw i64 %35, 2
%68 = add i64 %37, 2
%69 = icmp eq i64 %68, %33
br i1 %69, label %70, label %34
70: ; preds = %65, %28
%71 = phi i32 [ undef, %28 ], [ %66, %65 ]
%72 = phi i64 [ 0, %28 ], [ %67, %65 ]
%73 = phi i32 [ 1, %28 ], [ %66, %65 ]
%74 = icmp eq i64 %30, 0
br i1 %74, label %88, label %75
75: ; preds = %70
%76 = getelementptr inbounds i8, i8* %25, i64 %72
%77 = load i8, i8* %76
%78 = icmp eq i8 %77, 10
br i1 %78, label %83, label %79
79: ; preds = %75
%80 = icmp eq i64 %29, %72
br i1 %80, label %81, label %88
81: ; preds = %79
%82 = getelementptr inbounds i8, i8* %76, i64 1
br label %83
83: ; preds = %81, %75
%84 = phi i8* [ %82, %81 ], [ %76, %75 ]
%85 = add nsw i32 %73, 1
%86 = sext i32 %73 to i64
%87 = getelementptr inbounds [101 x i8*], [101 x i8*]* %3, i64 0, i64 %86
store i8* %84, i8** %87
br label %88
88: ; preds = %70, %83, %79, %20
%89 = phi i32 [ 1, %20 ], [ %71, %70 ], [ %73, %79 ], [ %85, %83 ]
%90 = bitcast [1 x %struct.pollfd]* %4 to i8*
%91 = load i32, i32* @STDIN_FILENO
%92 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %4, i64 0, i64 0
%93 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %4, i64 0, i64 0, i32 2
store i32 %91, i32* %93
%94 = load i32, i32* @POLLIN
%95 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %4, i64 0, i64 0, i32 0
store i32 %94, i32* %95
%96 = bitcast i32* %5 to i8*
%97 = getelementptr inbounds [1 x %struct.pollfd], [1 x %struct.pollfd]* %4, i64 0, i64 0, i32 1
%98 = add nsw i32 %89, -1
br label %99
99: ; preds = %145, %88
%100 = call i32 @poll(%struct.pollfd* %92, i32 1, i32 5000)
switch i32 %100, label %106 [
i32 -1, label %101
i32 0, label %104
]
101: ; preds = %99
%102 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%103 = call i32 @exit(i32 1)
unreachable
104: ; preds = %99
%105 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %106
106: ; preds = %99, %104
%107 = load i32, i32* %97
%108 = load i32, i32* @POLLIN
%109 = and i32 %108, %107
%110 = icmp eq i32 %109, 0
br i1 %110, label %111, label %112
111: ; preds = %106
br i1 %27, label %154, label %146
112: ; preds = %106
%113 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%114 = load i32, i32* %5
%115 = icmp slt i32 %114, %89
%116 = icmp sgt i32 %114, 0
%117 = and i1 %115, %116
br i1 %117, label %118, label %143
118: ; preds = %112
%119 = add nsw i32 %114, -1
%120 = zext i32 %119 to i64
%121 = getelementptr inbounds [101 x i8*], [101 x i8*]* %3, i64 0, i64 %120
%122 = load i8*, i8** %121
%123 = getelementptr inbounds i8, i8* %122, i64 1
%124 = zext i32 %114 to i64
%125 = getelementptr inbounds [101 x i8*], [101 x i8*]* %3, i64 0, i64 %124
%126 = load i8*, i8** %125
%127 = getelementptr inbounds i8, i8* %126, i64 -1
%128 = icmp ugt i8* %123, %127
br i1 %128, label %141, label %129
129: ; preds = %118, %129
%130 = phi i8* [ %134, %129 ], [ %123, %118 ]
%131 = load i8, i8* %130
%132 = sext i8 %131 to i32
%133 = call i32 @putchar(i32 %132)
%134 = getelementptr inbounds i8, i8* %130, i64 1
%135 = load i32, i32* %5
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds [101 x i8*], [101 x i8*]* %3, i64 0, i64 %136
%138 = load i8*, i8** %137
%139 = getelementptr inbounds i8, i8* %138, i64 -1
%140 = icmp ugt i8* %134, %139
br i1 %140, label %141, label %129
141: ; preds = %129, %118
%142 = call i32 @putchar(i32 10)
br label %145
143: ; preds = %112
%144 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i32 %98)
br label %145
145: ; preds = %143, %141
br label %99
146: ; preds = %111, %146
%147 = phi i64 [ %152, %146 ], [ 0, %111 ]
%148 = getelementptr inbounds i8, i8* %25, i64 %147
%149 = load i8, i8* %148
%150 = sext i8 %149 to i32
%151 = call i32 @putchar(i32 %150)
%152 = add nuw i64 %147, 1
%153 = icmp eq i64 %152, %22
br i1 %153, label %154, label %146
154: ; preds = %146, %111
%155 = call i32 @close(i32 %15)
ret i32 0
}