// File: /workspace/github_cpp_makefile_star2_O3/ekg[P]sgd2/src/sgd2.hpp
// Function: sgd2::build_graph_weighted(unsigned long, unsigned long, unsigned long*, unsigned long*, double*)
std::vector<std::vector<edge>> build_graph_weighted(uint64_t n, uint64_t m, uint64_t* I, uint64_t* J, double* V)
{
    // used to make graph undirected, in case graph is not already
    std::vector<std::unordered_map<uint64_t, double>> undirected(n);
    std::vector<std::vector<edge>> graph(n);

    for (uint64_t ij=0; ij<m; ij++)
    {
        uint64_t i = I[ij], j = J[ij];
        if (i >= n || j >= n)
            throw "i or j bigger than n";

        double v = V[ij];
        if (v <= 0)
            throw "v less or equal 0";

        if (i != j && undirected[j].find(i) == undirected[j].end()) // if key not there
        {
            undirected[i].insert({j, v});
            undirected[j].insert({i, v});
            graph[i].push_back(edge(j, v));
            graph[j].push_back(edge(i, v));
        }
        else
        {
            if (undirected[j][i] != v)
                throw "graph weights not symmetric";
        }
    }
    return graph;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r9, -0x80(%rbp)
movq %r8, -0x88(%rbp)
movq %rcx, -0x90(%rbp)
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x78(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0x7590
leaq -0x40(%rbp), %rdx
movq %r14, -0x50(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7630
testq %r12, %r12
je 0x2f98
xorl %r15d, %r15d
leaq 0x82f1(%rip), %rax      # 0xb0fe
movq %rax, -0x60(%rbp)
leaq -0x40(%rbp), %r14
movq %r12, -0x58(%rbp)
movq -0x90(%rbp), %rax
movq (%rax,%r15,8), %rax
movq %rax, -0x30(%rbp)
cmpq %rbx, %rax
jae 0x2fb4
movq -0x88(%rbp), %rcx
movq (%rcx,%r15,8), %r12
cmpq %rbx, %r12
jae 0x2fb4
movq -0x80(%rbp), %rcx
movsd (%rcx,%r15,8), %xmm1
xorpd %xmm0, %xmm0
movsd %xmm1, -0x48(%rbp)
ucomisd %xmm1, %xmm0
jae 0x2fe4
movq %r14, %r13
cmpq %r12, %rax
je 0x2e83
imulq $0x38, %r12, %r14
movq -0x78(%rbp), %rdi
addq %r14, %rdi
leaq -0x30(%rbp), %rsi
callq 0x8dbe
testq %rax, %rax
je 0x2ec1
imulq $0x38, %r12, %rdi
addq -0x78(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x921a
movsd (%rax), %xmm0
ucomisd -0x48(%rbp), %xmm0
movq %r13, %r14
movq -0x58(%rbp), %r12
jne 0x2fd9
jp 0x2fd9
incq %r15
cmpq %r15, %r12
jne 0x2e19
jmp 0x2f98
imulq $0x38, -0x30(%rbp), %rdi
addq -0x78(%rbp), %rdi
movq %r12, -0x40(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %r13, %rsi
callq 0x8e20
addq -0x78(%rbp), %r14
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x8e20
movq %r13, %r14
movq -0x30(%rbp), %rax
movq -0x50(%rbp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,2), %rdx
leaq (%rcx,%rdx,8), %rdi
movq %r12, -0x40(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x2f3d
movups -0x40(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x8(%rdi)
jmp 0x2f49
movq %r14, %rdx
callq 0x90cc
movq -0x30(%rbp), %rax
movq -0x50(%rbp), %rcx
movq (%rcx), %rcx
leaq (%r12,%r12,2), %rdx
leaq (%rcx,%rdx,8), %rdi
movq %rax, -0x40(%rbp)
movsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x2f87
movupd -0x40(%rbp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x8(%rdi)
movq -0x58(%rbp), %r12
jmp 0x2eb0
movq %r14, %rdx
callq 0x90cc
movq -0x58(%rbp), %r12
jmp 0x2eb0
leaq -0x78(%rbp), %rdi
callq 0x7710
movq -0x50(%rbp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x2080
leaq 0x80e7(%rip), %rcx      # 0xb0ac
movq %rcx, (%rax)
movq 0xbff1(%rip), %rsi      # 0xefc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x2220
leaq 0x8130(%rip), %rax      # 0xb110
movq %rax, -0x60(%rbp)
movl $0x8, %edi
callq 0x2080
movq -0x60(%rbp), %rcx
movq %rcx, (%rax)
movq 0xbfc4(%rip), %rsi      # 0xefc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x2220
movq %rax, %rbx
jmp 0x3025
jmp 0x3019
jmp 0x3019
jmp 0x3019
jmp 0x3019
jmp 0x3019
jmp 0x3019
jmp 0x3019
movq %rax, %rbx
movq -0x50(%rbp), %rdi
callq 0x76ae
leaq -0x78(%rbp), %rdi
callq 0x7710
movq %rbx, %rdi
callq 0x2230