// File: talyerushalmy[P]SimpleFileSystem/src/Files.cpp
// Function: Directory::duplicate(Directory const&)
void Directory::duplicate(const Directory& dir)
{
	this->children.clear();
	this->setName(dir.getName());
	this->setParent(dir.getParent());
	for (BaseFile* bf : dir.children)
	{
		if (Directory* d = dynamic_cast<Directory*>(bf))
		{
			Directory* new_d = new Directory(*d);
			new_d->setParent(this);
			this->children.push_back(new_d);
		}
		else if (File* f = dynamic_cast<File*>(bf))
		{
			File* new_f = new File(*f);
			this->children.push_back(new_f);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
addq $0x28, %rdi
callq 0x10290
movq -0x10(%rbp), %rsi
leaq -0x30(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0xeb30
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0xeb60
jmp 0xee40
leaq -0x30(%rbp), %rdi
callq 0x3130
movq -0x10(%rbp), %rdi
callq 0xf570
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0xf590
movq -0x10(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x102b0
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
callq 0x102e0
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x10310
testb $0x1, %al
jne 0xee9d
jmp 0xf06f
leaq -0x50(%rbp), %rdi
callq 0x10350
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, %rax
je 0xeeff
movq -0xa8(%rbp), %rdi
leaq 0xce94(%rip), %rsi      # 0x1bd60
leaq 0xce9d(%rip), %rdx      # 0x1bd70
xorl %eax, %eax
movl %eax, %ecx
callq 0x3210
movq %rax, -0xb0(%rbp)
jmp 0xef0a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x3130
jmp 0xf078
xorl %eax, %eax
movq %rax, -0xb0(%rbp)
jmp 0xef0a
movq -0xb0(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0xef97
movl $0x48, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
movq -0x68(%rbp), %rsi
callq 0xecd0
jmp 0xef3e
movq -0xa0(%rbp), %rsi
movq -0xb8(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0xf590
movq -0xa0(%rbp), %rdi
addq $0x28, %rdi
movq -0x70(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x78(%rbp), %rsi
callq 0x10370
jmp 0xf05f
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x31a0
jmp 0xf078
movq -0x60(%rbp), %rax
movq %rax, -0xc0(%rbp)
cmpq $0x0, %rax
je 0xefcf
movq -0xc0(%rbp), %rdi
leaq 0xcdaa(%rip), %rsi      # 0x1bd60
leaq 0xcdcb(%rip), %rdx      # 0x1bd88
xorl %eax, %eax
movl %eax, %ecx
callq 0x3210
movq %rax, -0xc8(%rbp)
jmp 0xefda
xorl %eax, %eax
movq %rax, -0xc8(%rbp)
jmp 0xefda
movq -0xc8(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0xf05d
movl $0x30, %edi
callq 0x31c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xd0(%rbp)
movq -0x80(%rbp), %rsi
callq 0xdc40
jmp 0xf00e
movq -0xa0(%rbp), %rdi
movq -0xd0(%rbp), %rax
movq %rax, -0x88(%rbp)
addq $0x28, %rdi
movq -0x88(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x90(%rbp), %rsi
callq 0x10370
jmp 0xf05d
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x31a0
jmp 0xf078
jmp 0xf05f
jmp 0xf061
leaq -0x50(%rbp), %rdi
callq 0x103a0
jmp 0xee87
addq $0xd0, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x3300
nopw %cs:(%rax,%rax)