// File: /workspace/github_cpp_makefile_star2_O2/negativeview[P]Software-Business-Sim/main.cpp
// Function: main
int main(int argc, char *argv[]) {
	int row, col;

	srand(time(NULL));
	masterState = new MasterState();

	masterState->addMessage("Congratulations!");
	masterState->addMessage("You are the proud CEO of a brand new company!");
	masterState->addMessage("You must make the best software (and the most money) using what you have been given.");

	// Advance time by 10 days just so something interesting might happen.
	masterState->advanceTime(10);

	int moneyLeft = masterState->getPlayerCompany()->getMoney();

	initscr();

	int currentDay = -1;
	while(true) {
		erase();
		getmaxyx(stdscr, row, col);

		// TODO: Fix this so that it goes to the far right.
		attron(A_STANDOUT);
		mvprintw(0, 0, " Day: %d Money: %d", masterState->getTime(), moneyLeft);
		for (int i = 27; i < col; ++i) {
			printw(" ");
		}
		attroff(A_STANDOUT);

		vector<char *> *messages = masterState->getMessages();
		for (int i = 0; i < messages->size(); ++i) {
			int thisRow = row - messages->size() - 2 + i;
			mvprintw(thisRow, 1, (*messages)[i]);
		}

		// Three blank spaces between options.

		move(2, col - 20);
		attron(A_STANDOUT);
		printw("      COMMANDS      ");
		attroff(A_STANDOUT);

		move(3, col - 20);
		attron(A_STANDOUT);
		printw(" A ");
		attroff(A_STANDOUT);

		char message[20];

		printw(" Applicants");
		sprintf(message, "[%d]", masterState->getPlayerCompany()->getKnownPeople()->size());
		move(3, col - strlen(message));
		printw(message);

		move(4, col - 20);
		attron(A_STANDOUT);
		printw(" I ");
		attroff(A_STANDOUT);
		printw(" Interview");

		move(5, col - 20);
		attron(A_STANDOUT);
		printw(" H ");
		attroff(A_STANDOUT);
		printw(" Hire");

		move(6, col - 20);
		attron(A_STANDOUT);
		printw(" E ");
		attroff(A_STANDOUT);
		printw(" *Employees");

		sprintf(message, "[%d]", masterState->getPlayerCompany()->getEmployees()->size());
		move(6, col - strlen(message));
		printw(message);

		move(7, col - 20);
		attron(A_STANDOUT);
		printw(" S ");
		attroff(A_STANDOUT);
		printw(" Status");

		move(8, col - 20);
		attron(A_STANDOUT);
		printw(" T ");
		attroff(A_STANDOUT);
		printw(" *Teams");

		move(9, col - 20);
		attron(A_STANDOUT);
		printw(" P ");
		attroff(A_STANDOUT);
		printw(" *Projects");
		sprintf(message, "[%d]", masterState->getPlayerCompany()->getProjects()->size());
		move(9, col - strlen(message));
		printw(message);

		move(10, col - 20);
		attron(A_STANDOUT);
		printw(" W ");
		attroff(A_STANDOUT);
		printw(" *Wait");

		move(11, col - 20);
		attron(A_STANDOUT);
		printw(" Q ");
		attroff(A_STANDOUT);
		printw(" Quit");

		refresh();
		curs_set(0);
		noecho();
		int input = getch();

		if (masterState->getTime() != currentDay) {
			masterState->clearMessages();
			currentDay = masterState->getTime();
		}
		switch(input) {
			case 'a':
				masterState->clearMessages();
				masterState->executeCommand("applicants");
				break;
			case 'e':
				masterState->clearMessages();
				masterState->executeCommand("employees");
				break;
			case 'h':
				masterState->executeCommand("hire");
				break;
			case 'i':
				masterState->executeCommand("interview");
				break;
			case 'p':
				masterState->executeCommand("project");
				break;
			case 's':
				masterState->clearMessages();
				masterState->executeCommand("status");
				break;
			case 'q':
				endwin();
				return 0;
			default:
				break;
		}
	}
	endwin();
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorl %edi, %edi
callq 0x32c0
movl %eax, %edi
callq 0x32f0
pushq $0x60
popq %rdi
callq 0x3300
movq %rax, %rbx
movq %rax, %rdi
callq 0x860c
movq %rbx, 0xdbfb(%rip)      # 0x112d0
leaq 0x7964(%rip), %rsi      # 0xb040
movq %rbx, %rdi
callq 0x8fc6
movq 0xdbe5(%rip), %rdi      # 0x112d0
leaq 0x795f(%rip), %rsi      # 0xb051
callq 0x8fc6
movq 0xdbd2(%rip), %rdi      # 0x112d0
leaq 0x797a(%rip), %rsi      # 0xb07f
callq 0x8fc6
movq 0xdbbf(%rip), %rdi      # 0x112d0
pushq $0xa
popq %rsi
callq 0x9038
movq 0xdbb0(%rip), %rdi      # 0x112d0
callq 0x902e
movq %rax, %rdi
callq 0x7274
movl %eax, -0x30(%rbp)
callq 0x3480
pushq $-0x1
popq %rax
movq 0xd891(%rip), %r12      # 0x10fd0
leaq 0x79b4(%rip), %r13      # 0xb0fa
movl %eax, -0x2c(%rbp)
jmp 0x37ab
movq 0xdb7e(%rip), %rdi      # 0x112d0
callq 0x8f8c
leaq 0x7f29(%rip), %rsi      # 0xb687
jmp 0x379f
cmpl $0x61, %ebx
jne 0x37ab
movq 0xdb64(%rip), %rdi      # 0x112d0
callq 0x8f8c
leaq 0x79fe(%rip), %rsi      # 0xb176
jmp 0x379f
movq 0xdb4f(%rip), %rdi      # 0x112d0
callq 0x8f8c
leaq 0x7a0b(%rip), %rsi      # 0xb198
jmp 0x379f
leaq 0x79f0(%rip), %rsi      # 0xb186
jmp 0x379f
leaq 0x79f1(%rip), %rsi      # 0xb190
movq 0xdb2a(%rip), %rdi      # 0x112d0
callq 0x9316
callq 0x3370
movq (%r12), %rdi
pushq $-0x1
popq %r14
pushq $-0x1
popq %rax
movl %eax, %r15d
testq %rdi, %rdi
je 0x37d3
movswq 0x4(%rdi), %r14
incq %r14
movswl 0x6(%rdi), %r15d
incl %r15d
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
movq 0xdaea(%rip), %rdi      # 0x112d0
callq 0x9010
xorl %edi, %edi
xorl %esi, %esi
leaq 0x78de(%rip), %rdx      # 0xb0d4
movl %eax, %ecx
movl -0x30(%rbp), %r8d
xorl %eax, %eax
callq 0x3400
pushq $0x1b
popq %rbx
cmpl %r15d, %ebx
jge 0x3819
movq %r13, %rdi
xorl %eax, %eax
callq 0x3310
incl %ebx
jmp 0x3806
movq %r12, %r13
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
movq 0xda9d(%rip), %rdi      # 0x112d0
callq 0x8f82
movq %rax, %rbx
addq $-0x2, %r14
xorl %r12d, %r12d
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r12, %rcx
jbe 0x386e
leal (%r14,%r12), %edi
subl %ecx, %edi
movq (%rax,%r12,8), %rdx
pushq $0x1
popq %rsi
xorl %eax, %eax
callq 0x3400
incq %r12
jmp 0x3842
leal -0x14(%r15), %ebx
pushq $0x2
popq %rdi
movl %ebx, %esi
callq 0x3200
movq %r13, %r12
movq (%r13), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x7851(%rip), %rdi      # 0xb0e7
xorl %eax, %eax
callq 0x3310
movq (%r13), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
pushq $0x3
popq %rdi
movl %ebx, %esi
callq 0x3200
movq (%r13), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x782e(%rip), %rdi      # 0xb0fc
xorl %eax, %eax
callq 0x3310
movq (%r13), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x7814(%rip), %rdi      # 0xb100
xorl %eax, %eax
callq 0x3310
movq 0xd9d6(%rip), %rdi      # 0x112d0
callq 0x902e
movq %rax, %rdi
callq 0x714e
movq 0x8(%rax), %rdx
subq (%rax), %rdx
sarq $0x3, %rdx
leaq -0x50(%rbp), %r14
movq %r14, %rdi
leaq 0x77ec(%rip), %rsi      # 0xb10c
xorl %eax, %eax
callq 0x3080
movq %r14, %rdi
callq 0x3160
movl %r15d, %esi
subl %eax, %esi
pushq $0x3
popq %rdi
callq 0x3200
movq %r14, %rdi
movq %r14, %r13
xorl %eax, %eax
callq 0x3310
pushq $0x4
popq %rdi
movl %ebx, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x77a7(%rip), %rdi      # 0xb111
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x778d(%rip), %rdi      # 0xb115
xorl %eax, %eax
callq 0x3310
pushq $0x5
popq %rdi
movl %ebx, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x7770(%rip), %rdi      # 0xb120
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x7756(%rip), %rdi      # 0xb124
xorl %eax, %eax
callq 0x3310
pushq $0x6
popq %r14
movl %r14d, %edi
movl %ebx, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x7730(%rip), %rdi      # 0xb12a
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x7716(%rip), %rdi      # 0xb12e
xorl %eax, %eax
callq 0x3310
movq 0xd8aa(%rip), %rdi      # 0x112d0
callq 0x902e
movq %rax, %rdi
callq 0x726a
movq 0x8(%rax), %rdx
subq (%rax), %rdx
sarq $0x3, %rdx
movq %r13, %rdi
leaq 0x76c4(%rip), %rsi      # 0xb10c
xorl %eax, %eax
callq 0x3080
movq %r13, %rdi
callq 0x3160
movl %r15d, %esi
subl %eax, %esi
movl %r14d, %edi
callq 0x3200
movq %r13, %rdi
xorl %eax, %eax
callq 0x3310
pushq $0x7
popq %rdi
movl %ebx, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x76ab(%rip), %rdi      # 0xb13a
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x7691(%rip), %rdi      # 0xb13e
xorl %eax, %eax
callq 0x3310
pushq $0x8
popq %rdi
movl %ebx, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x7671(%rip), %rdi      # 0xb146
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x7657(%rip), %rdi      # 0xb14a
xorl %eax, %eax
callq 0x3310
pushq $0x9
popq %r14
movl %r14d, %edi
movl %ebx, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x7633(%rip), %rdi      # 0xb152
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x7619(%rip), %rdi      # 0xb156
xorl %eax, %eax
callq 0x3310
movq 0xd785(%rip), %rdi      # 0x112d0
callq 0x902e
movq %rax, %rdi
callq 0x6cfc
movq 0x8(%rax), %rdx
subq (%rax), %rdx
sarq $0x3, %rdx
movq %r13, %rdi
leaq 0x759f(%rip), %rsi      # 0xb10c
xorl %eax, %eax
callq 0x3080
movq %r13, %rdi
callq 0x3160
subl %eax, %r15d
movl %r14d, %edi
movl %r15d, %esi
callq 0x3200
movq %r13, %rdi
xorl %eax, %eax
callq 0x3310
pushq $0xa
popq %rdi
movl %ebx, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x75ac(%rip), %rdi      # 0xb161
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x7592(%rip), %rdi      # 0xb165
xorl %eax, %eax
callq 0x3310
pushq $0xb
popq %rdi
movl %ebx, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x7571(%rip), %rdi      # 0xb16c
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x7557(%rip), %rdi      # 0xb170
xorl %eax, %eax
callq 0x3310
callq 0x34f0
xorl %edi, %edi
callq 0x3280
callq 0x3390
movq (%r12), %rdi
callq 0x3110
movl %eax, %ebx
movq 0xd68d(%rip), %rdi      # 0x112d0
callq 0x9010
cmpl -0x2c(%rbp), %eax
je 0x3c68
movq 0xd67c(%rip), %rdi      # 0x112d0
callq 0x8f8c
movq 0xd670(%rip), %rdi      # 0x112d0
callq 0x9010
movl %eax, -0x2c(%rbp)
leal -0x65(%rbx), %eax
cmpl $0xe, %eax
leaq 0x7485(%rip), %r13      # 0xb0fa
ja 0x3760
leaq 0x7382(%rip), %rcx      # 0xb004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
leaq 0x74f1(%rip), %rsi      # 0xb181
jmpq *%rax
callq 0x33a0
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
pushq $0x60
popq %rsi
movq %rbx, %rdi
callq 0x3320
movq %r14, %rdi
callq 0x3510
nop