// File: MichaelXanth[P]RPG_Game/Market/Market.cpp
// Function: Market::AddPotions(int const&)
void Market::AddPotions(const int& num)
{
    string potionName;
    Potion* tmpPotion;

    for (int i = 0; i < num; i++)
    {
        unsigned int level;
        float posibility;

        if ( ((double)rand() / RAND_MAX) < 0.7 )
            level = rand() % 30 + 1;
        else
            level = rand() % 70 + 31;

        potionName = name.potionsNames[rand() % name.potionsNames.size()];

        if ((double)(posibility = rand() % 100) < 100.0 / 3)
            tmpPotion = new Potion(potionName , ((rand() % 2) + 2) * level , level , (unsigned int)(((rand() % 6) + 1.0) * (level / 10.0) + 1) , 0 , 0);
        else if ((double)posibility < 200.0 / 3)
            tmpPotion = new Potion(potionName , ((rand() % 2) + 2) * level , level , 0 , (unsigned int)(((rand() % 6) + 1.0) * (level / 10.0) + 1) , 0);
        else
            tmpPotion = new Potion(potionName , ((rand() % 2) + 2) * level , level , 0 , 0 , (float)(3.0 * ((level / 25.0) + 1)) / 100.0);

        potionsArray.push_back(tmpPotion);

        if (minItemPrice > tmpPotion->GetPrice())
            minItemPrice = tmpPotion->GetPrice();
    }

    if (mostItems < potionsArray.size())
        mostItems = potionsArray.size();

    if (minPrice > minItemPrice)
        minPrice = minItemPrice;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4380
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl (%rcx), %eax
jge 0x30901
callq 0x40a0
cvtsi2sd %eax, %xmm1
movsd 0xcdb2(%rip), %xmm0     # 0x3d260
divsd %xmm0, %xmm1
movsd 0xbb56(%rip), %xmm0     # 0x3c010
ucomisd %xmm1, %xmm0
jbe 0x304d5
callq 0x40a0
movl $0x1e, %ecx
cltd
idivl %ecx
addl $0x1, %edx
movl %edx, -0x40(%rbp)
jmp 0x304e8
callq 0x40a0
movl $0x46, %ecx
cltd
idivl %ecx
addl $0x1f, %edx
movl %edx, -0x40(%rbp)
movq -0x90(%rbp), %rax
addq $0x48, %rax
movq %rax, -0xa0(%rbp)
callq 0x40a0
movq -0xa0(%rbp), %rdi
cltq
movq %rax, -0x98(%rbp)
callq 0x5010
movq -0xa0(%rbp), %rdi
movq %rax, %rcx
movq -0x98(%rbp), %rax
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
callq 0x4ff0
movq %rax, %rsi
leaq -0x30(%rbp), %rdi
callq 0x4050
jmp 0x30540
callq 0x40a0
movl $0x64, %ecx
cltd
idivl %ecx
cvtsi2ss %edx, %xmm0
movss %xmm0, -0x44(%rbp)
cvtss2sd %xmm0, %xmm1
movsd 0xfc16(%rip), %xmm0     # 0x40178
ucomisd %xmm1, %xmm0
jbe 0x30676
movl $0x40, %edi
callq 0x4270
movq %rax, -0xa8(%rbp)
jmp 0x3057f
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 0x2(%rax,%rcx), %eax
movl -0x40(%rbp), %ecx
imull %ecx, %eax
movl %eax, -0x58(%rbp)
callq 0x40a0
movq -0xa8(%rbp), %rdi
movslq %eax, %rcx
imulq $0x2aaaaaab, %rcx, %rdx # imm = 0x2AAAAAAB
movq %rdx, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rdx
addl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0xfb8b(%rip), %xmm1     # 0x40168
addsd %xmm1, %xmm0
movl -0x40(%rbp), %eax
cvtsi2sd %rax, %xmm2
movsd 0xccff(%rip), %xmm3     # 0x3d2f0
divsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movq %rsp, %rax
leaq -0x64(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x30(%rbp), %rsi
leaq -0x58(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x5c(%rbp), %r8
leaq -0x60(%rbp), %r9
callq 0x1e6f0
jmp 0x30638
movq -0xa8(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x30878
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x3098d
movq -0xa8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
callq 0x4240
jmp 0x3098d
movss -0x44(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0xfaf9(%rip), %xmm0     # 0x40180
ucomisd %xmm1, %xmm0
jbe 0x3078a
movl $0x40, %edi
callq 0x4270
movq %rax, -0xb0(%rbp)
jmp 0x306a4
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 0x2(%rax,%rcx), %eax
movl -0x40(%rbp), %ecx
imull %ecx, %eax
movl %eax, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
callq 0x40a0
movq -0xb0(%rbp), %rdi
movslq %eax, %rcx
imulq $0x2aaaaaab, %rcx, %rdx # imm = 0x2AAAAAAB
movq %rdx, %rcx
shrq $0x3f, %rcx
shrq $0x20, %rdx
addl %ecx, %edx
addl %edx, %edx
movl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
movsd 0xfa5f(%rip), %xmm1     # 0x40168
addsd %xmm1, %xmm0
movl -0x40(%rbp), %eax
cvtsi2sd %rax, %xmm2
movsd 0xcbd3(%rip), %xmm3     # 0x3d2f0
divsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movq %rsp, %rax
leaq -0x74(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x30(%rbp), %rsi
leaq -0x68(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x6c(%rbp), %r8
leaq -0x70(%rbp), %r9
callq 0x1e6f0
jmp 0x3075d
movq -0xb0(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x30876
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
callq 0x4240
jmp 0x3098d
movl $0x40, %edi
callq 0x4270
movq %rax, -0xb8(%rbp)
jmp 0x3079d
callq 0x40a0
movq -0xb8(%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 0x2(%rax,%rcx), %eax
movl -0x40(%rbp), %ecx
imull %ecx, %eax
movl %eax, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
movl -0x40(%rbp), %eax
cvtsi2sd %rax, %xmm0
movsd 0xf9a0(%rip), %xmm1     # 0x40188
divsd %xmm1, %xmm0
movsd 0xf974(%rip), %xmm1     # 0x40168
addsd %xmm1, %xmm0
movsd 0xf990(%rip), %xmm1     # 0x40190
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0xf8c4(%rip), %xmm1     # 0x400d8
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x84(%rbp)
movq %rsp, %rax
leaq -0x84(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x30(%rbp), %rsi
leaq -0x78(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq -0x7c(%rbp), %r8
leaq -0x80(%rbp), %r9
callq 0x1e6f0
jmp 0x3084c
movq -0xb8(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0x30876
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
callq 0x4240
jmp 0x3098d
jmp 0x30878
movq -0x90(%rbp), %rdi
addq $0x108, %rdi            # imm = 0x108
leaq -0x38(%rbp), %rsi
callq 0x27110
jmp 0x30891
movq -0x90(%rbp), %rax
movl 0x1e4(%rax), %eax
movl %eax, -0xc0(%rbp)
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movl %eax, -0xbc(%rbp)
jmp 0x308b9
movl -0xc0(%rbp), %eax
movl -0xbc(%rbp), %ecx
cmpl %ecx, %eax
jbe 0x308f1
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
callq *%rax
movl %eax, -0xc4(%rbp)
jmp 0x308de
movq -0x90(%rbp), %rax
movl -0xc4(%rbp), %ecx
movl %ecx, 0x1e4(%rax)
jmp 0x308f3
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x3048e
movq -0x90(%rbp), %rdi
movl 0x1ec(%rdi), %eax
movq %rax, -0xd0(%rbp)
addq $0x108, %rdi            # imm = 0x108
callq 0x26ea0
movq %rax, %rcx
movq -0xd0(%rbp), %rax
cmpq %rcx, %rax
jae 0x30953
movq -0x90(%rbp), %rdi
addq $0x108, %rdi            # imm = 0x108
callq 0x26ea0
movq %rax, %rcx
movq -0x90(%rbp), %rax
movl %ecx, 0x1ec(%rax)
movq -0x90(%rbp), %rcx
movl 0x1e8(%rcx), %eax
cmpl 0x1e4(%rcx), %eax
jbe 0x3097b
movq -0x90(%rbp), %rax
movl 0x1e4(%rax), %ecx
movl %ecx, 0x1e8(%rax)
leaq -0x30(%rbp), %rdi
callq 0x4160
addq $0xe0, %rsp
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x4160
movq -0x50(%rbp), %rdi
callq 0x4440
nop