// File: /workspace/github_cpp_makefile_star2_O1/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 $0x78, %rsp
movq %rcx, (%rsp)
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
movq (%rsi), %r13
movq 0x8(%rsi), %rbp
cmpq %rbp, %r13
je 0xad96
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 0xbf59
movq %r13, %rdi
movq %rbp, %rsi
callq 0xc03c
movq (%rbx), %r13
movq 0x8(%rbx), %rbp
cmpq %rbp, %r13
je 0xadcf
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 0xbf59
movq %r13, %rdi
movq %rbp, %rsi
callq 0xc03c
movq 0x8(%rbx), %rax
movq %rbx, 0x10(%rsp)
subq (%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r12), %r15
subq (%r12), %r15
shrq $0x2, %r15
testl %r15d, %r15d
jle 0xae45
movl %r15d, %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
xorl %ebp, %ebp
leaq 0x58(%rsp), %r13
movq (%r12), %rax
movq 0x8(%r12), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rbp, %rdx
jbe 0xb03c
movl (%rax,%rbp,4), %edx
movq %r13, %rdi
movq (%rsp), %rsi
callq 0x96fa
movq %r14, %rdi
movq %r13, %rsi
callq 0xa626
movq %r13, %rdi
callq 0x92e2
incq %rbp
cmpq %rbp, %rbx
jne 0xae02
movq (%r12), %rax
cmpq %rax, 0x8(%r12)
je 0xb07f
movl (%rax), %esi
movq (%rsp), %rdi
callq 0x97c0
cmpl $0x2, %r15d
jl 0xaeab
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 0xb06e
movl (%rax,%r13,4), %esi
addl %ebp, %esi
movq (%rsp), %rdi
callq 0x97c0
incq %r13
decl %ebp
cmpq %r13, %rbx
jne 0xae79
movq 0x8(%rsp), %rax
shrq $0x2, %rax
movq %rax, 0x8(%rsp)
testl %eax, %eax
movq 0x10(%rsp), %rbx
jle 0xaf64
movq 0x8(%rsp), %rbp
andl $0x7fffffff, %ebp       # imm = 0x7FFFFFFF
xorl %r12d, %r12d
leaq 0x18(%rsp), %r13
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
subq %rax, %rcx
je 0xb048
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r12, %rdx
jbe 0xb030
movslq (%rcx,%r12,4), %rsi
decq %rsi
movq (%rax), %rcx
movq 0x8(%rax), %rdx
subq %rcx, %rdx
sarq $0x5, %rdx
cmpq %rsi, %rdx
jbe 0xb065
shlq $0x5, %rsi
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq (%rcx,%rsi), %rax
movq 0x8(%rcx,%rsi), %rdx
addq %rax, %rdx
movq %r13, %rdi
movq %rax, %rsi
callq 0x3f5e
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x9880
movq %r13, %rdi
callq 0x92e2
incq %r12
cmpq %r12, %rbp
jne 0xaed9
movq 0x8(%rsp), %r13
testl %r13d, %r13d
jle 0xafda
movq 0x10(%rsp), %rcx
movq (%rcx), %rax
cmpq %rax, 0x8(%rcx)
je 0xb07f
movl (%rax), %edx
decl %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0xa8ae
cmpl $0x1, %r13d
je 0xafda
movl %r13d, %ebx
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movl $0x1, %r12d
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
movq 0x10(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %r12, %rdx
jbe 0xb030
movl (%rax,%r12,4), %edx
addl %ebp, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0xa8ae
incq %r12
decl %ebp
cmpq %r12, %rbx
jne 0xafa8
subl %r13d, %r15d
testl %r15d, %r15d
jle 0xb021
leaq 0x38(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0xa6f2
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x9880
movq %r13, %rdi
callq 0x92e2
movq %r14, %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0xa8ae
decl %r15d
jne 0xafe7
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5311(%rip), %rdi      # 0x10348
movq %r12, %rsi
jmp 0xb078
leaq 0x5305(%rip), %rdi      # 0x10348
movq %rbp, %rsi
jmp 0xb078
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
leaq 0x52e7(%rip), %rdi      # 0x10348
xorl %esi, %esi
jmp 0xb078
leaq 0x52dc(%rip), %rdi      # 0x10348
jmp 0xb078
leaq 0x52d3(%rip), %rdi      # 0x10348
movq %r13, %rsi
xorl %eax, %eax
callq 0x21f0
leaq 0x52c2(%rip), %rdi      # 0x10348
xorl %esi, %esi
xorl %edx, %edx
jmp 0xb078
jmp 0xb090
jmp 0xb090
movq %rax, %rbx
movq %r13, %rdi
callq 0x92e2
movq %rbx, %rdi
callq 0x2280
nop