// File: /workspace/github_cpp_makefile_star2_O1/ekg[P]sgd2/src/main.cpp
// Function: main
int main(void) {
    uint64_t n = 8;
    uint64_t len_I = 9;
    //uint64_t I[len_I] = { 0,0,1,2,3,4,4,5,6 };
    //uint64_t J[len_I] = { 1,2,3,3,4,5,6,7,7 };
    std::vector<uint64_t> I = { 0,0,1,2,3,4,4,5,6 };
    std::vector<uint64_t> J = { 1,2,3,3,4,5,6,7,7 };
    //double V[len_I] = { 1,2,1,1,3,1,2,2,1 };
    //double X[2*n]; // = { 0,0, .1,.1, .2,.2, .3,.3, .4,.4, .5,.5, .6,.6, .7,.7 };
    std::vector<double> X(2*n);
    std::random_device dev;
    // todo, seed with graph topology/contents to get a stable result
    std::mt19937 rng(dev());
    std::uniform_real_distribution<double> dist(0,1);
    for (uint64_t i = 0; i < 2*n; ++i) {
        X[i] = dist(rng);
    }
    //double X[2*n];
    uint64_t p = 10;
    uint64_t t_max = 30;
    double eps = 0.01;
    //layout_sparse_weighted(n, X, len_I, I, J, V, p, t_max, eps);
    sgd2::layout_sparse_unweighted(n, X.data(), I.size(), I.data(), J.data(), p, t_max, eps);
    /*
    for (uint64_t i = 0; i < n; ++i) {
        std::cout << X[i*2] << " " << X[i*2+1] << std::endl;
    }
    */
    draw_svg(n, X, len_I, I, J);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x2768, %rsp           # imm = 0x2768
leaq 0x3e83(%rip), %rsi      # 0xb310
leaq -0x13f0(%rbp), %rax
movl $0x9, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x30(%rbp), %rdi
leaq -0x2778(%rbp), %rcx
movl $0x9, %edx
movq %rax, %rsi
callq 0x83e8
leaq 0x3e9a(%rip), %rsi      # 0xb358
leaq -0x13f0(%rbp), %rax
movl $0x9, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x68(%rbp), %rdi
leaq -0x2778(%rbp), %rcx
movl $0x9, %edx
movq %rax, %rsi
callq 0x83e8
xorpd %xmm0, %xmm0
movapd %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movl $0x80, %edi
callq 0x2170
movq %rax, %rbx
movq %rax, -0x50(%rbp)
movq %rax, -0x48(%rbp)
subq $-0x80, %rax
movq %rax, -0x40(%rbp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x70(%rbx)
movupd %xmm0, 0x60(%rbx)
movupd %xmm0, 0x50(%rbx)
movupd %xmm0, 0x40(%rbx)
movupd %xmm0, 0x30(%rbx)
movupd %xmm0, 0x20(%rbx)
movupd %xmm0, 0x10(%rbx)
movupd %xmm0, (%rbx)
movq %rax, -0x48(%rbp)
leaq -0x13f0(%rbp), %rdi
callq 0x76d4
leaq -0x13f0(%rbp), %rdi
callq 0x21b0
movl %eax, %eax
movq %rax, -0x2778(%rbp)
movl $0x1, %ecx
movq %rax, %rdx
shrq $0x1e, %rdx
xorl %eax, %edx
imull $0x6c078965, %edx, %eax # imm = 0x6C078965
addl %ecx, %eax
movq %rax, -0x2778(%rbp,%rcx,8)
incq %rcx
cmpq $0x270, %rcx            # imm = 0x270
jne 0x756b
leaq -0x2778(%rbp), %r14
movq $0x270, 0x1380(%r14) # imm = 0x270
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x9d7d
addsd 0x3a63(%rip), %xmm0     # 0xb018
movsd %xmm0, (%rbx,%r15,8)
incq %r15
cmpq $0x10, %r15
jne 0x75a5
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
movq -0x68(%rbp), %r8
movq $0x1e, (%rsp)
movsd 0x3a69(%rip), %xmm0     # 0xb050
movl $0x8, %edi
movl $0xa, %r9d
movq %rbx, %rsi
callq 0x6d83
leaq -0x50(%rbp), %rsi
leaq -0x30(%rbp), %rcx
leaq -0x68(%rbp), %r8
movl $0x8, %edi
movl $0x9, %edx
callq 0x7089
leaq -0x13f0(%rbp), %rdi
callq 0x2140
movl $0x80, %esi
movq %rbx, %rdi
callq 0x2180
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x7643
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x7658
movq -0x20(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
xorl %eax, %eax
addq $0x2768, %rsp           # imm = 0x2768
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x76cb
jmp 0x767d
movq %rax, %r14
jmp 0x768c
movq %rax, %r14
jmp 0x7699
movq %rax, %r14
jmp 0x76ae
jmp 0x767d
movq %rax, %r14
leaq -0x13f0(%rbp), %rdi
callq 0x2140
movl $0x80, %esi
movq %rbx, %rdi
callq 0x2180
movq -0x68(%rbp), %rdi
testq %rdi, %rdi
je 0x76ae
movq -0x58(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x76c3
movq -0x20(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq %r14, %rdi
callq 0x2240
movq %rax, %rdi
callq 0x84c7
nop