#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 */
scalar_t__ getline(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ remove_trailing(char *);
int main() {
  char line[128];
  while (getline(line, 128) > 0) {
    remove_trailing(line);
    if (line[0] != '\0')
      printf("%s\n", line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
mov    $0x80,%esi
call   1050 <getline@plt>
cmp    $0x0,%rax
jle    1191 <main+0x61>
lea    -0x90(%rbp),%rdi
call   1040 <remove_trailing@plt>
movsbl -0x90(%rbp),%eax
cmp    $0x0,%eax
je     118c <main+0x5c>
lea    -0x90(%rbp),%rsi
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rsp,%rdi
mov    $0x80,%esi
call   1050 <getline@plt>
test   %rax,%rax
jle    118d <main+0x5d>
mov    %rsp,%rbx
lea    0xeaa(%rip),%r14
jmp    1172 <main+0x42>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x80,%esi
call   1050 <getline@plt>
test   %rax,%rax
jle    118d <main+0x5d>
mov    %rbx,%rdi
call   1040 <remove_trailing@plt>
cmpb   $0x0,(%rsp)
je     1160 <main+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
jmp    1160 <main+0x30>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
ret

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

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