#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 read(int, char *, int);
char *fline(int x) {
  static char data[384];
  int y = 0;
  while (y < 383) {
    if (read(x, &data[y], 1) != 1)
      break;
    if (data[y] == 10)
      break;
    y++;
  }
  if (y == 0)
    return NULL;
  data[y] = 0;
  return data;
}


x86 assembly (clang, -O0):
<fline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x17f,-0x10(%rbp)
jge    1183 <fline+0x73>
mov    -0xc(%rbp),%edi
movslq -0x10(%rbp),%rax
lea    0x2f03(%rip),%rsi
add    %rax,%rsi
mov    $0x1,%edx
call   1030 <read@plt>
cmp    $0x1,%eax
je     1158 <fline+0x48>
jmp    1183 <fline+0x73>
movslq -0x10(%rbp),%rcx
lea    0x2edd(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1175 <fline+0x65>
jmp    1183 <fline+0x73>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1122 <fline+0x12>
cmpl   $0x0,-0x10(%rbp)
jne    119a <fline+0x8a>
movq   $0x0,-0x8(%rbp)
jmp    11b4 <fline+0xa4>
movslq -0x10(%rbp),%rcx
lea    0x2e9b(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e90(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fline>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r15d
xor    %ebp,%ebp
lea    0x2f1d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r14,%rbp,1),%rbx
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <read@plt>
cmp    $0x1,%eax
jne    1162 <fline+0x52>
cmpb   $0xa,(%rbx)
je     1162 <fline+0x52>
add    $0x1,%rbp
cmp    $0x17f,%rbp
jne    1130 <fline+0x20>
mov    $0x17f,%ebp
jmp    1166 <fline+0x56>
test   %ebp,%ebp
je     116f <fline+0x5f>
mov    %ebp,%eax
movb   $0x0,(%rax,%r14,1)
jmp    1172 <fline+0x62>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@fline.data = internal global [384 x i8] zeroinitializer
define i8* @fline(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 0, i32* %4
br label %5
5: ; preds = %24, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 383
br i1 %7, label %8, label %27
8: ; preds = %5
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [384 x i8], [384 x i8]* @fline.data, i64 0, i64 %11
%13 = call i32 @read(i32 %9, i8* %12, i32 1)
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %8
br label %27
16: ; preds = %8
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [384 x i8], [384 x i8]* @fline.data, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 10
br i1 %22, label %23, label %24
23: ; preds = %16
br label %27
24: ; preds = %16
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %5
27: ; preds = %23, %15, %5
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %27
store i8* null, i8** %2
br label %35
31: ; preds = %27
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [384 x i8], [384 x i8]* @fline.data, i64 0, i64 %33
store i8 0, i8* %34
store i8* getelementptr inbounds ([384 x i8], [384 x i8]* @fline.data, i64 0, i64 0), i8** %2
br label %35
35: ; preds = %31, %30
%36 = load i8*, i8** %2
ret i8* %36
}

LLVM IR (-O2):
@fline.data = internal global [384 x i8] zeroinitializer
define i8* @fline(i32 %0) {
br label %2
2: ; preds = %1, %10
%3 = phi i64 [ 0, %1 ], [ %11, %10 ]
%4 = getelementptr inbounds [384 x i8], [384 x i8]* @fline.data, i64 0, i64 %3
%5 = tail call i32 @read(i32 %0, i8* %4, i32 1)
%6 = icmp eq i32 %5, 1
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = load i8, i8* %4
%9 = icmp eq i8 %8, 10
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = add nuw nsw i64 %3, 1
%12 = icmp eq i64 %11, 383
br i1 %12, label %16, label %2
13: ; preds = %7, %2
%14 = trunc i64 %3 to i32
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %10, %13
%17 = phi i64 [ %3, %13 ], [ 383, %10 ]
%18 = and i64 %17, 4294967295
%19 = getelementptr inbounds [384 x i8], [384 x i8]* @fline.data, i64 0, i64 %18
store i8 0, i8* %19
br label %20
20: ; preds = %13, %16
%21 = phi i8* [ getelementptr inbounds ([384 x i8], [384 x i8]* @fline.data, i64 0, i64 0), %16 ], [ null, %13 ]
ret i8* %21
}