// File: negativeview[P]Software-Business-Sim/MasterState.cpp
// Function: MasterState::advanceTime[abi:cxx11](int)
list <string> *MasterState::advanceTime(int amount) {
	for (int i = 0; i < amount; i++) {
		this->_time++;

		// One in ten chance of creating a new person.
		if (rand() % (this->_allWorkers->size() + 1) == 0) {
			this->_createWorkers(1);
		}

		for (list<Company *>::iterator it = this->_allCompanies->begin(); it != this->_allCompanies->end(); ++it) {
			Company *c = *it;
			c->doPayments(this->_time);

			for (list<Person *>::iterator it = this->_allWorkers->begin(); it != this->_allWorkers->end(); ++it) {
				int found = 0;
				vector<Person *> *knownPeople = c->getKnownPeople();
				for (vector<Person *>::iterator it2 = knownPeople->begin(); it2 != knownPeople->end(); ++it2) {
					if (*it == *it2) {
						found = 1;
						break;
					}
				}
				if (found == 0) {
					// Every person that's not already known has a 1 in 10
					// chance of becoming discovered by the company. This number
					// needs to be tweaked as it causes way too many employees
					// too early.
					if (rand() % 10) {
						c->addKnownPerson(*it);
					}
				}
			}

			c->advanceTime(this->_time);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x1303d
movq -0x60(%rbp), %rax
movl 0x20(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x20(%rax)
callq 0x30e0
movl %eax, %ecx
movq -0x60(%rbp), %rax
movslq %ecx, %rcx
movq %rcx, -0x68(%rbp)
movq 0x10(%rax), %rdi
callq 0x13a30
movq %rax, %rcx
movq -0x68(%rbp), %rax
addq $0x1, %rcx
xorl %edx, %edx
divq %rcx
cmpq $0x0, %rdx
jne 0x12eb9
movq -0x60(%rbp), %rdi
movl $0x1, %esi
callq 0x13040
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x13a60
movq %rax, -0x18(%rbp)
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x13ac0
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x13a90
testb $0x1, %al
jne 0x12ef1
jmp 0x1302d
leaq -0x18(%rbp), %rdi
callq 0x13af0
movq %rax, %rcx
movq -0x60(%rbp), %rax
movq (%rcx), %rcx
movq %rcx, -0x28(%rbp)
movq -0x28(%rbp), %rdi
movl 0x20(%rax), %esi
callq 0xc080
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x13b10
movq %rax, -0x30(%rbp)
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x13b70
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x13b40
testb $0x1, %al
jne 0x12f4c
jmp 0x1300f
movl $0x0, -0x3c(%rbp)
movq -0x28(%rbp), %rdi
callq 0xbfd0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0xa6b0
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
callq 0xa720
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0xa6e0
testb $0x1, %al
jne 0x12f8d
jmp 0x12fc8
leaq -0x30(%rbp), %rdi
callq 0x13ba0
movq (%rax), %rax
movq %rax, -0x70(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xa750
movq %rax, %rcx
movq -0x70(%rbp), %rax
cmpq (%rcx), %rax
jne 0x12fbb
movl $0x1, -0x3c(%rbp)
jmp 0x12fc8
jmp 0x12fbd
leaq -0x50(%rbp), %rdi
callq 0xa770
jmp 0x12f6d
cmpl $0x0, -0x3c(%rbp)
jne 0x12fff
callq 0x30e0
movl $0xa, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
je 0x12ffd
movq -0x28(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x13ba0
movq -0x78(%rbp), %rdi
movq (%rax), %rsi
callq 0xbff0
jmp 0x12fff
jmp 0x13001
leaq -0x30(%rbp), %rdi
callq 0x13bc0
jmp 0x12f25
movq -0x60(%rbp), %rax
movq -0x28(%rbp), %rdi
movl 0x20(%rax), %esi
callq 0xbeb0
leaq -0x18(%rbp), %rdi
callq 0x13be0
jmp 0x12eca
jmp 0x1302f
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x12e61
ud2
nop