// File: /workspace/github_cpp_makefile_star2_O3/arisKoutsou[P]oopproj/./src/livings/Hero.cpp
// Function: Hero::enterMarket(Market*)
void Hero :: enterMarket(Market* market) {
  market->getMenu().clearMenu();
  market->getMenu().displayMenu();
  int selection;
  string sellPrompt = "Please enter the name of the item/spell you want to sell";

  while ((selection = market->getMenu().getSelection())) {   
    market->getMenu().clearMenu();
    switch (selection) {
    case 1: {
      market->printInfo();
      break;
    }
    case 2: {
      string buyPrompt = "Please enter the name of the item/spell you want to buy";
      buyPrompt += "\n(Current Money: ";  
      stringstream ss;
      ss << getMoney();
      buyPrompt += ss.str();
      buyPrompt += ")";
      market->printInfo();
      string input = getUserInput(buyPrompt);
      this->buy(input);
      break;
    }
    case 3: {
      if (!this->inventory.hasSpells() && !this->inventory.hasItems()) {
	cout << "You have no items or spells for sale" << endl;
	break;
      }      
      inventory.printInfo();
      string input = getUserInput(sellPrompt);
      sell(input);
      break;
    }
    case 4: {
      market->getMenu().clearMenu();
      return;
    }
    case 5: {
      handleQuitCase();
      market->getMenu().clearMenu();
      if (quitGame) return;      
      break;
    }
    default: break;
    }
    market->getMenu().displayMenu();
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rsi, %r14
movq %rdi, %r15
movq %rsi, %rdi
callq 0xfe5e
movq %rax, %rdi
callq 0x4f7c
movq %r14, %rdi
callq 0xfe5e
movq (%rax), %rcx
movq %rax, %rdi
callq *(%rcx)
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x63d2(%rip), %rsi      # 0x1c121
leaq 0x6403(%rip), %rdx      # 0x1c159
leaq 0x40(%rsp), %rdi
callq 0x654a
leaq 0xc0(%r15), %r13
leaq 0x601a(%rip), %rbp      # 0x1bd88
leaq 0x20(%rsp), %rbx
movq %r14, %rdi
callq 0xfe5e
movq %rax, %rdi
callq 0x4ff8
movl %eax, %r12d
testl %eax, %eax
je 0x15fc3
movq %r14, %rdi
callq 0xfe5e
movq %rax, %rdi
callq 0x4f7c
decl %r12d
cmpl $0x4, %r12d
ja 0x15f52
movslq (%rbp,%r12,4), %rax
addq %rbp, %rax
jmpq *%rax
movq %r14, %rdi
callq 0x11dd0
jmp 0x15f52
movq %r13, %rdi
callq 0xca76
testb %al, %al
jne 0x15dde
movq %r13, %rdi
callq 0xca6a
testb %al, %al
je 0x15f67
movq %r13, %rdi
callq 0xea6a
leaq 0x60(%rsp), %r12
movq %r12, %rdi
leaq 0x40(%rsp), %rdx
callq 0x147a0
movq %r15, %rdi
movq %r12, %rsi
callq 0x15b12
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x15f52
movq 0x70(%rsp), %rsi
jmp 0x15f4a
callq 0x8c64
movq %r14, %rdi
callq 0xfe5e
movq %rax, %rdi
callq 0x4f7c
leaq 0xf42d(%rip), %rax      # 0x25269
cmpb $0x0, (%rax)
je 0x15f52
jmp 0x15fc3
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
movq %rbx, %rdi
leaq 0x62fc(%rip), %rsi      # 0x1c15a
leaq 0x632c(%rip), %rdx      # 0x1c191
callq 0x654a
movq %rbx, %rdi
leaq 0x631e(%rip), %rsi      # 0x1c192
callq 0x4470
leaq 0x60(%rsp), %rdi
callq 0x41c0
movl 0xac(%r15), %esi
leaq 0x70(%rsp), %rdi
callq 0x4420
movq %rsp, %rdi
leaq 0x78(%rsp), %rsi
callq 0x43c0
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x40e0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x15ecd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
leaq 0x56f4(%rip), %rsi      # 0x1b5cb
callq 0x4470
movq %r14, %rdi
callq 0x11dd0
movq %rsp, %r12
movq %r12, %rdi
movq %rbx, %rdx
callq 0x147a0
movq %r15, %rdi
movq %r12, %rsi
callq 0x15490
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x15f18
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
leaq 0x60(%rsp), %rdi
movq 0xf074(%rip), %rsi      # 0x24f98
callq 0x41f0
leaq 0xe0(%rsp), %rdi
callq 0x40f0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x15f52
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %r14, %rdi
callq 0xfe5e
movq (%rax), %rcx
movq %rax, %rdi
callq *(%rcx)
jmp 0x15d73
movl $0x24, %edx
movq 0xf04d(%rip), %rdi      # 0x24fc0
leaq 0x622a(%rip), %rsi      # 0x1c1a4
callq 0x42f0
movq 0xf03a(%rip), %rcx      # 0x24fc0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x4270
movsbl %al, %esi
movq 0xf01c(%rip), %rdi      # 0x24fc0
callq 0x4040
movq %rax, %rdi
callq 0x41b0
jmp 0x15f52
movq %r14, %rdi
callq 0xfe5e
movq %rax, %rdi
callq 0x4f7c
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x15fdf
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x42a0
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1607f
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x16082
movq 0x70(%rsp), %rsi
jmp 0x16075
jmp 0x1607f
jmp 0x16015
jmp 0x16040
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x16043
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x16043
jmp 0x16040
jmp 0x16039
movq %rax, %rbx
jmp 0x16061
jmp 0x1607f
movq %rax, %rbx
movq 0xef4e(%rip), %rsi      # 0x24f98
leaq 0x60(%rsp), %rdi
callq 0x41f0
leaq 0xe0(%rsp), %rdi
callq 0x40f0
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x16082
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x42a0
jmp 0x16082
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1609e
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x42a0
movq %rbx, %rdi
callq 0x4430