#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 *rline(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;
  }
  if (y == 0)
    return NULL;
  data[y] = 0;
  return data;
}


x86 assembly (clang, -O0):
<rline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x17f,-0x10(%rbp)
jge    1184 <rline+0x74>
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 <rline+0x48>
jmp    1184 <rline+0x74>
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x10(%rbp)
movslq %eax,%rcx
lea    0x2ed3(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    117f <rline+0x6f>
jmp    1184 <rline+0x74>
jmp    1122 <rline+0x12>
cmpl   $0x0,-0x10(%rbp)
jne    119b <rline+0x8b>
movq   $0x0,-0x8(%rbp)
jmp    11b5 <rline+0xa5>
movslq -0x10(%rbp),%rcx
lea    0x2e9a(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e8f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rline>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
xor    %ebp,%ebp
lea    0x2f20(%rip),%rbx
lea    (%rbx,%rbp,1),%rsi
mov    %r14d,%edi
mov    $0x1,%edx
call   1030 <read@plt>
cmp    $0x1,%eax
jne    114f <rline+0x3f>
lea    0x1(%rbp),%rax
cmpb   $0xa,0x0(%rbp,%rbx,1)
je     1156 <rline+0x46>
cmp    $0x17e,%rbp
mov    %rax,%rbp
jb     1120 <rline+0x10>
jmp    1156 <rline+0x46>
mov    %rbp,%rax
test   %ebp,%ebp
je     115e <rline+0x4e>
cltq
movb   $0x0,(%rax,%rbx,1)
jmp    1160 <rline+0x50>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@rline.data = internal global [384 x i8] zeroinitializer
define i8* @rline(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 = %25, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 383
br i1 %7, label %8, label %26
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]* @rline.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 %26
16: ; preds = %8
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds [384 x i8], [384 x i8]* @rline.data, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 10
br i1 %23, label %24, label %25
24: ; preds = %16
br label %26
25: ; preds = %16
br label %5
26: ; preds = %24, %15, %5
%27 = load i32, i32* %4
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %26
store i8* null, i8** %2
br label %34
30: ; preds = %26
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [384 x i8], [384 x i8]* @rline.data, i64 0, i64 %32
store i8 0, i8* %33
store i8* getelementptr inbounds ([384 x i8], [384 x i8]* @rline.data, i64 0, i64 0), i8** %2
br label %34
34: ; preds = %30, %29
%35 = load i8*, i8** %2
ret i8* %35
}

LLVM IR (-O2):
@rline.data = internal global [384 x i8] zeroinitializer
define i8* @rline(i32 %0) {
br label %2
2: ; preds = %1, %7
%3 = phi i64 [ 0, %1 ], [ %8, %7 ]
%4 = getelementptr inbounds [384 x i8], [384 x i8]* @rline.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 = add nuw nsw i64 %3, 1
%9 = load i8, i8* %4
%10 = icmp ne i8 %9, 10
%11 = icmp ult i64 %3, 382
%12 = select i1 %10, i1 %11, i1 false
br i1 %12, label %2, label %16
13: ; preds = %2
%14 = trunc i64 %3 to i32
%15 = icmp eq i32 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %7, %13
%17 = phi i64 [ %3, %13 ], [ %8, %7 ]
%18 = shl i64 %17, 32
%19 = ashr exact i64 %18, 32
%20 = getelementptr inbounds [384 x i8], [384 x i8]* @rline.data, i64 0, i64 %19
store i8 0, i8* %20
br label %21
21: ; preds = %13, %16
%22 = phi i8* [ getelementptr inbounds ([384 x i8], [384 x i8]* @rline.data, i64 0, i64 0), %16 ], [ null, %13 ]
ret i8* %22
}