getans() {
  static char line[128];
  register char *cp;
  register int c;
  flush();
  cp = line;
  while (c = getchar()) {
    if (c == '\n') {
      *cp = 0;
      return (line);
    }
    if (cp < (&line) + 1)
      *cp++ = c;
  }
  exit(1);
}


x86 assembly (clang, -O0):
<getans>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <flush@plt>
lea    0x2f0a(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     11ad <getans+0x7d>
cmpl   $0xa,-0xc(%rbp)
jne    117b <getans+0x4b>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2edb(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret
lea    0x2ece(%rip),%rax
add    $0x80,%rax
cmp    %rax,-0x8(%rbp)
jae    11a8 <getans+0x78>
mov    -0xc(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    114a <getans+0x1a>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<getans>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <flush@plt>
lea    0x2f0e(%rip),%rbx
lea    0x2f87(%rip),%r14
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%eax
je     116d <getans+0x3d>
test   %eax,%eax
je     117f <getans+0x4f>
cmp    %r14,%rbx
jae    1150 <getans+0x20>
mov    %al,(%rbx)
add    $0x1,%rbx
jmp    1150 <getans+0x20>
movb   $0x0,(%rbx)
lea    0x2ed9(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@getans.line = internal global [128 x i8] zeroinitializer
define i32 @getans() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i32 (...) @flush()
store i8* getelementptr inbounds ([128 x i8], [128 x i8]* @getans.line, i64 0, i64 0), i8** %1
br label %4
4: ; preds = %20, %0
%5 = call i32 (...) @getchar()
store i32 %5, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %21
7: ; preds = %4
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 10
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = load i8*, i8** %1
store i8 0, i8* %11
ret i32 ptrtoint ([128 x i8]* @getans.line to i32)
12: ; preds = %7
%13 = load i8*, i8** %1
%14 = icmp ult i8* %13, getelementptr inbounds ([128 x i8], [128 x i8]* @getans.line, i64 1, i32 0)
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i32, i32* %2
%17 = trunc i32 %16 to i8
%18 = load i8*, i8** %1
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %1
store i8 %17, i8* %18
br label %20
20: ; preds = %15, %12
br label %4
21: ; preds = %4
unreachable
}

LLVM IR (-O2):
@getans.line = internal global [128 x i8] zeroinitializer
define i32 @getans() {
%1 = tail call i32 (...) @flush()
br label %2
2: ; preds = %9, %0
%3 = phi i8* [ %11, %9 ], [ getelementptr inbounds ([128 x i8], [128 x i8]* @getans.line, i64 0, i64 0), %0 ]
%4 = icmp ult i8* %3, getelementptr inbounds ([128 x i8], [128 x i8]* @getans.line, i64 1, i64 0)
br label %5
5: ; preds = %2, %8
%6 = tail call i32 (...) @getchar()
switch i32 %6, label %8 [
i32 0, label %12
i32 10, label %7
]
7: ; preds = %5
store i8 0, i8* %3
ret i32 ptrtoint ([128 x i8]* @getans.line to i32)
8: ; preds = %5
br i1 %4, label %9, label %5
9: ; preds = %8
%10 = trunc i32 %6 to i8
%11 = getelementptr inbounds i8, i8* %3, i64 1
store i8 %10, i8* %3
br label %2
12: ; preds = %5
tail call void @exit(i32 1)
unreachable
}