#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*/ from;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int bof;
int boln;
char c;
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
char getc(int /*<<< orphan*/ *);
long findfrom(FILE *fd, long off, char **fromptr) {
  register c, boln, bof;
  register long ret;
  static char from[256];
  char *p;
  fseek(fd, off, 0);
  bof = 1;
  boln = 1;
  ret = off;
  *fromptr = "";
  for (;;) {
    c = getc(fd);
    if (c < 0)
      return (bof ? -1 : off);
    bof = 0;
    ++off;
    if (c == '\n') {
      boln = 1;
      ret = off;
      continue;
    }
    if (boln && c == 'F') {
      if (getc(fd) == 'r' && getc(fd) == 'o' && getc(fd) == 'm' &&
          getc(fd) == ' ') {
        fgets(from, sizeof(from), fd);
        *fromptr = from;
        for (p = from; *p && *p != ' ' && *p != '\n' && *p != '\r'; ++p)
          ;
        *p = 0;
        return (ret);
      }
      off = ret + 1;
      fseek(fd, off, 0);
    }
    boln = 0;
  }
}


x86 assembly (clang, -O0):
<findfrom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1040 <fseek@plt>
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
lea    0xe8c(%rip),%rcx
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
movsbl %al,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11bf <findfrom+0x8f>
cmpl   $0x0,-0x2c(%rbp)
je     11aa <findfrom+0x7a>
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x48(%rbp)
jmp    11b2 <findfrom+0x82>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1336 <findfrom+0x206>
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
cmpl   $0xa,-0x24(%rbp)
jne    11f0 <findfrom+0xc0>
movl   $0x1,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1177 <findfrom+0x47>
cmpl   $0x0,-0x28(%rbp)
je     132a <findfrom+0x1fa>
cmpl   $0x46,-0x24(%rbp)
jne    132a <findfrom+0x1fa>
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
movsbl %al,%eax
cmp    $0x72,%eax
jne    130f <findfrom+0x1df>
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
movsbl %al,%eax
cmp    $0x6f,%eax
jne    130f <findfrom+0x1df>
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
movsbl %al,%eax
cmp    $0x6d,%eax
jne    130f <findfrom+0x1df>
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
movsbl %al,%eax
cmp    $0x20,%eax
jne    130f <findfrom+0x1df>
mov    -0x10(%rbp),%rdx
lea    0x2ded(%rip),%rdi
mov    $0x100,%esi
call   1030 <fgets@plt>
mov    -0x20(%rbp),%rax
lea    0x2dd8(%rip),%rcx
mov    %rcx,(%rax)
lea    0x2dce(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x49(%rbp)
je     12d5 <findfrom+0x1a5>
mov    -0x40(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x49(%rbp)
je     12d5 <findfrom+0x1a5>
mov    -0x40(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x49(%rbp)
je     12d5 <findfrom+0x1a5>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
setne  %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    12e5 <findfrom+0x1b5>
jmp    12fb <findfrom+0x1cb>
jmp    12ea <findfrom+0x1ba>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1286 <findfrom+0x156>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1336 <findfrom+0x206>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1040 <fseek@plt>
movl   $0x0,-0x28(%rbp)
jmp    1177 <findfrom+0x47>
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findfrom>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
xor    %edx,%edx
call   1040 <fseek@plt>
lea    0xeb0(%rip),%rax
mov    %rax,(%r14)
mov    %r15,%rdi
call   1050 <getc@plt>
test   %al,%al
js     11f2 <findfrom+0xc2>
mov    %rbx,%r13
lea    0x1(%rbx),%r12
mov    $0x1,%cl
jmp    118e <findfrom+0x5e>
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r12,%rsi
xor    %edx,%edx
call   1040 <fseek@plt>
mov    %r12,%rbx
mov    %r15,%rdi
call   1050 <getc@plt>
xor    %ecx,%ecx
test   %al,%al
js     11f9 <findfrom+0xc9>
add    $0x1,%rbx
cmp    $0xa,%al
je     11e0 <findfrom+0xb0>
cmp    $0x46,%al
setne  %al
not    %cl
or     %al,%cl
test   $0x1,%cl
jne    1180 <findfrom+0x50>
mov    %r15,%rdi
call   1050 <getc@plt>
cmp    $0x72,%al
jne    1170 <findfrom+0x40>
mov    %r15,%rdi
call   1050 <getc@plt>
cmp    $0x6f,%al
jne    1170 <findfrom+0x40>
mov    %r15,%rdi
call   1050 <getc@plt>
cmp    $0x6d,%al
jne    1170 <findfrom+0x40>
mov    %r15,%rdi
call   1050 <getc@plt>
cmp    $0x20,%al
jne    1170 <findfrom+0x40>
jmp    1206 <findfrom+0xd6>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1050 <getc@plt>
test   %al,%al
jns    1163 <findfrom+0x33>
jmp    11f9 <findfrom+0xc9>
mov    $0xffffffffffffffff,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0x2e43(%rip),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1030 <fgets@plt>
mov    %rbx,(%r14)
movabs $0x100002401,%rax
jmp    1234 <findfrom+0x104>
nopl   0x0(%rax)
add    $0x1,%rbx
movzbl (%rbx),%ecx
cmp    $0x20,%rcx
ja     1230 <findfrom+0x100>
bt     %rcx,%rax
jae    1230 <findfrom+0x100>
movb   $0x0,(%rbx)
mov    %r13,%rbx
jmp    11f9 <findfrom+0xc9>

LLVM IR (-O0):
@findfrom.from = internal global [256 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
@bof = global i32 0
@boln = global i32 0
@c = global i8 0
define i64 @findfrom(i32* %0, i64 %1, i8** %2) {
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i8*
store i32* %0, i32** %5
store i64 %1, i64* %6
store i8** %2, i8*** %7
%13 = load i32*, i32** %5
%14 = load i64, i64* %6
%15 = call i32 @fseek(i32* %13, i64 %14, i32 0)
store i32 1, i32* %10
store i32 1, i32* %9
%16 = load i64, i64* %6
store i64 %16, i64* %11
%17 = load i8**, i8*** %7
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %17
br label %18
18: ; preds = %104, %37, %3
%19 = load i32*, i32** %5
%20 = call signext i8 @getc(i32* %19)
%21 = sext i8 %20 to i32
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %18
%25 = load i32, i32* %10
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %24
br label %30
28: ; preds = %24
%29 = load i64, i64* %6
br label %30
30: ; preds = %28, %27
%31 = phi i64 [ -1, %27 ], [ %29, %28 ]
store i64 %31, i64* %4
br label %105
32: ; preds = %18
store i32 0, i32* %10
%33 = load i64, i64* %6
%34 = add nsw i64 %33, 1
store i64 %34, i64* %6
%35 = load i32, i32* %8
%36 = icmp eq i32 %35, 10
br i1 %36, label %37, label %39
37: ; preds = %32
store i32 1, i32* %9
%38 = load i64, i64* %6
store i64 %38, i64* %11
br label %18
39: ; preds = %32
%40 = load i32, i32* %9
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %104
42: ; preds = %39
%43 = load i32, i32* %8
%44 = icmp eq i32 %43, 70
br i1 %44, label %45, label %104
45: ; preds = %42
%46 = load i32*, i32** %5
%47 = call signext i8 @getc(i32* %46)
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 114
br i1 %49, label %50, label %98
50: ; preds = %45
%51 = load i32*, i32** %5
%52 = call signext i8 @getc(i32* %51)
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 111
br i1 %54, label %55, label %98
55: ; preds = %50
%56 = load i32*, i32** %5
%57 = call signext i8 @getc(i32* %56)
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 109
br i1 %59, label %60, label %98
60: ; preds = %55
%61 = load i32*, i32** %5
%62 = call signext i8 @getc(i32* %61)
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 32
br i1 %64, label %65, label %98
65: ; preds = %60
%66 = load i32*, i32** %5
%67 = call i32 @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @findfrom.from, i64 0, i64 0), i32 256, i32* %66)
%68 = load i8**, i8*** %7
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @findfrom.from, i64 0, i64 0), i8** %68
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @findfrom.from, i64 0, i64 0), i8** %12
br label %69
69: ; preds = %92, %65
%70 = load i8*, i8** %12
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %89
74: ; preds = %69
%75 = load i8*, i8** %12
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp ne i32 %77, 32
br i1 %78, label %79, label %89
79: ; preds = %74
%80 = load i8*, i8** %12
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp ne i32 %82, 10
br i1 %83, label %84, label %89
84: ; preds = %79
%85 = load i8*, i8** %12
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = icmp ne i32 %87, 13
br label %89
89: ; preds = %84, %79, %74, %69
%90 = phi i1 [ false, %79 ], [ false, %74 ], [ false, %69 ], [ %88, %84 ]
br i1 %90, label %91, label %95
91: ; preds = %89
br label %92
92: ; preds = %91
%93 = load i8*, i8** %12
%94 = getelementptr inbounds i8, i8* %93, i32 1
store i8* %94, i8** %12
br label %69
95: ; preds = %89
%96 = load i8*, i8** %12
store i8 0, i8* %96
%97 = load i64, i64* %11
store i64 %97, i64* %4
br label %105
98: ; preds = %60, %55, %50, %45
%99 = load i64, i64* %11
%100 = add nsw i64 %99, 1
store i64 %100, i64* %6
%101 = load i32*, i32** %5
%102 = load i64, i64* %6
%103 = call i32 @fseek(i32* %101, i64 %102, i32 0)
br label %104
104: ; preds = %98, %42, %39
store i32 0, i32* %9
br label %18
105: ; preds = %95, %30
%106 = load i64, i64* %4
ret i64 %106
}

LLVM IR (-O2):
@findfrom.from = internal global [256 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
@bof = global i32 0
@boln = global i32 0
@c = global i8 0
define i64 @findfrom(i32* nocapture %0, i64 %1, i8** nocapture writeonly %2) {
%4 = tail call i32 @fseek(i32* %0, i64 %1, i32 0)
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = tail call signext i8 @getc(i32* %0)
%6 = icmp slt i8 %5, 0
br i1 %6, label %49, label %10
7: ; preds = %14
%8 = tail call signext i8 @getc(i32* %0)
%9 = icmp slt i8 %8, 0
br i1 %9, label %49, label %10
10: ; preds = %3, %7
%11 = phi i8 [ %8, %7 ], [ %5, %3 ]
%12 = phi i64 [ %18, %7 ], [ %1, %3 ]
%13 = add nsw i64 %12, 1
br label %14
14: ; preds = %10, %45
%15 = phi i8 [ %11, %10 ], [ %47, %45 ]
%16 = phi i1 [ true, %10 ], [ false, %45 ]
%17 = phi i64 [ %12, %10 ], [ %46, %45 ]
%18 = add nsw i64 %17, 1
%19 = icmp eq i8 %15, 10
br i1 %19, label %7, label %20
20: ; preds = %14
%21 = icmp eq i8 %15, 70
%22 = and i1 %16, %21
br i1 %22, label %23, label %45
23: ; preds = %20
%24 = tail call signext i8 @getc(i32* %0)
%25 = icmp eq i8 %24, 114
br i1 %25, label %26, label %43
26: ; preds = %23
%27 = tail call signext i8 @getc(i32* %0)
%28 = icmp eq i8 %27, 111
br i1 %28, label %29, label %43
29: ; preds = %26
%30 = tail call signext i8 @getc(i32* %0)
%31 = icmp eq i8 %30, 109
br i1 %31, label %32, label %43
32: ; preds = %29
%33 = tail call signext i8 @getc(i32* %0)
%34 = icmp eq i8 %33, 32
br i1 %34, label %35, label %43
35: ; preds = %32
%36 = tail call i32 @fgets(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @findfrom.from, i64 0, i64 0), i32 256, i32* %0)
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @findfrom.from, i64 0, i64 0), i8** %2
br label %37
37: ; preds = %40, %35
%38 = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @findfrom.from, i64 0, i64 0), %35 ], [ %41, %40 ]
%39 = load i8, i8* %38
switch i8 %39, label %40 [
i8 0, label %42
i8 32, label %42
i8 10, label %42
i8 13, label %42
]
40: ; preds = %37
%41 = getelementptr inbounds i8, i8* %38, i64 1
br label %37
42: ; preds = %37, %37, %37, %37
store i8 0, i8* %38
br label %49
43: ; preds = %32, %29, %26, %23
%44 = tail call i32 @fseek(i32* %0, i64 %13, i32 0)
br label %45
45: ; preds = %43, %20
%46 = phi i64 [ %13, %43 ], [ %18, %20 ]
%47 = tail call signext i8 @getc(i32* %0)
%48 = icmp slt i8 %47, 0
br i1 %48, label %49, label %14
49: ; preds = %7, %45, %3, %42
%50 = phi i64 [ %12, %42 ], [ -1, %3 ], [ %46, %45 ], [ %18, %7 ]
ret i64 %50
}