#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*/ exit(int);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int getc(int /*<<< orphan*/ *);
scalar_t__ isspace(int);
int /*<<< orphan*/ stderr;
long find_line(FILE *fp, char *file) {
  long line_beginning;
  int letter;
  for (line_beginning = ftell(fp), letter = getc(fp);;
       line_beginning = ftell(fp), letter = getc(fp)) {
    if (line_beginning == -1L) {
      fprintf(stderr, "\"ftell\" error in file \"%s\".\n", file);
      exit(1);
    } else if (letter == EOF) {
      if (feof(fp) == 0) {
        fprintf(stderr, "An error occurred while reading file \"%s\".\n", file);
        exit(1);
      } else
        return (-1L);
    } else if (isspace(letter) != 0)
      ;
    else if ((letter == ';') || (letter == '%') || (letter == '#')) {
      while ((letter != '\n') && (letter != EOF))
        letter = getc(fp);
    } else if (fseek(fp, line_beginning, 0) != 0) {
      fprintf(stderr, "\"fseek\" error in file \"%s\".\n\n", file);
      exit(1);
    } else
      return (line_beginning);
  }
}


x86 assembly (clang, -O0):
<find_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <getc@plt>
mov    %eax,-0x24(%rbp)
cmpq   $0xffffffffffffffff,-0x20(%rbp)
jne    11c7 <find_line+0x57>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe48(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x24(%rbp),%eax
mov    0x2e17(%rip),%rcx
cmp    (%rcx),%eax
jne    121c <find_line+0xac>
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
jne    120f <find_line+0x9f>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe1d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1318 <find_line+0x1a8>
mov    -0x24(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1233 <find_line+0xc3>
jmp    12eb <find_line+0x17b>
cmpl   $0x3b,-0x24(%rbp)
je     1251 <find_line+0xe1>
cmpl   $0x25,-0x24(%rbp)
je     1251 <find_line+0xe1>
cmpl   $0x23,-0x24(%rbp)
jne    129d <find_line+0x12d>
jmp    1256 <find_line+0xe6>
xor    %eax,%eax
cmpl   $0xa,-0x24(%rbp)
mov    %al,-0x25(%rbp)
je     1277 <find_line+0x107>
mov    -0x24(%rbp),%eax
mov    0x2d79(%rip),%rcx
cmp    (%rcx),%eax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    1287 <find_line+0x117>
jmp    1298 <find_line+0x128>
mov    -0x10(%rbp),%rdi
call   1090 <getc@plt>
mov    %eax,-0x24(%rbp)
jmp    1256 <find_line+0xe6>
jmp    12e6 <find_line+0x176>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1070 <fseek@plt>
cmp    $0x0,%rax
je     12d9 <find_line+0x169>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xd7f(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1318 <find_line+0x1a8>
jmp    12eb <find_line+0x17b>
jmp    12f0 <find_line+0x180>
jmp    12f5 <find_line+0x185>
jmp    12fa <find_line+0x18a>
mov    -0x10(%rbp),%rdi
call   1050 <ftell@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <getc@plt>
mov    %eax,-0x24(%rbp)
jmp    1199 <find_line+0x29>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1050 <ftell@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1090 <getc@plt>
cmp    $0xffffffffffffffff,%r15
je     125f <find_line+0xef>
mov    %eax,%ebp
mov    0x2e44(%rip),%r12
movabs $0x800002800000000,%r13
jmp    11cf <find_line+0x5f>
mov    %rbx,%rdi
call   1050 <ftell@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1090 <getc@plt>
mov    %eax,%ebp
cmp    $0xffffffffffffffff,%r15
je     125f <find_line+0xef>
cmp    (%r12),%ebp
je     1215 <find_line+0xa5>
mov    %ebp,%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    11b0 <find_line+0x40>
cmp    $0x3b,%ebp
ja     123b <find_line+0xcb>
mov    %ebp,%eax
bt     %rax,%r13
jae    123b <find_line+0xcb>
cmp    (%r12),%ebp
je     11b0 <find_line+0x40>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   1090 <getc@plt>
cmp    $0xa,%eax
je     11b0 <find_line+0x40>
cmp    (%r12),%eax
jne    1200 <find_line+0x90>
jmp    11b0 <find_line+0x40>
mov    %rbx,%rdi
call   1060 <feof@plt>
mov    $0xffffffffffffffff,%r15
test   %rax,%rax
je     1281 <find_line+0x111>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1070 <fseek@plt>
test   %rax,%rax
je     1229 <find_line+0xb9>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
lea    0xdec(%rip),%rsi
jmp    126f <find_line+0xff>
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
lea    0xd91(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
lea    0xd8c(%rip),%rsi
jmp    126f <find_line+0xff>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"\22ftell\22 error in file \22%s\22.\0A\00"
@EOF = global i32 0
@.str.1 = [44 x i8] c"An error occurred while reading file \22%s\22.\0A\00"
@.str.2 = [30 x i8] c"\22fseek\22 error in file \22%s\22.\0A\0A\00"
define i64 @find_line(i32* nocapture %0, i8* %1) {
%3 = tail call i64 @ftell(i32* %0)
%4 = tail call i32 @getc(i32* %0)
%5 = icmp eq i64 %3, -1
br i1 %5, label %6, label %10
6: ; preds = %42, %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %1)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2, %42
%11 = phi i32 [ %44, %42 ], [ %4, %2 ]
%12 = phi i64 [ %43, %42 ], [ %3, %2 ]
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %11, %13
br i1 %14, label %15, label %22
15: ; preds = %10
%16 = tail call i64 @feof(i32* %0)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %46
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %10
%23 = tail call i64 @isspace(i32 %11)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %42
25: ; preds = %22
switch i32 %11, label %35 [
i32 59, label %26
i32 37, label %26
i32 35, label %26
]
26: ; preds = %25, %25, %25
%27 = load i32, i32* @EOF
%28 = icmp eq i32 %11, %27
br i1 %28, label %42, label %29
29: ; preds = %26, %29
%30 = tail call i32 @getc(i32* %0)
%31 = icmp ne i32 %30, 10
%32 = load i32, i32* @EOF
%33 = icmp ne i32 %30, %32
%34 = select i1 %31, i1 %33, i1 false
br i1 %34, label %29, label %42
35: ; preds = %25
%36 = tail call i64 @fseek(i32* %0, i64 %12, i32 0)
%37 = icmp eq i64 %36, 0
br i1 %37, label %46, label %38
38: ; preds = %35
%39 = load i32, i32* @stderr
%40 = tail call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %1)
%41 = tail call i32 @exit(i32 1)
unreachable
42: ; preds = %29, %26, %22
%43 = tail call i64 @ftell(i32* %0)
%44 = tail call i32 @getc(i32* %0)
%45 = icmp eq i64 %43, -1
br i1 %45, label %6, label %10
46: ; preds = %35, %15
%47 = phi i64 [ -1, %15 ], [ %12, %35 ]
ret i64 %47
}