#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*/ delete_str(char *, int, int);
int /*<<< orphan*/ insert_str(char *, char *, int);
int instr_exclude_double_quoted(char *, char *, int);
int strlen(char *);
char *search_replace_word(char *source_destination, char *search_str,
                          char *replace_str) {
  int here, len_search = strlen(search_str);
  if ((here = instr_exclude_double_quoted(search_str, source_destination, 1)) ==
      -1) {
    return source_destination;
  }
  delete_str(source_destination, here, len_search);
  insert_str(replace_str, source_destination, here);
  return source_destination;
}


x86 assembly (clang, -O0):
<search_replace_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1,%edx
call   1040 <instr_exclude_double_quoted@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    118b <search_replace_word+0x4b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11b2 <search_replace_word+0x72>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1060 <delete_str@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1050 <insert_str@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_replace_word>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <instr_exclude_double_quoted@plt>
cmp    $0xffffffff,%eax
je     118c <search_replace_word+0x4c>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r15d,%edx
call   1060 <delete_str@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1050 <insert_str@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @search_replace_word(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = load i8*, i8** %6
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %9
%12 = load i8*, i8** %6
%13 = load i8*, i8** %5
%14 = call i32 @instr_exclude_double_quoted(i8* %12, i8* %13, i32 1)
store i32 %14, i32* %8
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = load i8*, i8** %5
store i8* %17, i8** %4
br label %28
18: ; preds = %3
%19 = load i8*, i8** %5
%20 = load i32, i32* %8
%21 = load i32, i32* %9
%22 = call i32 @delete_str(i8* %19, i32 %20, i32 %21)
%23 = load i8*, i8** %7
%24 = load i8*, i8** %5
%25 = load i32, i32* %8
%26 = call i32 @insert_str(i8* %23, i8* %24, i32 %25)
%27 = load i8*, i8** %5
store i8* %27, i8** %4
br label %28
28: ; preds = %18, %16
%29 = load i8*, i8** %4
ret i8* %29
}

LLVM IR (-O2):
define i8* @search_replace_word(i8* returned %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @instr_exclude_double_quoted(i8* %1, i8* %0, i32 1)
%6 = icmp eq i32 %5, -1
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = tail call i32 @delete_str(i8* %0, i32 %5, i32 %4)
%9 = tail call i32 @insert_str(i8* %2, i8* %0, i32 %5)
br label %10
10: ; preds = %3, %7
ret i8* %0
}