#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);
int /*<<< orphan*/ strcpy(char *, char *);
void trim(char *c) {
  char buf[1024];
  char *start, *end;
  strcpy(buf, c);
  start = buf;
  while (isspace(*start))
    start++;
  end = start;
  while (!isspace(*end))
    end++;
  *end = '\0';
  strcpy(c, start);
}


x86 assembly (clang, -O0):
<trim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
mov    -0x418(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     117d <trim+0x5d>
mov    -0x418(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x418(%rbp)
jmp    114d <trim+0x2d>
mov    -0x418(%rbp),%rax
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b0 <trim+0x90>
jmp    11c7 <trim+0xa7>
mov    -0x420(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x420(%rbp)
jmp    118b <trim+0x6b>
mov    -0x420(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x418(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trim>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rdi,%r14
mov    %rsp,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    -0x1(%rsp),%r15
nop
movsbl 0x1(%r15),%edi
add    $0x1,%r15
call   1040 <isspace@plt>
test   %rax,%rax
jne    1140 <trim+0x20>
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
movsbl (%rbx),%edi
call   1040 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
je     1160 <trim+0x40>
movb   $0x0,-0x1(%rbx)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @trim(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %2
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = call i32 @strcpy(i8* %6, i8* %7)
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
store i8* %9, i8** %4
br label %10
10: ; preds = %15, %1
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = call i64 @isspace(i8 signext %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %4
br label %10
18: ; preds = %10
%19 = load i8*, i8** %4
store i8* %19, i8** %5
br label %20
20: ; preds = %26, %18
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = call i64 @isspace(i8 signext %22)
%24 = icmp ne i64 %23, 0
%25 = xor i1 %24, true
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %5
br label %20
29: ; preds = %20
%30 = load i8*, i8** %5
store i8 0, i8* %30
%31 = load i8*, i8** %2
%32 = load i8*, i8** %4
%33 = call i32 @strcpy(i8* %31, i8* %32)
ret void
}

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