#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*/ cleanaline(char *, int);
int getaline(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int main(void) {
  int len;
  char line[10000];
  while ((len = getaline(line, 10000)) > 0) {
    cleanaline(line, len);
    if (line[0] == '\n')
      continue;
    printf("%s", line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2720,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x2720(%rbp),%rdi
mov    $0x2710,%esi
call   1030 <getaline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    119b <main+0x6b>
lea    -0x2720(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <cleanaline@plt>
movsbl -0x2720(%rbp),%eax
cmp    $0xa,%eax
jne    1183 <main+0x53>
jmp    1142 <main+0x12>
lea    -0x2720(%rbp),%rsi
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x2720,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x2718,%rsp
mov    %rsp,%rdi
mov    $0x2710,%esi
call   1030 <getaline@plt>
test   %eax,%eax
jle    118e <main+0x5e>
mov    %rsp,%rbx
lea    0xeab(%rip),%r14
jmp    1171 <main+0x41>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x2710,%esi
call   1030 <getaline@plt>
test   %eax,%eax
jle    118e <main+0x5e>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <cleanaline@plt>
cmpb   $0xa,(%rsp)
je     1160 <main+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
jmp    1160 <main+0x30>
xor    %eax,%eax
add    $0x2718,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10000 x i8]
store i32 0, i32* %1
br label %4
4: ; preds = %17, %16, %0
%5 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%6 = call i32 @getaline(i8* %5, i32 10000)
store i32 %6, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %4
%9 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%10 = load i32, i32* %2
%11 = call i32 @cleanaline(i8* %9, i32 %10)
%12 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 10
br i1 %15, label %16, label %17
16: ; preds = %8
br label %4
17: ; preds = %8
%18 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %4
20: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [10000 x i8]
%2 = getelementptr inbounds [10000 x i8], [10000 x i8]* %1, i64 0, i64 0
%3 = call i32 @getaline(i8* %2, i32 10000)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %0, %12
%6 = phi i32 [ %13, %12 ], [ %3, %0 ]
%7 = call i32 @cleanaline(i8* %2, i32 %6)
%8 = load i8, i8* %2
%9 = icmp eq i8 %8, 10
br i1 %9, label %12, label %10
10: ; preds = %5
%11 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %12
12: ; preds = %10, %5
%13 = call i32 @getaline(i8* %2, i32 10000)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %5, label %15
15: ; preds = %12, %0
ret i32 0
}