#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 */
typedef int /*<<< orphan*/ str;

/* Variables and functions */
scalar_t__ malloc(int);
scalar_t__ zChrSearch(char *, char, int);
char *zStrrmv(char *str, char *newstr, char *bad, int len) {
  if (!newstr)
    newstr = (char *)malloc(sizeof(str) * sizeof(char));
  char *src = str;
  newstr = str;
  while (*src)
    if (zChrSearch(bad, *src, len))
      *src++;
    else
      *newstr++ = *src++;
  newstr[len] = '\0';
}


x86 assembly (clang, -O0):
<zStrrmv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1150 <zStrrmv+0x30>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c4 <zStrrmv+0xa4>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    (%rax),%al
mov    -0x24(%rbp),%edx
movsbl %al,%esi
call   1030 <zChrSearch@plt>
cmp    $0x0,%rax
je     119d <zStrrmv+0x7d>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11bf <zStrrmv+0x9f>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1160 <zStrrmv+0x40>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zStrrmv>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rdi,%rbx
test   %rsi,%rsi
jne    113f <zStrrmv+0x1f>
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    (%rbx),%al
test   %al,%al
je     117b <zStrrmv+0x5b>
lea    0x1(%rbx),%rbp
jmp    115c <zStrrmv+0x3c>
nopl   0x0(%rax,%rax,1)
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
je     117b <zStrrmv+0x5b>
movsbl %al,%esi
mov    %r15,%rdi
mov    %r14d,%edx
call   1030 <zChrSearch@plt>
test   %rax,%rax
jne    1150 <zStrrmv+0x30>
movzbl -0x1(%rbp),%eax
mov    %al,(%rbx)
add    $0x1,%rbx
jmp    1150 <zStrrmv+0x30>
movslq %r14d,%rax
movb   $0x0,(%rbx,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define noalias i8* @zStrrmv(i8* nocapture %0, i8* readnone %1, i8* %2, i32 %3) {
%5 = icmp eq i8* %1, null
br i1 %5, label %6, label %8
6: ; preds = %4
%7 = tail call i64 @malloc(i32 8)
br label %8
8: ; preds = %6, %4
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 0
br i1 %10, label %25, label %11
11: ; preds = %8, %20
%12 = phi i8 [ %23, %20 ], [ %9, %8 ]
%13 = phi i8* [ %22, %20 ], [ %0, %8 ]
%14 = phi i8* [ %21, %20 ], [ %0, %8 ]
%15 = tail call i64 @zChrSearch(i8* %2, i8 signext %12, i32 %3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i8, i8* %13
%19 = getelementptr inbounds i8, i8* %14, i64 1
store i8 %18, i8* %14
br label %20
20: ; preds = %11, %17
%21 = phi i8* [ %19, %17 ], [ %14, %11 ]
%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 %11
25: ; preds = %20, %8
%26 = phi i8* [ %0, %8 ], [ %21, %20 ]
%27 = sext i32 %3 to i64
%28 = getelementptr inbounds i8, i8* %26, i64 %27
store i8 0, i8* %28
ret i8* undef
}