// File: /workspace/github_cpp_makefile_star2_O2/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 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq 0x1b33(%rip), %rdi      # 0x4624
callq 0x2200
leaq 0x1b57(%rip), %rdi      # 0x4654
callq 0x2200
leaq 0x16ae(%rip), %rsi      # 0x41b7
leaq 0x50(%rsp), %rdi
leaq 0xf0(%rsp), %rdx
callq 0x30c2
leaq 0xf0(%rsp), %rdi
movq %rbx, 0x28(%rsp)
movq %rbx, %rsi
callq 0x35ce
leaq 0x50(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x2290
leaq 0xf0(%rsp), %rdi
callq 0x20b0
leaq 0x1669(%rip), %rsi      # 0x41bf
leaq 0x50(%rsp), %rdi
callq 0x2260
movq 0x50(%rsp), %rdi
callq 0x2120
leaq 0xf0(%rsp), %rdi
callq 0x2170
leaq 0x16f4(%rip), %rsi      # 0x4272
leaq 0xf0(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x20e0
leaq 0x168(%rsp), %rdi
callq 0x2070
testb %al, %al
je 0x2e76
leaq 0xf0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21a0
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x110(%rsp,%rax)
jne 0x2e93
movq 0x43fa(%rip), %rbx      # 0x6fd0
leaq 0x1ac4(%rip), %r14      # 0x46a1
leaq 0x8(%rsp), %r15
leaq 0xf0(%rsp), %r12
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x110(%rsp,%rax)
jne 0x2c2b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2160
movq %rax, %rdi
movq %r15, %rsi
callq 0x2140
movq %rax, %rdi
callq 0x20c0
movq %r12, %rdi
movq %r15, %rsi
callq 0x21a0
jmp 0x2bea
leaq (%rsp,%rax), %rdi
addq $0xf0, %rdi
xorl %esi, %esi
callq 0x2220
leaq 0xf0(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21b0
leaq 0x15d2(%rip), %rsi      # 0x4227
leaq 0x70(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x30c2
leaq 0x70(%rsp), %rdi
callq 0x2f5d
movl %eax, %ebx
leaq 0x70(%rsp), %rdi
callq 0x20b0
testb %bl, %bl
je 0x2d1c
leaq 0xf0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21a0
leaq 0xd0(%rsp), %r14
leaq 0x7(%rsp), %r15
leaq 0x8(%rsp), %r12
leaq 0x30(%rsp), %r13
leaq 0x19f2(%rip), %rbp      # 0x46a4
leaq 0xf0(%rsp), %rbx
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x110(%rsp,%rax)
jne 0x2e11
movq %r14, %rdi
leaq 0x1560(%rip), %rsi      # 0x423e
movq %r15, %rdx
callq 0x30c2
movq %r12, %rdi
movq %r14, %rsi
callq 0x3081
movq %r14, %rdi
callq 0x20b0
movq %r13, %rdi
movq %r12, %rsi
callq 0x2290
movq %r13, %rdi
movq %rbp, %rsi
callq 0x2260
movq %rbx, %rdi
movq %r12, %rsi
callq 0x21a0
jmp 0x2cba
movq 0x42ad(%rip), %rdi      # 0x6fd0
leaq 0x1516(%rip), %rsi      # 0x4240
callq 0x2160
movq %rax, %rdi
callq 0x20c0
leaq 0xf0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x21a0
leaq 0x8(%rsp), %r15
leaq 0xb0(%rsp), %r13
leaq 0x7(%rsp), %rbp
leaq 0x90(%rsp), %rbx
leaq 0xf0(%rsp), %r12
movq 0xf0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x110(%rsp,%rax)
jne 0x2e11
movq 0x4244(%rip), %rdi      # 0x6fd0
movq %r15, %rsi
callq 0x2140
movq %r13, %rdi
leaq 0x14c0(%rip), %rsi      # 0x425e
movq %rbp, %rdx
callq 0x30c2
movq %r13, %rdi
callq 0x2f5d
movl %eax, %r14d
movq %r13, %rdi
callq 0x20b0
testb %r14b, %r14b
je 0x2e01
movq %rbx, %rdi
leaq 0x1476(%rip), %rsi      # 0x423e
movq %rbp, %rdx
callq 0x30c2
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3081
movq %rbx, %rdi
callq 0x20b0
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x2290
leaq 0x30(%rsp), %rdi
leaq 0x18a8(%rip), %rsi      # 0x46a4
callq 0x2260
movq %r12, %rdi
movq %r15, %rsi
callq 0x21a0
jmp 0x2d6b
leaq 0x30(%rsp), %rsi
movq 0x28(%rsp), %rdi
callq 0x36c4
leaq 0xf0(%rsp), %rdi
callq 0x2050
leaq 0x1438(%rip), %rdi      # 0x426c
callq 0x2120
leaq 0xf0(%rsp), %rdi
callq 0x2080
leaq 0x50(%rsp), %rdi
callq 0x20b0
leaq 0x8(%rsp), %rdi
callq 0x20b0
leaq 0x30(%rsp), %rdi
callq 0x20b0
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4153(%rip), %rdi      # 0x6fd0
leaq 0x134a(%rip), %rsi      # 0x41ce
callq 0x2160
movq %rax, %rdi
callq 0x20c0
jmp 0x2ebb
movq 0x4136(%rip), %rdi      # 0x6fd0
leaq 0x1350(%rip), %rsi      # 0x41f1
callq 0x2160
movq %rax, %rdi
callq 0x20c0
leaq 0xf0(%rsp), %rdi
callq 0x2050
pushq $0x1
popq %rdi
callq 0x2190
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
jmp 0x2f1a
jmp 0x2f27
jmp 0x2eea
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x20b0
jmp 0x2f37
jmp 0x2eea
movq %rax, %rbx
jmp 0x2f41
movq %rax, %rbx
jmp 0x2f37
jmp 0x2f27
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
jmp 0x2f1a
jmp 0x2f27
jmp 0x2f27
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
jmp 0x2f1a
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x20b0
jmp 0x2f2a
jmp 0x2f27
jmp 0x2f27
jmp 0x2f27
movq %rax, %rbx
leaq 0xf0(%rsp), %rdi
callq 0x2080
leaq 0x50(%rsp), %rdi
callq 0x20b0
leaq 0x8(%rsp), %rdi
callq 0x20b0
leaq 0x30(%rsp), %rdi
callq 0x20b0
movq %rbx, %rdi
callq 0x2240