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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x3f0(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <getline@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11f4 <main+0xd4>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x3f4(%rbp)
cmpl   $0x0,-0x3f4(%rbp)
jl     11dc <main+0xbc>
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
je     11c3 <main+0xa3>
movslq -0x3f4(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x9,%eax
je     11c3 <main+0xa3>
mov    -0x3f4(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0xa,-0x3f0(%rbp,%rax,1)
0a
mov    -0x3f4(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x0,-0x3f0(%rbp,%rax,1)
jmp    11dc <main+0xbc>
jmp    11c8 <main+0xa8>
mov    -0x3f4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3f4(%rbp)
jmp    115b <main+0x3b>
lea    -0x3f0(%rbp),%rsi
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
jmp    1132 <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   1040 <getline@plt>
test   %eax,%eax
jle    11a4 <main+0x84>
lea    0xebe(%rip),%r14
mov    %rsp,%rbx
jmp    116c <main+0x4c>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1040 <getline@plt>
test   %eax,%eax
jle    11a4 <main+0x84>
cmp    $0x2,%eax
jb     1150 <main+0x30>
add    $0xfffffffe,%eax
add    $0x1,%rax
jmp    1186 <main+0x66>
nopw   0x0(%rax,%rax,1)
add    $0xffffffffffffffff,%rax
jle    1150 <main+0x30>
movzbl -0x1(%rsp,%rax,1),%ecx
cmp    $0x9,%cl
je     1180 <main+0x60>
cmp    $0x20,%cl
je     1180 <main+0x60>
mov    %eax,%ecx
movb   $0xa,(%rsp,%rcx,1)
add    $0x1,%eax
movb   $0x0,(%rsp,%rax,1)
jmp    1150 <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]
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %42, %0
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%7 = call i32 @getline(i8* %6, i32 1000)
store i32 %7, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %45
9: ; preds = %5
%10 = load i32, i32* %2
%11 = sub nsw i32 %10, 2
store i32 %11, i32* %4
br label %12
12: ; preds = %39, %9
%13 = load i32, i32* %4
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %42
15: ; preds = %12
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 32
br i1 %21, label %22, label %38
22: ; preds = %15
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 9
br i1 %28, label %29, label %38
29: ; preds = %22
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %32
store i8 10, i8* %33
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %36
store i8 0, i8* %37
br label %42
38: ; preds = %22, %15
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, -1
store i32 %41, i32* %4
br label %12
42: ; preds = %29, %12
%43 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%44 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %43)
br label %5
45: ; 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 %29
5: ; preds = %0, %25
%6 = phi i32 [ %27, %25 ], [ %3, %0 ]
%7 = icmp ugt i32 %6, 1
br i1 %7, label %8, label %25
8: ; preds = %5
%9 = add nsw i32 %6, -2
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %8, %22
%12 = phi i64 [ %10, %8 ], [ %23, %22 ]
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
switch i8 %14, label %15 [
i8 32, label %22
i8 9, label %22
]
15: ; preds = %11
%16 = add nuw nsw i64 %12, 1
%17 = and i64 %16, 4294967295
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %17
store i8 10, i8* %18
%19 = add nuw i64 %12, 2
%20 = and i64 %19, 4294967295
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %20
store i8 0, i8* %21
br label %25
22: ; preds = %11, %11
%23 = add nsw i64 %12, -1
%24 = icmp sgt i64 %12, 0
br i1 %24, label %11, label %25
25: ; preds = %22, %5, %15
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%27 = call i32 @getline(i8* %2, i32 1000)
%28 = icmp sgt i32 %27, 0
br i1 %28, label %5, label %29
29: ; preds = %25, %0
ret i32 0
}