// File: /workspace/github_cpp_makefile_star2_O1/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 0x9b5a
movq %rax, %rdi
callq 0x7874
movq 0x8(%rax), %rcx
subq (%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0xa620(%rip), %rax      # 0xffd0
movq (%rax), %rdi
movl $0x1, %esi
callq 0x3130
movq 0x8(%rbx), %rdi
callq 0x9b5a
movq %rax, %rdi
callq 0x7874
movq %rbx, %rdi
movq %rax, %rsi
callq 0x6a80
leaq 0x5750(%rip), %rdx      # 0xb130
movq %rbx, %rdi
movq %rax, -0x30(%rbp)
movq %rax, %rsi
callq 0x6b42
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 0x5b03(%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 0x5a63
movq 0xa55b(%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 0x5a94
movq 0xa52f(%rip), %rax      # 0xffb0
movl 0x1c4(%rax), %esi
movq %r12, %rdi
movl $0x26, %edx
callq 0x32a0
shrq $0x3, -0x40(%rbp)
movq %r12, %rdi
movl $0x2, %esi
movl $0x27, %edx
callq 0x3350
cmpl $-0x1, %eax
je 0x5ac5
movq 0xa4f9(%rip), %rax      # 0xffb0
movl 0x1d4(%rax), %esi
movq %r12, %rdi
callq 0x30e0
movl $0x0, -0x34(%rbp)
movq %rbx, -0x48(%rbp)
movq -0x30(%rbp), %rdi
callq 0x3490
testq %rax, %rax
je 0x5bb0
movq %rax, %rdi
callq 0x34b0
movq %rax, %rdi
callq 0x8b9a
movq (%rax), %r15
movq %rax, -0x50(%rbp)
cmpq %rax, %r15
je 0x5bb0
movl $0x3, %r13d
movq 0x10(%r15), %r14
leaq -0x70(%rbp), %rdi
movq %r14, %rsi
callq 0xa832
movq -0x70(%rbp), %rbx
leaq -0x90(%rbp), %rdi
movq %r14, %rsi
callq 0xa860
movq -0x90(%rbp), %rcx
leaq -0xb0(%rbp), %rdi
leaq 0x5c00(%rip), %rsi      # 0xb740
movq %rbx, %rdx
xorl %eax, %eax
callq 0x3080
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x5b66
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x3320
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x5b7f
movq -0x60(%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 -0x50(%rbp), %r15
jne 0x5b08
movq %r12, %rdi
callq 0x3380
movq -0x48(%rbp), %rbx
movq %rbx, %rdi
callq 0x3120
cmpl $0x1b, %eax
je 0x5bf2
cmpl $0x103, %eax            # imm = 0x103
je 0x5be2
cmpl $0x102, %eax            # imm = 0x102
jne 0x5bf9
movq -0x30(%rbp), %rdi
movl $0x203, %esi            # imm = 0x203
jmp 0x5beb
movq -0x30(%rbp), %rdi
movl $0x202, %esi            # imm = 0x202
callq 0x3270
jmp 0x5bf9
movl $0x1, -0x34(%rbp)
movq %rbx, %rdi
callq 0x3380
cmpl $0x0, -0x34(%rbp)
je 0x5ad0
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x3230
movq %rbx, %rdi
callq 0x30b0
movq %rax, %rbx
movq -0x40(%rbp), %rax
testl %eax, %eax
jle 0x5c49
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 0x5c32
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 -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x5c85
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x3320
movq %rbx, %rdi
callq 0x3500
nop