#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*/ assert(int (*)(int));
int stub1(int);
char *remove_char(char *s, int (*tstchar)(int)) {
  char *ret = s;
  char *d = s;
  assert(s != NULL);
  assert(tstchar);
  for (; *s; s++)
    if (!(*tstchar)(*s))
      *d++ = *s;
  *d = '\0';
  return (ret);
}


x86 assembly (clang, -O0):
<remove_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
movslq %eax,%rdi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     119e <remove_char+0x8e>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
movsbl (%rcx),%edi
call   *%rax
cmp    $0x0,%eax
jne    1188 <remove_char+0x78>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    118d <remove_char+0x7d>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    114e <remove_char+0x3e>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_char>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1030 <assert@plt>
mov    %r15,%rdi
call   1030 <assert@plt>
mov    (%r14),%al
mov    %r14,%r12
test   %al,%al
je     1173 <remove_char+0x63>
lea    0x1(%r14),%rbx
mov    %r14,%r12
jmp    115b <remove_char+0x4b>
nopw   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1173 <remove_char+0x63>
movsbl %al,%edi
call   *%r15
test   %eax,%eax
jne    1150 <remove_char+0x40>
movzbl -0x1(%rbx),%eax
mov    %al,(%r12)
add    $0x1,%r12
jmp    1150 <remove_char+0x40>
movb   $0x0,(%r12)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @remove_char(i8* %0, i32 (i32)* %1) {
%3 = alloca i8*
%4 = alloca i32 (i32)*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i32 (i32)* %1, i32 (i32)** %4
%7 = load i8*, i8** %3
store i8* %7, i8** %5
%8 = load i8*, i8** %3
store i8* %8, i8** %6
%9 = load i8*, i8** %3
%10 = icmp ne i8* %9, null
%11 = zext i1 %10 to i32
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i32 (i32)*
%14 = call i32 @assert(i32 (i32)* %13)
%15 = load i32 (i32)*, i32 (i32)** %4
%16 = call i32 @assert(i32 (i32)* %15)
br label %17
17: ; preds = %34, %2
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
br i1 %20, label %21, label %37
21: ; preds = %17
%22 = load i32 (i32)*, i32 (i32)** %4
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i32 %22(i32 %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %21
%29 = load i8*, i8** %3
%30 = load i8, i8* %29
%31 = load i8*, i8** %6
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %6
store i8 %30, i8* %31
br label %33
33: ; preds = %28, %21
br label %34
34: ; preds = %33
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %3
br label %17
37: ; preds = %17
%38 = load i8*, i8** %6
store i8 0, i8* %38
%39 = load i8*, i8** %5
ret i8* %39
}

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