#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 EOF;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fgets(char *, long, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int getc(int /*<<< orphan*/ *);
char *malloc(long);
int /*<<< orphan*/ perror(char *);
char *next_entry(FILE *infile_p) {
  char *temp = NULL;
  long int orig_position = 0;
  long int buffsize = 0;
  int c;
  int count;
  orig_position = ftell(infile_p);
  if (orig_position < 0) {
    perror("Input error (ftell)");
    exit(1);
  }
  count = 0;
  if ((c = getc(infile_p)) < 0)
    return NULL;
  while ((c != '\n') && (c != EOF)) {
    count++;
    if ((c == EOF) && (count = 1)) {
      return NULL;
    }
    c = getc(infile_p);
  }
  buffsize = ftell(infile_p);
  if (buffsize < 0) {
    perror("Input error (ftell)");
    exit(1);
  }
  buffsize -= orig_position;
  temp = malloc(buffsize + 1);
  if (temp == NULL) {
    perror("malloc");
    exit(1);
  }
  if (fseek(infile_p, orig_position, SEEK_SET) != 0) {
    perror("Input error (fseek)");
    exit(1);
  }
  if (!fgets(temp, buffsize + 1, infile_p)) {
    perror("Input error (fgets)");
    exit(1);
  }
  return temp;
}


x86 assembly (clang, -O0):
<next_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jge    11c2 <next_entry+0x52>
lea    0xe4d(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <getc@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jge    11eb <next_entry+0x7b>
movq   $0x0,-0x8(%rbp)
jmp    1351 <next_entry+0x1e1>
jmp    11f0 <next_entry+0x80>
xor    %eax,%eax
cmpl   $0xa,-0x2c(%rbp)
mov    %al,-0x31(%rbp)
je     1211 <next_entry+0xa1>
mov    -0x2c(%rbp),%eax
mov    0x2ddf(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1221 <next_entry+0xb1>
jmp    1270 <next_entry+0x100>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2db4(%rip),%rcx
cmp    (%rcx),%eax
jne    125f <next_entry+0xef>
movl   $0x1,-0x30(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    1252 <next_entry+0xe2>
jmp    125f <next_entry+0xef>
movq   $0x0,-0x8(%rbp)
jmp    1351 <next_entry+0x1e1>
mov    -0x10(%rbp),%rdi
call   1090 <getc@plt>
mov    %eax,-0x2c(%rbp)
jmp    11f0 <next_entry+0x80>
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    129e <next_entry+0x12e>
lea    0xd71(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    12df <next_entry+0x16f>
lea    0xd44(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2cea(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
cmp    $0x0,%rax
je     1315 <next_entry+0x1a5>
lea    0xd15(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
add    $0x1,%rsi
mov    -0x10(%rbp),%rdx
call   1030 <fgets@plt>
cmp    $0x0,%eax
jne    1349 <next_entry+0x1d9>
lea    0xcf5(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_entry>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <ftell@plt>
test   %rax,%rax
js     122f <next_entry+0xbf>
mov    %rax,%r14
mov    %rbx,%rdi
call   1090 <getc@plt>
test   %eax,%eax
js     121d <next_entry+0xad>
cmp    $0xa,%eax
je     11c2 <next_entry+0x52>
mov    0x2e40(%rip),%r15
nopl   0x0(%rax,%rax,1)
cmp    (%r15),%eax
je     11c2 <next_entry+0x52>
mov    %rbx,%rdi
call   1090 <getc@plt>
cmp    $0xa,%eax
jne    11b0 <next_entry+0x40>
mov    %rbx,%rdi
call   1040 <ftell@plt>
test   %rax,%rax
js     122f <next_entry+0xbf>
mov    %rax,%r12
sub    %r14,%r12
add    $0x1,%r12
mov    %r12,%rdi
call   1050 <malloc@plt>
test   %rax,%rax
je     1238 <next_entry+0xc8>
mov    %rax,%r15
mov    0x2de8(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <fseek@plt>
test   %rax,%rax
jne    1241 <next_entry+0xd1>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <fgets@plt>
test   %eax,%eax
jne    1220 <next_entry+0xb0>
lea    0xe14(%rip),%rdi
jmp    1248 <next_entry+0xd8>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xdca(%rip),%rdi
jmp    1248 <next_entry+0xd8>
lea    0xdd5(%rip),%rdi
jmp    1248 <next_entry+0xd8>
lea    0xdd3(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Input error (ftell)\00"
@EOF = global i32 0
@.str.1 = [7 x i8] c"malloc\00"
@SEEK_SET = global i32 0
@.str.2 = [20 x i8] c"Input error (fseek)\00"
@.str.3 = [20 x i8] c"Input error (fgets)\00"
define i8* @next_entry(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i8* null, i8** %4
store i64 0, i64* %5
store i64 0, i64* %6
%9 = load i32*, i32** %3
%10 = call i64 @ftell(i32* %9)
store i64 %10, i64* %5
%11 = load i64, i64* %5
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %1
store i32 0, i32* %8
%17 = load i32*, i32** %3
%18 = call i32 @getc(i32* %17)
store i32 %18, i32* %7
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i8* null, i8** %2
br label %83
21: ; preds = %16
br label %22
22: ; preds = %39, %21
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 10
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i32, i32* %7
%27 = load i32, i32* @EOF
%28 = icmp ne i32 %26, %27
br label %29
29: ; preds = %25, %22
%30 = phi i1 [ false, %22 ], [ %28, %25 ]
br i1 %30, label %31, label %42
31: ; preds = %29
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
%34 = load i32, i32* %7
%35 = load i32, i32* @EOF
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %39
37: ; preds = %31
store i32 1, i32* %8
br i1 true, label %38, label %39
38: ; preds = %37
store i8* null, i8** %2
br label %83
39: ; preds = %37, %31
%40 = load i32*, i32** %3
%41 = call i32 @getc(i32* %40)
store i32 %41, i32* %7
br label %22
42: ; preds = %29
%43 = load i32*, i32** %3
%44 = call i64 @ftell(i32* %43)
store i64 %44, i64* %6
%45 = load i64, i64* %6
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %42
%48 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %42
%51 = load i64, i64* %5
%52 = load i64, i64* %6
%53 = sub nsw i64 %52, %51
store i64 %53, i64* %6
%54 = load i64, i64* %6
%55 = add nsw i64 %54, 1
%56 = call i8* @malloc(i64 %55)
store i8* %56, i8** %4
%57 = load i8*, i8** %4
%58 = icmp eq i8* %57, null
br i1 %58, label %59, label %62
59: ; preds = %50
%60 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %50
%63 = load i32*, i32** %3
%64 = load i64, i64* %5
%65 = load i32, i32* @SEEK_SET
%66 = call i64 @fseek(i32* %63, i64 %64, i32 %65)
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %62
%69 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %62
%72 = load i8*, i8** %4
%73 = load i64, i64* %6
%74 = add nsw i64 %73, 1
%75 = load i32*, i32** %3
%76 = call i32 @fgets(i8* %72, i64 %74, i32* %75)
%77 = icmp ne i32 %76, 0
br i1 %77, label %81, label %78
78: ; preds = %71
%79 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%80 = call i32 @exit(i32 1)
unreachable
81: ; preds = %71
%82 = load i8*, i8** %4
store i8* %82, i8** %2
br label %83
83: ; preds = %81, %38, %20
%84 = load i8*, i8** %2
ret i8* %84
}

LLVM IR (-O2):
@.str = [20 x i8] c"Input error (ftell)\00"
@EOF = global i32 0
@.str.1 = [7 x i8] c"malloc\00"
@SEEK_SET = global i32 0
@.str.2 = [20 x i8] c"Input error (fseek)\00"
@.str.3 = [20 x i8] c"Input error (fgets)\00"
define i8* @next_entry(i32* nocapture %0) {
%2 = tail call i64 @ftell(i32* %0)
%3 = icmp slt i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = tail call i32 @getc(i32* %0)
%9 = icmp slt i32 %8, 0
br i1 %9, label %48, label %10
10: ; preds = %7
%11 = icmp ne i32 %8, 10
%12 = load i32, i32* @EOF
%13 = icmp ne i32 %8, %12
%14 = select i1 %11, i1 %13, i1 false
br i1 %14, label %15, label %21
15: ; preds = %10, %15
%16 = tail call i32 @getc(i32* %0)
%17 = icmp ne i32 %16, 10
%18 = load i32, i32* @EOF
%19 = icmp ne i32 %16, %18
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %15, label %21
21: ; preds = %15, %10
%22 = tail call i64 @ftell(i32* %0)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %21
%28 = sub nsw i64 %22, %2
%29 = add nsw i64 %28, 1
%30 = tail call i8* @malloc(i64 %29)
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%34 = tail call i32 @exit(i32 1)
unreachable
35: ; preds = %27
%36 = load i32, i32* @SEEK_SET
%37 = tail call i64 @fseek(i32* %0, i64 %2, i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %35
%40 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%41 = tail call i32 @exit(i32 1)
unreachable
42: ; preds = %35
%43 = tail call i32 @fgets(i8* %30, i64 %29, i32* %0)
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%47 = tail call i32 @exit(i32 1)
unreachable
48: ; preds = %42, %7
%49 = phi i8* [ null, %7 ], [ %30, %42 ]
ret i8* %49
}