#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 *);
char *strrchr(char *, char);
char *mvcp_util_strip(char *input, char value) {
  if (input != NULL) {
    char *ptr = strrchr(input, value);
    if (ptr != NULL)
      *ptr = '\0';
    if (input[0] == value)
      memmove(input, input + 1, strlen(input));
  }
  return input;
}


x86 assembly (clang, -O0):
<mvcp_util_strip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11b4 <mvcp_util_strip+0x84>
mov    -0x8(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1170 <mvcp_util_strip+0x40>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    11af <mvcp_util_strip+0x7f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1050 <memmove@plt>
jmp    11b4 <mvcp_util_strip+0x84>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mvcp_util_strip>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
test   %rdi,%rdi
je     116f <mvcp_util_strip+0x3f>
mov    %esi,%ebp
movsbl %bpl,%esi
mov    %rbx,%rdi
call   1040 <strrchr@plt>
test   %rax,%rax
je     1151 <mvcp_util_strip+0x21>
movb   $0x0,(%rax)
cmp    %bpl,(%rbx)
jne    116f <mvcp_util_strip+0x3f>
lea    0x1(%rbx),%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <memmove@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i8* @mvcp_util_strip(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 = icmp ne i8* %6, null
br i1 %7, label %8, label %32
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = load i8, i8* %4
%11 = call i8* @strrchr(i8* %9, i8 signext %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = load i8*, i8** %5
store i8 0, i8* %15
br label %16
16: ; preds = %14, %8
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %20, %22
br i1 %23, label %24, label %31
24: ; preds = %16
%25 = load i8*, i8** %3
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8*, i8** %3
%29 = call i32 @strlen(i8* %28)
%30 = call i32 @memmove(i8* %25, i8* %27, i32 %29)
br label %31
31: ; preds = %24, %16
br label %32
32: ; preds = %31, %2
%33 = load i8*, i8** %3
ret i8* %33
}

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