// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
movq 0x8(%rdi), %rdi
callq 0x9abc
movq %rax, %rdi
callq 0x781a
movq 0x8(%rax), %rcx
subq (%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0xa62c(%rip), %rax      # 0xffd0
movq (%rax), %rdi
movl $0x1, %esi
callq 0x3130
movq 0x8(%rbx), %rdi
callq 0x9abc
movq %rax, %rdi
callq 0x781a
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6a68
leaq 0x575c(%rip), %rdx      # 0xb130
movq %rbx, %rdi
movq %rax, -0x30(%rbp)
movq %rax, %rsi
callq 0x6b2c
movq %rax, %rbx
callq 0x34e0
movl $0xa, %edi
movl $0x1e, %esi
movl $0x4, %edx
movl $0x2c, %ecx
callq 0x3340
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3540
leaq 0x5b0f(%rip), %rcx      # 0xb529
movq %r12, %rdi
movl $0x1, %esi
movl $0x2, %edx
xorl %eax, %eax
callq 0x3090
movq %r12, %rdi
movl $0x2, %esi
xorl %edx, %edx
callq 0x3350
cmpl $-0x1, %eax
je 0x5a57
movq 0xa567(%rip), %rax      # 0xffb0
movl 0x1d0(%rax), %esi
movq %r12, %rdi
callq 0x30e0
movq %r12, %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x3350
cmpl $-0x1, %eax
je 0x5a88
movq 0xa53b(%rip), %rax      # 0xffb0
movl 0x1c4(%rax), %esi
movq %r12, %rdi
movl $0x26, %edx
callq 0x32a0
shrq $0x3, -0x38(%rbp)
movq %r12, %rdi
movl $0x2, %esi
movl $0x27, %edx
callq 0x3350
cmpl $-0x1, %eax
je 0x5ab9
movq 0xa505(%rip), %rax      # 0xffb0
movl 0x1d4(%rax), %esi
movq %r12, %rdi
callq 0x30e0
movq %rbx, -0x40(%rbp)
movq -0x30(%rbp), %rdi
callq 0x3490
testq %rax, %rax
je 0x5b9d
movq %rax, %rdi
callq 0x34b0
movq %rax, %rdi
callq 0x8b16
movq (%rax), %r15
movq %rax, -0x48(%rbp)
cmpq %rax, %r15
je 0x5b9d
movl $0x3, %r13d
movq 0x10(%r15), %r14
leaq -0x68(%rbp), %rdi
movq %r14, %rsi
callq 0xa7b6
movq -0x68(%rbp), %rbx
leaq -0x88(%rbp), %rdi
movq %r14, %rsi
callq 0xa7e4
movq -0x88(%rbp), %rcx
leaq -0xb0(%rbp), %rdi
leaq 0x5c13(%rip), %rsi      # 0xb740
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3080
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x5b53
movq -0x78(%rbp), %rsi
incq %rsi
callq 0x3320
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x5b6c
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x3320
movq %r12, %rdi
movl %r13d, %esi
movl $0x2, %edx
callq 0x3350
incl %r13d
movq %r12, %rdi
leaq -0xb0(%rbp), %rsi
xorl %eax, %eax
callq 0x3050
movq (%r15), %r15
cmpq -0x48(%rbp), %r15
jne 0x5af5
movq %r12, %rdi
callq 0x3380
movq -0x40(%rbp), %rbx
movq %rbx, %rdi
callq 0x3120
cmpl $0x102, %eax            # imm = 0x102
je 0x5bcd
cmpl $0x103, %eax            # imm = 0x103
je 0x5bc6
cmpl $0x1b, %eax
jne 0x5bdb
jmp 0x5be8
movl $0x202, %esi            # imm = 0x202
jmp 0x5bd2
movl $0x203, %esi            # imm = 0x203
movq -0x30(%rbp), %rdi
callq 0x3270
movq %rbx, %rdi
callq 0x3380
jmp 0x5abd
movq %rbx, %rdi
callq 0x3380
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x3230
movq %rbx, %rdi
callq 0x30b0
movq %rax, %rbx
movq -0x38(%rbp), %rax
testl %eax, %eax
jle 0x5c2e
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movq (%rbx,%r14,8), %rdi
movq %rax, %r15
callq 0x33c0
movq %r15, %rax
incq %r14
cmpq %r14, %r15
jne 0x5c17
callq 0x33a0
movq -0x30(%rbp), %rdi
callq 0x3100
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x5c6a
movq -0x58(%rbp), %rsi
incq %rsi
callq 0x3320
movq %rbx, %rdi
callq 0x3500