// File: whitefusion[P]Jaipur_cardgame-/Player.cpp
// Function: Player::Trade(std::vector<int, std::allocator<int>>, std::vector<int, std::allocator<int>>, Market&)
void Player::Trade(vector<int> mcards, vector<int> hcards, Market &M){ // location for both market and hand cards from 1
    sort(mcards.begin(), mcards.end());
    sort(hcards.begin(), hcards.end());
    int hc = hcards.size();  
    int mc = mcards.size();
    int CamelNum = mc - hc;
    int i;

    // take mc cards from market to hand
    for (i = 0; i < mc; ++i)
        setHand(M.getGoods(mcards.at(i))); 
    // delete the mc cards from market
    M.delGoods(mcards.at(0));
    for (i = 1; i < mc; ++i){
        M.delGoods(mcards.at(i)-i);
    }
    // exchange hc cards from hand to market
    for (i = 0; i < hc; ++i)
        M.setGoods_byCard(hand.at(0).at(hcards.at(i)-1)); 
    // delete the hc cards from hand
    if (hc > 0){
        delHand(0,hcards.at(0)-1);
        for (i = 1; i < hc; ++i)
            delHand(0,hcards.at(i)-i-1);
    }

    // exchange CamelNum cards to market from herds
    for (i = 0; i < CamelNum; ++i){
        M.setGoods_byCard(getHand(1,0)); 
        delHand(1,0);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x130, %rsp            # imm = 0x130
movq %rsi, -0xe0(%rbp)
movq %rdi, %rax
movq -0xe0(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
movq %rdx, -0xd0(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
callq 0x15f90
movq -0xc8(%rbp), %rdi
movq %rax, -0x28(%rbp)
callq 0x15fc0
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x15f50
movq -0xd0(%rbp), %rdi
callq 0x15f90
movq -0xd0(%rbp), %rdi
movq %rax, -0x38(%rbp)
callq 0x15fc0
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x15f50
movq -0xd0(%rbp), %rdi
callq 0x9b40
movq -0xc8(%rbp), %rdi
movl %eax, -0x44(%rbp)
callq 0x9b40
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
subl -0x44(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x48(%rbp), %eax
jge 0x15015
movq -0xc8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, -0xf0(%rbp)
movslq -0x50(%rbp), %rsi
callq 0x9b60
movq -0xf0(%rbp), %rsi
movl (%rax), %edx
leaq -0x70(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x132c0
movq -0xd8(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x14750
jmp 0x14fe7
leaq -0x70(%rbp), %rdi
callq 0x12d40
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x14f96
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x12d40
jmp 0x1524e
movq -0xc8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, -0xf8(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x9b60
movq -0xf8(%rbp), %rdi
movl (%rax), %esi
callq 0x133d0
movl $0x1, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x48(%rbp), %eax
jge 0x15084
movq -0xc8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, -0x100(%rbp)
movslq -0x50(%rbp), %rsi
callq 0x9b60
movq -0x100(%rbp), %rdi
movl (%rax), %esi
subl -0x50(%rbp), %esi
callq 0x133d0
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x15045
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x15142
movq -0xd8(%rbp), %rdi
movq -0x20(%rbp), %rax
movq %rax, -0x110(%rbp)
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x15e70
movq -0xd0(%rbp), %rdi
movq %rax, -0x118(%rbp)
movslq -0x50(%rbp), %rsi
callq 0x9b60
movq -0x118(%rbp), %rdi
movl (%rax), %eax
decl %eax
movslq %eax, %rsi
callq 0x13890
movq %rax, %rsi
leaq -0xa0(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x121a0
movq -0x110(%rbp), %rdi
movq -0x108(%rbp), %rsi
callq 0x13510
jmp 0x1510b
leaq -0xa0(%rbp), %rdi
callq 0x12d40
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x1508b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x12d40
jmp 0x1524e
cmpl $0x0, -0x44(%rbp)
jle 0x151ad
movq -0xd0(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x9b60
movq -0xd8(%rbp), %rdi
movl (%rax), %edx
subl $0x1, %edx
xorl %esi, %esi
callq 0x14950
movl $0x1, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x151ab
movq -0xd0(%rbp), %rdi
movslq -0x50(%rbp), %rsi
callq 0x9b60
movq -0xd8(%rbp), %rdi
movl (%rax), %edx
subl -0x50(%rbp), %edx
subl $0x1, %edx
xorl %esi, %esi
callq 0x14950
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x15172
jmp 0x151ad
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x15245
movq -0xd8(%rbp), %rsi
movq -0x20(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x120(%rbp)
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x14820
movq -0x128(%rbp), %rdi
movq -0x120(%rbp), %rsi
callq 0x13510
jmp 0x15201
leaq -0xc0(%rbp), %rdi
callq 0x12d40
movq -0xd8(%rbp), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x14950
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x151b4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x12d40
jmp 0x1524e
addq $0x130, %rsp            # imm = 0x130
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x2360
nopw (%rax,%rax)