// File: /workspace/github_cpp_makefile_star2_O3/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 0x29cc(%rip), %rdi      # 0x5668
callq 0x2240
leaq 0x29f0(%rip), %rdi      # 0x5698
callq 0x2240
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x24fa(%rip), %rsi      # 0x51b7
leaq 0x24fa(%rip), %rdx      # 0x51be
leaq 0x48(%rsp), %rdi
callq 0x352a
leaq 0xf0(%rsp), %rdi
movq %rbx, 0x88(%rsp)
movq %rbx, %rsi
callq 0x3bce
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 0x2d21
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x2497(%rip), %rsi      # 0x51bf
leaq 0x48(%rsp), %rdi
callq 0x22b0
movq 0x48(%rsp), %rdi
callq 0x2160
leaq 0xf0(%rsp), %rdi
callq 0x21a0
leaq 0x2522(%rip), %rsi      # 0x5272
leaq 0xf0(%rsp), %rdi
movl $0x8, %edx
callq 0x2100
leaq 0x168(%rsp), %rdi
callq 0x2080
testb %al, %al
je 0x3183
leaq 0xf0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21e0
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x110(%rsp,%rax)
jne 0x31a9
movq 0x5226(%rip), %rbx      # 0x7fd0
leaq 0x2934(%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 0x2e2d
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 0x2dbe
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 0x23c4(%rip), %rsi      # 0x5227
leaq 0x23d3(%rip), %rdx      # 0x523d
leaq 0xd0(%rsp), %rdi
callq 0x352a
leaq 0xd0(%rsp), %rdi
callq 0x3320
movl %eax, %ebx
movq 0xd0(%rsp), %rdi
cmpq %r14, %rdi
je 0x2ea3
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x2190
testb %bl, %bl
je 0x2f73
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 0x280a(%rip), %rbp      # 0x56e8
leaq 0xf0(%rsp), %rbx
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x110(%rsp,%rax)
jne 0x30e5
movq %r14, 0xb0(%rsp)
movq %r15, %rdi
leaq 0x232c(%rip), %rsi      # 0x523e
leaq 0x2326(%rip), %rdx      # 0x523f
callq 0x352a
movq %r12, %rdi
movq %r15, %rsi
callq 0x349e
movq 0xb0(%rsp), %rdi
cmpq %r14, %rdi
je 0x2f46
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 0x2ee6
movq 0x5056(%rip), %rbx      # 0x7fd0
leaq 0x22bf(%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 0x5024(%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 0x30e5
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x4fb8(%rip), %rdi      # 0x7fd0
callq 0x21b0
movq %rbp, 0x90(%rsp)
movq %r13, %rdi
leaq 0x222f(%rip), %rsi      # 0x525e
leaq 0x2235(%rip), %rdx      # 0x526b
callq 0x352a
movq %r13, %rdi
callq 0x3320
movl %eax, %r12d
movq 0x90(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3063
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x2190
testb %r12b, %r12b
je 0x30d5
leaq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
leaq 0x68(%rsp), %r12
movq %r12, %rdi
leaq 0x21bd(%rip), %rsi      # 0x523e
leaq 0x21b7(%rip), %rdx      # 0x523f
callq 0x352a
movq %rbx, %rdi
movq %r12, %rsi
callq 0x349e
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x30b4
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 0x2618(%rip), %rsi      # 0x56e8
callq 0x22b0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x21e0
jmp 0x2fed
leaq 0x28(%rsp), %rsi
movq 0x88(%rsp), %rdi
leaq 0x38(%rsp), %rbp
callq 0x3d24
leaq 0xf0(%rsp), %rdi
callq 0x2060
leaq 0x215c(%rip), %rdi      # 0x526c
callq 0x2160
leaq 0xf0(%rsp), %rdi
callq 0x2090
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x313e
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x315a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3171
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 0x4e46(%rip), %rdi      # 0x7fd0
leaq 0x203d(%rip), %rsi      # 0x51ce
movl $0x22, %edx
callq 0x21b0
movq 0x4e2e(%rip), %rdi      # 0x7fd0
callq 0x20e0
jmp 0x31da
movq 0x4e20(%rip), %rdi      # 0x7fd0
leaq 0x203a(%rip), %rsi      # 0x51f1
movl $0x35, %edx
callq 0x21b0
movq 0x4e08(%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 0x32bc
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x32bc
jmp 0x32b9
jmp 0x324b
movq %rax, %rbx
leaq 0x100(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x32c9
movq 0x100(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x32c9
jmp 0x324b
movq %rax, %rbx
jmp 0x32e5
movq %rax, %rbx
jmp 0x32c9
jmp 0x32af
movq %rax, %rbx
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x32b2
movq 0x78(%rsp), %rsi
jmp 0x32a1
jmp 0x32b9
jmp 0x32af
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %rbp, %rdi
je 0x32b2
movq 0xa0(%rsp), %rsi
jmp 0x32a1
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
cmpq %r14, %rdi
je 0x32b2
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0x2190
jmp 0x32b2
jmp 0x32af
jmp 0x32af
movq %rax, %rbx
leaq 0x38(%rsp), %rbp
jmp 0x32bc
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x2090
leaq 0x58(%rsp), %rax
movq 0x48(%rsp), %rdi
cmpq %rax, %rdi
je 0x32e5
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x2190
leaq 0x18(%rsp), %rax
movq 0x8(%rsp), %rdi
cmpq %rax, %rdi
je 0x3301
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2190
movq 0x28(%rsp), %rdi
cmpq %rbp, %rdi
je 0x3318
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2190
movq %rbx, %rdi
callq 0x2290