// File: fjamour[P]icentral/src/paper_exp.cc
// Function: exp_brandes_p(graph_t&, int, std::vector<std::pair<unsigned int, unsigned int>, std::allocator<std::pair<unsigned int, unsigned int>>>, double)
double  exp_brandes_p(graph_t& graph,
            int num_iter,
            vector<edge_t> rand_edge_vec,
            double time_to_run_all_iter)
{
    printf("==========================================================\n");
    printf("Graph: \t\t\t%s\n", graph.graph_name.c_str());
    printf("Graph # nodes: \t\t%d\n", graph.size());
    printf("Graph # edges: \t\t%d\n", graph.edge_set.size());
    
    double  brandes_time;
    bool    do_all_iter = false;
    timer   tm;
    
    printf("Brandes runtime: \t");
    if(num_iter != -1) {
        tm.start();
        tr1_map_t(double) bc_vec = brandes_bc_hash_out(graph, num_iter);
        tm.stop();
        brandes_time = (tm.interval()*graph.size()/num_iter);
        if(brandes_time < time_to_run_all_iter) {
            do_all_iter = true;
        }
    } else {
        do_all_iter = true;
    }

    if(do_all_iter) {
        num_iter = -1;
        tm.start();
        tr1_map_t(double) bc_vec = brandes_bc_hash_out(graph, num_iter);
        tm.stop();
        brandes_time = tm.interval();
        printf("%f\n", brandes_time);
        printf("Brandes avg iter time: \t%f\n", tm.interval()/graph.size());
        printf("DID ALL ITERATIONS...\n");
    } else {
        printf("%f\n", brandes_time);
        printf("Brandes avg iter time: \t%f\n", tm.interval()/num_iter);
        printf("DID %d ITERATIONS...\n", num_iter);
    }
    
    return brandes_time;
}

// Assembly:
subq $0xf8, %rsp
movq %rdi, 0xf0(%rsp)
movl %esi, 0xec(%rsp)
movq %rdx, 0xe0(%rsp)
movsd %xmm0, 0xd8(%rsp)
leaq 0x17182(%rip), %rdi     # 0x7b2e0
movb $0x0, %al
callq 0x9040
movq 0xf0(%rsp), %rdi
addq $0x108, %rdi            # imm = 0x108
callq 0x9250
movq %rax, %rsi
leaq 0x17199(%rip), %rdi     # 0x7b31c
movb $0x0, %al
callq 0x9040
movq 0xf0(%rsp), %rdi
callq 0x56b40
movq %rax, %rsi
leaq 0x17189(%rip), %rdi     # 0x7b32a
movb $0x0, %al
callq 0x9040
movq 0xf0(%rsp), %rdi
addq $0x30, %rdi
callq 0x4dbe0
movq %rax, %rsi
leaq 0x1717c(%rip), %rdi     # 0x7b33f
movb $0x0, %al
callq 0x9040
movb $0x0, 0xcf(%rsp)
leaq 0x1717b(%rip), %rdi     # 0x7b354
movb $0x0, %al
callq 0x9040
cmpl $-0x1, 0xec(%rsp)
je 0x642e5
leaq 0xa8(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x2d430
movq 0xf0(%rsp), %rsi
movl 0xec(%rsp), %edx
leaq 0x78(%rsp), %rdi
callq 0x29120
movq 0x30(%rsp), %rdi
callq 0x2d450
jmp 0x64225
leaq 0xa8(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x28(%rsp)
jmp 0x6423a
movq 0xf0(%rsp), %rdi
callq 0x56b40
movq %rax, 0x20(%rsp)
jmp 0x6424e
movsd 0x28(%rsp), %xmm0
movq 0x20(%rsp), %rax
movq %rax, %xmm1
movaps 0x1704b(%rip), %xmm2    # 0x7b2b0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x1704f(%rip), %xmm2    # 0x7b2c0
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl 0xec(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0xd0(%rsp)
movsd 0xd0(%rsp), %xmm1
movsd 0xd8(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x642d9
movb $0x1, 0xcf(%rsp)
jmp 0x642d9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x2d420
jmp 0x64482
leaq 0x78(%rsp), %rdi
callq 0x2d420
jmp 0x642ed
movb $0x1, 0xcf(%rsp)
testb $0x1, 0xcf(%rsp)
je 0x6441d
movl $0xffffffff, 0xec(%rsp) # imm = 0xFFFFFFFF
leaq 0xa8(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x2d430
movq 0xf0(%rsp), %rsi
movl 0xec(%rsp), %edx
leaq 0x38(%rsp), %rdi
callq 0x29120
movq 0x18(%rsp), %rdi
callq 0x2d450
jmp 0x6433d
leaq 0xa8(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x10(%rsp)
jmp 0x64352
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0xd0(%rsp)
movsd 0xd0(%rsp), %xmm0
leaq 0x171df(%rip), %rdi     # 0x7b550
movb $0x1, %al
callq 0x9040
jmp 0x6437a
leaq 0xa8(%rsp), %rdi
callq 0x2d470
movsd %xmm0, 0x8(%rsp)
jmp 0x6438f
movq 0xf0(%rsp), %rdi
callq 0x56b40
movq %rax, (%rsp)
jmp 0x643a2
movsd 0x8(%rsp), %xmm0
movq (%rsp), %rax
movq %rax, %xmm1
movaps 0x16ef8(%rip), %xmm2    # 0x7b2b0
punpckldq %xmm2, %xmm1    # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movapd 0x16efc(%rip), %xmm2    # 0x7b2c0
subpd %xmm2, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
divsd %xmm1, %xmm0
leaq 0x1705c(%rip), %rdi     # 0x7b43a
movb $0x1, %al
callq 0x9040
jmp 0x643e7
leaq 0x17ded(%rip), %rdi     # 0x7c1db
xorl %eax, %eax
callq 0x9040
jmp 0x643f7
leaq 0x38(%rsp), %rdi
callq 0x2d420
jmp 0x64471
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x2d420
jmp 0x64482
movsd 0xd0(%rsp), %xmm0
leaq 0x17123(%rip), %rdi     # 0x7b550
movb $0x1, %al
callq 0x9040
leaq 0xa8(%rsp), %rdi
callq 0x2d470
cvtsi2sdl 0xec(%rsp), %xmm1
divsd %xmm1, %xmm0
leaq 0x16fe5(%rip), %rdi     # 0x7b43a
movb $0x1, %al
callq 0x9040
movl 0xec(%rsp), %esi
leaq 0x17d88(%rip), %rdi     # 0x7c1f2
movb $0x0, %al
callq 0x9040
movsd 0xd0(%rsp), %xmm0
addq $0xf8, %rsp
retq
movq 0x70(%rsp), %rdi
callq 0x9cf0
nopl (%rax)