// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, 0x10(%rsp)
movq (%rsi), %rdi
movq 0x8(%rsi), %rsi
callq 0x9d73
movq (%r14), %rdi
movq 0x8(%r14), %rsi
callq 0x9d73
movq 0x8(%r14), %rax
movq %r14, 0x18(%rsp)
subq (%r14), %rax
shrq $0x2, %rax
movq 0x8(%r13), %rcx
subq (%r13), %rcx
shrq $0x2, %rcx
movl %ecx, %r14d
movq %rax, 0x20(%rsp)
subl %eax, %r14d
xorl %ebp, %ebp
testl %ecx, %ecx
movl $0x0, %r15d
movq %rcx, 0x8(%rsp)
cmovgl %ecx, %r15d
leaq 0x68(%rsp), %r12
movq %r13, %rdi
cmpq %rbp, %r15
je 0x9043
movq %rbp, %rsi
callq 0x5358
movl (%rax), %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x7ff6
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x8b28
movq %r12, %rdi
callq 0x7d12
incq %rbp
jmp 0x900c
xorl %esi, %esi
callq 0x5358
movl (%rax), %esi
movq %rbx, %rdi
callq 0x806a
movslq 0x8(%rsp), %r15
pushq $0x1
popq %r12
pushq $-0x1
popq %rbp
cmpq %r15, %r12
jge 0x9083
movq %r13, %rdi
movq %r12, %rsi
callq 0x5358
movl (%rax), %esi
addl %ebp, %esi
movq %rbx, %rdi
callq 0x806a
incq %r12
decl %ebp
jmp 0x9060
movq 0x10(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x8(%rsp)
xorl %ebp, %ebp
movq 0x20(%rsp), %rax
testl %eax, %eax
movl $0x0, %r13d
cmovgl %eax, %r13d
leaq 0x48(%rsp), %r12
cmpq %rbp, %r13
je 0x90fb
movq 0x8(%rsp), %rdi
xorl %esi, %esi
callq 0x9940
movq %rax, %r15
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x5358
movslq (%rax), %rsi
decq %rsi
movq %r15, %rdi
callq 0x8396
movq %r12, %rdi
movq %rax, %rsi
callq 0x2200
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8118
movq %r12, %rdi
callq 0x7d12
incq %rbp
jmp 0x90a9
movq 0x20(%rsp), %r13
testl %r13d, %r13d
movq 0x10(%rsp), %r15
jle 0x9159
movq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x5358
movl (%rax), %edx
decl %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x8c4c
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
pushq $0x1
popq %r12
pushq $-0x2
popq %rbp
cmpq %r12, %r13
je 0x9159
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x5358
movl (%rax), %edx
addl %ebp, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x8c4c
incq %r12
decl %ebp
jmp 0x9132
xorl %eax, %eax
testl %r14d, %r14d
cmovlel %eax, %r14d
leaq 0x28(%rsp), %r12
pushq $0x1
popq %rbp
subl $0x1, %r14d
jb 0x91a0
movq %r12, %rdi
movq %r15, %rsi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x8ba0
movq %rbx, %rdi
movq %r12, %rsi
callq 0x8118
movq %r12, %rdi
callq 0x7d12
movq %r15, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x8c4c
jmp 0x916a
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x91b6
jmp 0x91b6
movq %rax, %rbx
movq %r12, %rdi
callq 0x7d12
movq %rbx, %rdi
callq 0x22a0
nop