#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 getlinex(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ trimr(char *);
int main() {
  int len;
  char line[1000];
  while ((len = getlinex(line, 1000)) > 0) {
    trimr(line);
    if (line[0] != '\n' && line[0] != '\0') {
      printf("%s", line);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3f0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1030 <getlinex@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11a3 <main+0x73>
lea    -0x3f0(%rbp),%rdi
call   1050 <trimr@plt>
movsbl -0x3f0(%rbp),%eax
cmp    $0xa,%eax
je     119e <main+0x6e>
movsbl -0x3f0(%rbp),%eax
cmp    $0x0,%eax
je     119e <main+0x6e>
lea    -0x3f0(%rbp),%rsi
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
jmp    1142 <main+0x12>
mov    -0x4(%rbp),%eax
add    $0x3f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1030 <getlinex@plt>
test   %eax,%eax
jle    1192 <main+0x62>
mov    %rsp,%rbx
lea    0xeab(%rip),%r14
jmp    1171 <main+0x41>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1030 <getlinex@plt>
test   %eax,%eax
jle    1192 <main+0x62>
mov    %rbx,%rdi
call   1050 <trimr@plt>
movzbl (%rsp),%eax
test   %al,%al
je     1160 <main+0x30>
cmp    $0xa,%al
je     1160 <main+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
jmp    1160 <main+0x30>
xor    %eax,%eax
add    $0x3e8,%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 [1000 x i8]
store i32 0, i32* %1
br label %4
4: ; preds = %23, %0
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = call i32 @getlinex(i8* %5, i32 1000)
store i32 %6, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %24
8: ; preds = %4
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%10 = call i32 @trimr(i8* %9)
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %23
15: ; preds = %8
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20, %15, %8
br label %4
24: ; preds = %4
%25 = load i32, i32* %1
ret i32 %25
}

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