#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 strlen(char *);
char *trim(char line[50]) {
  int index, change = 0;
  static char new_line[50];
  for (index = 0; index < strlen(line); index++) {
    if (line[index] != '\t' && line[index] != ' ') {
      new_line[index] = line[index];
      change = 1;
    }
  }
  if (change) {
    new_line[strlen(new_line) + 1] = '\0';
    return new_line;
  } else {
    return "";
  }
}


x86 assembly (clang, -O0):
<trim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11a3 <trim+0x93>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
je     1190 <trim+0x80>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
je     1190 <trim+0x80>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
movslq -0x14(%rbp),%rcx
lea    0x2eba(%rip),%rax
mov    %dl,(%rax,%rcx,1)
movl   $0x1,-0x18(%rbp)
jmp    1195 <trim+0x85>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112a <trim+0x1a>
cmpl   $0x0,-0x18(%rbp)
je     11da <trim+0xca>
lea    0x2e8c(%rip),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2e7a(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e6f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e5 <trim+0xd5>
lea    0xe1f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trim>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r12
call   1030 <strlen@plt>
lea    0xed9(%rip),%r14
test   %eax,%eax
jle    1182 <trim+0x72>
xor    %ebx,%ebx
lea    0x2f0c(%rip),%r15
xor    %ebp,%ebp
jmp    1153 <trim+0x43>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r12,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    116b <trim+0x5b>
movzbl (%r12,%rbx,1),%eax
cmp    $0x9,%al
je     1140 <trim+0x30>
cmp    $0x20,%al
je     1140 <trim+0x30>
mov    %al,(%rbx,%r15,1)
mov    $0x1,%ebp
jmp    1140 <trim+0x30>
test   %ebp,%ebp
je     1182 <trim+0x72>
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,0x1(%rax,%r15,1)
mov    %r15,%r14
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@trim.new_line = internal global [50 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
define i8* @trim(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %5
store i32 0, i32* %4
br label %6
6: ; preds = %37, %1
%7 = load i32, i32* %4
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %40
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 9
br i1 %18, label %19, label %36
19: ; preds = %11
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 32
br i1 %26, label %27, label %36
27: ; preds = %19
%28 = load i8*, i8** %3
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [50 x i8], [50 x i8]* @trim.new_line, i64 0, i64 %34
store i8 %32, i8* %35
store i32 1, i32* %5
br label %36
36: ; preds = %27, %19, %11
br label %37
37: ; preds = %36
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %6
40: ; preds = %6
%41 = load i32, i32* %5
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %40
%44 = call i32 @strlen(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @trim.new_line, i64 0, i64 0))
%45 = add nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [50 x i8], [50 x i8]* @trim.new_line, i64 0, i64 %46
store i8 0, i8* %47
store i8* getelementptr inbounds ([50 x i8], [50 x i8]* @trim.new_line, i64 0, i64 0), i8** %2
br label %49
48: ; preds = %40
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %2
br label %49
49: ; preds = %48, %43
%50 = load i8*, i8** %2
ret i8* %50
}

LLVM IR (-O2):
@trim.new_line = internal global [50 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
define i8* @trim(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %24
4: ; preds = %1, %11
%5 = phi i64 [ %13, %11 ], [ 0, %1 ]
%6 = phi i32 [ %12, %11 ], [ 0, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %5
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 9, label %11
i8 32, label %11
]
9: ; preds = %4
%10 = getelementptr inbounds [50 x i8], [50 x i8]* @trim.new_line, i64 0, i64 %5
store i8 %8, i8* %10
br label %11
11: ; preds = %4, %4, %9
%12 = phi i32 [ 1, %9 ], [ %6, %4 ], [ %6, %4 ]
%13 = add nuw nsw i64 %5, 1
%14 = tail call i32 @strlen(i8* %0)
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %13, %15
br i1 %16, label %4, label %17
17: ; preds = %11
%18 = icmp eq i32 %12, 0
br i1 %18, label %24, label %19
19: ; preds = %17
%20 = tail call i32 @strlen(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @trim.new_line, i64 0, i64 0))
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [50 x i8], [50 x i8]* @trim.new_line, i64 0, i64 %22
store i8 0, i8* %23
br label %24
24: ; preds = %1, %17, %19
%25 = phi i8* [ getelementptr inbounds ([50 x i8], [50 x i8]* @trim.new_line, i64 0, i64 0), %19 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %17 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %25
}