// File: /workspace/github_cpp_makefile_star2_O3/ynilu[P]elastic/traffic.cpp
// Function: Traffic::generate_traffic()
void Traffic::generate_traffic()
{
    double arrival_time = 0;
    for( int i = 0 ; i < num_requests ; ++i )
    {
        Event arrival;
        Event departure;

        arrival.type = Event::arrival;
        departure.type = Event::departure;
        arrival.request_id = i;
        departure.request_id = i;

        arrival.destination.clear();
        departure.destination.clear();

        // decide source
        int source = generate_source();
        arrival.source = source;
        departure.source = source;

        // decide destination set
        int num_dest = generate_num_dest(source_matrix[source]);
        arrival.num_dest = num_dest;
        departure.num_dest = num_dest;

        int count = 0;
        int temp_d;

        // gernerate all destinations (can be optimized)
        while( count < num_dest )
        {
            temp_d = generate_destination(source);

            if( temp_d != source )
            {
                if( arrival.destination.insert(temp_d).second == true ) // if a new element was inserted
                {
                    departure.destination.insert(temp_d);
                    total_dest_count[source][temp_d]++;
                    count++;
                }
            }
        }

        int bandwidth = generate_bandwidth();

        arrival.bandwidth = bandwidth;
        departure.bandwidth = bandwidth;

        arrival_time += get_interarrival_time( traffic_lambda, nextrand(aTime_seed) );
        double holding_time;
        holding_time = get_interarrival_time( traffic_mu, nextrand(hTime_seed) );

        arrival.arrival_time = arrival_time;
        arrival.holding_time = holding_time;

        event_list.push_back(arrival);

        departure.arrival_time = arrival_time + holding_time;
        departure.holding_time = 0;

        event_list.push_back(departure);
    }
    event_list.sort();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %r15
cmpl $0x0, 0x84(%rdi)
jle 0xefcd
leaq 0x48(%rsp), %rbx
leaq 0xa0(%rsp), %r14
leaq 0x68(%r15), %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
leaq 0x900d(%rip), %r12      # 0x17c80
xorl %edi, %edi
movq %r13, 0xe0(%rsp)
movq %r12, 0x30(%rsp)
xorl %ecx, %ecx
movl %ecx, 0x50(%rsp)
movq %rcx, 0x58(%rsp)
leaq 0x50(%rsp), %rax
movq %rax, 0x60(%rsp)
movq %rax, 0x68(%rsp)
movq %rcx, 0x70(%rsp)
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %edx, 0x40(%rsp)
movq $-0x1, %rsi
movq %rsi, 0x78(%rsp)
movsd 0x2b02(%rip), %xmm0     # 0x117c0
movsd %xmm0, 0x80(%rsp)
movq %r12, 0x88(%rsp)
movl %ecx, 0xa8(%rsp)
movq %rcx, 0xb0(%rsp)
leaq 0xa8(%rsp), %rax
movq %rax, 0xb8(%rsp)
movq %rax, 0xc0(%rsp)
movq %rcx, 0xc8(%rsp)
movl %edx, 0x98(%rsp)
movq %rsi, 0xd0(%rsp)
movsd %xmm0, 0xd8(%rsp)
movl %ecx, 0x38(%rsp)
movl $0x1, 0x90(%rsp)
movl %edi, 0x3c(%rsp)
movl %edi, 0xc(%rsp)
movl %edi, 0x94(%rsp)
movq %rbx, %rdi
callq 0xa280
movq %r14, %rdi
callq 0xa280
movq %r15, %rdi
callq 0xf118
movl %eax, %ebp
movl %eax, 0x40(%rsp)
movl %eax, 0x98(%rsp)
movslq %eax, %r14
movq 0x38(%r15), %rax
cvttsd2si (%rax,%r14,8), %esi
movq %r15, %rdi
callq 0xf19a
movl %eax, 0x78(%rsp)
movl %eax, 0xd0(%rsp)
testl %eax, %eax
jle 0xedd8
movl %eax, %r12d
xorl %r13d, %r13d
leaq (%r14,%r14,2), %rbx
movq %r15, %rdi
movl %r14d, %esi
callq 0xf256
movl %eax, 0x8(%rsp)
cmpl %ebp, %eax
je 0xedd3
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xa526
testb $0x1, %dl
je 0xedd3
leaq 0xa0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0xa526
movq 0x8(%r15), %rax
movslq 0x8(%rsp), %rcx
movq (%rax,%rbx,8), %rax
incl (%rax,%rcx,4)
incl %r13d
cmpl %r12d, %r13d
jl 0xed87
movq %r15, %rdi
callq 0xf2e4
movl %eax, 0x7c(%rsp)
movl %eax, 0xd4(%rsp)
xorps %xmm0, %xmm0
cvtsi2ssl 0x114(%r15), %xmm0
imulq $0x41a7, 0x120(%r15), %rcx # imm = 0x41A7
movq %rcx, %rax
movabsq $-0x7ffffffefffffffd, %rbx # imm = 0x8000000100000003
imulq %rbx
addq %rcx, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x1e, %rdx
addq %rax, %rdx
movq %rdx, %rax
shlq $0x1f, %rax
subq %rax, %rdx
addq %rcx, %rdx
movq %rdx, 0x120(%r15)
movss 0x2991(%rip), %xmm1     # 0x117d0
divss %xmm0, %xmm1
cvtsi2sd %edx, %xmm2
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movsd 0x297c(%rip), %xmm0     # 0x117d8
divsd %xmm0, %xmm2
movsd 0x21a8(%rip), %xmm0     # 0x11010
subsd %xmm2, %xmm0
callq 0x31b0
xorps %xmm1, %xmm1
cvtsi2ssl 0x118(%r15), %xmm1
imulq $0x41a7, 0x128(%r15), %rcx # imm = 0x41A7
mulsd 0x10(%rsp), %xmm0
movq %rcx, %rax
imulq %rbx
movapd 0x20(%rsp), %xmm2
addsd %xmm0, %xmm2
movapd %xmm2, 0x20(%rsp)
addq %rcx, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x1e, %rdx
addq %rax, %rdx
movq %rdx, %rax
shlq $0x1f, %rax
subq %rax, %rdx
addq %rcx, %rdx
movq %rdx, 0x128(%r15)
movss 0x28ff(%rip), %xmm0     # 0x117d0
divss %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
divsd 0x28ea(%rip), %xmm1     # 0x117d8
movsd 0x211a(%rip), %xmm0     # 0x11010
subsd %xmm1, %xmm0
callq 0x31b0
mulsd 0x10(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
movapd %xmm0, 0x10(%rsp)
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
cvtpd2ps %xmm1, %xmm0
movlpd %xmm0, 0x80(%rsp)
movq 0xe0(%rsp), %r13
movq %r13, %rdi
leaq 0x30(%rsp), %rsi
callq 0x9368
movq %rax, %rdi
movq %r13, %rsi
callq 0x3050
incq 0x78(%r15)
movapd 0x10(%rsp), %xmm0
addsd 0x20(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xd8(%rsp)
movl $0x0, 0xdc(%rsp)
movq %r13, %rdi
leaq 0x88(%rsp), %rsi
callq 0x9368
movq %rax, %rdi
movq %r13, %rsi
callq 0x3050
incq 0x78(%r15)
leaq 0x8cf0(%rip), %r12      # 0x17c80
movq %r12, 0x88(%rsp)
leaq 0xa0(%rsp), %r14
movq %r14, %rdi
callq 0xf8c2
movq %r12, 0x30(%rsp)
leaq 0x48(%rsp), %rbx
movq %rbx, %rdi
callq 0xf8c2
movl 0xc(%rsp), %edi
incl %edi
cmpl 0x84(%r15), %edi
jl 0xec7d
addq $0x68, %r15
movq %r15, %rdi
callq 0xf674
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xefef
jmp 0xefef
movq %rax, %r14
leaq 0x48(%rsp), %rbx
leaq 0x8c82(%rip), %r15      # 0x17c80
movq %r15, 0x88(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0xf8c2
movq %r15, 0x30(%rsp)
movq %rbx, %rdi
callq 0xf8c2
movq %r14, %rdi
callq 0x3370