#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 /*<<< orphan*/ reverse_line(char *, int);
void trim_line(char line[]) {
  int i = 0;
  if (line[1] == '\0')
    return;
  reverse_line(line, 1000);
  while (line[i] == ' ' || line[i] == '\t' || line[i] == '\n' ||
         line[i] == '\0') {
    line[i] = '\0';
    i++;
  }
  i--;
  line[i] = '\n';
  i--;
  line[i] = '\0';
  reverse_line(line, 1000);
  return;
}


x86 assembly (clang, -O0):
<trim_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    1139 <trim_line+0x29>
jmp    120c <trim_line+0xfc>
mov    -0x8(%rbp),%rdi
mov    $0x3e8,%esi
call   1030 <reverse_line@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0xd(%rbp)
je     11aa <trim_line+0x9a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0xd(%rbp)
je     11aa <trim_line+0x9a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0xd(%rbp)
je     11aa <trim_line+0x9a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    11ba <trim_line+0xaa>
jmp    11d4 <trim_line+0xc4>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1147 <trim_line+0x37>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0xa,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
mov    $0x3e8,%esi
call   1030 <reverse_line@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trim_line>:
push   %r14
push   %rbx
push   %rax
cmpb   $0x0,0x1(%rdi)
je     11a4 <trim_line+0x94>
mov    %rdi,%r14
movabs $0x100000000,%rbx
mov    $0x3e8,%esi
call   1030 <reverse_line@plt>
movabs $0xfffffffe00000000,%rax
ff ff ff
movabs $0xffffffff00000000,%rcx
ff ff ff
movabs $0x100000601,%rdx
mov    %r14,%rsi
cs nopw 0x0(%rax,%rax,1)
movzbl (%rsi),%edi
cmp    $0x20,%rdi
ja     117e <trim_line+0x6e>
bt     %rdi,%rdx
jae    117e <trim_line+0x6e>
movb   $0x0,(%rsi)
add    %rbx,%rax
add    %rbx,%rcx
add    $0x1,%rsi
jmp    1160 <trim_line+0x50>
sar    $0x20,%rcx
movb   $0xa,(%r14,%rcx,1)
sar    $0x20,%rax
movb   $0x0,(%r14,%rax,1)
mov    %r14,%rdi
mov    $0x3e8,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <reverse_line@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @trim_line(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 1
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
br label %69
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i32 @reverse_line(i8* %11, i32 1000)
br label %13
13: ; preds = %47, %10
%14 = load i8*, i8** %2
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 32
br i1 %20, label %45, label %21
21: ; preds = %13
%22 = load i8*, i8** %2
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 9
br i1 %28, label %45, label %29
29: ; preds = %21
%30 = load i8*, i8** %2
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 10
br i1 %36, label %45, label %37
37: ; preds = %29
%38 = load i8*, i8** %2
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 0
br label %45
45: ; preds = %37, %29, %21, %13
%46 = phi i1 [ true, %29 ], [ true, %21 ], [ true, %13 ], [ %44, %37 ]
br i1 %46, label %47, label %54
47: ; preds = %45
%48 = load i8*, i8** %2
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
store i8 0, i8* %51
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 1
store i32 %53, i32* %3
br label %13
54: ; preds = %45
%55 = load i32, i32* %3
%56 = add nsw i32 %55, -1
store i32 %56, i32* %3
%57 = load i8*, i8** %2
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
store i8 10, i8* %60
%61 = load i32, i32* %3
%62 = add nsw i32 %61, -1
store i32 %62, i32* %3
%63 = load i8*, i8** %2
%64 = load i32, i32* %3
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
store i8 0, i8* %66
%67 = load i8*, i8** %2
%68 = call i32 @reverse_line(i8* %67, i32 1000)
br label %69
69: ; preds = %54, %9
ret void
}

LLVM IR (-O2):
define void @trim_line(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
%3 = load i8, i8* %2
%4 = icmp eq i8 %3, 0
br i1 %4, label %23, label %5
5: ; preds = %1
%6 = tail call i32 @reverse_line(i8* %0, i32 1000)
br label %7
7: ; preds = %11, %5
%8 = phi i64 [ %12, %11 ], [ 0, %5 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
switch i8 %10, label %13 [
i8 32, label %11
i8 9, label %11
i8 10, label %11
i8 0, label %11
]
11: ; preds = %7, %7, %7, %7
store i8 0, i8* %9
%12 = add nuw i64 %8, 1
br label %7
13: ; preds = %7
%14 = shl i64 %8, 32
%15 = add i64 %14, -4294967296
%16 = ashr exact i64 %15, 32
%17 = getelementptr inbounds i8, i8* %0, i64 %16
store i8 10, i8* %17
%18 = shl i64 %8, 32
%19 = add i64 %18, -8589934592
%20 = ashr exact i64 %19, 32
%21 = getelementptr inbounds i8, i8* %0, i64 %20
store i8 0, i8* %21
%22 = tail call i32 @reverse_line(i8* %0, i32 1000)
br label %23
23: ; preds = %1, %13
ret void
}