#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 strlen(char *);
void str_delete(char *text, char *out, char one) {
  int j = 0;
  for (int i = 0; i < strlen(text); i++) {
    if (text[i] != one) {
      out[j] = text[i];
      j++;
    }
  }
}


x86 assembly (clang, -O0):
<str_delete>:
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)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    1199 <str_delete+0x89>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
je     1186 <str_delete+0x76>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118b <str_delete+0x7b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1133 <str_delete+0x23>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_delete>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <strlen@plt>
test   %eax,%eax
jle    1159 <str_delete+0x49>
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1143 <str_delete+0x33>
add    $0x1,%rbp
mov    %r12,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    1159 <str_delete+0x49>
movzbl (%r12,%rbp,1),%eax
cmp    %r15b,%al
je     1130 <str_delete+0x20>
movslq %ebx,%rbx
mov    %al,(%r14,%rbx,1)
add    $0x1,%ebx
jmp    1130 <str_delete+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @str_delete(i8* %0, i8* nocapture writeonly %1, i8 signext %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %17, %3
ret void
7: ; preds = %3, %17
%8 = phi i64 [ %19, %17 ], [ 0, %3 ]
%9 = phi i32 [ %18, %17 ], [ 0, %3 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %8
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, %2
br i1 %12, label %17, label %13
13: ; preds = %7
%14 = sext i32 %9 to i64
%15 = getelementptr inbounds i8, i8* %1, i64 %14
store i8 %11, i8* %15
%16 = add nsw i32 %9, 1
br label %17
17: ; preds = %7, %13
%18 = phi i32 [ %16, %13 ], [ %9, %7 ]
%19 = add nuw nsw i64 %8, 1
%20 = tail call i32 @strlen(i8* %0)
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %7, label %6
}