#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);
const char *__filter(const char *nptr) {
  char c;
  do {
    c = *(nptr++);
  } while (c == '\0' || isspace(c));
  if (!c == '\0' && !isspace(c))
    --nptr;
  return nptr;
}


x86 assembly (clang, -O0):
<__filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0xa(%rbp)
je     1155 <__filter+0x45>
movsbl -0x9(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    111c <__filter+0xc>
cmpb   $0x0,-0x9(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    1196 <__filter+0x86>
movsbl -0x9(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
jne    1196 <__filter+0x86>
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__filter>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rbx
add    $0x1,%r14
movzbl (%rbx),%eax
test   %al,%al
je     1120 <__filter+0x10>
movsbl %al,%ebp
mov    %ebp,%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    1120 <__filter+0x10>
mov    %ebp,%edi
call   1030 <isspace@plt>
lea    0x1(%rbx),%rcx
test   %rax,%rax
cmove  %rbx,%rcx
mov    %rcx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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