// File: /workspace/github_cpp_makefile_star2_O1/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, -0x68(%rbp)
movq %r8, -0x70(%rbp)
movq %rcx, -0x78(%rbp)
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x90(%rbp), %rdi
leaq -0x38(%rbp), %rdx
callq 0x7cb6
leaq -0x38(%rbp), %rdx
movq %r14, -0x48(%rbp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7d60
testq %r13, %r13
je 0x30a5
xorl %r15d, %r15d
leaq 0x821e(%rip), %rax      # 0xb0fe
movq %rax, -0x58(%rbp)
leaq -0x38(%rbp), %r14
movq -0x78(%rbp), %rax
movq (%rax,%r15,8), %rcx
movq %rcx, -0x50(%rbp)
cmpq %rbx, %rcx
jae 0x30c4
movq -0x70(%rbp), %rax
movq (%rax,%r15,8), %r12
cmpq %rbx, %r12
jae 0x30c4
movq -0x68(%rbp), %rax
movsd (%rax,%r15,8), %xmm1
xorpd %xmm0, %xmm0
movsd %xmm1, -0x40(%rbp)
ucomisd %xmm1, %xmm0
jae 0x30f4
cmpq %r12, %rcx
je 0x2fa5
movq -0x90(%rbp), %rdi
imulq $0x38, %r12, %rax
movq (%rdi,%rax), %r8
movq %rax, -0x60(%rbp)
movq 0x8(%rdi,%rax), %r9
movq %rcx, %rax
xorl %edx, %edx
divq %r9
movq %rdx, %rsi
movq (%r8,%rdx,8), %rdx
movl $0x0, %eax
testq %rdx, %rdx
je 0x2f9a
movq (%rdx), %r10
movq %rdx, %rax
cmpq 0x8(%r10), %rcx
je 0x2f9a
movq %r10, %r11
movq (%r10), %r10
testq %r10, %r10
je 0x2f98
movq 0x8(%r10), %r8
movq %r8, %rax
xorl %edx, %edx
divq %r9
movl $0x0, %eax
cmpq %rsi, %rdx
jne 0x2f9a
movq %r11, %rax
cmpq %r8, %rcx
jne 0x2f6d
jmp 0x2f9a
xorl %eax, %eax
testq %rax, %rax
je 0x2fd3
cmpq $0x0, (%rax)
je 0x2fd3
imulq $0x38, %r12, %rdi
addq -0x90(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x98fa
movsd (%rax), %xmm0
ucomisd -0x40(%rbp), %xmm0
jne 0x30e9
jnp 0x3099
jmp 0x30e9
imulq $0x38, %rcx, %rax
addq %rax, %rdi
movq %r12, -0x38(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r14, %rsi
callq 0x94f6
movq -0x60(%rbp), %rdi
addq -0x90(%rbp), %rdi
movq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movq %r14, %rsi
callq 0x94f6
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
movq (%rcx), %rcx
leaq (%rax,%rax,2), %rax
leaq (%rcx,%rax,8), %rdi
movq %r12, -0x38(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x304e
movups -0x38(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x8(%rdi)
jmp 0x3056
movq %r14, %rdx
callq 0x97ac
movq -0x48(%rbp), %rax
movq (%rax), %rax
leaq (%r12,%r12,2), %rcx
leaq (%rax,%rcx,8), %rdi
movq -0x50(%rbp), %rax
movq %rax, -0x38(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x3091
movupd -0x38(%rbp), %xmm0
movupd %xmm0, (%rsi)
addq $0x10, 0x8(%rdi)
jmp 0x3099
movq %r14, %rdx
callq 0x97ac
incq %r15
cmpq %r13, %r15
jne 0x2ee8
leaq -0x90(%rbp), %rdi
callq 0x7e4e
movq -0x48(%rbp), %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x2080
leaq 0x7fd7(%rip), %rcx      # 0xb0ac
movq %rcx, (%rax)
movq 0xbee1(%rip), %rsi      # 0xefc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x2230
leaq 0x8020(%rip), %rax      # 0xb110
movq %rax, -0x58(%rbp)
movl $0x8, %edi
callq 0x2080
movq -0x58(%rbp), %rcx
movq %rcx, (%rax)
movq 0xbeb4(%rip), %rsi      # 0xefc0
movq %rax, %rdi
xorl %edx, %edx
callq 0x2230
movq %rax, %rbx
jmp 0x3133
jmp 0x3127
jmp 0x3127
jmp 0x3127
jmp 0x3127
jmp 0x3127
jmp 0x3127
movq %rax, %rbx
movq -0x48(%rbp), %rdi
callq 0x7df2
leaq -0x90(%rbp), %rdi
callq 0x7e4e
movq %rbx, %rdi
callq 0x2240