#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(int, int);
scalar_t__ strlen(char const *);
void strByRemovingChar(char **output, const char *source, char car) {
  char currentchar;
  int count = 0;
  int sourcelen = (int)strlen(source);
  if (!source || !car) {
    return;
  }
  *output = calloc(1, sourcelen + 1);
  while ((currentchar = *source++)) {
    if (currentchar == car) {
      continue;
    }
    *((*output) + count++) = currentchar;
  }
  *((*output) + count) = '\0';
}


x86 assembly (clang, -O0):
<strByRemovingChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115d <strByRemovingChar+0x3d>
cmpb   $0x0,-0x11(%rbp)
jne    1162 <strByRemovingChar+0x42>
jmp    11dc <strByRemovingChar+0xbc>
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
mov    $0x1,%edi
call   1040 <calloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x12(%rbp)
cmp    $0x0,%al
je     11cd <strByRemovingChar+0xad>
movsbl -0x12(%rbp),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    11ad <strByRemovingChar+0x8d>
jmp    117c <strByRemovingChar+0x5c>
mov    -0x12(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x18(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    117c <strByRemovingChar+0x5c>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strByRemovingChar>:
push   %rbp
push   %r14
push   %rbx
test   %rsi,%rsi
je     1175 <strByRemovingChar+0x55>
mov    %edx,%ebp
test   %bpl,%bpl
je     1175 <strByRemovingChar+0x55>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%esi
mov    $0x1,%edi
call   1040 <calloc@plt>
mov    %rax,(%r14)
xor    %eax,%eax
movzbl (%rbx),%ecx
test   %cl,%cl
je     116c <strByRemovingChar+0x4c>
add    $0x1,%rbx
cmp    %bpl,%cl
je     1150 <strByRemovingChar+0x30>
mov    (%r14),%rdx
mov    %cl,(%rdx,%rax,1)
add    $0x1,%rax
jmp    1150 <strByRemovingChar+0x30>
mov    (%r14),%rcx
mov    %eax,%eax
movb   $0x0,(%rcx,%rax,1)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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