// File: /workspace/github_cpp_makefile_star2_O3/talyerushalmy[P]SimpleFileSystem/src/Commands.cpp
// Function: MkfileCommand::execute(FileSystem&)
void MkfileCommand::execute(FileSystem& fs)
{
	try
	{
		std::vector<std::string> arguments = StringTools::split(this->getArgs(), " ");

		if (arguments.size() != 2)
		{
			std::cout << "Usage: mkfile <path/filename> <size>" << std::endl;
			return;
		}
		for (std::string i : arguments)
		{
			if (StringTools::trim(i) == "")
			{
				std::cout << "Usage: mkfile <path/filename> <size>" << std::endl;
				return;
			}
		}

		unsigned int file_size = std::stoi(arguments[1].c_str());
		std::vector<std::string> path_parts = StringTools::split(arguments[0], "/");
		std::string file_name = path_parts.back();
		if (file_name == "")
		{
			std::cout << "File name not specified" << std::endl;
			return;
		}
		std::string path = arguments[0].substr(0, arguments[0].length() - file_name.length());
		Directory* dir = fs.getDirectoryFromPath(path) ? fs.getDirectoryFromPath(path) : &fs.getWorkingDirectory();
		if (!dir)
		{
			std::cout << "The system cannot find the path specified" << std::endl;
			return;
		}
		if (dir->childExists(file_name))
		{
			std::cout << "File already exists" << std::endl;
			return;
		}

		File* new_file = new File(file_name, file_size);
		dir->addFile(new_file);
	}
	catch (int e)
	{
		std::cout << "Usage: mkfile <path/filename> <size>" << std::endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rsi, -0x38(%rbp)
leaq -0x198(%rbp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x28(%rdi), %rsi
movq 0x30(%rdi), %rdx
addq %rsi, %rdx
leaq -0x1a8(%rbp), %rdi
callq 0x392c
leaq -0x178(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x71d3(%rip), %rsi      # 0xe173
leaq 0x71cd(%rip), %rdx      # 0xe174
leaq -0x188(%rbp), %rdi
callq 0xab8a
leaq -0x90(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
leaq -0x188(%rbp), %rdx
callq 0x34ec
movq -0x188(%rbp), %rdi
cmpq %r15, %rdi
je 0x6fde
callq 0x31a0
movq -0x1a8(%rbp), %rdi
cmpq %rbx, %rdi
je 0x6fef
callq 0x31a0
movq -0x90(%rbp), %r12
movq -0x88(%rbp), %rcx
movq %rcx, %rax
subq %r12, %rax
cmpq $0x40, %rax
jne 0x7283
cmpq %rcx, %r12
je 0x70a2
leaq -0x48(%rbp), %r14
leaq -0x58(%rbp), %r13
leaq -0x78(%rbp), %r15
movq %rcx, -0x30(%rbp)
movq %r14, -0x58(%rbp)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x392c
movq %r15, %rdi
movq %r13, %rbx
movq %r13, %rsi
callq 0x35f2
movq %r15, %rdi
leaq 0x711e(%rip), %rsi      # 0xe174
callq 0x3080
movl %eax, %r13d
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x7070
callq 0x31a0
testl %r13d, %r13d
je 0x72ce
movq -0x58(%rbp), %rdi
cmpq %r14, %rdi
je 0x7087
callq 0x31a0
addq $0x20, %r12
movq -0x30(%rbp), %rcx
cmpq %rcx, %r12
movq %rbx, %r13
leaq -0x78(%rbp), %r15
jne 0x7026
movq -0x90(%rbp), %r12
movq 0x20(%r12), %rsi
leaq -0x58(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x30b0
movq -0x58(%rbp), %r12
callq 0x3050
movq %rax, %r15
movl (%rax), %ebx
movl $0x0, (%rax)
leaq -0x78(%rbp), %r13
movq %r12, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x3230
cmpq %r12, (%r13)
je 0x74e1
movq %rax, %r14
movslq %r14d, %rax
cmpq %r14, %rax
jne 0x74ed
movl (%r15), %eax
cmpl $0x22, %eax
je 0x74ed
testl %eax, %eax
jne 0x710b
movl %ebx, (%r15)
leaq -0x48(%rbp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x711e
callq 0x31a0
movq -0x90(%rbp), %rax
leaq -0x158(%rbp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x168(%rbp), %rdi
callq 0x392c
leaq -0x138(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x70ab(%rip), %rsi      # 0xe203
leaq 0x70a5(%rip), %rdx      # 0xe204
leaq -0x148(%rbp), %rdi
callq 0xab8a
leaq -0xa8(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x148(%rbp), %rdx
callq 0x34ec
movq -0x148(%rbp), %rdi
cmpq %r15, %rdi
je 0x7196
callq 0x31a0
movq -0x168(%rbp), %rdi
cmpq %rbx, %rdi
je 0x71a7
callq 0x31a0
movq -0xa0(%rbp), %rax
leaq -0x58(%rbp), %rdi
movq %r12, (%rdi)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
callq 0x392c
movq -0x38(%rbp), %rbx
leaq 0x6fa4(%rip), %rsi      # 0xe174
leaq -0x58(%rbp), %rdi
callq 0x3080
testl %eax, %eax
je 0x732e
movq -0x90(%rbp), %rsi
movq 0x8(%rsi), %rcx
subq -0x50(%rbp), %rcx
leaq -0x78(%rbp), %rdi
xorl %edx, %edx
callq 0x31d0
leaq -0x118(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0x128(%rbp), %rdi
callq 0x392c
leaq -0x128(%rbp), %rsi
movq %rbx, %rdi
callq 0xacd6
testq %rax, %rax
je 0x7379
leaq -0xf8(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0x108(%rbp), %rdi
callq 0x392c
leaq -0x108(%rbp), %rsi
movq %rbx, %rdi
callq 0xacd6
movq %rax, %rbx
movq -0x108(%rbp), %rdi
cmpq %r13, %rdi
je 0x7384
callq 0x31a0
jmp 0x7384
movq 0xbd46(%rip), %rbx      # 0x12fd0
leaq 0x6f84(%rip), %rsi      # 0xe215
movl $0x24, %edx
movq %rbx, %rdi
callq 0x3200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq 0xbd14(%rip), %rdi      # 0x12fd0
callq 0x3030
movq %rax, %rdi
callq 0x3130
jmp 0x74c3
movq 0xbcfb(%rip), %rbx      # 0x12fd0
leaq 0x6f39(%rip), %rsi      # 0xe215
movl $0x24, %edx
movq %rbx, %rdi
movq %r14, %r15
callq 0x3200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq 0xbcc6(%rip), %rdi      # 0x12fd0
callq 0x3030
movq %rax, %rdi
callq 0x3130
movq -0x58(%rbp), %rdi
cmpq %r15, %rdi
je 0x74c3
callq 0x31a0
jmp 0x74c3
movq 0xbc9b(%rip), %rbx      # 0x12fd0
leaq 0x6efe(%rip), %rsi      # 0xe23a
movl $0x17, %edx
movq %rbx, %rdi
callq 0x3200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq 0xbc69(%rip), %rdi      # 0x12fd0
callq 0x3030
movq %rax, %rdi
callq 0x3130
jmp 0x74a9
movq %rbx, %rdi
callq 0xacc2
movq %rax, %rbx
movq -0x128(%rbp), %rdi
cmpq %r15, %rdi
je 0x7395
callq 0x31a0
testq %rbx, %rbx
je 0x73f2
leaq -0xd8(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
leaq -0xe8(%rbp), %rdi
callq 0x392c
leaq -0xe8(%rbp), %rsi
movq %rbx, %rdi
callq 0xbcda
movl %eax, %r15d
movq -0xe8(%rbp), %rdi
cmpq %r13, %rdi
je 0x73df
callq 0x31a0
testb %r15b, %r15b
je 0x743a
movl $0x13, %edx
leaq 0x6e62(%rip), %rsi      # 0xe252
jmp 0x73fe
movl $0x29, %edx
leaq 0x6d88(%rip), %rsi      # 0xe186
movq 0xbbcb(%rip), %rbx      # 0x12fd0
movq %rbx, %rdi
callq 0x3200
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x31b0
movsbl %al, %esi
movq 0xbba5(%rip), %rdi      # 0x12fd0
callq 0x3030
movq %rax, %rdi
callq 0x3130
jmp 0x7497
movl $0x30, %edi
callq 0x31c0
movq %rax, %r15
leaq -0xb8(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
leaq -0xc8(%rbp), %rdi
callq 0x392c
leaq -0xc8(%rbp), %rsi
movq %r15, %rdi
movl %r14d, %edx
callq 0xb346
movq -0xc8(%rbp), %rdi
cmpq %r13, %rdi
je 0x748c
callq 0x31a0
movq %rbx, %rdi
movq %r15, %rsi
callq 0xbc0c
leaq -0x68(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x74a9
callq 0x31a0
movq -0x58(%rbp), %rdi
cmpq %r12, %rdi
je 0x74b7
callq 0x31a0
leaq -0xa8(%rbp), %rdi
callq 0x36b8
leaq -0x90(%rbp), %rdi
callq 0x36b8
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6eed(%rip), %rdi      # 0xe3d5
callq 0x3110
leaq 0x6ee1(%rip), %rdi      # 0xe3d5
callq 0x3240
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0xc8(%rbp), %rdi
cmpq %r13, %rdi
je 0x751c
callq 0x31a0
jmp 0x751c
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq %r15, %rdi
jmp 0x75cb
jmp 0x75b7
jmp 0x7608
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0xe8(%rbp), %rdi
cmpq %r13, %rdi
jne 0x75cb
jmp 0x7610
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0x108(%rbp), %rdi
cmpq %r13, %rdi
je 0x75bf
callq 0x31a0
jmp 0x75bf
jmp 0x75d2
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
jmp 0x7630
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0x148(%rbp), %rdi
cmpq %r15, %rdi
je 0x7598
callq 0x31a0
jmp 0x7598
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0x168(%rbp), %rdi
cmpq %rbx, %rdi
jne 0x769b
jmp 0x76a0
jmp 0x7680
jmp 0x7680
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0x128(%rbp), %rdi
cmpq %r15, %rdi
je 0x7610
callq 0x31a0
jmp 0x7610
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
jmp 0x7622
jmp 0x768a
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
cmpl $0x0, (%r15)
jne 0x75f2
movl %ebx, (%r15)
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x769b
jmp 0x76a0
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
leaq -0x68(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x7622
callq 0x31a0
movq -0x58(%rbp), %rdi
cmpq %r12, %rdi
je 0x7630
callq 0x31a0
leaq -0xa8(%rbp), %rdi
callq 0x36b8
jmp 0x76a0
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0x188(%rbp), %rdi
cmpq %r15, %rdi
je 0x7661
callq 0x31a0
jmp 0x7661
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0x1a8(%rbp), %rdi
cmpq %rbx, %rdi
je 0x76ac
callq 0x31a0
jmp 0x76ac
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
jmp 0x76ac
jmp 0x7680
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
jmp 0x76a0
movq %rdx, -0x38(%rbp)
movq %rax, -0x30(%rbp)
movq -0x58(%rbp), %rdi
cmpq %r14, %rdi
je 0x76a0
callq 0x31a0
leaq -0x90(%rbp), %rdi
callq 0x36b8
cmpl $0x1, -0x38(%rbp)
jne 0x76f2
movq -0x30(%rbp), %rdi
callq 0x30c0
movq 0xb90e(%rip), %rdi      # 0x12fd0
leaq 0x6b4c(%rip), %rsi      # 0xe215
movl $0x24, %edx
callq 0x3200
movq 0xb8f6(%rip), %rdi      # 0x12fd0
callq 0x30e0
callq 0x3280
jmp 0x74cf
movq %rax, -0x30(%rbp)
callq 0x3280
movq -0x30(%rbp), %rdi
callq 0x32b0
nop