// File: /workspace/github_cpp_makefile_star2_O3/suyunu[P]Discrete-Event-Simulation/RandQueuing.cpp
// Function: RandQueuing::simulate()
void RandQueuing::simulate(){
	Job current;
	
	while(!order.empty()){
		pop_heap(order.begin(),order.end(),greater1());
		current = order.back();
		order.pop_back();
		
		currentTime = current.timeToGo;
		
		if(current.cond == -1){
			work(current, 0);
		}
		else{
			int toGo = whereToGoRand(current);
			if(!units[current.cond].jobQ.empty()){
				units[current.cond].Jcounter++;
				Job temp = units[current.cond].jobQ.front();
				units[current.cond].jobQ.pop();
				
				temp.timeToGo = currentTime + units[current.cond].procTime;
				jobs[temp.no] = temp;
				
				order.push_back(temp);
				push_heap (order.begin(),order.end(),greater1());
			}
			else
				units[current.cond].isWorking = false;
			
			if(toGo != -1)
				work(current, toGo);
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdi, %rbx
leaq -0x50(%rbp), %rdi
callq 0x268c
leaq 0x28(%rbx), %r15
leaq -0x90(%rbp), %r12
leaq -0xb0(%rbp), %r13
movq 0x28(%rbx), %rdi
movq 0x30(%rbx), %rax
cmpq %rax, %rdi
je 0x319e
movq %rax, %rcx
subq %rdi, %rcx
cmpq $0x21, %rcx
jl 0x2fd2
leaq -0x20(%rax), %rdx
movups -0x20(%rax), %xmm0
movups -0x10(%rax), %xmm1
movaps %xmm1, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movups (%rdi), %xmm0
movups 0xc(%rdi), %xmm1
movups %xmm1, -0x14(%rax)
movups %xmm0, -0x20(%rax)
subq %rdi, %rdx
sarq $0x5, %rdx
movaps -0xb0(%rbp), %xmm0
movaps -0xa0(%rbp), %xmm1
movaps %xmm0, -0x90(%rbp)
movaps %xmm1, -0x80(%rbp)
xorl %esi, %esi
movq %r12, %rcx
callq 0x3921
movq %r12, %rdi
callq 0x26a6
movq %r13, %rdi
callq 0x26a6
movq 0x30(%rbx), %rax
leaq -0x20(%rax), %rdi
movups -0x20(%rax), %xmm0
movupd -0x14(%rax), %xmm1
movupd %xmm1, -0x44(%rbp)
movaps %xmm0, -0x50(%rbp)
movq %rdi, 0x30(%rbx)
callq 0x26a6
movsd -0x40(%rbp), %xmm0
movsd %xmm0, 0x8(%rbx)
cmpl $-0x1, -0x38(%rbp)
je 0x31b9
movq %rbx, %rdi
leaq -0x50(%rbp), %rsi
callq 0x3284
movl %eax, %r14d
movq 0x20(%rbx), %rax
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rdx
movq 0x20(%rax,%rdx), %rcx
cmpq %rcx, 0x40(%rax,%rdx)
je 0x30ab
leaq (%rax,%rdx), %rdi
addq $0x10, %rdi
incl 0x54(%rdi)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movaps %xmm1, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
callq 0x3a68
movsd 0x8(%rbx), %xmm0
movq 0x20(%rbx), %rax
movslq -0x38(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addsd 0x8(%rax,%rcx), %xmm0
movsd %xmm0, -0x60(%rbp)
movq 0x18(%rbx), %rax
movslq -0x70(%rbp), %rcx
shlq $0x5, %rcx
movups -0x64(%rbp), %xmm0
movups %xmm0, 0xc(%rax,%rcx)
movaps -0x70(%rbp), %xmm0
movups %xmm0, (%rax,%rcx)
movq 0x30(%rbx), %rsi
cmpq 0x38(%rbx), %rsi
je 0x30b5
movaps -0x70(%rbp), %xmm0
movaps -0x60(%rbp), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
movq 0x30(%rbx), %rdx
addq $0x20, %rdx
movq %rdx, 0x30(%rbx)
jmp 0x30c5
movb $0x0, 0x6c(%rax,%rdx)
jmp 0x3185
movq %r15, %rdi
leaq -0x70(%rbp), %rdx
callq 0x36e8
movq 0x30(%rbx), %rdx
movq (%r15), %rax
movups -0x20(%rdx), %xmm0
movups -0x10(%rdx), %xmm1
movaps %xmm1, -0xa0(%rbp)
movaps %xmm0, -0xb0(%rbp)
movq %rdx, %rsi
subq %rax, %rsi
sarq $0x5, %rsi
leaq -0x1(%rsi), %rcx
movupd -0x20(%rdx), %xmm0
movupd -0x10(%rdx), %xmm1
movapd %xmm0, -0x90(%rbp)
movapd %xmm1, -0x80(%rbp)
cmpq $0x2, %rsi
jl 0x314f
movsd -0x80(%rbp), %xmm0
leaq -0x1(%rcx), %rdx
movq %rdx, %rsi
shrq %rsi
movq %rsi, %rdi
shlq $0x5, %rdi
movsd 0x10(%rax,%rdi), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x314f
addq %rax, %rdi
shlq $0x5, %rcx
movupd (%rdi), %xmm1
movups 0xc(%rdi), %xmm2
movups %xmm2, 0xc(%rax,%rcx)
movupd %xmm1, (%rax,%rcx)
movq %rsi, %rcx
cmpq $0x1, %rdx
ja 0x310e
xorl %ecx, %ecx
shlq $0x5, %rcx
movups -0x84(%rbp), %xmm0
movups %xmm0, 0xc(%rax,%rcx)
movapd -0x90(%rbp), %xmm0
movupd %xmm0, (%rax,%rcx)
movq %r12, %rdi
callq 0x26a6
movq %r13, %rdi
callq 0x26a6
leaq -0x70(%rbp), %rdi
callq 0x26a6
cmpl $-0x1, %r14d
je 0x2f4e
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x3204
leaq -0x50(%rbp), %rdi
callq 0x26a6
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0x50(%rbp), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x3204
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
jmp 0x31e6
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x26a6
leaq -0xb0(%rbp), %rdi
callq 0x26a6
jmp 0x31f2
jmp 0x31ef
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x26a6
movq %rbx, %rdi
callq 0x2250
nop