#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 BUFSIZ;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ SEEK_END;
int STDIN_FILENO;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fdopen(int, char *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
size_t fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
char *malloc(long);
int /*<<< orphan*/ perror(char *);
char *realloc(char *, long);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strncat(char *, char *, size_t);
void read_lines(int fd, int lines_num) {
  FILE *pFile;
  char *buf, *buf_temp, *temp;
  size_t num_read;
  int i;
  long int size;
  long int lines = 0;
  long int offset = 0;
  pFile = fdopen(fd, "r");
  if (pFile == NULL) {
    perror("fdopen");
    exit(EXIT_FAILURE);
  }
  if (fd == STDIN_FILENO) {
    buf_temp = malloc(sizeof(char) * BUFSIZ + sizeof(char));
    if (buf_temp == NULL) {
      perror("malloc");
      exit(EXIT_FAILURE);
    }
    buf = malloc(sizeof(char) * BUFSIZ + sizeof(char));
    if (buf == NULL) {
      perror("malloc");
      exit(EXIT_FAILURE);
    }
    size = BUFSIZ;
    while (1) {
      num_read = fread(buf_temp, sizeof(char), BUFSIZ, stdin);
      buf_temp[num_read] = '\0';
      strncat(buf, buf_temp, num_read);
      if (feof(stdin))
        break;
      if (num_read == BUFSIZ) {
        size += BUFSIZ + sizeof(char);
        temp = realloc(buf, size);
        if (temp == NULL) {
          perror("realloc");
          free(buf);
          exit(EXIT_FAILURE);
        }
        buf = temp;
      }
    }
    free(buf_temp);
  } else {
    fseek(pFile, 0, SEEK_END);
    size = ftell(pFile);
    rewind(pFile);
    buf = malloc(size);
    if (buf == NULL) {
      perror("malloc");
      exit(EXIT_FAILURE);
    }
    num_read = fread(buf, 1, size, pFile);
    fclose(pFile);
  }
  for (i = size - 1; i >= 0; i--) {
    if (buf[i] == '\n') {
      lines++;
      if (lines == lines_num + 1) {
        offset = i;
        break;
      }
    }
  }
  if (lines_num > lines)
    offset = 0;
  offset++;
  temp = buf;
  buf = buf + offset;
  fputs(buf, stdout);
  free(temp);
}


x86 assembly (clang, -O0):
<read_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x4(%rbp),%edi
lea    0xdf8(%rip),%rsi
call   10e0 <fdopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1236 <read_lines+0x56>
lea    0xddf(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x4(%rbp),%eax
mov    0x2d78(%rip),%rcx
cmp    (%rcx),%eax
jne    13be <read_lines+0x1de>
mov    0x2d81(%rip),%rax
movslq (%rax),%rdi
shl    $0x0,%rdi
add    $0x1,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1288 <read_lines+0xa8>
lea    0xd94(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2d47(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    0x2d41(%rip),%rax
movslq (%rax),%rdi
shl    $0x0,%rdi
add    $0x1,%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12c8 <read_lines+0xe8>
lea    0xd54(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    0x2d01(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2cef(%rip),%rax
movslq (%rax),%rdx
mov    0x2cf5(%rip),%rax
mov    (%rax),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1080 <strncat@plt>
mov    0x2cc0(%rip),%rax
mov    (%rax),%rdi
call   10a0 <feof@plt>
cmp    $0x0,%rax
je     1337 <read_lines+0x157>
jmp    13b0 <read_lines+0x1d0>
mov    -0x30(%rbp),%rax
mov    0x2c8e(%rip),%rcx
movslq (%rcx),%rcx
cmp    %rcx,%rax
jne    13ab <read_lines+0x1cb>
mov    0x2c7b(%rip),%rax
movslq (%rax),%rax
add    $0x1,%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   10d0 <realloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    13a3 <read_lines+0x1c3>
lea    0xc89(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2c2c(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    12d6 <read_lines+0xf6>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    143d <read_lines+0x25d>
mov    -0x10(%rbp),%rdi
mov    0x2c1f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1090 <ftell@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <rewind@plt>
mov    -0x40(%rbp),%rdi
call   10b0 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    141a <read_lines+0x23a>
lea    0xc02(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2bb5(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x40(%rbp),%rax
sub    $0x1,%rax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     14ae <read_lines+0x2ce>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    149b <read_lines+0x2bb>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jne    1496 <read_lines+0x2b6>
movslq -0x34(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    14ae <read_lines+0x2ce>
jmp    149b <read_lines+0x2bb>
jmp    14a0 <read_lines+0x2c0>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    1448 <read_lines+0x268>
movslq -0x8(%rbp),%rax
cmp    -0x48(%rbp),%rax
jle    14c4 <read_lines+0x2e4>
movq   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    -0x50(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2ad1(%rip),%rax
mov    (%rax),%esi
call   1070 <fputs@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_lines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%ebx
lea    0xe09(%rip),%rsi
call   10e0 <fdopen@plt>
test   %rax,%rax
je     13b5 <read_lines+0x1d5>
mov    %rax,%r12
mov    0x2da9(%rip),%rax
cmp    %ebx,(%rax)
jne    12d2 <read_lines+0xf2>
mov    0x2db2(%rip),%rax
mov    (%rax),%ebp
movslq %ebp,%r13
lea    0x1(%r13),%rbx
mov    %rbx,%rdi
call   10b0 <malloc@plt>
test   %rax,%rax
je     13ac <read_lines+0x1cc>
mov    %rax,%r12
mov    %r14,(%rsp)
mov    %rbx,%rdi
call   10b0 <malloc@plt>
test   %rax,%rax
je     13ac <read_lines+0x1cc>
mov    0x2d89(%rip),%r14
mov    %rax,%r15
nopw   0x0(%rax,%rax,1)
movslq %ebp,%rdx
mov    (%r14),%rcx
mov    %r12,%rdi
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,%rbx
movb   $0x0,(%r12,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rax,%rdx
call   1080 <strncat@plt>
mov    (%r14),%rdi
call   10a0 <feof@plt>
test   %rax,%rax
jne    1329 <read_lines+0x149>
mov    0x2d2f(%rip),%rax
movslq (%rax),%rbp
cmp    %rbp,%rbx
jne    1260 <read_lines+0x80>
add    %rbx,%r13
add    $0x1,%r13
mov    %r15,%rdi
mov    %r13,%rsi
call   10d0 <realloc@plt>
mov    0x2d0e(%rip),%rcx
mov    (%rcx),%ebp
test   %rax,%rax
je     13cf <read_lines+0x1ef>
mov    %rax,%r15
jmp    1260 <read_lines+0x80>
mov    0x2d0f(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %r12,%rdi
call   1090 <ftell@plt>
mov    %rax,%r13
mov    %r12,%rdi
call   1060 <rewind@plt>
mov    %r13,%rdi
call   10b0 <malloc@plt>
test   %rax,%rax
je     13ac <read_lines+0x1cc>
mov    %rax,%r15
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r13,%rdx
mov    %r12,%rcx
call   1040 <fread@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
jmp    1335 <read_lines+0x155>
mov    %r12,%rdi
call   1030 <free@plt>
mov    (%rsp),%r14
add    $0xffffffff,%r13d
mov    $0x1,%eax
js     1374 <read_lines+0x194>
lea    0x1(%r14),%ecx
movslq %ecx,%rcx
xor    %edx,%edx
jmp    1356 <read_lines+0x176>
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%r13d
js     136f <read_lines+0x18f>
mov    %r13d,%edi
cmpb   $0xa,(%r15,%rdi,1)
jne    1350 <read_lines+0x170>
add    $0x1,%rdx
cmp    %rcx,%rdx
jne    1350 <read_lines+0x170>
add    $0x1,%rdi
jmp    137b <read_lines+0x19b>
mov    %rdx,%rcx
jmp    1376 <read_lines+0x196>
xor    %ecx,%ecx
mov    $0x1,%edi
movslq %r14d,%rdx
cmp    %rdx,%rcx
cmovl  %rax,%rdi
add    %r15,%rdi
mov    0x2c31(%rip),%rax
mov    (%rax),%esi
call   1070 <fputs@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
lea    0xc56(%rip),%rdi
jmp    13bc <read_lines+0x1dc>
lea    0xc46(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2c00(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>
lea    0xc3a(%rip),%rdi
call   10f0 <perror@plt>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    13c1 <read_lines+0x1e1>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"fdopen\00"
@EXIT_FAILURE = global i32 0
@STDIN_FILENO = global i32 0
@BUFSIZ = global i32 0
@.str.2 = [7 x i8] c"malloc\00"
@stdin = global i32* null
@.str.3 = [8 x i8] c"realloc\00"
@SEEK_END = global i32 0
@stdout = global i32 0
define void @read_lines(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
store i32 %0, i32* %3
store i32 %1, i32* %4
store i64 0, i64* %12
store i64 0, i64* %13
%14 = load i32, i32* %3
%15 = call i32* @fdopen(i32 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %5
%16 = load i32*, i32** %5
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %2
%23 = load i32, i32* %3
%24 = load i32, i32* @STDIN_FILENO
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %98
26: ; preds = %22
%27 = load i32, i32* @BUFSIZ
%28 = sext i32 %27 to i64
%29 = mul i64 1, %28
%30 = add i64 %29, 1
%31 = call i8* @malloc(i64 %30)
store i8* %31, i8** %7
%32 = load i8*, i8** %7
%33 = icmp eq i8* %32, null
br i1 %33, label %34, label %38
34: ; preds = %26
%35 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %26
%39 = load i32, i32* @BUFSIZ
%40 = sext i32 %39 to i64
%41 = mul i64 1, %40
%42 = add i64 %41, 1
%43 = call i8* @malloc(i64 %42)
store i8* %43, i8** %6
%44 = load i8*, i8** %6
%45 = icmp eq i8* %44, null
br i1 %45, label %46, label %50
46: ; preds = %38
%47 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %38
%51 = load i32, i32* @BUFSIZ
%52 = sext i32 %51 to i64
store i64 %52, i64* %11
br label %53
53: ; preds = %50, %94
%54 = load i8*, i8** %7
%55 = load i32, i32* @BUFSIZ
%56 = sext i32 %55 to i64
%57 = load i32*, i32** @stdin
%58 = call i64 @fread(i8* %54, i32 1, i64 %56, i32* %57)
store i64 %58, i64* %9
%59 = load i8*, i8** %7
%60 = load i64, i64* %9
%61 = getelementptr inbounds i8, i8* %59, i64 %60
store i8 0, i8* %61
%62 = load i8*, i8** %6
%63 = load i8*, i8** %7
%64 = load i64, i64* %9
%65 = call i32 @strncat(i8* %62, i8* %63, i64 %64)
%66 = load i32*, i32** @stdin
%67 = call i64 @feof(i32* %66)
%68 = icmp ne i64 %67, 0
br i1 %68, label %69, label %70
69: ; preds = %53
br label %95
70: ; preds = %53
%71 = load i64, i64* %9
%72 = load i32, i32* @BUFSIZ
%73 = sext i32 %72 to i64
%74 = icmp eq i64 %71, %73
br i1 %74, label %75, label %94
75: ; preds = %70
%76 = load i32, i32* @BUFSIZ
%77 = sext i32 %76 to i64
%78 = add i64 %77, 1
%79 = load i64, i64* %11
%80 = add i64 %79, %78
store i64 %80, i64* %11
%81 = load i8*, i8** %6
%82 = load i64, i64* %11
%83 = call i8* @realloc(i8* %81, i64 %82)
store i8* %83, i8** %8
%84 = load i8*, i8** %8
%85 = icmp eq i8* %84, null
br i1 %85, label %86, label %92
86: ; preds = %75
%87 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%88 = load i8*, i8** %6
%89 = call i32 @free(i8* %88)
%90 = load i32, i32* @EXIT_FAILURE
%91 = call i32 @exit(i32 %90)
unreachable
92: ; preds = %75
%93 = load i8*, i8** %8
store i8* %93, i8** %6
br label %94
94: ; preds = %92, %70
br label %53
95: ; preds = %69
%96 = load i8*, i8** %7
%97 = call i32 @free(i8* %96)
br label %121
98: ; preds = %22
%99 = load i32*, i32** %5
%100 = load i32, i32* @SEEK_END
%101 = call i32 @fseek(i32* %99, i32 0, i32 %100)
%102 = load i32*, i32** %5
%103 = call i64 @ftell(i32* %102)
store i64 %103, i64* %11
%104 = load i32*, i32** %5
%105 = call i32 @rewind(i32* %104)
%106 = load i64, i64* %11
%107 = call i8* @malloc(i64 %106)
store i8* %107, i8** %6
%108 = load i8*, i8** %6
%109 = icmp eq i8* %108, null
br i1 %109, label %110, label %114
110: ; preds = %98
%111 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%112 = load i32, i32* @EXIT_FAILURE
%113 = call i32 @exit(i32 %112)
unreachable
114: ; preds = %98
%115 = load i8*, i8** %6
%116 = load i64, i64* %11
%117 = load i32*, i32** %5
%118 = call i64 @fread(i8* %115, i32 1, i64 %116, i32* %117)
store i64 %118, i64* %9
%119 = load i32*, i32** %5
%120 = call i32 @fclose(i32* %119)
br label %121
121: ; preds = %114, %95
%122 = load i64, i64* %11
%123 = sub nsw i64 %122, 1
%124 = trunc i64 %123 to i32
store i32 %124, i32* %10
br label %125
125: ; preds = %149, %121
%126 = load i32, i32* %10
%127 = icmp sge i32 %126, 0
br i1 %127, label %128, label %152
128: ; preds = %125
%129 = load i8*, i8** %6
%130 = load i32, i32* %10
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds i8, i8* %129, i64 %131
%133 = load i8, i8* %132
%134 = sext i8 %133 to i32
%135 = icmp eq i32 %134, 10
br i1 %135, label %136, label %148
136: ; preds = %128
%137 = load i64, i64* %12
%138 = add nsw i64 %137, 1
store i64 %138, i64* %12
%139 = load i64, i64* %12
%140 = load i32, i32* %4
%141 = add nsw i32 %140, 1
%142 = sext i32 %141 to i64
%143 = icmp eq i64 %139, %142
br i1 %143, label %144, label %147
144: ; preds = %136
%145 = load i32, i32* %10
%146 = sext i32 %145 to i64
store i64 %146, i64* %13
br label %152
147: ; preds = %136
br label %148
148: ; preds = %147, %128
br label %149
149: ; preds = %148
%150 = load i32, i32* %10
%151 = add nsw i32 %150, -1
store i32 %151, i32* %10
br label %125
152: ; preds = %144, %125
%153 = load i32, i32* %4
%154 = sext i32 %153 to i64
%155 = load i64, i64* %12
%156 = icmp sgt i64 %154, %155
br i1 %156, label %157, label %158
157: ; preds = %152
store i64 0, i64* %13
br label %158
158: ; preds = %157, %152
%159 = load i64, i64* %13
%160 = add nsw i64 %159, 1
store i64 %160, i64* %13
%161 = load i8*, i8** %6
store i8* %161, i8** %8
%162 = load i8*, i8** %6
%163 = load i64, i64* %13
%164 = getelementptr inbounds i8, i8* %162, i64 %163
store i8* %164, i8** %6
%165 = load i8*, i8** %6
%166 = load i32, i32* @stdout
%167 = call i32 @fputs(i8* %165, i32 %166)
%168 = load i8*, i8** %8
%169 = call i32 @free(i8* %168)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"fdopen\00"
@EXIT_FAILURE = global i32 0
@STDIN_FILENO = global i32 0
@BUFSIZ = global i32 0
@.str.2 = [7 x i8] c"malloc\00"
@stdin = global i32* null
@.str.3 = [8 x i8] c"realloc\00"
@SEEK_END = global i32 0
@stdout = global i32 0
define void @read_lines(i32 %0, i32 %1) {
%3 = tail call i32* @fdopen(i32 %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = load i32, i32* @STDIN_FILENO
%11 = icmp eq i32 %10, %0
br i1 %11, label %12, label %60
12: ; preds = %9
%13 = load i32, i32* @BUFSIZ
%14 = sext i32 %13 to i64
%15 = add nsw i64 %14, 1
%16 = tail call i8* @malloc(i64 %15)
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %12
%23 = tail call i8* @malloc(i64 %15)
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %49
25: ; preds = %22
%26 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = tail call i32 @exit(i32 %27)
unreachable
29: ; preds = %49, %39
%30 = phi i32 [ %40, %39 ], [ %50, %49 ]
%31 = sext i32 %30 to i64
%32 = load i32*, i32** @stdin
%33 = tail call i64 @fread(i8* %16, i32 1, i64 %31, i32* %32)
%34 = getelementptr inbounds i8, i8* %16, i64 %33
store i8 0, i8* %34
%35 = tail call i32 @strncat(i8* %51, i8* %16, i64 %33)
%36 = load i32*, i32** @stdin
%37 = tail call i64 @feof(i32* %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %58
39: ; preds = %29
%40 = load i32, i32* @BUFSIZ
%41 = sext i32 %40 to i64
%42 = icmp eq i64 %33, %41
br i1 %42, label %43, label %29
43: ; preds = %39
%44 = add i64 %52, 1
%45 = add i64 %44, %33
%46 = tail call i8* @realloc(i8* %51, i64 %45)
%47 = icmp eq i8* %46, null
%48 = load i32, i32* @BUFSIZ
br i1 %47, label %53, label %49
49: ; preds = %22, %43
%50 = phi i32 [ %48, %43 ], [ %13, %22 ]
%51 = phi i8* [ %46, %43 ], [ %23, %22 ]
%52 = phi i64 [ %45, %43 ], [ %14, %22 ]
br label %29
53: ; preds = %43
%54 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%55 = tail call i32 @free(i8* %51)
%56 = load i32, i32* @EXIT_FAILURE
%57 = tail call i32 @exit(i32 %56)
unreachable
58: ; preds = %29
%59 = tail call i32 @free(i8* %16)
br label %74
60: ; preds = %9
%61 = load i32, i32* @SEEK_END
%62 = tail call i32 @fseek(i32* %3, i32 0, i32 %61)
%63 = tail call i64 @ftell(i32* %3)
%64 = tail call i32 @rewind(i32* %3)
%65 = tail call i8* @malloc(i64 %63)
%66 = icmp eq i8* %65, null
br i1 %66, label %67, label %71
67: ; preds = %60
%68 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%69 = load i32, i32* @EXIT_FAILURE
%70 = tail call i32 @exit(i32 %69)
unreachable
71: ; preds = %60
%72 = tail call i64 @fread(i8* %65, i32 1, i64 %63, i32* %3)
%73 = tail call i32 @fclose(i32* %3)
br label %74
74: ; preds = %71, %58
%75 = phi i8* [ %51, %58 ], [ %65, %71 ]
%76 = phi i64 [ %52, %58 ], [ %63, %71 ]
%77 = trunc i64 %76 to i32
%78 = add i32 %77, -1
%79 = icmp sgt i32 %78, -1
br i1 %79, label %80, label %100
80: ; preds = %74
%81 = add nsw i32 %1, 1
%82 = sext i32 %81 to i64
br label %83
83: ; preds = %80, %93
%84 = phi i32 [ %78, %80 ], [ %95, %93 ]
%85 = phi i64 [ 0, %80 ], [ %94, %93 ]
%86 = zext i32 %84 to i64
%87 = getelementptr inbounds i8, i8* %75, i64 %86
%88 = load i8, i8* %87
%89 = icmp eq i8 %88, 10
br i1 %89, label %90, label %93
90: ; preds = %83
%91 = add nsw i64 %85, 1
%92 = icmp eq i64 %91, %82
br i1 %92, label %97, label %93
93: ; preds = %83, %90
%94 = phi i64 [ %91, %90 ], [ %85, %83 ]
%95 = add i32 %84, -1
%96 = icmp sgt i32 %95, -1
br i1 %96, label %83, label %100
97: ; preds = %90
%98 = zext i32 %84 to i64
%99 = add nuw nsw i64 %98, 1
br label %100
100: ; preds = %93, %74, %97
%101 = phi i64 [ %82, %97 ], [ 0, %74 ], [ %94, %93 ]
%102 = phi i64 [ %99, %97 ], [ 1, %74 ], [ 1, %93 ]
%103 = sext i32 %1 to i64
%104 = icmp slt i64 %101, %103
%105 = select i1 %104, i64 1, i64 %102
%106 = getelementptr inbounds i8, i8* %75, i64 %105
%107 = load i32, i32* @stdout
%108 = tail call i32 @fputs(i8* %106, i32 %107)
%109 = tail call i32 @free(i8* %75)
ret void
}