#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 */
char *calloc(size_t, int);
size_t strlen(char *);
char *strutil_remove_each(char *string, char *chars) {
  char *shortened = calloc(strlen(string) - strlen(chars) + 1, sizeof(char));
  size_t index = 0;
  char exclude = 0;
  for (size_t i = 0; i < strlen(string); i++) {
    for (size_t j = 0; j < strlen(chars); j++) {
      if (string[i] == chars[j]) {
        exclude = 1;
        break;
      }
    }
    if (!exclude) {
      shortened[index] = string[i];
      index++;
    }
    exclude = 0;
  }
  shortened[index] = '\0';
  return shortened;
}


x86 assembly (clang, -O0):
<strutil_remove_each>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x40(%rbp),%rdi
sub    %rax,%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
jae    123d <strutil_remove_each+0x11d>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cmp    %rcx,%rax
jae    11fc <strutil_remove_each+0xdc>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x10(%rbp),%rcx
mov    -0x38(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    11e6 <strutil_remove_each+0xc6>
movb   $0x1,-0x21(%rbp)
jmp    11fc <strutil_remove_each+0xdc>
jmp    11eb <strutil_remove_each+0xcb>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    119c <strutil_remove_each+0x7c>
cmpb   $0x0,-0x21(%rbp)
jne    1228 <strutil_remove_each+0x108>
mov    -0x8(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1173 <strutil_remove_each+0x53>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strutil_remove_each>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
sub    %rax,%r15
add    $0x1,%r15
mov    %r15,%rdi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%r15
cmpb   $0x0,(%r14)
je     11b0 <strutil_remove_each+0x90>
xor    %r13d,%r13d
xor    %r12d,%r12d
jmp    1189 <strutil_remove_each+0x69>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %cl,(%r15,%r12,1)
add    $0x1,%r12
add    $0x1,%r13
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    %rax,%r13
jae    11b3 <strutil_remove_each+0x93>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    (%r14,%r13,1),%cl
test   %rax,%rax
je     1170 <strutil_remove_each+0x50>
xor    %edx,%edx
nopl   0x0(%rax)
cmp    (%rbx,%rdx,1),%cl
je     1178 <strutil_remove_each+0x58>
add    $0x1,%rdx
cmp    %rdx,%rax
jne    11a0 <strutil_remove_each+0x80>
jmp    1170 <strutil_remove_each+0x50>
xor    %r12d,%r12d
movb   $0x0,(%r15,%r12,1)
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @strutil_remove_each(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8
%8 = alloca i64
%9 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%10 = load i8*, i8** %3
%11 = call i64 @strlen(i8* %10)
%12 = load i8*, i8** %4
%13 = call i64 @strlen(i8* %12)
%14 = sub i64 %11, %13
%15 = add i64 %14, 1
%16 = call i8* @calloc(i64 %15, i32 1)
store i8* %16, i8** %5
store i64 0, i64* %6
store i8 0, i8* %7
store i64 0, i64* %8
br label %17
17: ; preds = %59, %2
%18 = load i64, i64* %8
%19 = load i8*, i8** %3
%20 = call i64 @strlen(i8* %19)
%21 = icmp ult i64 %18, %20
br i1 %21, label %22, label %62
22: ; preds = %17
store i64 0, i64* %9
br label %23
23: ; preds = %42, %22
%24 = load i64, i64* %9
%25 = load i8*, i8** %4
%26 = call i64 @strlen(i8* %25)
%27 = icmp ult i64 %24, %26
br i1 %27, label %28, label %45
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = load i64, i64* %8
%31 = getelementptr inbounds i8, i8* %29, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = load i8*, i8** %4
%35 = load i64, i64* %9
%36 = getelementptr inbounds i8, i8* %34, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %33, %38
br i1 %39, label %40, label %41
40: ; preds = %28
store i8 1, i8* %7
br label %45
41: ; preds = %28
br label %42
42: ; preds = %41
%43 = load i64, i64* %9
%44 = add i64 %43, 1
store i64 %44, i64* %9
br label %23
45: ; preds = %40, %23
%46 = load i8, i8* %7
%47 = icmp ne i8 %46, 0
br i1 %47, label %58, label %48
48: ; preds = %45
%49 = load i8*, i8** %3
%50 = load i64, i64* %8
%51 = getelementptr inbounds i8, i8* %49, i64 %50
%52 = load i8, i8* %51
%53 = load i8*, i8** %5
%54 = load i64, i64* %6
%55 = getelementptr inbounds i8, i8* %53, i64 %54
store i8 %52, i8* %55
%56 = load i64, i64* %6
%57 = add i64 %56, 1
store i64 %57, i64* %6
br label %58
58: ; preds = %48, %45
store i8 0, i8* %7
br label %59
59: ; preds = %58
%60 = load i64, i64* %8
%61 = add i64 %60, 1
store i64 %61, i64* %8
br label %17
62: ; preds = %17
%63 = load i8*, i8** %5
%64 = load i64, i64* %6
%65 = getelementptr inbounds i8, i8* %63, i64 %64
store i8 0, i8* %65
%66 = load i8*, i8** %5
ret i8* %66
}

LLVM IR (-O2):
define i8* @strutil_remove_each(i8* nocapture %0, i8* nocapture %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = add i64 %3, 1
%6 = sub i64 %5, %4
%7 = tail call i8* @calloc(i64 %6, i32 1)
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %2, %31
%11 = phi i64 [ %33, %31 ], [ 0, %2 ]
%12 = phi i64 [ %32, %31 ], [ 0, %2 ]
%13 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%14 = icmp eq i64 %13, 0
%15 = getelementptr inbounds i8, i8* %0, i64 %11
%16 = load i8, i8* %15
br i1 %14, label %28, label %22
17: ; preds = %31, %2
%18 = phi i64 [ 0, %2 ], [ %32, %31 ]
%19 = getelementptr inbounds i8, i8* %7, i64 %18
store i8 0, i8* %19
ret i8* %7
20: ; preds = %22
%21 = icmp eq i64 %27, %13
br i1 %21, label %28, label %22
22: ; preds = %10, %20
%23 = phi i64 [ %27, %20 ], [ 0, %10 ]
%24 = getelementptr inbounds i8, i8* %1, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %16, %25
%27 = add nuw i64 %23, 1
br i1 %26, label %31, label %20
28: ; preds = %20, %10
%29 = getelementptr inbounds i8, i8* %7, i64 %12
store i8 %16, i8* %29
%30 = add i64 %12, 1
br label %31
31: ; preds = %22, %28
%32 = phi i64 [ %30, %28 ], [ %12, %22 ]
%33 = add nuw i64 %11, 1
%34 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%35 = icmp ult i64 %33, %34
br i1 %35, label %10, label %17
}