#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 */
scalar_t__ isspace(char);
char *strchr(char *, char);
char *globus_l_options_trim(char *ins) {
  char *end;
  while (isspace(*ins)) {
    ins++;
  }
  end = strchr(ins, '\0') - 1;
  while (isspace(*end)) {
    end--;
  }
  end++;
  *end = '\0';
  return ins;
}


x86 assembly (clang, -O0):
<globus_l_options_trim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1153 <globus_l_options_trim+0x33>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112c <globus_l_options_trim+0xc>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1030 <strchr@plt>
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     118d <globus_l_options_trim+0x6d>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1166 <globus_l_options_trim+0x46>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<globus_l_options_trim>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
nopl   0x0(%rax,%rax,1)
movsbl (%r15),%edi
call   1040 <isspace@plt>
add    $0x1,%r15
test   %rax,%rax
jne    1130 <globus_l_options_trim+0x10>
lea    -0x1(%r15),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %rax,%rbx
add    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl -0x2(%rbx),%edi
call   1040 <isspace@plt>
add    $0xffffffffffffffff,%rbx
test   %rax,%rax
jne    1160 <globus_l_options_trim+0x40>
movb   $0x0,(%rbx)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @globus_l_options_trim(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
br label %4
4: ; preds = %9, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = call i64 @isspace(i8 signext %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %4
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %2
br label %4
12: ; preds = %4
%13 = load i8*, i8** %2
%14 = call i8* @strchr(i8* %13, i8 signext 0)
%15 = getelementptr inbounds i8, i8* %14, i64 -1
store i8* %15, i8** %3
br label %16
16: ; preds = %21, %12
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = call i64 @isspace(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i32 -1
store i8* %23, i8** %3
br label %16
24: ; preds = %16
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
%27 = load i8*, i8** %3
store i8 0, i8* %27
%28 = load i8*, i8** %2
ret i8* %28
}

LLVM IR (-O2):
define i8* @globus_l_options_trim(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i8* [ %0, %1 ], [ %7, %2 ]
%4 = load i8, i8* %3
%5 = tail call i64 @isspace(i8 signext %4)
%6 = icmp eq i64 %5, 0
%7 = getelementptr inbounds i8, i8* %3, i64 1
br i1 %6, label %8, label %2
8: ; preds = %2
%9 = tail call i64 @strlen(i8* %3)
%10 = getelementptr i8, i8* %3, i64 %9
br label %11
11: ; preds = %11, %8
%12 = phi i8* [ %10, %8 ], [ %13, %11 ]
%13 = getelementptr inbounds i8, i8* %12, i64 -1
%14 = load i8, i8* %13
%15 = tail call i64 @isspace(i8 signext %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %11
17: ; preds = %11
store i8 0, i8* %12
ret i8* %3
}