// File: /workspace/github_cpp_makefile_star2_O1/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 $0xd8, %rsp
movq %rdi, %r15
cmpl $0x0, 0x84(%rdi)
jle 0xe7e3
leaq 0x38(%rsp), %rbx
leaq 0x90(%rsp), %r14
leaq 0x68(%r15), %r13
xorps %xmm0, %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x97f4(%rip), %r12      # 0x17c80
xorl %edi, %edi
movq %r13, 0xd0(%rsp)
movq %r12, 0x20(%rsp)
xorl %ecx, %ecx
movl %ecx, 0x40(%rsp)
movq %rcx, 0x48(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x50(%rsp)
movq %rax, 0x58(%rsp)
movq %rcx, 0x60(%rsp)
movq $-0x1, %rdx
movq %rdx, 0x2c(%rsp)
movq %rdx, 0x68(%rsp)
movabsq $-0x407fffff40800000, %rsi # imm = 0xBF800000BF800000
movq %rsi, 0x70(%rsp)
movq %r12, 0x78(%rsp)
movl %ecx, 0x98(%rsp)
movq %rcx, 0xa0(%rsp)
leaq 0x98(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq %rax, 0xb0(%rsp)
movq %rcx, 0xb8(%rsp)
movl $0xffffffff, 0x88(%rsp) # imm = 0xFFFFFFFF
movq %rdx, 0xc0(%rsp)
movq %rsi, 0xc8(%rsp)
movabsq $-0xffffffff, %rax      # imm = 0xFFFFFFFF00000001
movq %rax, 0x80(%rsp)
movl %ecx, 0x28(%rsp)
movl %edi, 0x2c(%rsp)
movl %edi, 0x1c(%rsp)
movl %edi, 0x84(%rsp)
movq %rbx, %rdi
callq 0x9b30
movq %r14, %rdi
callq 0x9b30
movq %r15, %rdi
callq 0xe92c
movl %eax, %ebp
movl %eax, 0x30(%rsp)
movl %eax, 0x88(%rsp)
movslq %eax, %r14
movq 0x38(%r15), %rax
cvttsd2si (%rax,%r14,8), %esi
movq %r15, %rdi
callq 0xe9ae
movl %eax, 0x68(%rsp)
movl %eax, 0xc0(%rsp)
testl %eax, %eax
jle 0xe5f2
movl %eax, %r12d
xorl %r13d, %r13d
leaq (%r14,%r14,2), %rbx
movq %r15, %rdi
movl %r14d, %esi
callq 0xea6a
movl %eax, 0x4(%rsp)
cmpl %ebp, %eax
je 0xe5ed
leaq 0x38(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x9dd6
testb $0x1, %dl
je 0xe5ed
leaq 0x90(%rsp), %rdi
leaq 0x4(%rsp), %rsi
callq 0x9dd6
movq 0x8(%r15), %rax
movslq 0x4(%rsp), %rcx
movq (%rax,%rbx,8), %rax
incl (%rax,%rcx,4)
incl %r13d
cmpl %r12d, %r13d
jl 0xe5a1
movq %r15, %rdi
callq 0xeaf8
movl %eax, 0x6c(%rsp)
movl %eax, 0xc4(%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 0x312f(%rip), %xmm1     # 0x11788
divss %xmm0, %xmm1
cvtsi2sd %edx, %xmm2
xorps %xmm0, %xmm0
cvtss2sd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x311a(%rip), %xmm0     # 0x11790
divsd %xmm0, %xmm2
movsd 0x298e(%rip), %xmm0     # 0x11010
subsd %xmm2, %xmm0
callq 0x31b0
xorps %xmm1, %xmm1
cvtsi2ssl 0x118(%r15), %xmm1
imulq $0x41a7, 0x128(%r15), %rcx # imm = 0x41A7
mulsd 0x8(%rsp), %xmm0
movq %rcx, %rax
imulq %rbx
movsd 0x10(%rsp), %xmm2
addsd %xmm0, %xmm2
movsd %xmm2, 0x10(%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 0x309d(%rip), %xmm0     # 0x11788
divss %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
divsd 0x3088(%rip), %xmm1     # 0x11790
movsd 0x2900(%rip), %xmm0     # 0x11010
subsd %xmm1, %xmm0
callq 0x31b0
mulsd 0x8(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsd2ss 0x10(%rsp), %xmm1
movss %xmm1, 0x70(%rsp)
movsd %xmm0, 0x8(%rsp)
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x74(%rsp)
movq 0xd0(%rsp), %r13
movq %r13, %rdi
leaq 0x20(%rsp), %rsi
callq 0x8fa6
movq %rax, %rdi
movq %r13, %rsi
callq 0x3050
incq 0x78(%r15)
movsd 0x8(%rsp), %xmm0
addsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0xc8(%rsp)
movl $0x0, 0xcc(%rsp)
movq %r13, %rdi
leaq 0x78(%rsp), %rsi
callq 0x8fa6
movq %rax, %rdi
movq %r13, %rsi
callq 0x3050
incq 0x78(%r15)
leaq 0x94d7(%rip), %r12      # 0x17c80
movq %r12, 0x78(%rsp)
leaq 0x90(%rsp), %r14
movq %r14, %rdi
callq 0xf0f2
movq %r12, 0x20(%rsp)
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0xf0f2
movl 0x1c(%rsp), %edi
incl %edi
cmpl 0x84(%r15), %edi
jl 0xe496
addq $0x68, %r15
movq %r15, %rdi
callq 0xee8a
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xe805
jmp 0xe805
movq %rax, %r14
leaq 0x38(%rsp), %rbx
leaq 0x946c(%rip), %r15      # 0x17c80
movq %r15, 0x78(%rsp)
leaq 0x90(%rsp), %rdi
callq 0xf0f2
movq %r15, 0x20(%rsp)
movq %rbx, %rdi
callq 0xf0f2
movq %r14, %rdi
callq 0x3370
nop