#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 *last_token(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void strip_char(char *string, char char_to_strip) {
  int i;
  char *p;
  for (i = 0; i < strlen(string); i++) {
    if (string[i] == char_to_strip) {
      p = last_token(&string[i], char_to_strip);
      strcpy(&string[i], p);
    }
  }
}


x86 assembly (clang, -O0):
<strip_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11bc <strip_char+0x8c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    11a9 <strip_char+0x79>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
add    %rax,%rdi
movsbl -0x9(%rbp),%esi
call   1050 <last_token@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11ae <strip_char+0x7e>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1149 <strip_char+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_char>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r12
call   1040 <strlen@plt>
test   %eax,%eax
jle    1185 <strip_char+0x55>
xor    %ebx,%ebx
movsbl %r15b,%r14d
jmp    1163 <strip_char+0x33>
nop
add    $0x1,%rbx
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1185 <strip_char+0x55>
cmp    %r15b,(%r12,%rbx,1)
jne    1150 <strip_char+0x20>
lea    (%r12,%rbx,1),%rbp
mov    %rbp,%rdi
mov    %r14d,%esi
call   1050 <last_token@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
call   1030 <strcpy@plt>
jmp    1150 <strip_char+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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