// File: /workspace/github_cpp_makefile_star2_O1/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
movl $0x60, %edi
callq 0x3300
movq %rax, %rbx
movq %rax, %rdi
callq 0x8d04
movq %rbx, 0xcb51(%rip)      # 0x102c8
leaq 0x78c2(%rip), %rsi      # 0xb040
movq %rbx, %rdi
callq 0x9adc
movq 0xcb3b(%rip), %rdi      # 0x102c8
leaq 0x78bd(%rip), %rsi      # 0xb051
callq 0x9adc
movq 0xcb28(%rip), %rdi      # 0x102c8
leaq 0x78d8(%rip), %rsi      # 0xb07f
callq 0x9adc
movq 0xcb15(%rip), %rdi      # 0x102c8
movl $0xa, %esi
callq 0x9b64
movq 0xcb04(%rip), %rdi      # 0x102c8
callq 0x9b5a
movq %rax, %rdi
callq 0x787e
movl %eax, -0x30(%rbp)
callq 0x3470
movl $0xffffffff, -0x2c(%rbp) # imm = 0xFFFFFFFF
movq 0xc7e9(%rip), %r12      # 0xffd0
leaq 0x790c(%rip), %r13      # 0xb0fa
jmp 0x3850
movq 0xcad1(%rip), %rdi      # 0x102c8
callq 0x9a98
leaq 0x7e8a(%rip), %rsi      # 0xb68d
jmp 0x3844
cmpl $0x61, %ebx
jne 0x3850
movq 0xcab7(%rip), %rdi      # 0x102c8
callq 0x9a98
leaq 0x7959(%rip), %rsi      # 0xb176
jmp 0x3844
movq 0xcaa2(%rip), %rdi      # 0x102c8
callq 0x9a98
leaq 0x7966(%rip), %rsi      # 0xb198
jmp 0x3844
leaq 0x794b(%rip), %rsi      # 0xb186
jmp 0x3844
leaq 0x794c(%rip), %rsi      # 0xb190
movq 0xca7d(%rip), %rdi      # 0x102c8
callq 0x9f30
callq 0x3370
movq (%r12), %rdi
testq %rdi, %rdi
je 0x3868
movswq 0x4(%rdi), %r14
incq %r14
jmp 0x386f
movq $-0x1, %r14
testq %rdi, %rdi
je 0x387c
movswl 0x6(%rdi), %ebx
incl %ebx
jmp 0x3881
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
movq 0xca34(%rip), %rdi      # 0x102c8
callq 0x9b3c
xorl %edi, %edi
xorl %esi, %esi
leaq 0x7830(%rip), %rdx      # 0xb0d4
movl %eax, %ecx
movl -0x30(%rbp), %r8d
xorl %eax, %eax
callq 0x3400
cmpl $0x1c, %ebx
jl 0x38c9
leal -0x1b(%rbx), %r15d
movq %r13, %rdi
xorl %eax, %eax
callq 0x3310
decl %r15d
jne 0x38ba
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
movq 0xc9e8(%rip), %rdi      # 0x102c8
callq 0x9a8e
movq %rax, %r13
movq (%rax), %rax
movq 0x8(%r13), %rcx
subq %rax, %rcx
je 0x392c
sarq $0x3, %rcx
addq $-0x2, %r14
xorl %r15d, %r15d
leal (%r14,%r15), %edi
subl %ecx, %edi
movq (%rax,%r15,8), %rdx
movl $0x1, %esi
xorl %eax, %eax
callq 0x3400
incq %r15
movq (%r13), %rax
movq 0x8(%r13), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r15, %rcx
ja 0x38ff
leal -0x14(%rbx), %r13d
movl $0x2, %edi
movl %r13d, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x7793(%rip), %rdi      # 0xb0e7
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
movl $0x3, %edi
movl %r13d, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x776d(%rip), %rdi      # 0xb0fc
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x7753(%rip), %rdi      # 0xb100
xorl %eax, %eax
callq 0x3310
movq 0xc90d(%rip), %rdi      # 0x102c8
callq 0x9b5a
movq %rax, %rdi
callq 0x7702
movq 0x8(%rax), %rdx
subq (%rax), %rdx
sarq $0x3, %rdx
leaq -0x50(%rbp), %r15
movq %r15, %rdi
leaq 0x772b(%rip), %r14      # 0xb10c
movq %r14, %rsi
xorl %eax, %eax
callq 0x3080
movq %r15, %rdi
callq 0x3170
movl %ebx, %esi
subl %eax, %esi
movl $0x3, %edi
callq 0x3200
movq %r15, %rdi
xorl %eax, %eax
callq 0x3310
movl $0x4, %edi
movl %r13d, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x76e2(%rip), %rdi      # 0xb111
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x76c8(%rip), %rdi      # 0xb115
xorl %eax, %eax
callq 0x3310
movl $0x5, %edi
movl %r13d, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x76a8(%rip), %rdi      # 0xb120
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x768e(%rip), %rdi      # 0xb124
xorl %eax, %eax
callq 0x3310
movl $0x6, %edi
movl %r13d, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x7669(%rip), %rdi      # 0xb12a
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x764f(%rip), %rdi      # 0xb12e
xorl %eax, %eax
callq 0x3310
movq 0xc7db(%rip), %rdi      # 0x102c8
callq 0x9b5a
movq %rax, %rdi
callq 0x7874
movq 0x8(%rax), %rdx
subq (%rax), %rdx
sarq $0x3, %rdx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x3080
movq %r15, %rdi
callq 0x3170
movl %ebx, %esi
subl %eax, %esi
movl $0x6, %edi
callq 0x3200
movq %r15, %rdi
xorl %eax, %eax
callq 0x3310
movl $0x7, %edi
movl %r13d, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x75e4(%rip), %rdi      # 0xb13a
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x75ca(%rip), %rdi      # 0xb13e
xorl %eax, %eax
callq 0x3310
movl $0x8, %edi
movl %r13d, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x75a7(%rip), %rdi      # 0xb146
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x758d(%rip), %rdi      # 0xb14a
xorl %eax, %eax
callq 0x3310
movl $0x9, %edi
movl %r13d, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x756a(%rip), %rdi      # 0xb152
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x7550(%rip), %rdi      # 0xb156
xorl %eax, %eax
callq 0x3310
movq 0xc6b4(%rip), %rdi      # 0x102c8
callq 0x9b5a
movq %rax, %rdi
callq 0x7250
movq 0x8(%rax), %rdx
subq (%rax), %rdx
sarq $0x3, %rdx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x3080
movq %r15, %rdi
callq 0x3170
subl %eax, %ebx
movl $0x9, %edi
movl %ebx, %esi
callq 0x3200
movq %r15, %rdi
xorl %eax, %eax
callq 0x3310
movl $0xa, %edi
movl %r13d, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x74e4(%rip), %rdi      # 0xb161
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x74ca(%rip), %rdi      # 0xb165
xorl %eax, %eax
callq 0x3310
movl $0xb, %edi
movl %r13d, %esi
callq 0x3200
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x3190
leaq 0x74a6(%rip), %rdi      # 0xb16c
xorl %eax, %eax
callq 0x3310
movq (%r12), %rdi
movl $0x10000, %esi          # imm = 0x10000
xorl %edx, %edx
callq 0x33f0
leaq 0x748c(%rip), %rdi      # 0xb170
xorl %eax, %eax
callq 0x3310
callq 0x34e0
xorl %edi, %edi
callq 0x3280
callq 0x3390
movq (%r12), %rdi
callq 0x3120
movl %eax, %ebx
movq 0xc5ba(%rip), %rdi      # 0x102c8
callq 0x9b3c
cmpl -0x2c(%rbp), %eax
je 0x3d33
movq 0xc5a9(%rip), %rdi      # 0x102c8
callq 0x9a98
movq 0xc59d(%rip), %rdi      # 0x102c8
callq 0x9b3c
movl %eax, -0x2c(%rbp)
leal -0x65(%rbx), %eax
cmpl $0xe, %eax
leaq 0x73ba(%rip), %r13      # 0xb0fa
ja 0x3805
leaq 0x72b7(%rip), %rcx      # 0xb004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
leaq 0x7426(%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
movl $0x60, %esi
movq %rbx, %rdi
callq 0x3320
movq %r14, %rdi
callq 0x3500
nop