// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
leaq 0xa8(%rsp), %r15
leaq 0x68(%rdi), %r14
xorpd %xmm0, %xmm0
xorl %ecx, %ecx
leaq 0x8(%rsp), %r13
movq %r14, 0x30(%rsp)
cmpl 0x84(%rbx), %ecx
jge 0xca2d
movapd %xmm0, 0x10(%rsp)
leaq 0xb4cb(%rip), %rdx      # 0x17c90
movq %rdx, 0x90(%rsp)
andl $0x0, 0xb0(%rsp)
andq $0x0, 0xb8(%rsp)
leaq 0xb0(%rsp), %rax
movq %rax, 0xc0(%rsp)
movq %rax, 0xc8(%rsp)
andq $0x0, 0xd0(%rsp)
orl $-0x1, 0xa0(%rsp)
orq $-0x1, 0xd8(%rsp)
movq %rdx, 0x38(%rsp)
andl $0x0, 0x58(%rsp)
andq $0x0, 0x60(%rsp)
leaq 0x58(%rsp), %rax
movq %rax, 0x68(%rsp)
movq %rax, 0x70(%rsp)
andq $0x0, 0x78(%rsp)
orl $-0x1, 0x48(%rsp)
orq $-0x1, 0x80(%rsp)
movsd 0x2f45(%rip), %xmm0     # 0xf790
movsd %xmm0, 0xe0(%rsp)
andl $0x0, 0x98(%rsp)
movsd %xmm0, 0x88(%rsp)
movl $0x1, 0x40(%rsp)
movl %ecx, 0x9c(%rsp)
movl %ecx, 0xc(%rsp)
movl %ecx, 0x44(%rsp)
movq %r15, %rdi
callq 0x7f42
leaq 0x50(%rsp), %rdi
callq 0x7f42
movq %rbx, %rdi
callq 0xcb24
movl %eax, %ebp
movl %eax, 0xa0(%rsp)
movl %eax, 0x48(%rsp)
movq %r13, %r15
movslq %eax, %r13
movq 0x38(%rbx), %rax
cvttsd2si (%rax,%r13,8), %esi
movq %rbx, %rdi
callq 0xcb80
movl %eax, %r12d
movl %eax, 0xd8(%rsp)
movl %eax, 0x80(%rsp)
xorl %r14d, %r14d
imulq $0x18, %r13, %rax
movq %rax, 0x20(%rsp)
movq %r15, %r13
leaq 0xa8(%rsp), %r15
movq %rbx, %rdi
cmpl %r12d, %r14d
jge 0xc931
movl %ebp, %esi
callq 0xcbf2
movl %eax, 0x8(%rsp)
cmpl %ebp, %eax
je 0xc8e3
movq %r15, %rdi
movq %r13, %rsi
callq 0x840e
testb $0x1, %dl
je 0xc8e3
leaq 0x50(%rsp), %rdi
movq %r13, %rsi
callq 0x840e
movq 0x8(%rbx), %rax
movslq 0x8(%rsp), %rcx
movq 0x20(%rsp), %rdx
movq (%rax,%rdx), %rax
incl (%rax,%rcx,4)
incl %r14d
jmp 0xc8e3
callq 0xcc58
movl %eax, 0xdc(%rsp)
movl %eax, 0x84(%rsp)
cvtsi2ssl 0x114(%rbx), %xmm0
imulq $0x41a7, 0x120(%rbx), %rax # imm = 0x41A7
cqto
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
idivq %r14
movq %rdx, 0x120(%rbx)
movl %edx, %esi
callq 0xcd94
cvtsi2ssl 0x118(%rbx), %xmm1
movapd 0x10(%rsp), %xmm2
addsd %xmm0, %xmm2
movapd %xmm2, 0x10(%rsp)
imulq $0x41a7, 0x128(%rbx), %rax # imm = 0x41A7
cqto
idivq %r14
movq %rdx, 0x128(%rbx)
movaps %xmm1, %xmm0
movl %edx, %esi
callq 0xcd94
movaps 0x10(%rsp), %xmm1
movaps %xmm0, 0x20(%rsp)
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
cvtpd2ps %xmm1, %xmm0
movlpd %xmm0, 0xe0(%rsp)
movq 0x30(%rsp), %r14
movq %r14, %rdi
leaq 0x90(%rsp), %r12
movq %r12, %rsi
callq 0xcf18
leaq 0x38(%rsp), %rbp
movapd 0x20(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x88(%rsp)
andl $0x0, 0x8c(%rsp)
movq %r14, %rdi
movq %rbp, %rsi
callq 0xcf18
movq %rbp, %rdi
callq 0xce3e
movq %r12, %rdi
callq 0xce3e
movl 0xc(%rsp), %ecx
incl %ecx
movapd 0x10(%rsp), %xmm0
jmp 0xc7ac
movq %r14, %rdi
callq 0xcf24
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xca4b
jmp 0xca4b
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0xce3e
leaq 0x90(%rsp), %rdi
callq 0xce3e
movq %rbx, %rdi
callq 0x2320
nop