// File: MichaelXanth[P]RPG_Game/Market/Market.cpp
// Function: Market::AddWeapons(int const&)
void Market::AddWeapons(const int& num)
{
    string weaponName;
    Weapon* tmpWeapon;

    for (int i = 0; i < num; i++)
    {
        unsigned int level;
        bool hand = rand() % 2;
        int wdamage;

        if ( ((double)rand() / RAND_MAX) < 0.7 )
            level = rand() % 30 + 1;
        else
            level = rand() % 70 + 31;

        weaponName = name.weaponsNames[rand() % name.weaponsNames.size()];

        wdamage = (unsigned int)((hand + 1.0) * level * ((double)(rand() % 2) + 1) / 2.0);

        tmpWeapon = new Weapon(weaponName , ((rand() % 2) + 3) * level , level , wdamage , hand);

        weaponsArray.push_back(tmpWeapon);

        if (minItemPrice > tmpWeapon->GetPrice())
            minItemPrice = tmpWeapon->GetPrice();
    }

    if (mostItems < weaponsArray.size())
        mostItems = weaponsArray.size();

    if (minPrice > minItemPrice)
        minPrice = minItemPrice;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4380
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x303c9
callq 0x40a0
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
setne %al
andb $0x1, %al
movb %al, -0x41(%rbp)
callq 0x40a0
cvtsi2sd %eax, %xmm1
movsd 0xd09d(%rip), %xmm0     # 0x3d260
divsd %xmm0, %xmm1
movsd 0xbe41(%rip), %xmm0     # 0x3c010
ucomisd %xmm1, %xmm0
jbe 0x301ea
callq 0x40a0
movl $0x1e, %ecx
cltd
idivl %ecx
addl $0x1, %edx
movl %edx, -0x40(%rbp)
jmp 0x301fd
callq 0x40a0
movl $0x46, %ecx
cltd
idivl %ecx
addl $0x1f, %edx
movl %edx, -0x40(%rbp)
movq -0x68(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x78(%rbp)
callq 0x40a0
movq -0x78(%rbp), %rdi
cltq
movq %rax, -0x70(%rbp)
callq 0x5010
movq -0x78(%rbp), %rdi
movq %rax, %rcx
movq -0x70(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
callq 0x4ff0
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x4050
jmp 0x30243
movzbl -0x41(%rbp), %eax
andl $0x1, %eax
cvtsi2sd %eax, %xmm0
movsd 0xff12(%rip), %xmm1     # 0x40168
movsd %xmm1, -0x90(%rbp)
addsd %xmm1, %xmm0
movl -0x40(%rbp), %eax
cvtsi2sd %rax, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
callq 0x40a0
movsd -0x90(%rbp), %xmm2
movsd -0x88(%rbp), %xmm0
movl %eax, %edx
shrl $0x1f, %edx
movl %eax, %ecx
addl %edx, %ecx
andl $-0x2, %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd 0xfec3(%rip), %xmm1     # 0x40170
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, -0x48(%rbp)
movl $0x38, %edi
callq 0x4270
movq %rax, -0x80(%rbp)
jmp 0x302c9
callq 0x40a0
movq -0x80(%rbp), %rdi
movl %eax, %ecx
movl %ecx, %eax
shrl $0x1f, %eax
movl %ecx, %edx
addl %eax, %edx
andl $-0x2, %edx
movl %ecx, %eax
negl %edx
movl %edx, %ecx
leal 0x3(%rax,%rcx), %eax
movl -0x40(%rbp), %ecx
imull %ecx, %eax
movl %eax, -0x58(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x5c(%rbp)
leaq -0x30(%rbp), %rsi
leaq -0x58(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x5c(%rbp), %r8
leaq -0x41(%rbp), %r9
callq 0x1e520
jmp 0x30314
movq -0x68(%rbp), %rdi
movq -0x80(%rbp), %rax
movq %rax, -0x38(%rbp)
addq $0xf0, %rdi
leaq -0x38(%rbp), %rsi
callq 0x27030
jmp 0x30332
movq -0x68(%rbp), %rax
movl 0x1e4(%rax), %eax
movl %eax, -0x98(%rbp)
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movl %eax, -0x94(%rbp)
jmp 0x30357
movl -0x98(%rbp), %eax
movl -0x94(%rbp), %ecx
cmpl %ecx, %eax
jbe 0x303b9
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movl %eax, -0x9c(%rbp)
jmp 0x3037c
movq -0x68(%rbp), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, 0x1e4(%rax)
jmp 0x303b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x30446
movq -0x80(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
callq 0x4240
jmp 0x30446
jmp 0x303bb
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3018b
movq -0x68(%rbp), %rdi
movl 0x1ec(%rdi), %eax
movq %rax, -0xa8(%rbp)
addq $0xf0, %rdi
callq 0x26e80
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jae 0x30412
movq -0x68(%rbp), %rdi
addq $0xf0, %rdi
callq 0x26e80
movq %rax, %rcx
movq -0x68(%rbp), %rax
movl %ecx, 0x1ec(%rax)
movq -0x68(%rbp), %rcx
movl 0x1e8(%rcx), %eax
cmpl 0x1e4(%rcx), %eax
jbe 0x30434
movq -0x68(%rbp), %rax
movl 0x1e4(%rax), %ecx
movl %ecx, 0x1e8(%rax)
leaq -0x30(%rbp), %rdi
callq 0x4160
addq $0xb0, %rsp
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x4160
movq -0x50(%rbp), %rdi
callq 0x4440
nopl (%rax,%rax)