// File: t0mm4rx[P]piscine_cpp/day01/ex07/main.cpp
// Function: main
int main(int argc, char **argv)
{
	if (argc != 4)
	{
		std::cout << "Error ! Usage: ./replace <file> <find> <replace>" << std::endl;
		return (2);
	}
	if (!strlen(argv[2]) || !strlen(argv[3]))
	{
		std::cout << "Error: strings shouldn't be empty" << std::endl;
		return (2);
	}
	return (find_and_replace(argv[1], std::string(argv[1]) + std::string(".replace"), argv[2], argv[3]));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x4, -0x8(%rbp)
je 0x27cd
movq 0x2832(%rip), %rdi      # 0x4fd8
leaq 0x89e(%rip), %rsi       # 0x304b
callq 0x2160
movq %rax, %rdi
movq 0x280c(%rip), %rsi      # 0x4fc8
callq 0x2170
movl $0x2, -0x4(%rbp)
jmp 0x2aea
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x20c0
cmpq $0x0, %rax
je 0x27f3
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x20c0
cmpq $0x0, %rax
jne 0x2821
movq 0x27de(%rip), %rdi      # 0x4fd8
leaq 0x87b(%rip), %rsi       # 0x307c
callq 0x2160
movq %rax, %rdi
movq 0x27b8(%rip), %rsi      # 0x4fc8
callq 0x2170
movl $0x2, -0x4(%rbp)
jmp 0x2aea
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x118(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x2270
movq -0x118(%rbp), %rsi
movq -0x110(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x2b00
jmp 0x2859
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x128(%rbp)
leaq -0x89(%rbp), %rdi
movq %rdi, -0x120(%rbp)
callq 0x2270
movq -0x128(%rbp), %rsi
movq -0x120(%rbp), %rdx
leaq -0x88(%rbp), %rdi
callq 0x2b00
jmp 0x2897
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x130(%rbp)
callq 0x2270
movq -0x130(%rbp), %rdx
leaq 0x7e6(%rip), %rsi       # 0x309e
leaq -0xb0(%rbp), %rdi
callq 0x2b00
jmp 0x28c6
leaq -0x68(%rbp), %rdi
leaq -0x88(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
callq 0x2bb0
jmp 0x28df
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x140(%rbp)
leaq -0xd9(%rbp), %rdi
movq %rdi, -0x138(%rbp)
callq 0x2270
movq -0x140(%rbp), %rsi
movq -0x138(%rbp), %rdx
leaq -0xd8(%rbp), %rdi
callq 0x2b00
jmp 0x291d
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x150(%rbp)
leaq -0x101(%rbp), %rdi
movq %rdi, -0x148(%rbp)
callq 0x2270
movq -0x150(%rbp), %rsi
movq -0x148(%rbp), %rdx
leaq -0x100(%rbp), %rdi
callq 0x2b00
jmp 0x295b
leaq -0x30(%rbp), %rdi
leaq -0x68(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
leaq -0x100(%rbp), %rcx
callq 0x2410
movl %eax, -0x154(%rbp)
jmp 0x297e
movl -0x154(%rbp), %eax
movl %eax, -0x4(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x20e0
leaq -0x101(%rbp), %rdi
callq 0x2190
leaq -0xd8(%rbp), %rdi
callq 0x20e0
leaq -0xd9(%rbp), %rdi
callq 0x2190
leaq -0x68(%rbp), %rdi
callq 0x20e0
leaq -0xb0(%rbp), %rdi
callq 0x20e0
leaq -0xb1(%rbp), %rdi
callq 0x2190
leaq -0x88(%rbp), %rdi
callq 0x20e0
leaq -0x89(%rbp), %rdi
callq 0x2190
leaq -0x30(%rbp), %rdi
callq 0x20e0
leaq -0x31(%rbp), %rdi
callq 0x2190
jmp 0x2aea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2adf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2aca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2ab2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2aa6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2a91
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2a79
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x20e0
leaq -0x101(%rbp), %rdi
callq 0x2190
leaq -0xd8(%rbp), %rdi
callq 0x20e0
leaq -0xd9(%rbp), %rdi
callq 0x2190
leaq -0x68(%rbp), %rdi
callq 0x20e0
leaq -0xb0(%rbp), %rdi
callq 0x20e0
leaq -0xb1(%rbp), %rdi
callq 0x2190
leaq -0x88(%rbp), %rdi
callq 0x20e0
leaq -0x89(%rbp), %rdi
callq 0x2190
leaq -0x30(%rbp), %rdi
callq 0x20e0
leaq -0x31(%rbp), %rdi
callq 0x2190
jmp 0x2af6
movl -0x4(%rbp), %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x2260
nop