#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 */
scalar_t__ StrDelete(char **, int, int, int /*<<< orphan*/);
scalar_t__ StrInsert(char **, char *, int, int /*<<< orphan*/);
int ReplaceString(char *string, int start, int length, char *replace_string) {
  if (StrDelete(&string, start, length, 0) == 0)
    if (StrInsert(&string, replace_string, start, 0) == 0)
      return 1;
    else
      return 0;
  return 0;
}


x86 assembly (clang, -O0):
<ReplaceString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    -0x10(%rbp),%rdi
xor    %ecx,%ecx
call   1030 <StrDelete@plt>
cmp    $0x0,%rax
jne    1185 <ReplaceString+0x65>
mov    -0x20(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    -0x10(%rbp),%rdi
xor    %ecx,%ecx
call   1040 <StrInsert@plt>
cmp    $0x0,%rax
jne    1179 <ReplaceString+0x59>
movl   $0x1,-0x4(%rbp)
jmp    118c <ReplaceString+0x6c>
movl   $0x0,-0x4(%rbp)
jmp    118c <ReplaceString+0x6c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReplaceString>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %esi,%ebp
mov    %rdi,0x8(%rsp)
lea    0x8(%rsp),%rdi
xor    %ebx,%ebx
xor    %ecx,%ecx
call   1030 <StrDelete@plt>
test   %rax,%rax
jne    115e <ReplaceString+0x3e>
lea    0x8(%rsp),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1040 <StrInsert@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ReplaceString(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
%10 = load i32, i32* %7
%11 = load i32, i32* %8
%12 = call i64 @StrDelete(i8** %6, i32 %10, i32 %11, i32 0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %4
%15 = load i8*, i8** %9
%16 = load i32, i32* %7
%17 = call i64 @StrInsert(i8** %6, i8* %15, i32 %16, i32 0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 1, i32* %5
br label %22
20: ; preds = %14
store i32 0, i32* %5
br label %22
21: ; preds = %4
store i32 0, i32* %5
br label %22
22: ; preds = %21, %20, %19
%23 = load i32, i32* %5
ret i32 %23
}

LLVM IR (-O2):
define i32 @ReplaceString(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i8*
store i8* %0, i8** %5
%6 = call i64 @StrDelete(i8** %5, i32 %1, i32 %2, i32 0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = call i64 @StrInsert(i8** %5, i8* %3, i32 %1, i32 0)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %4, %8
%13 = phi i32 [ %11, %8 ], [ 0, %4 ]
ret i32 %13
}