#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 */
struct stat {
  int /*<<< orphan*/ st_size;
};
typedef int ssize_t;

/* Variables and functions */
int __findline(int, int (*)(char const *, void *), void *, int /*<<< orphan*/,
               int /*<<< orphan*/, int);
scalar_t__ fstat(int, struct stat *);
ssize_t findline(int fd, int (*comp)(const char *, void *), void *param,
                 int maxlen) {
  struct stat state;
  if (fstat(fd, &state))
    return -1;
  return __findline(fd, comp, param, 0, state.st_size, maxlen);
}


x86 assembly (clang, -O0):
<findline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1030 <fstat@plt>
cmp    $0x0,%rax
je     1158 <findline+0x38>
movl   $0xffffffff,-0x4(%rbp)
jmp    1175 <findline+0x55>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
xor    %ecx,%ecx
call   1040 <__findline@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findline>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %edi,%ebx
mov    %rsp,%rsi
call   1030 <fstat@plt>
test   %rax,%rax
je     114f <findline+0x2f>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rsp),%r8d
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r15,%rdx
xor    %ecx,%ecx
mov    %r14d,%r9d
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <__findline@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
define i32 @findline(i32 %0, i32 (i8*, i8*)* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32 (i8*, i8*)*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca %struct.stat
store i32 %0, i32* %6
store i32 (i8*, i8*)* %1, i32 (i8*, i8*)** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%11 = load i32, i32* %6
%12 = call i64 @fstat(i32 %11, %struct.stat* %10)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %4
store i32 -1, i32* %5
br label %23
15: ; preds = %4
%16 = load i32, i32* %6
%17 = load i32 (i8*, i8*)*, i32 (i8*, i8*)** %7
%18 = load i8*, i8** %8
%19 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%20 = load i32, i32* %19
%21 = load i32, i32* %9
%22 = call i32 @__findline(i32 %16, i32 (i8*, i8*)* %17, i8* %18, i32 0, i32 %20, i32 %21)
store i32 %22, i32* %5
br label %23
23: ; preds = %15, %14
%24 = load i32, i32* %5
ret i32 %24
}

LLVM IR (-O2):
%struct.stat = type { i32 }
define i32 @findline(i32 %0, i32 (i8*, i8*)* %1, i8* %2, i32 %3) {
%5 = alloca %struct.stat
%6 = bitcast %struct.stat* %5 to i8*
%7 = call i64 @fstat(i32 %0, %struct.stat* %5)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%11 = load i32, i32* %10
%12 = tail call i32 @__findline(i32 %0, i32 (i8*, i8*)* %1, i8* %2, i32 0, i32 %11, i32 %3)
br label %13
13: ; preds = %4, %9
%14 = phi i32 [ %12, %9 ], [ -1, %4 ]
ret i32 %14
}