#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 *);
main() {
  int i;
  int len;
  char line[10];
  while ((len = getline(line, 10)) > 0) {
    i = len - 1;
    while (i >= 0 && (line[i] == ' ' || line[i] == '\t' || line[i] == '\n'))
      --i;
    ++i;
    if (i > 0) {
      if (line[len - 1] == '\n') {
        line[i] = '\n';
        ++i;
      }
      line[i] = '\0';
      printf("%s", line);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x16(%rbp),%rdi
mov    $0xa,%esi
call   1040 <getline@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jle    121e <main+0xfe>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x17(%rbp)
jl     11a7 <main+0x87>
movslq -0x8(%rbp),%rax
movsbl -0x16(%rbp,%rax,1),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x18(%rbp)
je     11a1 <main+0x81>
movslq -0x8(%rbp),%rax
movsbl -0x16(%rbp,%rax,1),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x18(%rbp)
je     11a1 <main+0x81>
movslq -0x8(%rbp),%rax
movsbl -0x16(%rbp,%rax,1),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x18(%rbp)
mov    -0x18(%rbp),%al
mov    %al,-0x17(%rbp)
mov    -0x17(%rbp),%al
test   $0x1,%al
jne    11b7 <main+0x97>
jmp    11c5 <main+0xa5>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1152 <main+0x32>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1219 <main+0xf9>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x16(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    1200 <main+0xe0>
movslq -0x8(%rbp),%rax
movb   $0xa,-0x16(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movb   $0x0,-0x16(%rbp,%rax,1)
lea    -0x16(%rbp),%rsi
lea    0xdec(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0x6(%rsp),%rdi
mov    $0xa,%esi
call   1040 <getline@plt>
test   %eax,%eax
jle    11c3 <main+0xa3>
lea    0xeb9(%rip),%r14
lea    0x6(%rsp),%r15
movabs $0x100000600,%rbx
jmp    1183 <main+0x63>
nopl   0x0(%rax,%rax,1)
mov    %ecx,%eax
movb   $0x0,0x6(%rsp,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    $0xa,%esi
call   1040 <getline@plt>
test   %eax,%eax
jle    11c3 <main+0xa3>
add    $0xffffffff,%eax
lea    0x1(%rax),%rcx
nopw   0x0(%rax,%rax,1)
movzbl 0x5(%rsp,%rcx,1),%edx
cmp    $0x20,%rdx
ja     11b0 <main+0x90>
bt     %rdx,%rbx
jae    11b0 <main+0x90>
add    $0xffffffffffffffff,%rcx
jg     1190 <main+0x70>
jmp    1172 <main+0x52>
nopl   0x0(%rax)
cmpb   $0xa,0x6(%rsp,%rax,1)
jne    1160 <main+0x40>
mov    %ecx,%eax
movb   $0xa,0x6(%rsp,%rax,1)
add    $0x1,%ecx
jmp    1160 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
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 [10 x i8]
store i32 0, i32* %1
br label %5
5: ; preds = %68, %0
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%7 = call i32 @getline(i8* %6, i32 10)
store i32 %7, i32* %3
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %69
9: ; preds = %5
%10 = load i32, i32* %3
%11 = sub nsw i32 %10, 1
store i32 %11, i32* %2
br label %12
12: ; preds = %40, %9
%13 = load i32, i32* %2
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %38
15: ; preds = %12
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 32
br i1 %21, label %36, label %22
22: ; preds = %15
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 9
br i1 %28, label %36, label %29
29: ; preds = %22
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 10
br label %36
36: ; preds = %29, %22, %15
%37 = phi i1 [ true, %22 ], [ true, %15 ], [ %35, %29 ]
br label %38
38: ; preds = %36, %12
%39 = phi i1 [ false, %12 ], [ %37, %36 ]
br i1 %39, label %40, label %43
40: ; preds = %38
%41 = load i32, i32* %2
%42 = add nsw i32 %41, -1
store i32 %42, i32* %2
br label %12
43: ; preds = %38
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
%46 = load i32, i32* %2
%47 = icmp sgt i32 %46, 0
br i1 %47, label %48, label %68
48: ; preds = %43
%49 = load i32, i32* %3
%50 = sub nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 10
br i1 %55, label %56, label %62
56: ; preds = %48
%57 = load i32, i32* %2
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %58
store i8 10, i8* %59
%60 = load i32, i32* %2
%61 = add nsw i32 %60, 1
store i32 %61, i32* %2
br label %62
62: ; preds = %56, %48
%63 = load i32, i32* %2
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %64
store i8 0, i8* %65
%66 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%67 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %66)
br label %68
68: ; preds = %62, %43
br label %5
69: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = call i32 @getline(i8* %2, i32 10)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %34
5: ; preds = %0, %31
%6 = phi i32 [ %32, %31 ], [ %3, %0 ]
%7 = add nsw i32 %6, -1
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %5, %13
%10 = phi i64 [ %8, %5 ], [ %14, %13 ]
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %16 [
i8 32, label %13
i8 9, label %13
i8 10, label %13
]
13: ; preds = %9, %9, %9
%14 = add nsw i64 %10, -1
%15 = icmp sgt i64 %10, 0
br i1 %15, label %9, label %31
16: ; preds = %9
%17 = trunc i64 %10 to i32
%18 = add nuw nsw i32 %17, 1
%19 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %8
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 10
br i1 %21, label %22, label %26
22: ; preds = %16
%23 = zext i32 %18 to i64
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %23
store i8 10, i8* %24
%25 = add nuw nsw i32 %17, 2
br label %26
26: ; preds = %22, %16
%27 = phi i32 [ %25, %22 ], [ %18, %16 ]
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 %28
store i8 0, i8* %29
%30 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %31
31: ; preds = %13, %26
%32 = call i32 @getline(i8* %2, i32 10)
%33 = icmp sgt i32 %32, 0
br i1 %33, label %5, label %34
34: ; preds = %31, %0
ret i32 0
}