#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*/ printf(char *, char, char *);
char *strchr(char *, char);
void rmcharfromset(char *vals, char x) {
  char *p = strchr(vals, x);
  if (!p) {
    printf("What the--- ?? How do remove %c from %s\n", x, vals);
    return;
  } else {
    while (*p) {
      *p = *(p + 1);
      p++;
    }
    *p = 0;
  }
}


x86 assembly (clang, -O0):
<rmcharfromset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1169 <rmcharfromset+0x49>
mov    -0x9(%rbp),%al
mov    -0x8(%rbp),%rdx
lea    0xea4(%rip),%rdi
movsbl %al,%esi
call   1040 <printf@plt>
jmp    11a0 <rmcharfromset+0x80>
jmp    116e <rmcharfromset+0x4e>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1199 <rmcharfromset+0x79>
mov    -0x18(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116e <rmcharfromset+0x4e>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rmcharfromset>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <strchr@plt>
test   %rax,%rax
je     1153 <rmcharfromset+0x33>
cmpb   $0x0,(%rax)
je     116c <rmcharfromset+0x4c>
nopw   0x0(%rax,%rax,1)
lea    0x1(%rax),%rcx
movzbl 0x1(%rax),%edx
mov    %dl,(%rax)
mov    %rcx,%rax
test   %dl,%dl
jne    1140 <rmcharfromset+0x20>
jmp    116f <rmcharfromset+0x4f>
movsbl %bpl,%esi
lea    0xea2(%rip),%rdi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printf@plt>
mov    %rax,%rcx
movb   $0x0,(%rcx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"What the--- ?? How do remove %c from %s\0A\00"
define void @rmcharfromset(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i8*
store i8* %0, i8** %3
store i8 %1, i8* %4
%6 = load i8*, i8** %3
%7 = load i8, i8* %4
%8 = call i8* @strchr(i8* %6, i8 signext %7)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i8, i8* %4
%13 = load i8*, i8** %3
%14 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8 signext %12, i8* %13)
br label %29
15: ; preds = %2
br label %16
16: ; preds = %20, %15
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i8*, i8** %5
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = load i8*, i8** %5
store i8 %23, i8* %24
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %5
br label %16
27: ; preds = %16
%28 = load i8*, i8** %5
store i8 0, i8* %28
br label %29
29: ; preds = %11, %27
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"What the--- ?? How do remove %c from %s\0A\00"
define void @rmcharfromset(i8* %0, i8 signext %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8 signext %1, i8* %0)
br label %17
7: ; preds = %2
%8 = load i8, i8* %3
%9 = icmp eq i8 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %7, %10
%11 = phi i8* [ %12, %10 ], [ %3, %7 ]
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
store i8 %13, i8* %11
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %10
15: ; preds = %10, %7
%16 = phi i8* [ %3, %7 ], [ %12, %10 ]
store i8 0, i8* %16
br label %17
17: ; preds = %15, %5
ret void
}