#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 *, int, char *);
main() {
  int len;
  char line[1000];
  while ((len = getline(line, 1000)) > 0) {
    while (line[len - 1] == '\n' || line[len - 1] == ' ' ||
           line[len - 1] == '\t') {
      len--;
    }
    if (line[len] != '\0') {
      line[len] = '\n';
      line[len + 1] = '\0';
    }
    if (len > 0)
      printf("%3d %s", len, 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    1229 <main+0x109>
jmp    1154 <main+0x34>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x3f0(%rbp,%rax,1),%ecx
ff
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x3f1(%rbp)
je     11b2 <main+0x92>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x3f0(%rbp,%rax,1),%ecx
ff
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x3f1(%rbp)
je     11b2 <main+0x92>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x9,%eax
sete   %al
mov    %al,-0x3f1(%rbp)
mov    -0x3f1(%rbp),%al
test   $0x1,%al
jne    11c5 <main+0xa5>
jmp    11d3 <main+0xb3>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x34>
movslq -0x8(%rbp),%rax
movsbl -0x3f0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     1204 <main+0xe4>
movslq -0x8(%rbp),%rax
movb   $0xa,-0x3f0(%rbp,%rax,1)
0a
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x3f0(%rbp,%rax,1)
cmpl   $0x0,-0x8(%rbp)
jle    1224 <main+0x104>
mov    -0x8(%rbp),%esi
lea    -0x3f0(%rbp),%rdx
lea    0xde1(%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   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3f0,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1040 <getline@plt>
test   %eax,%eax
jle    11dd <main+0xbd>
lea    0xeb4(%rip),%r14
mov    %rsp,%r12
movabs $0x100000000,%r15
movabs $0x100000600,%r13
movabs $0xffffffff00000000,%rbx
ff ff ff
jmp    1181 <main+0x61>
nop
mov    %r12,%rdi
mov    $0x3e8,%esi
call   1040 <getline@plt>
test   %eax,%eax
jle    11dd <main+0xbd>
mov    %eax,%esi
mov    %rsi,%rax
shl    $0x20,%rax
nopw   0x0(%rax,%rax,1)
movzbl -0x1(%rsp,%rsi,1),%ecx
cmp    $0x20,%rcx
ja     11b0 <main+0x90>
bt     %rcx,%r13
jae    11b0 <main+0x90>
add    %rbx,%rax
add    $0xffffffffffffffff,%rsi
jmp    1190 <main+0x70>
nopw   0x0(%rax,%rax,1)
mov    %rax,%rcx
sar    $0x20,%rcx
cmpb   $0x0,(%rsp,%rcx,1)
je     11cc <main+0xac>
movb   $0xa,(%rsp,%rcx,1)
add    %r15,%rax
sar    $0x20,%rax
movb   $0x0,(%rsp,%rax,1)
test   %esi,%esi
jle    1170 <main+0x50>
mov    %r14,%rdi
mov    %r12,%rdx
call   1030 <printf@plt>
jmp    1170 <main+0x50>
xor    %eax,%eax
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%3d %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [1000 x i8]
store i32 0, i32* %1
br label %4
4: ; preds = %60, %0
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%6 = call i32 @getline(i8* %5, i32 1000)
store i32 %6, i32* %2
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %61
8: ; preds = %4
br label %9
9: ; preds = %35, %8
%10 = load i32, i32* %2
%11 = sub nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 10
br i1 %16, label %33, label %17
17: ; preds = %9
%18 = load i32, i32* %2
%19 = sub nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 32
br i1 %24, label %33, label %25
25: ; preds = %17
%26 = load i32, i32* %2
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 9
br label %33
33: ; preds = %25, %17, %9
%34 = phi i1 [ true, %17 ], [ true, %9 ], [ %32, %25 ]
br i1 %34, label %35, label %38
35: ; preds = %33
%36 = load i32, i32* %2
%37 = add nsw i32 %36, -1
store i32 %37, i32* %2
br label %9
38: ; preds = %33
%39 = load i32, i32* %2
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %53
45: ; preds = %38
%46 = load i32, i32* %2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %47
store i8 10, i8* %48
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %51
store i8 0, i8* %52
br label %53
53: ; preds = %45, %38
%54 = load i32, i32* %2
%55 = icmp sgt i32 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %53
%57 = load i32, i32* %2
%58 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%59 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %57, i8* %58)
br label %60
60: ; preds = %56, %53
br label %4
61: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"%3d %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 %33
5: ; preds = %0, %30
%6 = phi i32 [ %31, %30 ], [ %3, %0 ]
%7 = zext i32 %6 to i64
br label %8
8: ; preds = %13, %5
%9 = phi i64 [ %7, %5 ], [ %10, %13 ]
%10 = add nsw i64 %9, -1
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %14 [
i8 10, label %13
i8 32, label %13
i8 9, label %13
]
13: ; preds = %8, %8, %8
br label %8
14: ; preds = %8
%15 = trunc i64 %9 to i32
%16 = shl i64 %9, 32
%17 = ashr exact i64 %16, 32
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %14
store i8 10, i8* %18
%22 = shl i64 %9, 32
%23 = add i64 %22, 4294967296
%24 = ashr exact i64 %23, 32
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %24
store i8 0, i8* %25
br label %26
26: ; preds = %21, %14
%27 = icmp sgt i32 %15, 0
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %15, i8* %2)
br label %30
30: ; preds = %28, %26
%31 = call i32 @getline(i8* %2, i32 1000)
%32 = icmp sgt i32 %31, 0
br i1 %32, label %5, label %33
33: ; preds = %30, %0
ret i32 0
}