#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*/ *strchr(char const *, char);
size_t strlen(char *);
char *ne_shave(char *str, const char *whitespace) {
  char *pnt, *ret = str;
  while (*ret != '\0' && strchr(whitespace, *ret) != NULL) {
    ret++;
  }
  pnt = &ret[strlen(ret)];
  while (pnt > ret && strchr(whitespace, *(pnt - 1)) != NULL) {
    pnt--;
  }
  *pnt = '\0';
  return ret;
}


x86 assembly (clang, -O0):
<ne_shave>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21(%rbp)
je     1167 <ne_shave+0x47>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
movsbl (%rax),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1177 <ne_shave+0x57>
jmp    1188 <ne_shave+0x68>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1138 <ne_shave+0x18>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    -0x20(%rbp),%rcx
mov    %al,-0x31(%rbp)
jbe    11d5 <ne_shave+0xb5>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movsbl -0x1(%rax),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11e5 <ne_shave+0xc5>
jmp    11f6 <ne_shave+0xd6>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    11a7 <ne_shave+0x87>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ne_shave>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%al
test   %al,%al
je     115d <ne_shave+0x3d>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%esi
mov    %r14,%rdi
call   1040 <strchr@plt>
test   %rax,%rax
je     115d <ne_shave+0x3d>
movzbl 0x1(%r15),%eax
add    $0x1,%r15
test   %al,%al
jne    1140 <ne_shave+0x20>
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %rax,%r12
add    %r15,%r12
nopl   0x0(%rax,%rax,1)
mov    %r12,%rbx
cmp    %r15,%r12
jbe    118d <ne_shave+0x6d>
lea    -0x1(%rbx),%r12
movsbl -0x1(%rbx),%esi
mov    %r14,%rdi
call   1040 <strchr@plt>
test   %rax,%rax
jne    1170 <ne_shave+0x50>
movb   $0x0,(%rbx)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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