// File: /workspace/github_cpp_makefile_star2_O1/rvthak[P]Makefile-Maker/input.cpp
// Function: SystemInput(Makefile&)
void SystemInput(Makefile &mk){
	string buf, tmp;
	printf(" => Searching for files in current directory...\n");
	printf(" > Files found:\n");

	// Get the files found in a temporary file
	string str="find *.";
	str+=mk.getFormat();
	str+=">/tmp/mkfl.tmp";
	system(str.c_str());

	// Safely open tmp file
	ifstream file;
	file.open("/tmp/mkfl.tmp");
	if(!file.is_open()){ cout << " Fatal Error: Failed to read files" <<endl; exit(1); }

	// Print available files if any
	file >> tmp;
	if( file.eof()){
		cout << " (!) No files found in the set format. Terminating..." << endl;
		file.close();
		exit(1);
	}
	while(!file.eof()){
		cout << "    " << tmp << endl;
		file >> tmp;
	}

	// return to beginning of file
	file.clear();
	file.seekg(0, ios::beg);

	// Add all files to list
	if( getDesision(" (i) Select all? (y/n)")){
		file >> tmp;
		while(!file.eof()){
			changeFormat(tmp, "o");
			buf+=tmp;
			buf+=" ";
			file >> tmp;
		}
	}
	else{
		// Let the user choose files one by one (maybe implement a toggle mode where you choose by numbers)
		cout << " (i) Select the ones to add: " << endl;
		file >> tmp;
		while(!file.eof()){
			cout << tmp;
			if( getDesision("\t: add? (y/n)") ){
				changeFormat(tmp, "o");
				buf+=tmp;
				buf+=" ";
			}
			file >> tmp;
		}

	}
	//cout << " (i) Buf: " << buf << endl;
	mk.setFileList(buf);

	// Close and delete the tmp file
	file.close();
	system("rm -f /tmp/mkfl.tmp");
	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2f8, %rsp            # imm = 0x2F8
movq %rdi, %rbx
leaq 0x38(%rsp), %rbp
movq %rbp, -0x10(%rbp)
xorl %eax, %eax
movq %rax, -0x8(%rbp)
movb %al, (%rbp)
leaq 0x18(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x29c8(%rip), %rdi      # 0x5668
callq 0x2240
leaq 0x29ec(%rip), %rdi      # 0x5698
callq 0x2240
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x24f6(%rip), %rsi      # 0x51b7
leaq 0x24f6(%rip), %rdx      # 0x51be
leaq 0x48(%rsp), %rdi
callq 0x352e
leaq 0xf0(%rsp), %rdi
movq %rbx, 0x88(%rsp)
movq %rbx, %rsi
callq 0x3bf6
movq 0xf0(%rsp), %rsi
movq 0xf8(%rsp), %rdx
leaq 0x48(%rsp), %rdi
callq 0x20b0
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2d25
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x2493(%rip), %rsi      # 0x51bf
leaq 0x48(%rsp), %rdi
callq 0x22b0
movq 0x48(%rsp), %rdi
callq 0x2160
leaq 0xf0(%rsp), %rdi
callq 0x21a0
leaq 0x251e(%rip), %rsi      # 0x5272
leaq 0xf0(%rsp), %rdi
movl $0x8, %edx
callq 0x2100
leaq 0x168(%rsp), %rdi
callq 0x2080
testb %al, %al
je 0x3187
leaq 0xf0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21e0
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x110(%rsp,%rax)
jne 0x31ad
movq 0x5222(%rip), %rbx      # 0x7fd0
leaq 0x2930(%rip), %r14      # 0x56e5
leaq 0xf0(%rsp), %r15
leaq 0x8(%rsp), %r12
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x110(%rsp,%rax)
jne 0x2e31
movl $0x4, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21b0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %rbx, %rdi
callq 0x21b0
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %r13, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2120
movq %r15, %rdi
movq %r12, %rsi
callq 0x21e0
jmp 0x2dc2
leaq (%rsp,%rax), %rdi
addq $0xf0, %rdi
xorl %esi, %esi
callq 0x2270
leaq 0xf0(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21f0
leaq 0xe0(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x23c0(%rip), %rsi      # 0x5227
leaq 0x23cf(%rip), %rdx      # 0x523d
leaq 0xd0(%rsp), %rdi
callq 0x352e
leaq 0xd0(%rsp), %rdi
callq 0x3324
movl %eax, %ebx
movq 0xd0(%rsp), %rdi
cmpq %r14, %rdi
je 0x2ea7
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x2190
testb %bl, %bl
je 0x2f77
leaq 0xf0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21e0
leaq 0xc0(%rsp), %r14
leaq 0xb0(%rsp), %r15
leaq 0x8(%rsp), %r12
leaq 0x28(%rsp), %r13
leaq 0x2806(%rip), %rbp      # 0x56e8
leaq 0xf0(%rsp), %rbx
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x110(%rsp,%rax)
jne 0x30e9
movq %r14, 0xb0(%rsp)
movq %r15, %rdi
leaq 0x2328(%rip), %rsi      # 0x523e
leaq 0x2322(%rip), %rdx      # 0x523f
callq 0x352e
movq %r12, %rdi
movq %r15, %rsi
callq 0x34a2
movq 0xb0(%rsp), %rdi
cmpq %r14, %rdi
je 0x2f4a
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r13, %rdi
callq 0x20b0
movq %r13, %rdi
movq %rbp, %rsi
callq 0x22b0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x21e0
jmp 0x2eea
movq 0x5052(%rip), %rbx      # 0x7fd0
leaq 0x22bb(%rip), %rsi      # 0x5240
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq 0x5020(%rip), %rdi      # 0x7fd0
callq 0x2030
movq %rax, %rdi
callq 0x2120
leaq 0xf0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21e0
leaq 0xa0(%rsp), %rbp
leaq 0x90(%rsp), %r13
leaq 0x8(%rsp), %rbx
leaq 0x28(%rsp), %r14
leaq 0xf0(%rsp), %r15
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x110(%rsp,%rax)
jne 0x30e9
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x4fb4(%rip), %rdi      # 0x7fd0
callq 0x21b0
movq %rbp, 0x90(%rsp)
movq %r13, %rdi
leaq 0x222b(%rip), %rsi      # 0x525e
leaq 0x2231(%rip), %rdx      # 0x526b
callq 0x352e
movq %r13, %rdi
callq 0x3324
movl %eax, %r12d
movq 0x90(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3067
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2190
testb %r12b, %r12b
je 0x30d9
leaq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
leaq 0x68(%rsp), %r12
movq %r12, %rdi
leaq 0x21b9(%rip), %rsi      # 0x523e
leaq 0x21b3(%rip), %rdx      # 0x523f
callq 0x352e
movq %rbx, %rdi
movq %r12, %rsi
callq 0x34a2
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x30b8
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x20b0
movq %r14, %rdi
leaq 0x2614(%rip), %rsi      # 0x56e8
callq 0x22b0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x21e0
jmp 0x2ff1
leaq 0x28(%rsp), %rsi
movq 0x88(%rsp), %rdi
leaq 0x38(%rsp), %rbp
callq 0x3d4c
leaq 0xf0(%rsp), %rdi
callq 0x2060
leaq 0x2158(%rip), %rdi      # 0x526c
callq 0x2160
leaq 0xf0(%rsp), %rdi
callq 0x2090
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x3142
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x315e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3175
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2190
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4e42(%rip), %rdi      # 0x7fd0
leaq 0x2039(%rip), %rsi      # 0x51ce
movl $0x22, %edx
callq 0x21b0
movq 0x4e2a(%rip), %rdi      # 0x7fd0
callq 0x20e0
jmp 0x31de
movq 0x4e1c(%rip), %rdi      # 0x7fd0
leaq 0x2036(%rip), %rsi      # 0x51f1
movl $0x35, %edx
callq 0x21b0
movq 0x4e04(%rip), %rdi      # 0x7fd0
callq 0x20e0
leaq 0xf0(%rsp), %rdi
callq 0x2060
movl $0x1, %edi
callq 0x21d0
movq %rax, %rbx
movq 0xd0(%rsp), %rdi
cmpq %r14, %rdi
je 0x32c0
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x32c0
jmp 0x32bd
jmp 0x324f
movq %rax, %rbx
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x32cd
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x32cd
jmp 0x324f
movq %rax, %rbx
jmp 0x32e9
movq %rax, %rbx
jmp 0x32cd
jmp 0x32b3
movq %rax, %rbx
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x32b6
movq 0x78(%rsp), %rsi
jmp 0x32a5
jmp 0x32bd
jmp 0x32b3
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %rbp, %rdi
je 0x32b6
movq 0xa0(%rsp), %rsi
jmp 0x32a5
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r14, %rdi
je 0x32b6
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x32b6
jmp 0x32b3
jmp 0x32b3
movq %rax, %rbx
leaq 0x38(%rsp), %rbp
jmp 0x32c0
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x2090
leaq 0x58(%rsp), %rax
movq 0x48(%rsp), %rdi
cmpq %rax, %rdi
je 0x32e9
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x18(%rsp), %rax
movq 0x8(%rsp), %rdi
cmpq %rax, %rdi
je 0x3305
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x331c
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2190
movq %rbx, %rdi
callq 0x2290