#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 */
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ round_for_all(char *);
int /*<<< orphan*/ stdin;
int main(void) {
  char *p = NULL;
  size_t len;
  ssize_t nbytes;
  while ((nbytes = getline(&p, &len, stdin)) != -1) {
    if (p[nbytes - 1] == '\n')
      p[nbytes - 1] = 0;
    round_for_all(p);
    free(p);
    p = NULL;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <getline@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     11b3 <main+0x83>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1194 <main+0x64>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1040 <round_for_all@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x10(%rbp)
jmp    1147 <main+0x17>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,(%rsp)
mov    0x2ea0(%rip),%r15
mov    (%r15),%edx
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1050 <getline@plt>
cmp    $0xffffffff,%eax
je     11b1 <main+0x81>
mov    %rsp,%r14
lea    0x8(%rsp),%rbx
jmp    1199 <main+0x69>
nopw   0x0(%rax,%rax,1)
call   1040 <round_for_all@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
movq   $0x0,(%rsp)
mov    (%r15),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <getline@plt>
cmp    $0xffffffff,%eax
je     11b1 <main+0x81>
mov    (%rsp),%rdi
cltq
cmpb   $0xa,-0x1(%rax,%rdi,1)
jne    1170 <main+0x40>
movb   $0x0,-0x1(%rdi,%rax,1)
mov    (%rsp),%rdi
jmp    1170 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
store i8* null, i8** %2
br label %5
5: ; preds = %24, %0
%6 = load i32, i32* @stdin
%7 = call i32 @getline(i8** %2, i64* %3, i32 %6)
store i32 %7, i32* %4
%8 = icmp ne i32 %7, -1
br i1 %8, label %9, label %29
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 10
br i1 %17, label %18, label %24
18: ; preds = %9
%19 = load i8*, i8** %2
%20 = load i32, i32* %4
%21 = sub nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
store i8 0, i8* %23
br label %24
24: ; preds = %18, %9
%25 = load i8*, i8** %2
%26 = call i32 @round_for_all(i8* %25)
%27 = load i8*, i8** %2
%28 = call i32 @free(i8* %27)
store i8* null, i8** %2
br label %5
29: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @main() {
%1 = alloca i8*
%2 = alloca i64
%3 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%4 = bitcast i64* %2 to i8*
%5 = load i32, i32* @stdin
%6 = call i32 @getline(i8** %1, i64* %2, i32 %5)
%7 = icmp eq i32 %6, -1
br i1 %7, label %26, label %8
8: ; preds = %0, %18
%9 = phi i32 [ %24, %18 ], [ %6, %0 ]
%10 = load i8*, i8** %1
%11 = add nsw i32 %9, -1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 10
br i1 %15, label %16, label %18
16: ; preds = %8
store i8 0, i8* %13
%17 = load i8*, i8** %1
br label %18
18: ; preds = %16, %8
%19 = phi i8* [ %17, %16 ], [ %10, %8 ]
%20 = call i32 @round_for_all(i8* %19)
%21 = load i8*, i8** %1
%22 = call i32 @free(i8* %21)
store i8* null, i8** %1
%23 = load i32, i32* @stdin
%24 = call i32 @getline(i8** %1, i64* %2, i32 %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %8
26: ; preds = %18, %0
ret i32 0
}