#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__ zstring_search_chr(char const *, char);
char *zstring_remove_chr(char *str, const char *bad) {
  char *src = str, *dst = str;
  while (*src)
    if (zstring_search_chr(bad, *src))
      src++;
    else
      *dst++ = *src++;
  *dst = '\0';
  return str;
}


x86 assembly (clang, -O0):
<zstring_remove_chr>:
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)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     118f <zstring_remove_chr+0x7f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
call   1030 <zstring_search_chr@plt>
cmp    $0x0,%rax
je     1168 <zstring_remove_chr+0x58>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    118a <zstring_remove_chr+0x7a>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    1130 <zstring_remove_chr+0x20>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zstring_remove_chr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%al
mov    %rdi,%r12
test   %al,%al
je     1159 <zstring_remove_chr+0x49>
mov    %rsi,%r15
lea    0x1(%r14),%rbx
mov    %r14,%r12
jmp    113b <zstring_remove_chr+0x2b>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1159 <zstring_remove_chr+0x49>
movsbl %al,%esi
mov    %r15,%rdi
call   1030 <zstring_search_chr@plt>
test   %rax,%rax
jne    1130 <zstring_remove_chr+0x20>
movzbl -0x1(%rbx),%eax
mov    %al,(%r12)
add    $0x1,%r12
jmp    1130 <zstring_remove_chr+0x20>
movb   $0x0,(%r12)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @zstring_remove_chr(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** %5
%8 = load i8*, i8** %3
store i8* %8, i8** %6
br label %9
9: ; preds = %28, %2
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = call i64 @zstring_search_chr(i8* %14, i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %5
br label %28
22: ; preds = %13
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %5
%25 = load i8, i8* %23
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %6
store i8 %25, i8* %26
br label %28
28: ; preds = %22, %19
br label %9
29: ; preds = %9
%30 = load i8*, i8** %6
store i8 0, i8* %30
%31 = load i8*, i8** %3
ret i8* %31
}

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