#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 */
int /*<<< orphan*/ exit(int);
int lseek(int, int, int);
int /*<<< orphan*/ printf(char *, char);
int /*<<< orphan*/ read(int, char *, int);
int printLine(int fd, int start) {
  char bfr;
  int len;
  len = lseek(fd, 0L, 2);
  while (lseek(fd, start, 0) < len) {
    start++;
    read(fd, &bfr, sizeof(char));
    printf("%c", (char)bfr);
    if ((char)bfr == '\n')
      return start;
  }
  exit(1);
}


x86 assembly (clang, -O0):
<printLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <lseek@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
xor    %edx,%edx
call   1040 <lseek@plt>
cmp    -0x10(%rbp),%eax
jge    11bb <printLine+0x7b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
lea    0xe69(%rip),%rdi
movsbl -0x9(%rbp),%esi
call   1030 <printf@plt>
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
jne    11b6 <printLine+0x76>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret
jmp    1160 <printLine+0x20>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<printLine>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%r13d
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <lseek@plt>
mov    %eax,%r14d
lea    0x7(%rsp),%r15
lea    0xe95(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %ebx,%esi
xor    %edx,%edx
call   1040 <lseek@plt>
cmp    %r14d,%eax
jge    11b9 <printLine+0x79>
add    $0x1,%ebx
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <read@plt>
movsbl 0x7(%rsp),%ebp
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
cmp    $0xa,%ebp
jne    1170 <printLine+0x30>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
define i32 @printLine(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = call i32 @lseek(i32 %7, i32 0, i32 2)
store i32 %8, i32* %6
br label %9
9: ; preds = %27, %2
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = call i32 @lseek(i32 %10, i32 %11, i32 0)
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %28
15: ; preds = %9
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
%18 = load i32, i32* %3
%19 = call i32 @read(i32 %18, i8* %5, i32 1)
%20 = load i8, i8* %5
%21 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %20)
%22 = load i8, i8* %5
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 10
br i1 %24, label %25, label %27
25: ; preds = %15
%26 = load i32, i32* %4
ret i32 %26
27: ; preds = %15
br label %9
28: ; preds = %9
%29 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define i32 @printLine(i32 %0, i32 %1) {
%3 = alloca i8
%4 = tail call i32 @lseek(i32 %0, i32 0, i32 2)
br label %5
5: ; preds = %9, %2
%6 = phi i32 [ %1, %2 ], [ %10, %9 ]
%7 = tail call i32 @lseek(i32 %0, i32 %6, i32 0)
%8 = icmp slt i32 %7, %4
br i1 %8, label %9, label %16
9: ; preds = %5
%10 = add nsw i32 %6, 1
%11 = call i32 @read(i32 %0, i8* %3, i32 1)
%12 = load i8, i8* %3
%13 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %12)
%14 = icmp eq i8 %12, 10
br i1 %14, label %15, label %5
15: ; preds = %9
ret i32 %10
16: ; preds = %5
%17 = tail call i32 @exit(i32 1)
unreachable
}