// File: MichaelXanth[P]RPG_Game/Market/Market.cpp
// Function: Market::AddIceSpells(int const&)
void Market::AddIceSpells(const int& num)
{
    string spellName;
    IceSpell* tmpIceSpell;

    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.iceSpellsNames[rand() % name.iceSpellsNames.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;
        }

        tmpIceSpell = new IceSpell(spellName , ((rand() % 2) + 3) * level, (rand() % 4) + 1 , level, tmpMinDamage , tmpMaxDamage,
                                  ((rand() % 4) + 1) * level , ((rand() % 2) + 1) * level);

        iceSpellsArray.push_back(tmpIceSpell);

        if (minSpellPrice > tmpIceSpell->GetPrice())
            minSpellPrice = tmpIceSpell->GetPrice();
    }

    if (mostItems < iceSpellsArray.size())
        mostItems = iceSpellsArray.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 0x300ca
callq 0x40a0
cvtsi2sd %eax, %xmm1
movsd 0xd425(%rip), %xmm0     # 0x3d260
divsd %xmm0, %xmm1
movsd 0xc1c9(%rip), %xmm0     # 0x3c010
ucomisd %xmm1, %xmm0
jbe 0x2fe62
callq 0x40a0
movl $0x1e, %ecx
cltd
idivl %ecx
addl $0x1, %edx
movl %edx, -0x40(%rbp)
jmp 0x2fe75
callq 0x40a0
movl $0x46, %ecx
cltd
idivl %ecx
addl $0x1f, %edx
movl %edx, -0x40(%rbp)
movq -0x78(%rbp), %rax
addq $0x60, %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 0x2fec4
jmp 0x2fec6
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 0x2fec6
movl -0x48(%rbp), %eax
cmpl -0x44(%rbp), %eax
jge 0x2ff2d
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 0x2ff2d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x30147
movl $0x48, %edi
callq 0x4270
movq %rax, -0x90(%rbp)
jmp 0x2ff40
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
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)
callq 0x40a0
movq -0x90(%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 0x1(%rax,%rcx), %eax
movl -0x40(%rbp), %ecx
imull %ecx, %eax
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 0x3b1e0
jmp 0x30020
movq -0x78(%rbp), %rdi
movq -0x90(%rbp), %rax
movq %rax, -0x38(%rbp)
addq $0xd8, %rdi
leaq -0x38(%rbp), %rsi
callq 0x26ee0
jmp 0x30041
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 0x30066
movl -0x98(%rbp), %eax
movl -0x94(%rbp), %ecx
cmpl %ecx, %eax
jbe 0x300ba
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movl %eax, -0x9c(%rbp)
jmp 0x3008b
movq -0x78(%rbp), %rax
movl -0x9c(%rbp), %ecx
movl %ecx, 0x1e0(%rax)
jmp 0x300ba
movq -0x90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
callq 0x4240
jmp 0x30147
jmp 0x300bc
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x2fe1b
movq -0x78(%rbp), %rdi
movl 0x1ec(%rdi), %eax
movq %rax, -0xa8(%rbp)
addq $0xd8, %rdi
callq 0x26e60
movq %rax, %rcx
movq -0xa8(%rbp), %rax
cmpq %rcx, %rax
jae 0x30113
movq -0x78(%rbp), %rdi
addq $0xd8, %rdi
callq 0x26e60
movq %rax, %rcx
movq -0x78(%rbp), %rax
movl %ecx, 0x1ec(%rax)
movq -0x78(%rbp), %rcx
movl 0x1e8(%rcx), %eax
cmpl 0x1e0(%rcx), %eax
jbe 0x30135
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
nopl (%rax)