#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 getLine(char *, int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ rtrim(char *);
int main(void) {
  int c, len;
  char line[1000];
  while ((len = getLine(line, 1000)) > 0) {
    if (rtrim(line) > 0) {
      printf("%s", line);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1050 <getLine@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jle    118d <main+0x5d>
lea    -0x400(%rbp),%rdi
call   1040 <rtrim@plt>
cmp    $0x0,%rax
jle    1188 <main+0x58>
lea    -0x400(%rbp),%rsi
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3e8,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1050 <getLine@plt>
test   %eax,%eax
jle    118b <main+0x5b>
mov    %rsp,%rbx
lea    0xeab(%rip),%r14
jmp    1171 <main+0x41>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1050 <getLine@plt>
test   %eax,%eax
jle    118b <main+0x5b>
mov    %rbx,%rdi
call   1040 <rtrim@plt>
test   %rax,%rax
jle    1160 <main+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <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 i32
%4 = alloca [1000 x i8]
store i32 0, i32* %1
br label %5
5: ; preds = %16, %0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%7 = call i32 @getLine(i8* %6, i32 1000)
store i32 %7, i32* %3
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%11 = call i64 @rtrim(i8* %10)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13, %9
br label %5
17: ; preds = %5
ret i32 0
}

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 @getLine(i8* %2, i32 1000)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %13
5: ; preds = %0, %10
%6 = call i64 @rtrim(i8* %2)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, 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 = %8, %5
%11 = call i32 @getLine(i8* %2, i32 1000)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %5, label %13
13: ; preds = %10, %0
ret i32 0
}