#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 *StripLeadingAndTrailingSpaces(char *oneline) {
  char *t;
  if (!oneline || !*oneline) {
    return oneline;
  }
  t = oneline;
  t += strlen(oneline) - 1;
  while ((*t == ' ' || *t == '\t' || *t == '\n' || *t == '\r') &&
         t != oneline) {
    *t-- = 0;
  }
  t = oneline;
  while ((*t == ' ' || *t == '\t') && *t != 0) {
    t++;
  }
  return t;
}


x86 assembly (clang, -O0):
<StripLeadingAndTrailingSpaces>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1134 <StripLeadingAndTrailingSpaces+0x24>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1141 <StripLeadingAndTrailingSpaces+0x31>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1245 <StripLeadingAndTrailingSpaces+0x135>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
sub    $0x1,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     11aa <StripLeadingAndTrailingSpaces+0x9a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
je     11aa <StripLeadingAndTrailingSpaces+0x9a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     11aa <StripLeadingAndTrailingSpaces+0x9a>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xd,%ecx
mov    %al,-0x19(%rbp)
jne    11b8 <StripLeadingAndTrailingSpaces+0xa8>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11c8 <StripLeadingAndTrailingSpaces+0xb8>
jmp    11df <StripLeadingAndTrailingSpaces+0xcf>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x0,(%rax)
jmp    1165 <StripLeadingAndTrailingSpaces+0x55>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     120c <StripLeadingAndTrailingSpaces+0xfc>
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x9,%ecx
mov    %al,-0x1a(%rbp)
jne    121c <StripLeadingAndTrailingSpaces+0x10c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    122c <StripLeadingAndTrailingSpaces+0x11c>
jmp    123d <StripLeadingAndTrailingSpaces+0x12d>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11e7 <StripLeadingAndTrailingSpaces+0xd7>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StripLeadingAndTrailingSpaces>:
push   %rbx
test   %rdi,%rdi
je     1171 <StripLeadingAndTrailingSpaces+0x61>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1173 <StripLeadingAndTrailingSpaces+0x63>
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    $0xffffffff,%eax
cltq
movabs $0x100002600,%rcx
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx,%rax,1),%edx
cmp    $0x20,%rdx
ja     1164 <StripLeadingAndTrailingSpaces+0x54>
bt     %rdx,%rcx
jae    1164 <StripLeadingAndTrailingSpaces+0x54>
test   %rax,%rax
je     1164 <StripLeadingAndTrailingSpaces+0x54>
movb   $0x0,(%rbx,%rax,1)
add    $0xffffffffffffffff,%rax
jmp    1140 <StripLeadingAndTrailingSpaces+0x30>
nop
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x20,%al
je     1160 <StripLeadingAndTrailingSpaces+0x50>
cmp    $0x9,%al
je     1160 <StripLeadingAndTrailingSpaces+0x50>
jmp    1173 <StripLeadingAndTrailingSpaces+0x63>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

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

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