#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 */
char EOF;
int /*<<< orphan*/ SEEK_SET;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
long int get_offset(FILE *fpin, int linea) {
  char c = ' ';
  long int originalpos = ftell(fpin);
  long int result;
  if (linea == 0)
    return 0;
  for (; linea > 0 && c != EOF;) {
    c = fgetc(fpin);
    if (c == '\n') {
      linea--;
    }
  }
  result = ftell(fpin);
  fseek(fpin, originalpos, SEEK_SET);
  return result;
}


x86 assembly (clang, -O0):
<get_offset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movb   $0x20,-0x15(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1167 <get_offset+0x37>
movq   $0x0,-0x8(%rbp)
jmp    11f3 <get_offset+0xc3>
jmp    116c <get_offset+0x3c>
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x29(%rbp)
jle    1191 <get_offset+0x61>
movsbl -0x15(%rbp),%eax
mov    0x2e62(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11a1 <get_offset+0x71>
jmp    11c8 <get_offset+0x98>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%eax
cmp    $0xa,%eax
jne    11c3 <get_offset+0x93>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    116c <get_offset+0x3c>
mov    -0x10(%rbp),%rdi
call   1040 <ftell@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2df4(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_offset>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1040 <ftell@plt>
test   %ebp,%ebp
je     119c <get_offset+0x6c>
mov    %rax,%r14
jle    1178 <get_offset+0x48>
mov    0x2e97(%rip),%r15
cmpb   $0x20,(%r15)
je     1178 <get_offset+0x48>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <fgetc@plt>
xor    %ecx,%ecx
cmp    $0xa,%al
sete   %cl
sub    %ecx,%ebp
je     1178 <get_offset+0x48>
cmp    (%r15),%al
jne    1160 <get_offset+0x30>
mov    %rbx,%rdi
call   1040 <ftell@plt>
mov    %rax,%rbp
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fseek@plt>
mov    %rbp,%rax
jmp    119e <get_offset+0x6e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i8 0
@SEEK_SET = global i32 0
define i64 @get_offset(i32* %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8
%7 = alloca i64
%8 = alloca i64
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8 32, i8* %6
%9 = load i32*, i32** %4
%10 = call i64 @ftell(i32* %9)
store i64 %10, i64* %7
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %2
store i64 0, i64* %3
br label %44
14: ; preds = %2
br label %15
15: ; preds = %35, %14
%16 = load i32, i32* %5
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i8, i8* %6
%20 = sext i8 %19 to i32
%21 = load i8, i8* @EOF
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %20, %22
br label %24
24: ; preds = %18, %15
%25 = phi i1 [ false, %15 ], [ %23, %18 ]
br i1 %25, label %26, label %36
26: ; preds = %24
%27 = load i32*, i32** %4
%28 = call signext i8 @fgetc(i32* %27)
store i8 %28, i8* %6
%29 = load i8, i8* %6
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 10
br i1 %31, label %32, label %35
32: ; preds = %26
%33 = load i32, i32* %5
%34 = add nsw i32 %33, -1
store i32 %34, i32* %5
br label %35
35: ; preds = %32, %26
br label %15
36: ; preds = %24
%37 = load i32*, i32** %4
%38 = call i64 @ftell(i32* %37)
store i64 %38, i64* %8
%39 = load i32*, i32** %4
%40 = load i64, i64* %7
%41 = load i32, i32* @SEEK_SET
%42 = call i32 @fseek(i32* %39, i64 %40, i32 %41)
%43 = load i64, i64* %8
store i64 %43, i64* %3
br label %44
44: ; preds = %36, %13
%45 = load i64, i64* %3
ret i64 %45
}

LLVM IR (-O2):
@EOF = global i8 0
@SEEK_SET = global i32 0
define i64 @get_offset(i32* nocapture %0, i32 %1) {
%3 = tail call i64 @ftell(i32* %0)
%4 = icmp eq i32 %1, 0
br i1 %4, label %24, label %5
5: ; preds = %2
%6 = icmp sgt i32 %1, 0
%7 = load i8, i8* @EOF
%8 = icmp ne i8 %7, 32
%9 = select i1 %6, i1 %8, i1 false
br i1 %9, label %10, label %20
10: ; preds = %5, %10
%11 = phi i32 [ %15, %10 ], [ %1, %5 ]
%12 = tail call signext i8 @fgetc(i32* %0)
%13 = icmp eq i8 %12, 10
%14 = sext i1 %13 to i32
%15 = add nsw i32 %11, %14
%16 = icmp ne i32 %15, 0
%17 = load i8, i8* @EOF
%18 = icmp ne i8 %12, %17
%19 = select i1 %16, i1 %18, i1 false
br i1 %19, label %10, label %20
20: ; preds = %10, %5
%21 = tail call i64 @ftell(i32* %0)
%22 = load i32, i32* @SEEK_SET
%23 = tail call i32 @fseek(i32* %0, i64 %3, i32 %22)
br label %24
24: ; preds = %2, %20
%25 = phi i64 [ %21, %20 ], [ 0, %2 ]
ret i64 %25
}