#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 **, size_t *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
char *trimline(char *, char **);
int main(int argc, char **argv) {
  size_t n = 0;
  char *line = NULL;
  char *trimmed = NULL;
  char *saveptr = NULL;
  while (getline(&line, &n, stdin) > -1) {
    trimmed = trimline(line, &saveptr);
    while ((trimmed = trimline(NULL, &saveptr)))
      printf("%s\n", trimmed);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <getline@plt>
cmp    $0xffffffff,%eax
jle    11cb <main+0x9b>
mov    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <trimline@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    -0x30(%rbp),%rsi
call   1040 <trimline@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11c6 <main+0x96>
mov    -0x28(%rbp),%rsi
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
jmp    1196 <main+0x66>
jmp    1166 <main+0x36>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x18(%rsp)
mov    0x2e89(%rip),%r13
mov    0x0(%r13),%edx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1050 <getline@plt>
test   %eax,%eax
js     11cc <main+0x9c>
lea    0x18(%rsp),%rbx
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%r15
lea    0xe74(%rip),%r12
jmp    11a3 <main+0x73>
xchg   %ax,%ax
mov    0x0(%r13),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <getline@plt>
test   %eax,%eax
js     11cc <main+0x9c>
mov    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1040 <trimline@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <trimline@plt>
test   %rax,%rax
je     1190 <main+0x60>
mov    %r12,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
jmp    11b0 <main+0x80>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%8 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%9 = load i32, i32* @stdin
%10 = call i32 @getline(i8** %4, i64* %3, i32 %9)
%11 = icmp sgt i32 %10, -1
br i1 %11, label %16, label %26
12: ; preds = %21, %16
%13 = load i32, i32* @stdin
%14 = call i32 @getline(i8** %4, i64* %3, i32 %13)
%15 = icmp sgt i32 %14, -1
br i1 %15, label %16, label %26
16: ; preds = %2, %12
%17 = load i8*, i8** %4
%18 = call i8* @trimline(i8* %17, i8** %5)
%19 = call i8* @trimline(i8* null, i8** %5)
%20 = icmp eq i8* %19, null
br i1 %20, label %12, label %21
21: ; preds = %16, %21
%22 = phi i8* [ %24, %21 ], [ %19, %16 ]
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i8* @trimline(i8* null, i8** %5)
%25 = icmp eq i8* %24, null
br i1 %25, label %12, label %21
26: ; preds = %12, %2
ret i32 0
}