// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movq %rdi, %r14
leaq -0x78(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rsi, -0x68(%rbp)
cmpl $0x0, (%rsi)
jle 0x19857
leaq 0xa8(%r14), %rax
movq %rax, -0x60(%rbp)
xorl %r15d, %r15d
callq 0x3060
cvtsi2sd %eax, %xmm0
divsd 0xac15(%rip), %xmm0     # 0x24260
movsd %xmm0, -0x38(%rbp)
callq 0x3060
movsd 0x99b3(%rip), %xmm0     # 0x23010
movsd -0x38(%rbp), %xmm1
ucomisd %xmm1, %xmm0
movl $0x46, %ecx
movl $0x1e, %edx
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(%r14), %rsi
movq 0x98(%r14), %rcx
subq %rsi, %rcx
sarq $0x5, %rcx
xorl %edx, %edx
divq %rcx
shlq $0x5, %rdx
addq %rdx, %rsi
leaq -0x88(%rbp), %rdi
callq 0x30c0
callq 0x3060
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
andl $-0x2, %ecx
negl %ecx
leal (%rax,%rcx), %r12d
addl $0x2, %r12d
imull -0x2c(%rbp), %r12d
callq 0x3060
leal 0x3(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
andl $-0x4, %ecx
negl %ecx
leal (%rax,%rcx), %ebx
addl $0x2, %ebx
imull -0x2c(%rbp), %ebx
cmpl %ebx, %r12d
je 0x196ba
movl $0x48, %edi
callq 0x31a0
movq %rax, %r13
movq %r15, -0x38(%rbp)
movq %r14, %r15
cmpl %r12d, %ebx
movl %r12d, %r14d
cmovgl %ebx, %r14d
cmovll %ebx, %r12d
callq 0x3060
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
andl $-0x2, %ecx
negl %ecx
addl %ecx, %eax
addl $0x3, %eax
imull -0x2c(%rbp), %eax
movl %eax, -0x58(%rbp)
callq 0x3060
leal 0x3(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
andl $-0x4, %ecx
negl %ecx
addl %ecx, %eax
incl %eax
movl %eax, -0x54(%rbp)
movl %r12d, -0x50(%rbp)
movl %r14d, -0x4c(%rbp)
callq 0x3060
leal 0x3(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
andl $-0x4, %ecx
negl %ecx
addl %ecx, %eax
incl %eax
imull -0x2c(%rbp), %eax
movl %eax, -0x48(%rbp)
callq 0x3060
cltq
imulq $0x2aaaaaab, %rax, %rcx # imm = 0x2AAAAAAB
movq %rcx, %rdx
shrq $0x3f, %rdx
shrq $0x20, %rcx
addl %edx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,2), %ecx
negl %ecx
addl %ecx, %eax
incl %eax
movl -0x2c(%rbp), %ecx
imulq $0x51eb851f, %rcx, %rcx # imm = 0x51EB851F
shrq $0x23, %rcx
incl %ecx
imull %eax, %ecx
movl %ecx, -0x44(%rbp)
subq $0x8, %rsp
movq %r13, %rdi
leaq -0x88(%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 0x22ca4
addq $0x20, %rsp
movq %r13, -0x40(%rbp)
movq %r15, %r14
movq 0xb0(%r15), %rsi
cmpq 0xb8(%r15), %rsi
je 0x19810
movq %r13, (%rsi)
addq $0x8, 0xb0(%r14)
movq -0x38(%rbp), %r15
jmp 0x19821
movq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0x17d08
movq -0x38(%rbp), %r15
movl 0x1e0(%r14), %ebx
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
cmpl %eax, %ebx
jbe 0x19847
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movl %eax, 0x1e0(%r14)
incl %r15d
movq -0x68(%rbp), %rax
cmpl (%rax), %r15d
jl 0x1963a
movl 0x1ec(%r14), %ecx
movq 0xb0(%r14), %rax
subq 0xa8(%r14), %rax
sarq $0x3, %rax
cmpq %rcx, %rax
jbe 0x1987c
movl %eax, 0x1ec(%r14)
movl 0x1e0(%r14), %eax
cmpl %eax, 0x1e8(%r14)
jbe 0x19893
movl %eax, 0x1e8(%r14)
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x198a8
callq 0x3170
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq %r13, %rdi
callq 0x3170
jmp 0x198c7
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x198dc
callq 0x3170
movq %rbx, %rdi
callq 0x32f0