// File: /workspace/github_cpp_makefile_star2_O2/MichaelXanth[P]RPG_Game/Market/Market.cpp
// Function: Market::AddLightingSpells(int const&)
void Market::AddLightingSpells(const int& num)
{
    string spellName;
    LightingSpell* tmpLightingSpell;

    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.lightingSpellsNames[rand() % name.lightingSpellsNames.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;
        }

        tmpLightingSpell = new LightingSpell(spellName , ((rand() % 2) + 3) * level, (rand() % 4) + 1 , level, tmpMinDamage , tmpMaxDamage,
                                             ((rand() % 4) + 1) * level , (unsigned int)((rand() % 6) + 1) * ((level / 25) + 1));

        lightingSpellsArray.push_back(tmpLightingSpell);

        if (minSpellPrice > tmpLightingSpell->GetPrice())
            minSpellPrice = tmpLightingSpell->GetPrice();
    }

    if (mostItems < lightingSpellsArray.size())
        mostItems = lightingSpellsArray.size();

    if (minPrice > minSpellPrice)
        minPrice = minSpellPrice;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, -0x70(%rbp)
movq %rdi, %r13
leaq -0x88(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xa8(%rdi), %rax
movq %rax, -0x60(%rbp)
xorl %ecx, %ecx
pushq $0x2
popq %r14
pushq $0x4
popq %rbx
movq %rdi, -0x68(%rbp)
movq -0x70(%rbp), %rax
cmpl (%rax), %ecx
jge 0x13100
movq %rcx, -0x78(%rbp)
callq 0x3060
cvtsi2sd %eax, %xmm0
divsd 0x82ee(%rip), %xmm0     # 0x1b260
movsd %xmm0, -0x38(%rbp)
callq 0x3060
movsd 0x708c(%rip), %xmm0     # 0x1a010
movsd -0x38(%rbp), %xmm1
ucomisd %xmm1, %xmm0
pushq $0x46
popq %rcx
pushq $0x1e
popq %rdx
cmoval %edx, %ecx
cltd
idivl %ecx
leal 0x1(%rdx), %eax
addl $0x1f, %edx
ucomisd %xmm1, %xmm0
cmoval %eax, %edx
movl %edx, -0x2c(%rbp)
callq 0x3060
cltq
movq 0x90(%r13), %rsi
movq 0x98(%r13), %rcx
subq %rsi, %rcx
sarq $0x5, %rcx
xorl %edx, %edx
divq %rcx
shlq $0x5, %rdx
addq %rdx, %rsi
leaq -0x98(%rbp), %rdi
callq 0x30f0
callq 0x3060
cltd
idivl %r14d
movl %edx, %r15d
addl $0x2, %r15d
imull -0x2c(%rbp), %r15d
callq 0x3060
cltd
idivl %ebx
movl %edx, %r12d
addl $0x2, %r12d
imull -0x2c(%rbp), %r12d
cmpl %r12d, %r15d
je 0x12fdd
pushq $0x48
popq %rdi
callq 0x31e0
movq %rax, -0x38(%rbp)
cmpl %r15d, %r12d
movl %r15d, %r13d
cmovgl %r12d, %r13d
cmovll %r12d, %r15d
callq 0x3060
cltd
idivl %r14d
addl $0x3, %edx
imull -0x2c(%rbp), %edx
movl %edx, -0x58(%rbp)
callq 0x3060
cltd
idivl %ebx
incl %edx
movl %edx, -0x54(%rbp)
movl %r15d, -0x50(%rbp)
movl %r13d, -0x4c(%rbp)
callq 0x3060
cltd
idivl %ebx
incl %edx
imull -0x2c(%rbp), %edx
movl %edx, -0x48(%rbp)
callq 0x3060
cltd
pushq $0x6
popq %rcx
idivl %ecx
movl %edx, %ecx
incl %ecx
movl -0x2c(%rbp), %eax
xorl %edx, %edx
pushq $0x19
popq %rsi
divl %esi
incl %eax
imull %ecx, %eax
movl %eax, -0x44(%rbp)
subq $0x8, %rsp
movq -0x38(%rbp), %r15
movq %r15, %rdi
leaq -0x98(%rbp), %rsi
leaq -0x58(%rbp), %rdx
leaq -0x54(%rbp), %rcx
leaq -0x2c(%rbp), %r8
leaq -0x50(%rbp), %r9
leaq -0x44(%rbp), %rax
pushq %rax
leaq -0x48(%rbp), %rax
pushq %rax
leaq -0x4c(%rbp), %rax
pushq %rax
callq 0x19778
addq $0x20, %rsp
movq %r15, -0x40(%rbp)
movq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x113ec
movq -0x68(%rbp), %r13
movl 0x1e0(%r13), %r15d
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
cmpl %eax, %r15d
jbe 0x130f5
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movl %eax, 0x1e0(%r13)
movq -0x78(%rbp), %rcx
incl %ecx
jmp 0x12f51
movl 0x1ec(%r13), %ecx
movq 0xb0(%r13), %rax
subq 0xa8(%r13), %rax
sarq $0x3, %rax
cmpq %rcx, %rax
jbe 0x13125
movl %eax, 0x1ec(%r13)
movl 0x1e0(%r13), %eax
cmpl %eax, 0x1e8(%r13)
jbe 0x1313c
movl %eax, 0x1e8(%r13)
leaq -0x98(%rbp), %rdi
callq 0x30c0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r15, %rdi
callq 0x31b0
jmp 0x13167
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x30c0
movq %rbx, %rdi
callq 0x3330
nop