// File: /workspace/github_cpp_makefile_star2_O1/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, %r14
leaq -0x198(%rbp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x28(%rdi), %rsi
movq 0x30(%rdi), %rdx
addq %rsi, %rdx
leaq -0x1a8(%rbp), %rdi
callq 0x3954
leaq -0x178(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x71bc(%rip), %rsi      # 0xe173
leaq 0x71b6(%rip), %rdx      # 0xe174
leaq -0x188(%rbp), %rdi
callq 0xabe4
leaq -0x90(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
leaq -0x188(%rbp), %rdx
callq 0x34ec
movq -0x188(%rbp), %rdi
cmpq %r15, %rdi
je 0x6ff5
callq 0x31a0
movq -0x1a8(%rbp), %rdi
cmpq %rbx, %rdi
je 0x7006
callq 0x31a0
movq -0x90(%rbp), %r12
movq -0x88(%rbp), %rcx
movq %rcx, %rax
subq %r12, %rax
cmpq $0x40, %rax
jne 0x7286
movq %r14, -0x30(%rbp)
cmpq %rcx, %r12
je 0x70b6
leaq -0x48(%rbp), %r14
leaq -0x58(%rbp), %r13
leaq -0x78(%rbp), %r15
movq %rcx, -0x38(%rbp)
movq %r14, -0x58(%rbp)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x3954
movq %r15, %rdi
movq %r13, %rbx
movq %r13, %rsi
callq 0x35f2
movq %r15, %rdi
leaq 0x7103(%rip), %rsi      # 0xe174
callq 0x3080
movl %eax, %r13d
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x708b
callq 0x31a0
testl %r13d, %r13d
je 0x72d1
movq -0x58(%rbp), %rdi
cmpq %r14, %rdi
je 0x70a2
callq 0x31a0
addq $0x20, %r12
movq -0x38(%rbp), %rcx
cmpq %rcx, %r12
movq %rbx, %r13
leaq -0x78(%rbp), %r15
jne 0x7041
movq -0x90(%rbp), %rax
movq 0x20(%rax), %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 0x74ff
movq %rax, %r14
movslq %r14d, %rax
cmpq %r14, %rax
jne 0x750b
movl (%r15), %eax
cmpl $0x22, %eax
je 0x750b
testl %eax, %eax
jne 0x7125
movl %ebx, (%r15)
leaq -0x48(%rbp), %r12
movq -0x10(%r12), %rdi
cmpq %r12, %rdi
je 0x7138
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 0x3954
leaq -0x138(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x7091(%rip), %rsi      # 0xe203
leaq 0x708b(%rip), %rdx      # 0xe204
leaq -0x148(%rbp), %rdi
callq 0xabe4
leaq -0xa8(%rbp), %rdi
leaq -0x168(%rbp), %rsi
leaq -0x148(%rbp), %rdx
callq 0x34ec
movq -0x148(%rbp), %rdi
cmpq %r15, %rdi
je 0x71b0
callq 0x31a0
movq -0x168(%rbp), %rdi
cmpq %rbx, %rdi
je 0x71c1
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 0x3954
leaq 0x6f8e(%rip), %rsi      # 0xe174
leaq -0x58(%rbp), %rdi
callq 0x3080
testl %eax, %eax
je 0x7331
movq -0x90(%rbp), %rsi
movq 0x8(%rsi), %rcx
subq -0x50(%rbp), %rcx
leaq -0x78(%rbp), %rdi
xorl %edx, %edx
callq 0x31d0
leaq -0x118(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0x128(%rbp), %rdi
callq 0x3954
leaq -0x128(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0xad2e
movq %rax, %r15
testq %rax, %rax
je 0x737c
leaq -0xf8(%rbp), %rax
movq %rax, -0x10(%rax)
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
addq %rsi, %rdx
leaq -0x108(%rbp), %rdi
callq 0x3954
leaq -0x108(%rbp), %rsi
movq -0x30(%rbp), %rdi
callq 0xad2e
jmp 0x7385
movq 0xbd43(%rip), %rbx      # 0x12fd0
leaq 0x6f81(%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 0xbd11(%rip), %rdi      # 0x12fd0
callq 0x3030
movq %rax, %rdi
callq 0x3130
jmp 0x74e1
movq 0xbcf8(%rip), %rbx      # 0x12fd0
leaq 0x6f36(%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 0xbcc3(%rip), %rdi      # 0x12fd0
callq 0x3030
movq %rax, %rdi
callq 0x3130
movq -0x58(%rbp), %rdi
cmpq %r15, %rdi
je 0x74e1
callq 0x31a0
jmp 0x74e1
movq 0xbc98(%rip), %rbx      # 0x12fd0
leaq 0x6efb(%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 0xbc66(%rip), %rdi      # 0x12fd0
callq 0x3030
movq %rax, %rdi
callq 0x3130
jmp 0x74c7
movq -0x30(%rbp), %rdi
callq 0xad1a
movq %rax, %rbx
testq %r15, %r15
je 0x73a2
leaq -0xf8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x73a2
callq 0x31a0
movq -0x128(%rbp), %rdi
cmpq %r13, %rdi
je 0x73b3
callq 0x31a0
testq %rbx, %rbx
je 0x7410
leaq -0xd8(%rbp), %r13
movq %r13, -0x10(%r13)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
leaq -0xe8(%rbp), %rdi
callq 0x3954
leaq -0xe8(%rbp), %rsi
movq %rbx, %rdi
callq 0xbd50
movl %eax, %r15d
movq -0xe8(%rbp), %rdi
cmpq %r13, %rdi
je 0x73fd
callq 0x31a0
testb %r15b, %r15b
je 0x7458
movl $0x13, %edx
leaq 0x6e44(%rip), %rsi      # 0xe252
jmp 0x741c
movl $0x29, %edx
leaq 0x6d6a(%rip), %rsi      # 0xe186
movq 0xbbad(%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 0xbb87(%rip), %rdi      # 0x12fd0
callq 0x3030
movq %rax, %rdi
callq 0x3130
jmp 0x74b5
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 0x3954
leaq -0xc8(%rbp), %rsi
movq %r15, %rdi
movl %r14d, %edx
callq 0xb3d2
movq -0xc8(%rbp), %rdi
cmpq %r13, %rdi
je 0x74aa
callq 0x31a0
movq %rbx, %rdi
movq %r15, %rsi
callq 0xbc84
leaq -0x68(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x74c7
callq 0x31a0
movq -0x58(%rbp), %rdi
cmpq %r12, %rdi
je 0x74d5
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 0x6ecf(%rip), %rdi      # 0xe3d5
callq 0x3110
leaq 0x6ec3(%rip), %rdi      # 0xe3d5
callq 0x3240
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq -0xc8(%rbp), %rdi
cmpq %r13, %rdi
je 0x753a
callq 0x31a0
jmp 0x753a
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq %r15, %rdi
jmp 0x75e4
jmp 0x7621
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq -0xe8(%rbp), %rdi
jmp 0x75df
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
testq %r15, %r15
je 0x75d8
leaq -0xf8(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x75d8
callq 0x31a0
jmp 0x75d8
jmp 0x75eb
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
jmp 0x7649
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq -0x148(%rbp), %rdi
cmpq %r15, %rdi
je 0x75b1
callq 0x31a0
jmp 0x75b1
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq -0x168(%rbp), %rdi
cmpq %rbx, %rdi
jne 0x76b4
jmp 0x76b9
jmp 0x7699
jmp 0x7699
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq -0x128(%rbp), %rdi
cmpq %r13, %rdi
je 0x7629
callq 0x31a0
jmp 0x7629
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
jmp 0x763b
jmp 0x76a3
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
cmpl $0x0, (%r15)
jne 0x760b
movl %ebx, (%r15)
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x76b4
jmp 0x76b9
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
leaq -0x68(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x763b
callq 0x31a0
movq -0x58(%rbp), %rdi
cmpq %r12, %rdi
je 0x7649
callq 0x31a0
leaq -0xa8(%rbp), %rdi
callq 0x36b8
jmp 0x76b9
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq -0x188(%rbp), %rdi
cmpq %r15, %rdi
je 0x767a
callq 0x31a0
jmp 0x767a
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq -0x1a8(%rbp), %rdi
cmpq %rbx, %rdi
je 0x76c5
callq 0x31a0
jmp 0x76c5
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
jmp 0x76c5
jmp 0x7699
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
jmp 0x76b9
movq %rdx, -0x30(%rbp)
movq %rax, -0x38(%rbp)
movq -0x58(%rbp), %rdi
cmpq %r14, %rdi
je 0x76b9
callq 0x31a0
leaq -0x90(%rbp), %rdi
callq 0x36b8
cmpl $0x1, -0x30(%rbp)
jne 0x770b
movq -0x38(%rbp), %rdi
callq 0x30c0
movq 0xb8f5(%rip), %rdi      # 0x12fd0
leaq 0x6b33(%rip), %rsi      # 0xe215
movl $0x24, %edx
callq 0x3200
movq 0xb8dd(%rip), %rdi      # 0x12fd0
callq 0x30e0
callq 0x3280
jmp 0x74ed
movq %rax, -0x38(%rbp)
callq 0x3280
movq -0x38(%rbp), %rdi
callq 0x32b0