// File: 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
movq %rsp, %rbp
subq $0x3d0, %rsp            # imm = 0x3D0
movq %rdi, -0x8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x22c0
leaq -0x48(%rbp), %rdi
callq 0x22c0
leaq 0x32c7(%rip), %rdi      # 0x650f
xorl %eax, %eax
callq 0x2050
jmp 0x3251
leaq 0x32e8(%rip), %rdi      # 0x6540
xorl %eax, %eax
callq 0x2050
jmp 0x3261
leaq -0x79(%rbp), %rdi
movq %rdi, -0x350(%rbp)
callq 0x2370
movq -0x350(%rbp), %rdx
leaq 0x32d2(%rip), %rsi      # 0x6551
leaq -0x78(%rbp), %rdi
callq 0x3ba0
jmp 0x328a
leaq -0x79(%rbp), %rdi
callq 0x2210
movq -0x8(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x4440
jmp 0x32a5
leaq -0x78(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x2290
jmp 0x32b7
leaq -0xa0(%rbp), %rdi
callq 0x2110
leaq 0x328f(%rip), %rsi      # 0x6559
leaq -0x78(%rbp), %rdi
callq 0x21d0
jmp 0x32d5
leaq -0x78(%rbp), %rdi
callq 0x20e0
movq %rax, %rdi
callq 0x2190
jmp 0x32e8
leaq -0x2a8(%rbp), %rdi
callq 0x2240
jmp 0x32f6
leaq 0x330f(%rip), %rsi      # 0x660c
leaq -0x2a8(%rbp), %rdi
movl $0x8, %edx
callq 0x2120
jmp 0x3310
leaq -0x2a8(%rbp), %rdi
callq 0x2320
movb %al, -0x351(%rbp)
jmp 0x3324
movb -0x351(%rbp), %al
testb $0x1, %al
jne 0x33d9
jmp 0x3334
movq 0x5c95(%rip), %rdi      # 0x8fd0
leaq 0x3226(%rip), %rsi      # 0x6568
callq 0x21e0
movq %rax, -0x360(%rbp)
jmp 0x3350
movq -0x360(%rbp), %rdi
movq 0x5c62(%rip), %rsi      # 0x8fc0
callq 0x21f0
jmp 0x3365
movl $0x1, %edi
callq 0x2260
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3934
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x79(%rbp), %rdi
callq 0x2210
jmp 0x3934
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x392b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x2110
jmp 0x392b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x391f
leaq -0x2a8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2280
jmp 0x33eb
movq -0x2a8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x2a8(%rbp,%rax), %rdi
callq 0x23a0
movb %al, -0x361(%rbp)
jmp 0x340b
movb -0x361(%rbp), %al
testb $0x1, %al
jne 0x3417
jmp 0x3460
movq 0x5bb2(%rip), %rdi      # 0x8fd0
leaq 0x3166(%rip), %rsi      # 0x658b
callq 0x21e0
movq %rax, -0x370(%rbp)
jmp 0x3433
movq -0x370(%rbp), %rdi
movq 0x5b7f(%rip), %rsi      # 0x8fc0
callq 0x21f0
jmp 0x3448
leaq -0x2a8(%rbp), %rdi
callq 0x2080
jmp 0x3456
movl $0x1, %edi
callq 0x2260
jmp 0x3462
movq -0x2a8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x2a8(%rbp,%rax), %rdi
callq 0x23a0
movb %al, -0x371(%rbp)
jmp 0x3482
movb -0x371(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x3490
jmp 0x34f1
movq 0x5b39(%rip), %rdi      # 0x8fd0
leaq 0x321b(%rip), %rsi      # 0x66b9
callq 0x21e0
movq %rax, -0x380(%rbp)
jmp 0x34ac
movq -0x380(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x21b0
movq %rax, -0x388(%rbp)
jmp 0x34c5
movq -0x388(%rbp), %rdi
movq 0x5aed(%rip), %rsi      # 0x8fc0
callq 0x21f0
jmp 0x34da
leaq -0x2a8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2280
jmp 0x34ec
jmp 0x3462
movq -0x2a8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x2a8(%rbp,%rax), %rdi
xorl %esi, %esi
callq 0x2340
jmp 0x350d
xorl %edx, %edx
movl %edx, %esi
leaq -0x2a8(%rbp), %rdi
callq 0x22a0
jmp 0x351f
leaq -0x2c9(%rbp), %rdi
movq %rdi, -0x390(%rbp)
callq 0x2370
movq -0x390(%rbp), %rdx
leaq 0x3081(%rip), %rsi      # 0x65c1
leaq -0x2c8(%rbp), %rdi
callq 0x3ba0
jmp 0x354e
leaq -0x2c8(%rbp), %rdi
callq 0x3950
movb %al, -0x391(%rbp)
jmp 0x3562
leaq -0x2c8(%rbp), %rdi
callq 0x2110
leaq -0x2c9(%rbp), %rdi
callq 0x2210
movb -0x391(%rbp), %al
testb $0x1, %al
jne 0x3589
jmp 0x36d2
leaq -0x2a8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2280
jmp 0x359b
jmp 0x359d
movq -0x2a8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x2a8(%rbp,%rax), %rdi
callq 0x23a0
movb %al, -0x392(%rbp)
jmp 0x35bd
movb -0x392(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x35ce
jmp 0x36cd
leaq -0x2f1(%rbp), %rdi
movq %rdi, -0x3a0(%rbp)
callq 0x2370
movq -0x3a0(%rbp), %rdx
leaq 0x2fe9(%rip), %rsi      # 0x65d8
leaq -0x2f0(%rbp), %rdi
callq 0x3ba0
jmp 0x35fd
leaq -0x48(%rbp), %rdi
leaq -0x2f0(%rbp), %rsi
callq 0x3b30
jmp 0x360f
leaq -0x2f0(%rbp), %rdi
callq 0x2110
leaq -0x2f1(%rbp), %rdi
callq 0x2210
leaq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2290
jmp 0x3636
leaq 0x307f(%rip), %rsi      # 0x66bc
leaq -0x28(%rbp), %rdi
callq 0x21d0
jmp 0x3648
leaq -0x2a8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2280
jmp 0x365a
jmp 0x359d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3685
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x2c8(%rbp), %rdi
callq 0x2110
leaq -0x2c9(%rbp), %rdi
callq 0x2210
jmp 0x391f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x36bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x2f0(%rbp), %rdi
callq 0x2110
leaq -0x2f1(%rbp), %rdi
callq 0x2210
jmp 0x391f
jmp 0x38c4
movq 0x58f7(%rip), %rdi      # 0x8fd0
leaq 0x2efa(%rip), %rsi      # 0x65da
callq 0x21e0
movq %rax, -0x3a8(%rbp)
jmp 0x36ee
movq -0x3a8(%rbp), %rdi
movq 0x58c4(%rip), %rsi      # 0x8fc0
callq 0x21f0
jmp 0x3703
leaq -0x2a8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2280
jmp 0x3715
jmp 0x3717
movq -0x2a8(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x2a8(%rbp,%rax), %rdi
callq 0x23a0
movb %al, -0x3a9(%rbp)
jmp 0x3737
movb -0x3a9(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x3748
jmp 0x38c2
movq 0x5881(%rip), %rdi      # 0x8fd0
leaq -0x48(%rbp), %rsi
callq 0x21b0
jmp 0x375a
leaq -0x319(%rbp), %rdi
movq %rdi, -0x3b8(%rbp)
callq 0x2370
movq -0x3b8(%rbp), %rdx
leaq 0x2e7d(%rip), %rsi      # 0x65f8
leaq -0x318(%rbp), %rdi
callq 0x3ba0
jmp 0x3789
leaq -0x318(%rbp), %rdi
callq 0x3950
movb %al, -0x3b9(%rbp)
jmp 0x379d
leaq -0x318(%rbp), %rdi
callq 0x2110
leaq -0x319(%rbp), %rdi
callq 0x2210
movb -0x3b9(%rbp), %al
testb $0x1, %al
jne 0x37c4
jmp 0x38ab
leaq -0x341(%rbp), %rdi
movq %rdi, -0x3c8(%rbp)
callq 0x2370
movq -0x3c8(%rbp), %rdx
leaq 0x2df3(%rip), %rsi      # 0x65d8
leaq -0x340(%rbp), %rdi
callq 0x3ba0
jmp 0x37f3
leaq -0x48(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x3b30
jmp 0x3805
leaq -0x340(%rbp), %rdi
callq 0x2110
leaq -0x341(%rbp), %rdi
callq 0x2210
leaq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2290
jmp 0x382c
leaq 0x2e89(%rip), %rsi      # 0x66bc
leaq -0x28(%rbp), %rdi
callq 0x21d0
jmp 0x383e
jmp 0x38ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3866
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x318(%rbp), %rdi
callq 0x2110
leaq -0x319(%rbp), %rdi
callq 0x2210
jmp 0x391f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x389d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x340(%rbp), %rdi
callq 0x2110
leaq -0x341(%rbp), %rdi
callq 0x2210
jmp 0x391f
leaq -0x2a8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x2280
jmp 0x38bd
jmp 0x3717
jmp 0x38c4
movq -0x8(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4800
jmp 0x38d3
leaq -0x2a8(%rbp), %rdi
callq 0x2080
jmp 0x38e1
leaq 0x2d1e(%rip), %rdi      # 0x6606
callq 0x2190
jmp 0x38ef
leaq -0x2a8(%rbp), %rdi
callq 0x20a0
leaq -0x78(%rbp), %rdi
callq 0x2110
leaq -0x48(%rbp), %rdi
callq 0x2110
leaq -0x28(%rbp), %rdi
callq 0x2110
addq $0x3d0, %rsp            # imm = 0x3D0
popq %rbp
retq
leaq -0x2a8(%rbp), %rdi
callq 0x20a0
leaq -0x78(%rbp), %rdi
callq 0x2110
leaq -0x48(%rbp), %rdi
callq 0x2110
leaq -0x28(%rbp), %rdi
callq 0x2110
movq -0x50(%rbp), %rdi
callq 0x2360
nop