#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*/ memset(char *, char, int);
int strlen(char *);
char *strstr(char *, char *);
void EraseString(char *Buff, char *Target) {
  char *ptr;
  int len;
  len = (Target ? strlen(Target) : 0);
  ptr = strstr(Buff, Target);
  while (ptr) {
    memset(ptr, ' ', len);
    ptr = strstr(ptr, Target);
  }
}


x86 assembly (clang, -O0):
<EraseString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115c <EraseString+0x2c>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
jmp    1166 <EraseString+0x36>
xor    %eax,%eax
mov    %eax,-0x20(%rbp)
jmp    1166 <EraseString+0x36>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11af <EraseString+0x7f>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    $0x20,%esi
call   1040 <memset@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x18(%rbp)
jmp    117d <EraseString+0x4d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EraseString>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rsi,%rsi
je     114b <EraseString+0x1b>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
jmp    114d <EraseString+0x1d>
xor    %ebp,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1182 <EraseString+0x52>
mov    %rax,%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %ebp,%edx
call   1040 <memset@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1160 <EraseString+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @EraseString(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
br label %13
12: ; preds = %2
br label %13
13: ; preds = %12, %9
%14 = phi i32 [ %11, %9 ], [ 0, %12 ]
store i32 %14, i32* %6
%15 = load i8*, i8** %3
%16 = load i8*, i8** %4
%17 = call i8* @strstr(i8* %15, i8* %16)
store i8* %17, i8** %5
br label %18
18: ; preds = %21, %13
%19 = load i8*, i8** %5
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i8*, i8** %5
%23 = load i32, i32* %6
%24 = call i32 @memset(i8* %22, i8 signext 32, i32 %23)
%25 = load i8*, i8** %5
%26 = load i8*, i8** %4
%27 = call i8* @strstr(i8* %25, i8* %26)
store i8* %27, i8** %5
br label %18
28: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @EraseString(i8* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @strlen(i8* %1)
br label %6
6: ; preds = %2, %4
%7 = phi i32 [ %5, %4 ], [ 0, %2 ]
%8 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%9 = icmp eq i8* %8, null
br i1 %9, label %15, label %10
10: ; preds = %6, %10
%11 = phi i8* [ %13, %10 ], [ %8, %6 ]
%12 = tail call i32 @memset(i8* %11, i8 signext 32, i32 %7)
%13 = tail call i8* @strstr(i8* %11, i8* dereferenceable(1) %1)
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %10
15: ; preds = %10, %6
ret void
}