// File: /workspace/github_c_makefile_star2_O0/niuyuling[P]CProxy/http_request.c
// Function: replace
char *replace(char *replace_memory, int *replace_memory_len, const char *src, const int src_len, const char *dest, const int dest_len)
{
    if (!replace_memory || !src || !dest)
        return replace_memory;

    char *p;
    int diff;

    if (src_len == dest_len) {
        for (p = memmem(replace_memory, *replace_memory_len, src, src_len); p; p = memmem(p, *replace_memory_len - (p - replace_memory), src, src_len)) {
            memcpy(p, dest, dest_len);
            p += dest_len;
        }
    } else if (src_len < dest_len) {
        int before_len;
        char *before_end, *new_replace_memory;

        diff = dest_len - src_len;
        for (p = memmem(replace_memory, *replace_memory_len, src, src_len); p; p = memmem(p, *replace_memory_len - (p - replace_memory), src, src_len)) {
            *replace_memory_len += diff;
            before_len = p - replace_memory;
            new_replace_memory = (char *)realloc(replace_memory, *replace_memory_len + 1);
            if (new_replace_memory == NULL) {
                free(replace_memory);
                return NULL;
            }
            replace_memory = new_replace_memory;
            before_end = replace_memory + before_len;
            p = before_end + dest_len;
            memmove(p, p - diff, *replace_memory_len - (p - replace_memory));
            memcpy(before_end, dest, dest_len);
        }
    } else if (src_len > dest_len) {
        diff = src_len - dest_len;
        for (p = memmem(replace_memory, *replace_memory_len, src, src_len); p; p = memmem(p, *replace_memory_len - (p - replace_memory), src, src_len)) {
            *replace_memory_len -= diff;
            memcpy(p, dest, dest_len);
            p += dest_len;
            memmove(p, p + diff, *replace_memory_len - (p - replace_memory));
        }
    }

    replace_memory[*replace_memory_len] = '\0';
    return replace_memory;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x4d34
cmpq $0x0, -0x20(%rbp)
je 0x4d34
cmpq $0x0, -0x30(%rbp)
jne 0x4d41
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x4fc3
movl -0x24(%rbp), %eax
cmpl -0x34(%rbp), %eax
jne 0x4dbf
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq (%rax), %rsi
movq -0x20(%rbp), %rdx
movslq -0x24(%rbp), %rcx
callq 0x22f0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x4dba
movq -0x40(%rbp), %rdi
movq -0x30(%rbp), %rsi
movslq -0x34(%rbp), %rdx
callq 0x2300
movl -0x34(%rbp), %ecx
movq -0x40(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq (%rax), %rsi
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
subq %rax, %rsi
movq -0x20(%rbp), %rdx
movslq -0x24(%rbp), %rcx
callq 0x22f0
movq %rax, -0x40(%rbp)
jmp 0x4d65
jmp 0x4fac
movl -0x24(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x4ee3
movl -0x34(%rbp), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq (%rax), %rsi
movq -0x20(%rbp), %rdx
movslq -0x24(%rbp), %rcx
callq 0x22f0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x4ede
movl -0x44(%rbp), %ecx
movq -0x18(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl (%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x23e0
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x4e4a
movq -0x10(%rbp), %rdi
callq 0x2030
movq $0x0, -0x8(%rbp)
jmp 0x4fc3
movq -0x58(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movslq -0x48(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movslq -0x34(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x40(%rbp), %rsi
movslq -0x44(%rbp), %rcx
xorl %eax, %eax
subq %rcx, %rax
addq %rax, %rsi
movq -0x18(%rbp), %rax
movslq (%rax), %rdx
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
subq %rax, %rdx
callq 0x2450
movq -0x50(%rbp), %rdi
movq -0x30(%rbp), %rsi
movslq -0x34(%rbp), %rdx
callq 0x2300
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq (%rax), %rsi
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
subq %rax, %rsi
movq -0x20(%rbp), %rdx
movslq -0x24(%rbp), %rcx
callq 0x22f0
movq %rax, -0x40(%rbp)
jmp 0x4df0
jmp 0x4faa
movl -0x24(%rbp), %eax
cmpl -0x34(%rbp), %eax
jle 0x4fa8
movl -0x24(%rbp), %eax
subl -0x34(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq (%rax), %rsi
movq -0x20(%rbp), %rdx
movslq -0x24(%rbp), %rcx
callq 0x22f0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x4fa6
movl -0x44(%rbp), %edx
movq -0x18(%rbp), %rax
movl (%rax), %ecx
subl %edx, %ecx
movl %ecx, (%rax)
movq -0x40(%rbp), %rdi
movq -0x30(%rbp), %rsi
movslq -0x34(%rbp), %rdx
callq 0x2300
movl -0x34(%rbp), %ecx
movq -0x40(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x40(%rbp), %rsi
movslq -0x44(%rbp), %rax
addq %rax, %rsi
movq -0x18(%rbp), %rax
movslq (%rax), %rdx
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
subq %rax, %rdx
callq 0x2450
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq (%rax), %rsi
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
subq %rax, %rsi
movq -0x20(%rbp), %rdx
movslq -0x24(%rbp), %rcx
callq 0x22f0
movq %rax, -0x40(%rbp)
jmp 0x4f14
jmp 0x4fa8
jmp 0x4faa
jmp 0x4fac
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq (%rcx), %rcx
movb $0x0, (%rax,%rcx)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)