#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*/ memmove(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
void r_str_rmch(char *s, char ch) {
  for (; *s; s++) {
    if (*s == ch)
      memmove(s, s + 1, strlen(s));
  }
}


x86 assembly (clang, -O0):
<r_str_rmch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1194 <r_str_rmch+0x74>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    117e <r_str_rmch+0x5e>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1040 <memmove@plt>
jmp    1183 <r_str_rmch+0x63>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1132 <r_str_rmch+0x12>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<r_str_rmch>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     116b <r_str_rmch+0x4b>
mov    %esi,%r14d
mov    %rdi,%rbx
add    $0x1,%rbx
jmp    114b <r_str_rmch+0x2b>
cs nopw 0x0(%rax,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     116b <r_str_rmch+0x4b>
cmp    %r14b,%al
jne    1140 <r_str_rmch+0x20>
lea    -0x1(%rbx),%rbp
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <memmove@plt>
jmp    1140 <r_str_rmch+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @r_str_rmch(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
store i8 %1, i8* %4
br label %5
5: ; preds = %24, %2
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %27
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = load i8, i8* %4
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %12, %14
br i1 %15, label %16, label %23
16: ; preds = %9
%17 = load i8*, i8** %3
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i64 1
%20 = load i8*, i8** %3
%21 = call i32 @strlen(i8* %20)
%22 = call i32 @memmove(i8* %17, i8* %19, i32 %21)
br label %23
23: ; preds = %16, %9
br label %24
24: ; preds = %23
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
br label %5
27: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @r_str_rmch(i8* %0, i8 signext %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %17, label %5
5: ; preds = %2, %13
%6 = phi i8 [ %15, %13 ], [ %3, %2 ]
%7 = phi i8* [ %14, %13 ], [ %0, %2 ]
%8 = icmp eq i8 %6, %1
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = tail call i32 @strlen(i8* %7)
%12 = tail call i32 @memmove(i8* %7, i8* %10, i32 %11)
br label %13
13: ; preds = %5, %9
%14 = getelementptr inbounds i8, i8* %7, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %5
17: ; preds = %13, %2
ret void
}