// File: /workspace/github_cpp_makefile_star2_O2/negativeview[P]Software-Business-Sim/EmployeesCommand.cpp
// Function: EmployeesCommand::executeCommand(char const*)
void EmployeesCommand::executeCommand(const char *line) {
	int n_choices = this->_masterState->getPlayerCompany()->getEmployees()->size();
    keypad(stdscr, TRUE);
	MENU *my_menu = this->setupMenu((vector<NamedObject *> *)(this->_masterState->getPlayerCompany()->getEmployees()));
	WINDOW *my_menu_win = this->setupWindow(my_menu, "Employees");
	refresh();

	WINDOW *my_details_win = newwin(10, 30, 4, 44);
    box(my_details_win, 0, 0);
    mvwprintw(my_details_win, 1, 2, "Details");
	mvwaddch(my_details_win, 2, 0, ACS_LTEE);
	mvwhline(my_details_win, 2, 1, ACS_HLINE, 38);
	mvwaddch(my_details_win, 2, 39, ACS_RTEE);

    int c;
    int done = 0;
	while(!done) {
		ITEM *currentItem = current_item(my_menu);
		if (currentItem) {
			Person *p = (Person *)item_userptr(currentItem);

			list<Trait *> *realTraits = p->getRealTraits();
			int down = 3;
			for(list<Trait *>::iterator it = realTraits->begin(); it != realTraits->end(); ++it) {
				Trait *t = *it;
				char message[30];
				sprintf(message, "%10s: %s", t->getName().c_str(), t->getDiscoveryModifiedText().c_str());
				wmove(my_details_win, down, 2);
				down++;
				wprintw(my_details_win, message);
			}
		}
		wrefresh(my_details_win);

		c = wgetch(my_menu_win);
		switch(c) {
			case KEY_DOWN:
				menu_driver(my_menu, REQ_DOWN_ITEM);
				break;
			case KEY_UP:
				menu_driver(my_menu, REQ_UP_ITEM);
				break;
			case 27:
				done = 1;
				break;
		}

		wrefresh(my_menu_win);
	}

	/* Unpost and free all the memory taken up */
	unpost_menu(my_menu);

	ITEM **my_items = menu_items(my_menu);
	for(int i = 0; i < n_choices; ++i)
		free_item(my_items[i]);
	endwin();
	free_menu(my_menu);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %r14
movq 0x8(%rdi), %rdi
callq 0x902e
movq %rax, %rdi
callq 0x726a
movq 0x8(%rax), %rcx
subq (%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0xb7c2(%rip), %rax      # 0x10fd0
movq (%rax), %rdi
pushq $0x1
popq %rbx
movl %ebx, %esi
callq 0x3120
movq 0x8(%r14), %rdi
callq 0x902e
movq %rax, %rdi
callq 0x726a
movq %r14, %rdi
movq %rax, %rsi
callq 0x658e
leaq 0x58f2(%rip), %rdx      # 0xb130
movq %r14, %rdi
movq %rax, -0x30(%rbp)
movq %rax, %rsi
callq 0x664c
movq %rax, %r15
callq 0x34f0
pushq $0xa
popq %rdi
pushq $0x1e
popq %rsi
pushq $0x4
popq %rdx
pushq $0x2c
popq %rcx
callq 0x3340
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3550
leaq 0x5ca7(%rip), %rcx      # 0xb523
pushq $0x2
popq %r14
movq %r12, %rdi
movl %ebx, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x3090
movq %r12, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x3350
cmpl $-0x1, %eax
je 0x58b6
movq 0xb710(%rip), %rax      # 0x10fb8
movl 0x1d0(%rax), %esi
movq %r12, %rdi
callq 0x30e0
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r12, %rdi
callq 0x3350
cmpl $-0x1, %eax
je 0x58e1
movq 0xb6e8(%rip), %rax      # 0x10fb8
movl 0x1c4(%rax), %esi
pushq $0x26
popq %rdx
movq %r12, %rdi
callq 0x32a0
shrq $0x3, -0x38(%rbp)
pushq $0x2
popq %rsi
pushq $0x27
popq %rdx
movq %r12, %rdi
callq 0x3350
cmpl $-0x1, %eax
je 0x590e
movq 0xb6b8(%rip), %rax      # 0x10fb8
movl 0x1d4(%rax), %esi
movq %r12, %rdi
callq 0x30e0
xorl %ebx, %ebx
movq %r15, -0x40(%rbp)
movq %r12, -0x48(%rbp)
testl %ebx, %ebx
jne 0x5a34
movq -0x30(%rbp), %rdi
callq 0x34a0
testq %rax, %rax
je 0x59e0
movq %rax, %rdi
callq 0x34c0
movq %rax, %rdi
callq 0x83ce
movq %rax, %rbx
movq %rax, -0x50(%rbp)
pushq $0x3
popq %r15
movq (%rbx), %rbx
cmpq -0x50(%rbp), %rbx
je 0x59e0
movq 0x10(%rbx), %r14
leaq -0x70(%rbp), %rdi
movq %r14, %rsi
callq 0x9f0a
movq -0x70(%rbp), %r12
movl %r15d, %r13d
leaq -0x90(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x9f26
movq -0x90(%rbp), %rcx
leaq -0xb0(%rbp), %r14
movq %r14, %rdi
leaq 0x5d9f(%rip), %rsi      # 0xb73a
movq %r12, %rdx
xorl %eax, %eax
callq 0x3080
movq %r15, %rdi
callq 0x3170
leaq -0x70(%rbp), %rdi
callq 0x3170
movq -0x48(%rbp), %r12
movq %r12, %rdi
movl %r13d, %esi
pushq $0x2
popq %rdx
callq 0x3350
incl %r13d
movq %r12, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x3050
movl %r13d, %r15d
jmp 0x594d
movq %r12, %rdi
callq 0x3380
movq -0x40(%rbp), %r15
movq %r15, %rdi
callq 0x3110
cmpl $0x1b, %eax
je 0x5a24
xorl %ebx, %ebx
cmpl $0x103, %eax            # imm = 0x103
je 0x5a14
cmpl $0x102, %eax            # imm = 0x102
jne 0x5a27
movq -0x30(%rbp), %rdi
movl $0x203, %esi            # imm = 0x203
jmp 0x5a1d
movq -0x30(%rbp), %rdi
movl $0x202, %esi            # imm = 0x202
callq 0x3270
jmp 0x5a27
pushq $0x1
popq %rbx
movq %r15, %rdi
callq 0x3380
jmp 0x5918
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x3230
movq %rbx, %rdi
callq 0x30b0
movq %rax, %rbx
xorl %r14d, %r14d
movq -0x38(%rbp), %r15
testl %r15d, %r15d
cmovlel %r14d, %r15d
cmpq %r14, %r15
je 0x5a6c
movq (%rbx,%r14,8), %rdi
callq 0x33c0
incq %r14
jmp 0x5a59
callq 0x33a0
movq -0x30(%rbp), %rdi
callq 0x30f0
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3510