// File: /workspace/github_cpp_makefile_star2_O3/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 0x4581(%rip), %rsi      # 0xb310
leaq -0x13e8(%rbp), %rax
movl $0x9, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x30(%rbp), %rdi
leaq -0x2770(%rbp), %rcx
movl $0x9, %edx
movq %rax, %rsi
callq 0x7cbc
leaq 0x4598(%rip), %rsi      # 0xb358
leaq -0x13e8(%rbp), %rax
movl $0x9, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq -0x48(%rbp), %rdi
leaq -0x2770(%rbp), %rcx
movl $0x9, %edx
movq %rax, %rsi
callq 0x7cbc
movl $0x80, %edi
callq 0x2160
movq %rax, %rbx
movq %rax, -0x60(%rbp)
subq $-0x80, %rax
movq %rax, -0x50(%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, -0x58(%rbp)
leaq -0x13e8(%rbp), %rdi
callq 0x6fc0
leaq -0x13e8(%rbp), %rdi
callq 0x21a0
movl %eax, %eax
movq %rax, -0x2770(%rbp)
movl $0x1, %ecx
movq %rax, %rdx
shrq $0x1e, %rdx
xorl %eax, %edx
imull $0x6c078965, %edx, %eax # imm = 0x6C078965
addl %ecx, %eax
movq %rax, -0x2770(%rbp,%rcx,8)
incq %rcx
cmpq $0x270, %rcx            # imm = 0x270
jne 0x6e58
leaq -0x2770(%rbp), %r14
movq $0x270, 0x1380(%r14) # imm = 0x270
xorl %r15d, %r15d
movq %r14, %rdi
callq 0x96b7
addsd 0x4176(%rip), %xmm0     # 0xb018
movsd %xmm0, (%rbx,%r15,8)
incq %r15
cmpq $0x10, %r15
jne 0x6e92
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
movq -0x48(%rbp), %r8
movq $0x1e, (%rsp)
movsd 0x417c(%rip), %xmm0     # 0xb050
movl $0x8, %edi
movl $0xa, %r9d
movq %rbx, %rsi
callq 0x6685
leaq -0x60(%rbp), %rsi
leaq -0x30(%rbp), %rcx
leaq -0x48(%rbp), %r8
movl $0x8, %edi
movl $0x9, %edx
callq 0x698b
leaq -0x13e8(%rbp), %rdi
callq 0x2130
movl $0x80, %esi
movq %rbx, %rdi
callq 0x2170
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x6f30
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x6f45
movq -0x20(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
xorl %eax, %eax
addq $0x2768, %rsp           # imm = 0x2768
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6fb8
jmp 0x6f6a
movq %rax, %r14
jmp 0x6f79
movq %rax, %r14
jmp 0x6f86
movq %rax, %r14
jmp 0x6f9b
jmp 0x6f6a
movq %rax, %r14
leaq -0x13e8(%rbp), %rdi
callq 0x2130
movl $0x80, %esi
movq %rbx, %rdi
callq 0x2170
movq -0x48(%rbp), %rdi
testq %rdi, %rdi
je 0x6f9b
movq -0x38(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x6fb0
movq -0x20(%rbp), %rsi
subq %rdi, %rsi
callq 0x2170
movq %r14, %rdi
callq 0x2230
movq %rax, %rdi
callq 0x7da0