// File: whitefusion[P]Jaipur_cardgame-/Player.cpp
// Function: Player::Sell(std::vector<int, std::allocator<int>>, All_Tokens&, All_Bonus&)
void Player::Sell(vector<int> goods2sell, All_Tokens &AT, All_Bonus &AB){ // pass an integer vector that contains the location(from 1) of the cards
    sort(goods2sell.begin(), goods2sell.end()); // just convenient for delete
    int i;
    int n = goods2sell.size();
    for (i = 0; i< n; ++i){
        int l = goods2sell.at(i)-1;
        string type = hand.at(0).at(l).getCard(); 
        int id = type2id[type];
        // update points, token number
        if (AT.getSize(id) != 0){
            point[0] += AT.getToken(id).getVal();
            point[2] += AT.getToken(id).getVal();
            AT.deleteToken(id);
            GTokenNum ++;
        }
    }

    // delete the handcard, update card size
    delHand(0,goods2sell.at(0)-1);
    for (i = 1; i < n; ++i)
        delHand(0,goods2sell.at(i)-i-1);

    //update the bonus points, bonus
    if (n > 2){
        point[1] += AB.getBonus(n).getVal(); 
        point[2] += AB.getBonus(n).getVal();
        AB.delBonus(n);
        BTokenNum++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rsi, -0x130(%rbp)
movq %rdi, %rax
movq -0x130(%rbp), %rdi
movq %rdi, -0x120(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x128(%rbp)
callq 0x15f90
movq -0x120(%rbp), %rdi
movq %rax, -0x28(%rbp)
callq 0x15fc0
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x15f50
movq -0x120(%rbp), %rdi
callq 0x9b40
movl %eax, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x14c96
movq -0x120(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x9b60
movq -0x128(%rbp), %rdi
movl (%rax), %eax
decl %eax
movl %eax, -0x3c(%rbp)
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x15e70
movq %rax, %rdi
movslq -0x3c(%rbp), %rsi
callq 0x13890
movq %rax, %rsi
leaq -0x60(%rbp), %rdi
movq %rdi, -0x140(%rbp)
callq 0x12d60
movq -0x140(%rbp), %rsi
leaq 0x167ca(%rip), %rdi     # 0x2b308
callq 0x5c90
movq %rax, -0x138(%rbp)
jmp 0x14b4c
movq -0x138(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x18(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x8c30
movl %eax, -0x144(%rbp)
jmp 0x14b6c
movl -0x144(%rbp), %eax
cmpl $0x0, %eax
je 0x14c71
movq -0x18(%rbp), %rsi
movl -0x64(%rbp), %edx
leaq -0xa0(%rbp), %rdi
callq 0x8ca0
jmp 0x14b90
leaq -0xa0(%rbp), %rdi
callq 0x5860
movl %eax, -0x148(%rbp)
jmp 0x14ba4
movq -0x128(%rbp), %rax
movl -0x148(%rbp), %edx
movl 0x48(%rax), %ecx
addl %edx, %ecx
movl %ecx, 0x48(%rax)
leaq -0xa0(%rbp), %rdi
callq 0x5440
movq -0x18(%rbp), %rsi
movl -0x64(%rbp), %edx
leaq -0xc8(%rbp), %rdi
callq 0x8ca0
jmp 0x14bda
leaq -0xc8(%rbp), %rdi
callq 0x5860
movl %eax, -0x14c(%rbp)
jmp 0x14bee
movq -0x128(%rbp), %rax
movl -0x14c(%rbp), %edx
movl 0x50(%rax), %ecx
addl %edx, %ecx
movl %ecx, 0x50(%rax)
leaq -0xc8(%rbp), %rdi
callq 0x5440
movq -0x18(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x8d80
jmp 0x14c1d
movq -0x128(%rbp), %rax
movl 0x58(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x58(%rax)
jmp 0x14c71
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x14c88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x5440
jmp 0x14c88
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x5440
jmp 0x14c88
leaq -0x60(%rbp), %rdi
callq 0x2130
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x14ada
leaq -0x60(%rbp), %rdi
callq 0x2130
jmp 0x14dfa
movq -0x120(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x9b60
movq -0x128(%rbp), %rdi
movl (%rax), %edx
subl $0x1, %edx
xorl %esi, %esi
callq 0x14950
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0x14cf9
movq -0x120(%rbp), %rdi
movslq -0x34(%rbp), %rsi
callq 0x9b60
movq -0x128(%rbp), %rdi
movl (%rax), %edx
subl -0x34(%rbp), %edx
subl $0x1, %edx
xorl %esi, %esi
callq 0x14950
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x14cc0
cmpl $0x2, -0x38(%rbp)
jle 0x14df1
movq -0x20(%rbp), %rsi
movl -0x38(%rbp), %edx
leaq -0xf0(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0xf6c0
movq -0x158(%rbp), %rdi
callq 0x5860
movl %eax, -0x150(%rbp)
jmp 0x14d31
movq -0x128(%rbp), %rax
movl -0x150(%rbp), %edx
movl 0x4c(%rax), %ecx
addl %edx, %ecx
movl %ecx, 0x4c(%rax)
leaq -0xf0(%rbp), %rdi
callq 0x5440
movq -0x20(%rbp), %rsi
movl -0x38(%rbp), %edx
leaq -0x118(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0xf6c0
movq -0x168(%rbp), %rdi
callq 0x5860
movl %eax, -0x15c(%rbp)
jmp 0x14d80
movq -0x128(%rbp), %rax
movl -0x15c(%rbp), %ecx
addl 0x50(%rax), %ecx
movl %ecx, 0x50(%rax)
leaq -0x118(%rbp), %rdi
callq 0x5440
movq -0x20(%rbp), %rdi
movl -0x38(%rbp), %esi
callq 0xf7a0
movq -0x128(%rbp), %rax
movl 0x5c(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x5c(%rax)
jmp 0x14df1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x5440
jmp 0x14dfa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x5440
jmp 0x14dfa
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x2360
nopw %cs:(%rax,%rax)