#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*/ fflush(int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ stdout;
char *stralloc(char *);
char *getLine(void) {
  char *pass;
  char buf[1023 + 1];
  int i, ch;
  i = 0;
  fflush(stdout);
  while ((ch = getchar()) != '\n')
    if (i < 1023)
      buf[i++] = ch;
  buf[i] = 0;
  pass = stralloc(buf);
  return pass;
}


x86 assembly (clang, -O0):
<getLine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x414(%rbp)
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x418(%rbp)
cmp    $0xa,%eax
je     11a0 <getLine+0x70>
cmpl   $0x3ff,-0x414(%rbp)
jge    119b <getLine+0x6b>
mov    -0x418(%rbp),%eax
mov    %al,%cl
mov    -0x414(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x414(%rbp)
cltq
mov    %cl,-0x410(%rbp,%rax,1)
jmp    1153 <getLine+0x23>
movslq -0x414(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
lea    -0x410(%rbp),%rdi
call   1030 <stralloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLine>:
push   %rbx
sub    $0x400,%rsp
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
jne    116c <getLine+0x3c>
movslq %ebx,%rax
movb   $0x0,(%rsp,%rax,1)
mov    %rsp,%rdi
call   1030 <stralloc@plt>
add    $0x400,%rsp
pop    %rbx
ret
xor    %ebx,%ebx
jmp    117c <getLine+0x4c>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     1154 <getLine+0x24>
cmp    $0x3fe,%ebx
jg     1170 <getLine+0x40>
movslq %ebx,%rcx
add    $0x1,%ebx
mov    %al,(%rsp,%rcx,1)
jmp    1170 <getLine+0x40>

LLVM IR (-O0):
@stdout = global i32 0
define i8* @getLine() {
%1 = alloca i8*
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %3
%5 = load i32, i32* @stdout
%6 = call i32 @fflush(i32 %5)
br label %7
7: ; preds = %20, %0
%8 = call i32 (...) @getchar()
store i32 %8, i32* %4
%9 = icmp ne i32 %8, 10
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 1023
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %4
%15 = trunc i32 %14 to i8
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %18
store i8 %15, i8* %19
br label %20
20: ; preds = %13, %10
br label %7
21: ; preds = %7
%22 = load i32, i32* %3
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %23
store i8 0, i8* %24
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%26 = call i8* @stralloc(i8* %25)
store i8* %26, i8** %1
%27 = load i8*, i8** %1
ret i8* %27
}

LLVM IR (-O2):
@stdout = global i32 0
define i8* @getLine() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdout
%4 = tail call i32 @fflush(i32 %3)
%5 = tail call i32 (...) @getchar()
%6 = icmp eq i32 %5, 10
br i1 %6, label %20, label %7
7: ; preds = %0, %16
%8 = phi i32 [ %18, %16 ], [ %5, %0 ]
%9 = phi i32 [ %17, %16 ], [ 0, %0 ]
%10 = icmp slt i32 %9, 1023
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = trunc i32 %8 to i8
%13 = add nsw i32 %9, 1
%14 = sext i32 %9 to i64
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %14
store i8 %12, i8* %15
br label %16
16: ; preds = %11, %7
%17 = phi i32 [ %13, %11 ], [ %9, %7 ]
%18 = tail call i32 (...) @getchar()
%19 = icmp eq i32 %18, 10
br i1 %19, label %20, label %7
20: ; preds = %16, %0
%21 = phi i32 [ 0, %0 ], [ %17, %16 ]
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %22
store i8 0, i8* %23
%24 = call i8* @stralloc(i8* %2)
ret i8* %24
}