// File: /workspace/github_cpp_makefile_star2_O3/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, 0x18(%rsp)
movq %rsi, %r12
movq %rdi, %r14
movq (%rsi), %r13
movq 0x8(%rsi), %rbp
cmpq %rbp, %r13
je 0xad38
movq %rbp, %rax
subq %r13, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r13, %rdi
movq %rbp, %rsi
callq 0xbeef
movq %r13, %rdi
movq %rbp, %rsi
callq 0xbfd2
movq 0x18(%rsp), %r15
movq (%r15), %rbp
movq 0x8(%r15), %r13
cmpq %r13, %rbp
movq %rbx, 0x10(%rsp)
je 0xad8e
movq %r13, %rax
subq %rbp, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbp, %rdi
movq %r13, %rsi
callq 0xbeef
movq %rbp, %rdi
movq %r13, %rsi
callq 0xbfd2
movq (%r15), %rax
movq %rax, 0x20(%rsp)
movq 0x8(%r15), %rax
movq %rax, 0x8(%rsp)
jmp 0xad98
movq %rbp, 0x20(%rsp)
movq %rbp, 0x8(%rsp)
movq (%r12), %rax
movq 0x8(%r12), %rcx
movq %rcx, %r15
subq %rax, %r15
shrq $0x2, %r15
testl %r15d, %r15d
jle 0xae0d
movl %r15d, %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
xorl %ebp, %ebp
leaq 0x68(%rsp), %r13
movq (%r12), %rax
movq 0x8(%r12), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rbp, %rdx
jbe 0xb019
movl (%rax,%rbp,4), %edx
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0x96b2
movq %r14, %rdi
movq %r13, %rsi
callq 0xa600
movq %r13, %rdi
callq 0x9292
incq %rbp
cmpq %rbp, %rbx
jne 0xadc0
movq (%r12), %rax
movq 0x8(%r12), %rcx
cmpq %rax, %rcx
je 0xb00c
movl (%rax), %esi
movq 0x10(%rsp), %rdi
callq 0x9778
cmpl $0x2, %r15d
jl 0xae6f
movl %r15d, %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl $0x1, %r13d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq (%r12), %rax
movq 0x8(%r12), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0xb02e
movl (%rax,%r13,4), %esi
addl %ebp, %esi
movq 0x10(%rsp), %rdi
callq 0x9778
incq %r13
decl %ebp
cmpq %r13, %rbx
jne 0xae3c
movq 0x8(%rsp), %rax
subq 0x20(%rsp), %rax
shrq $0x2, %rax
movq %rax, 0x8(%rsp)
testl %eax, %eax
jle 0xafa1
movq 0x8(%rsp), %rbp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
xorl %r12d, %r12d
leaq 0x28(%rsp), %r13
movq 0x10(%rsp), %rbx
movq 0x8(%r14), %rax
cmpq %rax, 0x10(%r14)
je 0xb00c
movq 0x18(%rsp), %rdx
movq (%rdx), %rcx
movq 0x8(%rdx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r12, %rdx
jbe 0xb000
movslq (%rcx,%r12,4), %rsi
decq %rsi
movq (%rax), %rcx
movq 0x8(%rax), %rdx
subq %rcx, %rdx
sarq $0x5, %rdx
cmpq %rsi, %rdx
jbe 0xb025
shlq $0x5, %rsi
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
movq (%rcx,%rsi), %rax
movq 0x8(%rcx,%rsi), %rdx
addq %rax, %rdx
movq %r13, %rdi
movq %rax, %rsi
callq 0x3f2e
movq %rbx, %rdi
movq %r13, %rsi
callq 0x9838
movq %r13, %rdi
callq 0x9292
incq %r12
cmpq %r12, %rbp
jne 0xaea2
cmpl $0x0, 0x8(%rsp)
movq 0x18(%rsp), %r13
jle 0xafa1
movq (%r13), %rax
cmpq %rax, 0x8(%r13)
je 0xb00c
movl (%rax), %edx
decl %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0xa858
cmpl $0x1, 0x8(%rsp)
je 0xafa1
movq 0x8(%rsp), %rbx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl $0x1, %r12d
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
movq (%r13), %rax
movq 0x8(%r13), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r12, %rdx
jbe 0xb000
movl (%rax,%r12,4), %edx
addl %ebp, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0xa858
incq %r12
decl %ebp
cmpq %r12, %rbx
jne 0xaf73
subl 0x8(%rsp), %r15d
testl %r15d, %r15d
movq 0x10(%rsp), %rbx
jle 0xafee
leaq 0x48(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0xa6bc
movq %rbx, %rdi
movq %r13, %rsi
callq 0x9838
movq %r13, %rdi
callq 0x9292
movq %r14, %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0xa858
decl %r15d
jne 0xafb5
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5351(%rip), %rdi      # 0x10358
movq %r12, %rsi
jmp 0xb038
leaq 0x5345(%rip), %rdi      # 0x10358
xorl %esi, %esi
xorl %edx, %edx
jmp 0xb038
leaq 0x5338(%rip), %rdi      # 0x10358
movq %rbp, %rsi
jmp 0xb038
leaq 0x532c(%rip), %rdi      # 0x10358
jmp 0xb038
leaq 0x5323(%rip), %rdi      # 0x10358
movq %r13, %rsi
xorl %eax, %eax
callq 0x21f0
jmp 0xb043
jmp 0xb043
movq %rax, %rbx
movq %r13, %rdi
callq 0x9292
movq %rbx, %rdi
callq 0x2280