// File: MichaelXanth[P]RPG_Game/Market/Market.cpp
// Function: Market::AddFireSpells(int const&)
void Market::AddFireSpells(const int& num)
{
    string spellName;
    FireSpell* tmpFireSpell;

    for (int i = 0; i < num; i++)
    {
        unsigned int level;
        int tmpMinDamage;
        int tmpMaxDamage;

        if ( ((double)rand() / RAND_MAX) < 0.7 )
            level = rand() % 30 + 1;
        else
            level = rand() % 70 + 31;

        spellName = name.fireSpellsNames[rand() % name.fireSpellsNames.size()];

        do {
            tmpMinDamage = ((rand() % 2) + 2) * level;
            tmpMaxDamage = ((rand() % 4) + 2) * level;
        } while(tmpMinDamage == tmpMaxDamage);

        if (tmpMaxDamage < tmpMinDamage)
        {
            int temp     = tmpMinDamage;
            tmpMinDamage = tmpMaxDamage;
            tmpMaxDamage = temp;
        }

        tmpFireSpell = new FireSpell(spellName , ((rand() % 2) + 3) * level, (rand() % 4) + 1 , level, tmpMinDamage , tmpMaxDamage,
                                    ((rand() % 4) + 1) * level , (unsigned int)((3.0 / 2.0) * level));

        fireSpellsArray.push_back(tmpFireSpell);

        if (minSpellPrice > tmpFireSpell->GetPrice())
            minSpellPrice = tmpFireSpell->GetPrice();
    }

    if (mostItems < fireSpellsArray.size())
        mostItems = fireSpellsArray.size();

    if (minPrice > minSpellPrice)
        minPrice = minSpellPrice;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4380
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x2fd60
callq 0x40a0
cvtsi2sd %eax, %xmm1
movsd 0xd785(%rip), %xmm0     # 0x3d260
divsd %xmm0, %xmm1
movsd 0xc529(%rip), %xmm0     # 0x3c010
ucomisd %xmm1, %xmm0
jbe 0x2fb02
callq 0x40a0
movl $0x1e, %ecx
cltd
idivl %ecx
addl $0x1, %edx
movl %edx, -0x40(%rbp)
jmp 0x2fb15
callq 0x40a0
movl $0x46, %ecx
cltd
idivl %ecx
addl $0x1f, %edx
movl %edx, -0x40(%rbp)
movq -0x78(%rbp), %rax
addq $0x78, %rax
movq %rax, -0x88(%rbp)
callq 0x40a0
movq -0x88(%rbp), %rdi
cltq
movq %rax, -0x80(%rbp)
callq 0x5010
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movq -0x80(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
callq 0x4ff0
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x4050
jmp 0x2fb64
jmp 0x2fb66
callq 0x40a0
movl $0x2, %ecx
cltd
idivl %ecx
movl %edx, %eax
addl $0x2, %eax
imull -0x40(%rbp), %eax
movl %eax, -0x44(%rbp)
callq 0x40a0
movl $0x4, %ecx
cltd
idivl %ecx
movl %edx, %eax
addl $0x2, %eax
imull -0x40(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x48(%rbp), %eax
je 0x2fb66
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x2fbcd
movl -0x44(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x58(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0x2fbcd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2fddd
movl $0x48, %edi
callq 0x4270
movq %rax, -0x90(%rbp)
jmp 0x2fbe0
callq 0x40a0
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, -0x5c(%rbp)
callq 0x40a0
movl %eax, %edx
movl %edx, %ecx
addl $0x3, %ecx
testl %edx, %edx
movl %edx, %eax
cmovsl %ecx, %eax
andl $-0x4, %eax
negl %eax
movl %eax, %ecx
movl %edx, %eax
leal 0x1(%rax,%rcx), %eax
movl %eax, -0x60(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x68(%rbp)
callq 0x40a0
movq -0x90(%rbp), %rdi
movl %eax, %edx
movl %edx, %ecx
addl $0x3, %ecx
testl %edx, %edx
movl %edx, %eax
cmovsl %ecx, %eax
andl $-0x4, %eax
negl %eax
movl %eax, %ecx
movl %edx, %eax
leal 0x1(%rax,%rcx), %eax
movl -0x40(%rbp), %ecx
imull %ecx, %eax
movl %eax, -0x6c(%rbp)
movl -0x40(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0x104eb(%rip), %xmm1    # 0x40160
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, -0x70(%rbp)
movq %rsp, %rax
leaq -0x70(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq -0x6c(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq -0x68(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x30(%rbp), %rsi
leaq -0x5c(%rbp), %rdx
leaq -0x60(%rbp), %rcx
leaq -0x40(%rbp), %r8
leaq -0x64(%rbp), %r9
callq 0x3b2f0
jmp 0x2fcb6
movq -0x78(%rbp), %rdi
movq -0x90(%rbp), %rax
movq %rax, -0x38(%rbp)
addq $0xc0, %rdi
leaq -0x38(%rbp), %rsi
callq 0x26f50
jmp 0x2fcd7
movq -0x78(%rbp), %rax
movl 0x1e0(%rax), %eax
movl %eax, -0x98(%rbp)
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0x94(%rbp)
jmp 0x2fcfc
movl -0x98(%rbp), %eax
movl -0x94(%rbp), %ecx
cmpl %ecx, %eax
jbe 0x2fd50
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0x9c(%rbp)
jmp 0x2fd21
movq -0x78(%rbp), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, 0x1e0(%rax)
jmp 0x2fd50
movq -0x90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
callq 0x4240
jmp 0x2fddd
jmp 0x2fd52
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2fabb
movq -0x78(%rbp), %rdi
movl 0x1ec(%rdi), %eax
movq %rax, -0xa8(%rbp)
addq $0xc0, %rdi
callq 0x26e40
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jae 0x2fda9
movq -0x78(%rbp), %rdi
addq $0xc0, %rdi
callq 0x26e40
movq %rax, %rcx
movq -0x78(%rbp), %rax
movl %ecx, 0x1ec(%rax)
movq -0x78(%rbp), %rcx
movl 0x1e8(%rcx), %eax
cmpl 0x1e0(%rcx), %eax
jbe 0x2fdcb
movq -0x78(%rbp), %rax
movl 0x1e0(%rax), %ecx
movl %ecx, 0x1e8(%rax)
leaq -0x30(%rbp), %rdi
callq 0x4160
addq $0xc0, %rsp
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x4160
movq -0x50(%rbp), %rdi
callq 0x4440
nop