#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*/ free(char *);
char *strdup(char *);
int strlen(char *);
char *strrchrs(char *, char *, int);
int remove_from_chrs_r(char **string, char filters_array[], int negate) {
  char *pos = strrchrs(*string, filters_array, negate);
  if (!pos)
    return strlen(*string);
  if (!*pos) {
    *string = strdup("");
    return 0;
  }
  pos++;
  pos = strdup(pos);
  free(*string);
  *string = pos;
  return strlen(*string);
}


x86 assembly (clang, -O0):
<remove_from_chrs_r>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <strrchrs@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1189 <remove_from_chrs_r+0x49>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4(%rbp)
jmp    11f7 <remove_from_chrs_r+0xb7>
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11b8 <remove_from_chrs_r+0x78>
lea    0xe63(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11f7 <remove_from_chrs_r+0xb7>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_from_chrs_r>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
call   1050 <strrchrs@plt>
test   %rax,%rax
je     1178 <remove_from_chrs_r+0x38>
cmpb   $0x0,(%rax)
je     1187 <remove_from_chrs_r+0x47>
add    $0x1,%rax
mov    %rax,%rdi
call   1060 <strdup@plt>
mov    %rax,%r14
mov    (%rbx),%rdi
call   1030 <free@plt>
mov    %r14,(%rbx)
mov    %r14,%rdi
jmp    117b <remove_from_chrs_r+0x3b>
mov    (%rbx),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <strlen@plt>
lea    0xe72(%rip),%rdi
call   1060 <strdup@plt>
mov    %rax,(%rbx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i32 @remove_from_chrs_r(i8** %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8** %0, i8*** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i8**, i8*** %5
%10 = load i8*, i8** %9
%11 = load i8*, i8** %6
%12 = load i32, i32* %7
%13 = call i8* @strrchrs(i8* %10, i8* %11, i32 %12)
store i8* %13, i8** %8
%14 = load i8*, i8** %8
%15 = icmp ne i8* %14, null
br i1 %15, label %20, label %16
16: ; preds = %3
%17 = load i8**, i8*** %5
%18 = load i8*, i8** %17
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %4
br label %40
20: ; preds = %3
%21 = load i8*, i8** %8
%22 = load i8, i8* %21
%23 = icmp ne i8 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = call i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%26 = load i8**, i8*** %5
store i8* %25, i8** %26
store i32 0, i32* %4
br label %40
27: ; preds = %20
%28 = load i8*, i8** %8
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %8
%30 = load i8*, i8** %8
%31 = call i8* @strdup(i8* %30)
store i8* %31, i8** %8
%32 = load i8**, i8*** %5
%33 = load i8*, i8** %32
%34 = call i32 @free(i8* %33)
%35 = load i8*, i8** %8
%36 = load i8**, i8*** %5
store i8* %35, i8** %36
%37 = load i8**, i8*** %5
%38 = load i8*, i8** %37
%39 = call i32 @strlen(i8* %38)
store i32 %39, i32* %4
br label %40
40: ; preds = %27, %24, %16
%41 = load i32, i32* %4
ret i32 %41
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i32 @remove_from_chrs_r(i8** nocapture %0, i8* %1, i32 %2) {
%4 = load i8*, i8** %0
%5 = tail call i8* @strrchrs(i8* %4, i8* %1, i32 %2)
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %3
%8 = load i8*, i8** %0
%9 = tail call i32 @strlen(i8* %8)
br label %21
10: ; preds = %3
%11 = load i8, i8* %5
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call dereferenceable_or_null(1) i8* @strdup(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %0
br label %21
15: ; preds = %10
%16 = getelementptr inbounds i8, i8* %5, i64 1
%17 = tail call i8* @strdup(i8* %16)
%18 = load i8*, i8** %0
%19 = tail call i32 @free(i8* %18)
store i8* %17, i8** %0
%20 = tail call i32 @strlen(i8* %17)
br label %21
21: ; preds = %15, %13, %7
%22 = phi i32 [ %20, %15 ], [ 0, %13 ], [ %9, %7 ]
ret i32 %22
}