#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 */

/* Variables and functions */
char *nextline(char *, int);
char *__seekline(char *base, int len) {
  char *head = nextline(base, len);
  char *end;
  if (head == NULL)
    return NULL;
  end = nextline(head, len - (head - base));
  if (end == NULL)
    return NULL;
  return head;
}


x86 assembly (clang, -O0):
<__seekline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <nextline@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1147 <__seekline+0x37>
movq   $0x0,-0x8(%rbp)
jmp    1188 <__seekline+0x78>
mov    -0x20(%rbp),%rdi
movslq -0x14(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rdx
sub    %rdx,%rcx
sub    %rcx,%rax
mov    %eax,%esi
call   1030 <nextline@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1180 <__seekline+0x70>
movq   $0x0,-0x8(%rbp)
jmp    1188 <__seekline+0x78>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__seekline>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <nextline@plt>
test   %rax,%rax
je     113e <__seekline+0x2e>
mov    %rax,%r14
sub    %r14d,%ebx
add    %ebp,%ebx
mov    %rax,%rdi
mov    %ebx,%esi
call   1030 <nextline@plt>
test   %rax,%rax
cmove  %rax,%r14
jmp    1141 <__seekline+0x31>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @__seekline(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i8*, i8** %4
%9 = load i32, i32* %5
%10 = call i8* @nextline(i8* %8, i32 %9)
store i8* %10, i8** %6
%11 = load i8*, i8** %6
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %2
store i8* null, i8** %3
br label %31
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = load i8*, i8** %6
%19 = load i8*, i8** %4
%20 = ptrtoint i8* %18 to i64
%21 = ptrtoint i8* %19 to i64
%22 = sub i64 %20, %21
%23 = sub nsw i64 %17, %22
%24 = trunc i64 %23 to i32
%25 = call i8* @nextline(i8* %15, i32 %24)
store i8* %25, i8** %7
%26 = load i8*, i8** %7
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %29
28: ; preds = %14
store i8* null, i8** %3
br label %31
29: ; preds = %14
%30 = load i8*, i8** %6
store i8* %30, i8** %3
br label %31
31: ; preds = %29, %28, %13
%32 = load i8*, i8** %3
ret i8* %32
}

LLVM IR (-O2):
define i8* @__seekline(i8* %0, i32 %1) {
%3 = tail call i8* @nextline(i8* %0, i32 %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %14, label %5
5: ; preds = %2
%6 = ptrtoint i8* %3 to i64
%7 = ptrtoint i8* %0 to i64
%8 = sub i64 %7, %6
%9 = trunc i64 %8 to i32
%10 = add i32 %9, %1
%11 = tail call i8* @nextline(i8* %3, i32 %10)
%12 = icmp eq i8* %11, null
%13 = select i1 %12, i8* null, i8* %3
br label %14
14: ; preds = %5, %2
%15 = phi i8* [ null, %2 ], [ %13, %5 ]
ret i8* %15
}