// File: 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
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x130(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x130(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x84(%rcx), %eax
jge 0x27784
leaq -0x70(%rbp), %rdi
callq 0x27f80
leaq -0xc8(%rbp), %rdi
callq 0x27f80
jmp 0x273b6
movl $0x0, -0x68(%rbp)
movl $0x1, -0xc0(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0xbc(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x28600
leaq -0xb0(%rbp), %rdi
callq 0x28600
movq -0x130(%rbp), %rdi
callq 0x279a0
movl %eax, -0x134(%rbp)
jmp 0x273ff
movq -0x130(%rbp), %rdi
movl -0x134(%rbp), %eax
movl %eax, -0xd8(%rbp)
movl -0xd8(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0xd8(%rbp), %eax
movl %eax, -0xb8(%rbp)
addq $0x38, %rdi
movslq -0xd8(%rbp), %rsi
callq 0x28440
movq -0x130(%rbp), %rdi
cvttsd2si (%rax), %esi
callq 0x27a50
movl %eax, -0x138(%rbp)
jmp 0x2744f
movl -0x138(%rbp), %eax
movl %eax, -0xdc(%rbp)
movl -0xdc(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0xdc(%rbp), %eax
movl %eax, -0x80(%rbp)
movl $0x0, -0xe0(%rbp)
movl -0xe0(%rbp), %eax
cmpl -0xdc(%rbp), %eax
jge 0x275e3
movq -0x130(%rbp), %rdi
movl -0xd8(%rbp), %esi
callq 0x27b00
movl %eax, -0x13c(%rbp)
jmp 0x274a3
movl -0x13c(%rbp), %eax
movl %eax, -0xe4(%rbp)
movl -0xe4(%rbp), %eax
cmpl -0xd8(%rbp), %eax
je 0x275de
leaq -0x58(%rbp), %rdi
leaq -0xe4(%rbp), %rsi
callq 0xbc00
movb %dl, -0x149(%rbp)
movq %rax, -0x148(%rbp)
jmp 0x274e0
movb -0x149(%rbp), %al
movq -0x148(%rbp), %rcx
movq %rcx, -0x108(%rbp)
movb %al, -0x100(%rbp)
movq -0x108(%rbp), %rax
movq %rax, -0xf8(%rbp)
movb -0x100(%rbp), %al
movb %al, -0xf0(%rbp)
movb -0xf0(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x275dc
leaq -0xb0(%rbp), %rdi
leaq -0xe4(%rbp), %rsi
callq 0xbc00
movb %dl, -0x159(%rbp)
movq %rax, -0x158(%rbp)
jmp 0x2754a
movq -0x130(%rbp), %rdi
movb -0x159(%rbp), %al
movq -0x158(%rbp), %rcx
movq %rcx, -0x118(%rbp)
movb %al, -0x110(%rbp)
addq $0x8, %rdi
movslq -0xd8(%rbp), %rsi
callq 0x1c180
movq %rax, %rdi
movslq -0xe4(%rbp), %rsi
callq 0xb210
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0xe0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe0(%rbp)
jmp 0x275dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
jmp 0x27779
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd0(%rbp)
movl %eax, -0xd4(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x27ff0
jmp 0x27779
jmp 0x275de
jmp 0x27477
movq -0x130(%rbp), %rdi
callq 0x27bc0
movl %eax, -0x160(%rbp)
jmp 0x275f7
movq -0x130(%rbp), %rdi
movl -0x160(%rbp), %eax
movl %eax, -0x11c(%rbp)
movl -0x11c(%rbp), %eax
movl %eax, -0x24(%rbp)
movl -0x11c(%rbp), %eax
movl %eax, -0x7c(%rbp)
cvtsi2ssl 0x114(%rdi), %xmm0
movss %xmm0, -0x16c(%rbp)
movq %rdi, %rsi
addq $0x120, %rsi            # imm = 0x120
callq 0x27ed0
movq %rax, -0x168(%rbp)
jmp 0x27644
movss -0x16c(%rbp), %xmm0
movq -0x130(%rbp), %rdi
movq -0x168(%rbp), %rax
movl %eax, %esi
callq 0x27e70
movsd %xmm0, -0x178(%rbp)
jmp 0x2766b
movq -0x130(%rbp), %rdi
movsd -0x178(%rbp), %xmm1
movsd -0x10(%rbp), %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x10(%rbp)
cvtsi2ssl 0x118(%rdi), %xmm0
movss %xmm0, -0x184(%rbp)
movq %rdi, %rsi
addq $0x128, %rsi            # imm = 0x128
callq 0x27ed0
movq %rax, -0x180(%rbp)
jmp 0x276b0
movss -0x184(%rbp), %xmm0
movq -0x130(%rbp), %rdi
movq -0x180(%rbp), %rax
movl %eax, %esi
callq 0x27e70
movsd %xmm0, -0x190(%rbp)
jmp 0x276d7
movq -0x130(%rbp), %rdi
movsd -0x190(%rbp), %xmm0
movsd %xmm0, -0x128(%rbp)
movsd -0x10(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x20(%rbp)
movsd -0x128(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x1c(%rbp)
addq $0x68, %rdi
leaq -0x70(%rbp), %rsi
callq 0x28620
jmp 0x2771c
movq -0x130(%rbp), %rdi
movsd -0x10(%rbp), %xmm0
movsd -0x128(%rbp), %xmm1
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x78(%rbp)
movl $0x0, -0x74(%rbp)
addq $0x68, %rdi
leaq -0xc8(%rbp), %rsi
callq 0x28620
jmp 0x27756
leaq -0xc8(%rbp), %rdi
callq 0x27ff0
leaq -0x70(%rbp), %rdi
callq 0x27ff0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x27389
leaq -0x70(%rbp), %rdi
callq 0x27ff0
jmp 0x2779d
movq -0x130(%rbp), %rdi
addq $0x68, %rdi
callq 0x28660
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
movq -0xd0(%rbp), %rdi
callq 0x3340
nopl (%rax)