#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 /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int get_line_number(FILE *pFile) {
  int line_number = 0;
  char line[(256)];
  if (!pFile) {
    fprintf(stderr,
            "get_line_number() failed - file descriptor is NULL.\n"
            " - %s:%d\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/msoula/romhacking/refs/heads/master/"
            "hacks/knt/src/utils/util.c",
            42);
    return -1;
  }
  fseek(pFile, 0, SEEK_SET);
  fgets(line, (256), pFile);
  while (!feof(pFile)) {
    line_number++;
    fgets(line, (256), pFile);
  }
  fseek(pFile, 0, SEEK_SET);
  return line_number;
}


x86 assembly (clang, -O0):
<get_line_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118e <get_line_number+0x4e>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
lea    0xec6(%rip),%rdx
mov    $0x2a,%ecx
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1212 <get_line_number+0xd2>
mov    -0x10(%rbp),%rdi
mov    0x2e3f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1030 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d5 <get_line_number+0x95>
jmp    11f8 <get_line_number+0xb8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x100,%esi
call   1030 <fgets@plt>
jmp    11b7 <get_line_number+0x77>
mov    -0x10(%rbp),%rdi
mov    0x2dd5(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_line_number>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x108,%rsp
test   %rdi,%rdi
je     11bf <get_line_number+0x7f>
mov    %rdi,%r14
mov    0x2e7b(%rip),%r12
mov    (%r12),%edx
xor    %ebx,%ebx
xor    %esi,%esi
call   1060 <fseek@plt>
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
mov    %r14,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    11af <get_line_number+0x6f>
xor    %ebx,%ebx
mov    %rsp,%r15
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    %r15,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
mov    %r14,%rdi
call   1050 <feof@plt>
test   %eax,%eax
je     1190 <get_line_number+0x50>
mov    (%r12),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <fseek@plt>
jmp    11e5 <get_line_number+0xa5>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
lea    0xe68(%rip),%rdx
mov    $0x2a,%ecx
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [62 x i8] c"get_line_number() failed - file descriptor is NULL.\0A - %s:%d\0A\00"
@.str.1 = [153 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/msoula/romhacking/refs/heads/master/hacks/knt/src/utils/util.c\00"
@SEEK_SET = global i32 0
define i32 @get_line_number(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [256 x i8]
store i32* %0, i32** %3
store i32 0, i32* %4
%6 = load i32*, i32** %3
%7 = icmp ne i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 42)
store i32 -1, i32* %2
br label %34
11: ; preds = %1
%12 = load i32*, i32** %3
%13 = load i32, i32* @SEEK_SET
%14 = call i32 @fseek(i32* %12, i32 0, i32 %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%16 = load i32*, i32** %3
%17 = call i32 @fgets(i8* %15, i32 256, i32* %16)
br label %18
18: ; preds = %23, %11
%19 = load i32*, i32** %3
%20 = call i32 @feof(i32* %19)
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
br i1 %22, label %23, label %29
23: ; preds = %18
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%27 = load i32*, i32** %3
%28 = call i32 @fgets(i8* %26, i32 256, i32* %27)
br label %18
29: ; preds = %18
%30 = load i32*, i32** %3
%31 = load i32, i32* @SEEK_SET
%32 = call i32 @fseek(i32* %30, i32 0, i32 %31)
%33 = load i32, i32* %4
store i32 %33, i32* %2
br label %34
34: ; preds = %29, %8
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [62 x i8] c"get_line_number() failed - file descriptor is NULL.\0A - %s:%d\0A\00"
@.str.1 = [153 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/msoula/romhacking/refs/heads/master/hacks/knt/src/utils/util.c\00"
@SEEK_SET = global i32 0
define i32 @get_line_number(i32* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = icmp eq i32* %0, null
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.1, i64 0, i64 0), i32 42)
br label %24
8: ; preds = %1
%9 = load i32, i32* @SEEK_SET
%10 = tail call i32 @fseek(i32* %0, i32 0, i32 %9)
%11 = call i32 @fgets(i8* %3, i32 256, i32* %0)
%12 = call i32 @feof(i32* %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %8, %14
%15 = phi i32 [ %16, %14 ], [ 0, %8 ]
%16 = add nuw nsw i32 %15, 1
%17 = call i32 @fgets(i8* %3, i32 256, i32* %0)
%18 = call i32 @feof(i32* %0)
%19 = icmp eq i32 %18, 0
br i1 %19, label %14, label %20
20: ; preds = %14, %8
%21 = phi i32 [ 0, %8 ], [ %16, %14 ]
%22 = load i32, i32* @SEEK_SET
%23 = call i32 @fseek(i32* %0, i32 0, i32 %22)
br label %24
24: ; preds = %20, %5
%25 = phi i32 [ %21, %20 ], [ -1, %5 ]
ret i32 %25
}