// File: /workspace/github_cpp_makefile_star2_O2/ekg[P]sgd2/src/main.cpp
// Function: draw_svg(unsigned long, std::vector<double, std::allocator<double>> const&, unsigned long, std::vector<unsigned long, std::allocator<unsigned long>> const&, std::vector<unsigned long, std::allocator<unsigned long>> const&)
void draw_svg(uint64_t n, const std::vector<double>& X, uint64_t len_I, const std::vector<uint64_t>& I, const std::vector<uint64_t>& J) {
    double scale = 5.0;
    double border = 10.0;
    double min_x = 0;
    double min_y = 0;
    double max_x = 0;
    double max_y = 0;
    // determine boundaries
    for (uint64_t i = 0; i < n; ++i) {
        double x = X[i*2]*scale;
        double y = X[i*2+1]*scale;
        if (x < min_x) min_x = x;
        if (x > max_x) max_x = x;
        if (y < min_y) min_y = y;
        if (y > max_y) max_y = y;
    }
    double width = max_x - min_x;
    double height = max_y - min_y;
    
    std::cout << "<svg width=\"" << width + border << "\" height=\"" << height + border << "\" "
              << "viewBox=\"" << min_x - border/2<< " " << min_y - border/2 << " " << width + border << " " << height + border << "\" xmlns=\"http://www.w3.org/2000/svg\">"
              << "<style type=\"text/css\">"
              << "line{stroke:black;stroke-width:1.0;stroke-opacity:1.0;stroke-linecap:round;}"
        //<< "circle{{r:" << 1.0 << ";fill:black;fill-opacity:" << 1.0 << "}}"
              << "</style>"
              << std::endl;

    for (uint64_t i = 0; i < len_I; ++i) {
        uint64_t a = I[i];
        uint64_t b = J[i];
        std::cout << "<line x1=\"" << X[a*2]*scale << "\" x2=\"" << X[b*2]*scale
                  << "\" y1=\"" << X[a*2+1]*scale << "\" y2=\"" << X[b*2+1]*scale << "\"/>"
                  << std::endl;
    }

    /* // to draw nodes
    for (uint64_t i = 0; i < n; ++i) {
        std::cout << "<circle cx=\"" << X[i*2]*scale << "\" cy=\"" << X[i*2+1]*scale << "\" r=\"1.0\"/>" << std::endl;
    }
    */
    std::cout << "</svg>" << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, -0x58(%rbp)
movq %rcx, -0x50(%rbp)
movq %rdx, -0x60(%rbp)
movq %rsi, %r12
movq (%rsi), %rax
addq $0x8, %rax
xorpd %xmm4, %xmm4
xorpd %xmm5, %xmm5
xorpd %xmm6, %xmm6
xorpd %xmm3, %xmm3
subq $0x1, %rdi
jb 0x56ff
movsd -0x8(%rax), %xmm0
movsd 0x5973(%rip), %xmm2     # 0xb038
mulsd %xmm2, %xmm0
movsd (%rax), %xmm1
mulsd %xmm2, %xmm1
movapd %xmm0, %xmm2
minsd %xmm3, %xmm2
maxsd %xmm5, %xmm0
movapd %xmm1, %xmm3
minsd %xmm6, %xmm3
maxsd %xmm4, %xmm1
addq $0x10, %rax
movapd %xmm1, %xmm4
movapd %xmm0, %xmm5
movapd %xmm3, %xmm6
movapd %xmm2, %xmm3
jmp 0x56b2
subsd %xmm3, %xmm5
movsd %xmm5, -0x38(%rbp)
subsd %xmm6, %xmm4
movsd %xmm4, -0x30(%rbp)
movq 0xb8b8(%rip), %rdi      # 0x10fd0
leaq 0x5a41(%rip), %rsi      # 0xb160
movsd %xmm6, -0x48(%rbp)
movsd %xmm3, -0x40(%rbp)
callq 0x2140
movsd -0x38(%rbp), %xmm0
addsd 0x5905(%rip), %xmm0     # 0xb040
movsd %xmm0, -0x38(%rbp)
movq %rax, %rdi
callq 0x21c0
leaq 0x5a1e(%rip), %rsi      # 0xb16d
movq %rax, %rdi
callq 0x2140
movsd -0x30(%rbp), %xmm0
addsd 0x58dc(%rip), %xmm0     # 0xb040
movsd %xmm0, -0x30(%rbp)
movq %rax, %rdi
callq 0x21c0
leaq 0x5a00(%rip), %rsi      # 0xb178
movq %rax, %rdi
callq 0x2140
leaq 0x59f4(%rip), %rsi      # 0xb17b
movq %rax, %rdi
callq 0x2140
movsd -0x40(%rbp), %xmm0
addsd 0x58ac(%rip), %xmm0     # 0xb048
movq %rax, %rdi
callq 0x21c0
leaq 0x59ce(%rip), %rbx      # 0xb179
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2140
movsd -0x48(%rbp), %xmm0
addsd 0x5885(%rip), %xmm0     # 0xb048
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2140
movq %rax, %rdi
movsd -0x38(%rbp), %xmm0
callq 0x21c0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2140
movq %rax, %rdi
movsd -0x30(%rbp), %xmm0
callq 0x21c0
leaq 0x5983(%rip), %rsi      # 0xb185
movq %rax, %rdi
callq 0x2140
leaq 0x599a(%rip), %rsi      # 0xb1ab
movq %rax, %rdi
callq 0x2140
leaq 0x59a3(%rip), %rsi      # 0xb1c3
movq %rax, %rdi
callq 0x2140
leaq 0x59e1(%rip), %rsi      # 0xb210
movq %rax, %rdi
callq 0x2140
movq %rax, %rdi
callq 0x2080
xorl %ebx, %ebx
leaq 0x59f1(%rip), %r13      # 0xb239
cmpq %rbx, -0x60(%rbp)
je 0x5939
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq (%rax,%rbx,8), %r15
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq (%rax,%rbx,8), %r14
movq 0xb761(%rip), %rdi      # 0x10fd0
leaq 0x59a3(%rip), %rsi      # 0xb219
callq 0x2140
movq (%r12), %rcx
shlq $0x4, %r15
movsd (%rcx,%r15), %xmm0
movsd 0x57a7(%rip), %xmm1     # 0xb038
mulsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
leaq 0x597d(%rip), %rsi      # 0xb224
callq 0x2140
movq (%r12), %rcx
shlq $0x4, %r14
movsd (%rcx,%r14), %xmm0
mulsd 0x5776(%rip), %xmm0     # 0xb038
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
leaq 0x5957(%rip), %rsi      # 0xb22b
callq 0x2140
movq (%r12), %rcx
movsd 0x8(%rcx,%r15), %xmm0
mulsd 0x574c(%rip), %xmm0     # 0xb038
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
leaq 0x5934(%rip), %rsi      # 0xb232
callq 0x2140
movq (%r12), %rcx
movsd 0x8(%rcx,%r14), %xmm0
mulsd 0x5722(%rip), %xmm0     # 0xb038
movq %rax, %rdi
callq 0x21c0
movq %rax, %rdi
movq %r13, %rsi
callq 0x2140
movq %rax, %rdi
callq 0x2080
incq %rbx
jmp 0x5848
movq 0xb690(%rip), %rdi      # 0x10fd0
leaq 0x58f6(%rip), %rsi      # 0xb23d
callq 0x2140
movq %rax, %rdi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2080