#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 strlen(char const *);
char *strstr(char *, char const *);
void str_blank_out(char *s, const char *target) {
  char *p;
  int i, n;
  if (s == NULL || target == NULL || *target == '\0')
    return;
  n = strlen(target);
  p = strstr(s, target);
  while (p) {
    for (i = 0; i < n; i++)
      p[i] = ' ';
    p = strstr(p + n, target);
  }
}


x86 assembly (clang, -O0):
<str_blank_out>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1156 <str_blank_out+0x36>
cmpq   $0x0,-0x10(%rbp)
je     1156 <str_blank_out+0x36>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    115b <str_blank_out+0x3b>
jmp    11cd <str_blank_out+0xad>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11cd <str_blank_out+0xad>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11b0 <str_blank_out+0x90>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    118a <str_blank_out+0x6a>
mov    -0x18(%rbp),%rdi
movslq -0x20(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x18(%rbp)
jmp    1178 <str_blank_out+0x58>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_blank_out>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %rdi,%rdi
je     11ad <str_blank_out+0x7d>
mov    %rsi,%r12
test   %rsi,%rsi
je     11ad <str_blank_out+0x7d>
cmpb   $0x0,(%r12)
je     11ad <str_blank_out+0x7d>
mov    %rdi,%rbp
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
mov    %r12,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     11ad <str_blank_out+0x7d>
mov    %rax,%rbp
movslq %r14d,%rbx
mov    %ebx,%r15d
jmp    1196 <str_blank_out+0x66>
cs nopw 0x0(%rax,%rax,1)
nop
add    %rbx,%rbp
mov    %rbp,%rdi
mov    %r12,%rsi
call   1050 <strstr@plt>
mov    %rax,%rbp
test   %rax,%rax
je     11ad <str_blank_out+0x7d>
test   %r14d,%r14d
jle    1180 <str_blank_out+0x50>
mov    %rbp,%rdi
mov    $0x20,%esi
mov    %r15,%rdx
call   1040 <memset@plt>
jmp    1180 <str_blank_out+0x50>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @str_blank_out(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
%4 = icmp eq i8* %1, null
%5 = or i1 %3, %4
br i1 %5, label %24, label %6
6: ; preds = %2
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 0
br i1 %8, label %24, label %9
9: ; preds = %6
%10 = tail call i32 @strlen(i8* %1)
%11 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* %1)
%12 = icmp eq i8* %11, null
br i1 %12, label %24, label %13
13: ; preds = %9
%14 = icmp sgt i32 %10, 0
%15 = sext i32 %10 to i64
%16 = zext i32 %10 to i64
br label %17
17: ; preds = %13, %20
%18 = phi i8* [ %11, %13 ], [ %22, %20 ]
br i1 %14, label %19, label %20
19: ; preds = %17
br label %20
20: ; preds = %19, %17
%21 = getelementptr inbounds i8, i8* %18, i64 %15
%22 = tail call i8* @strstr(i8* %21, i8* %1)
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %17
24: ; preds = %20, %9, %2, %6
ret void
}