// File: /workspace/github_cpp_makefile_star2_O1/MichaelXanth[P]RPG_Game/Market/Market.cpp
// Function: Market::NewStuff(std::vector<Hero*, std::allocator<Hero*>>&)
void Market::NewStuff(vector<Hero *>& heroes)
{
    if (heroes.size() == 1)
    {
        if (heroes[0]->Living::GetLevel() < prevLevel + 2)
            return;

        prevLevel = heroes[0]->Living::GetLevel();
    
    } else {
        unsigned int averageLevel = 0;

        for (unsigned int i = 0; i < heroes.size(); i++)
            averageLevel += heroes[i]->Living::GetLevel();
        
        averageLevel /= heroes.size();

        if (averageLevel < prevLevel + 2)
            return;

        prevLevel = averageLevel;
    }

    if (rand() % prevLevel < prevLevel / 6)
        AddLightingSpells(rand() % 10);

    if (rand() % prevLevel < prevLevel / 6)
        AddFireSpells(rand() % 10);

    if (rand() % prevLevel < prevLevel / 6)
        AddIceSpells(rand() % 10);

    if (rand() % prevLevel < prevLevel / 6)
        AddWeapons(rand() % 10);

    if (rand() % prevLevel < prevLevel / 6)
        AddPotions(rand() % 10);

    if (rand() % prevLevel < prevLevel / 6)
        AddArmors(rand() % 10);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rax
movq 0x8(%rsi), %rcx
subq %rax, %rcx
cmpq $0x8, %rcx
jne 0x1ab4d
movq (%rax), %rdi
callq 0x108f0
movl 0x1f0(%rbx), %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jb 0x1ad88
movq (%r14), %rax
movq (%rax), %rdi
callq 0x108f0
movl %eax, 0x1f0(%rbx)
jmp 0x1abb1
movq (%r14), %rax
movq 0x8(%r14), %rcx
xorl %r15d, %r15d
subq %rax, %rcx
je 0x1ab8e
movl $0x1, %r12d
xorl %edx, %edx
movq (%rax,%rdx,8), %rdi
callq 0x108f0
addl %eax, %r15d
movl %r12d, %edx
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
incl %r12d
cmpq %rdx, %rcx
ja 0x1ab64
movl %r15d, %r15d
jmp 0x1ab92
sarq $0x3, %rcx
movq %r15, %rax
xorl %edx, %edx
divq %rcx
movl 0x1f0(%rbx), %ecx
addl $0x2, %ecx
cmpl %eax, %ecx
ja 0x1ad88
movl %eax, 0x1f0(%rbx)
callq 0x3060
movl 0x1f0(%rbx), %ecx
xorl %edx, %edx
divl %ecx
movl $0xaaaaaaab, %r14d      # imm = 0xAAAAAAAB
imulq %r14, %rcx
shrq $0x22, %rcx
cmpl %ecx, %edx
jae 0x1ac02
callq 0x3060
cltq
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
leaq -0x24(%rbp), %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x195d8
callq 0x3060
movl 0x1f0(%rbx), %ecx
xorl %edx, %edx
divl %ecx
imulq %rcx, %r14
shrq $0x22, %r14
cmpl %r14d, %edx
jae 0x1ac4e
callq 0x3060
cltq
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
leaq -0x24(%rbp), %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x198c4
callq 0x3060
movl 0x1f0(%rbx), %ecx
xorl %edx, %edx
divl %ecx
movl $0xaaaaaaab, %r14d      # imm = 0xAAAAAAAB
imulq %r14, %rcx
shrq $0x22, %rcx
cmpl %ecx, %edx
jae 0x1ac9f
callq 0x3060
cltq
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
leaq -0x24(%rbp), %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x19b8e
callq 0x3060
movl 0x1f0(%rbx), %ecx
xorl %edx, %edx
divl %ecx
imulq %rcx, %r14
shrq $0x22, %r14
cmpl %r14d, %edx
jae 0x1aceb
callq 0x3060
cltq
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
leaq -0x24(%rbp), %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x19e54
callq 0x3060
movl 0x1f0(%rbx), %ecx
xorl %edx, %edx
divl %ecx
movl $0xaaaaaaab, %r14d      # imm = 0xAAAAAAAB
imulq %r14, %rcx
shrq $0x22, %rcx
cmpl %ecx, %edx
jae 0x1ad3c
callq 0x3060
cltq
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
leaq -0x24(%rbp), %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x1a0bc
callq 0x3060
movl 0x1f0(%rbx), %ecx
xorl %edx, %edx
divl %ecx
imulq %rcx, %r14
shrq $0x22, %r14
cmpl %r14d, %edx
jae 0x1ad88
callq 0x3060
cltq
imulq $0x66666667, %rax, %rcx # imm = 0x66666667
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x22, %rcx
addl %edx, %ecx
addl %ecx, %ecx
leal (%rcx,%rcx,4), %ecx
subl %ecx, %eax
leaq -0x24(%rbp), %rsi
movl %eax, (%rsi)
movq %rbx, %rdi
callq 0x1a4a6
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop