// File: 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
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movsd 0x154a9(%rip), %xmm0    # 0x1e030
movsd %xmm0, -0x30(%rbp)
movsd 0x15494(%rip), %xmm0    # 0x1e028
movsd %xmm0, -0x38(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpq -0x8(%rbp), %rax
jae 0x8c82
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rsi
shlq %rsi
callq 0xbda0
movsd (%rax), %xmm0
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x10(%rbp), %rdi
movq -0x60(%rbp), %rsi
shlq %rsi
addq $0x1, %rsi
callq 0xbda0
movsd (%rax), %xmm0
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x68(%rbp), %xmm1
movsd -0x40(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x8c29
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x68(%rbp), %xmm0
ucomisd -0x50(%rbp), %xmm0
jbe 0x8c3f
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x70(%rbp), %xmm1
movsd -0x48(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x8c59
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movsd -0x70(%rbp), %xmm0
ucomisd -0x58(%rbp), %xmm0
jbe 0x8c6f
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x8c71
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x8bc1
movsd -0x50(%rbp), %xmm0
subsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd -0x58(%rbp), %xmm0
subsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movq 0x25329(%rip), %rdi     # 0x2dfd0
leaq 0x15482(%rip), %rsi     # 0x1e130
callq 0x2180
movq %rax, %rdi
movsd -0x78(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
callq 0x22e0
movq %rax, %rdi
leaq 0x1546e(%rip), %rsi     # 0x1e13d
callq 0x2180
movq %rax, %rdi
movsd -0x80(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
callq 0x22e0
movq %rax, %rdi
leaq 0x15458(%rip), %rsi     # 0x1e148
callq 0x2180
movq %rax, %rdi
leaq 0x1544c(%rip), %rsi     # 0x1e14b
callq 0x2180
movq %rax, %rdi
movsd -0x40(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd 0x152f7(%rip), %xmm2    # 0x1e010
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
callq 0x22e0
movq %rax, %rdi
leaq 0x15419(%rip), %rsi     # 0x1e149
callq 0x2180
movq %rax, %rdi
movsd -0x48(%rbp), %xmm0
movsd -0x38(%rbp), %xmm1
movsd 0x152c6(%rip), %xmm2    # 0x1e010
divsd %xmm2, %xmm1
subsd %xmm1, %xmm0
callq 0x22e0
movq %rax, %rdi
leaq 0x153e8(%rip), %rsi     # 0x1e149
callq 0x2180
movq %rax, %rdi
movsd -0x78(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
callq 0x22e0
movq %rax, %rdi
leaq 0x153c7(%rip), %rsi     # 0x1e149
callq 0x2180
movq %rax, %rdi
movsd -0x80(%rbp), %xmm0
addsd -0x38(%rbp), %xmm0
callq 0x22e0
movq %rax, %rdi
leaq 0x153b2(%rip), %rsi     # 0x1e155
callq 0x2180
movq %rax, %rdi
leaq 0x153c9(%rip), %rsi     # 0x1e17b
callq 0x2180
movq %rax, %rdi
leaq 0x153d2(%rip), %rsi     # 0x1e193
callq 0x2180
movq %rax, %rdi
leaq 0x15410(%rip), %rsi     # 0x1e1e0
callq 0x2180
movq %rax, %rdi
movq 0x251d9(%rip), %rsi     # 0x2dfb8
callq 0x21b0
movq $0x0, -0x88(%rbp)
movq -0x88(%rbp), %rax
cmpq -0x18(%rbp), %rax
jae 0x8f6d
movq -0x20(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0xb270
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x28(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0xb270
movq (%rax), %rax
movq %rax, -0x98(%rbp)
movq 0x25195(%rip), %rdi     # 0x2dfd0
leaq 0x153a7(%rip), %rsi     # 0x1e1e9
callq 0x2180
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rdi
movq -0x90(%rbp), %rsi
shlq %rsi
callq 0xbda0
movq -0xb8(%rbp), %rdi
movsd (%rax), %xmm0
mulsd -0x30(%rbp), %xmm0
callq 0x22e0
movq %rax, %rdi
leaq 0x15374(%rip), %rsi     # 0x1e1f4
callq 0x2180
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x98(%rbp), %rsi
shlq %rsi
callq 0xbda0
movq -0xb0(%rbp), %rdi
movsd (%rax), %xmm0
mulsd -0x30(%rbp), %xmm0
callq 0x22e0
movq %rax, %rdi
leaq 0x1533d(%rip), %rsi     # 0x1e1fb
callq 0x2180
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rdi
movq -0x90(%rbp), %rsi
shlq %rsi
addq $0x1, %rsi
callq 0xbda0
movq -0xa8(%rbp), %rdi
movsd (%rax), %xmm0
mulsd -0x30(%rbp), %xmm0
callq 0x22e0
movq %rax, %rdi
leaq 0x15302(%rip), %rsi     # 0x1e202
callq 0x2180
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x98(%rbp), %rsi
shlq %rsi
addq $0x1, %rsi
callq 0xbda0
movq -0xa0(%rbp), %rdi
movsd (%rax), %xmm0
mulsd -0x30(%rbp), %xmm0
callq 0x22e0
movq %rax, %rdi
leaq 0x152c7(%rip), %rsi     # 0x1e209
callq 0x2180
movq %rax, %rdi
movq 0x25067(%rip), %rsi     # 0x2dfb8
callq 0x21b0
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0x8def
movq 0x2505c(%rip), %rdi     # 0x2dfd0
leaq 0x15292(%rip), %rsi     # 0x1e20d
callq 0x2180
movq %rax, %rdi
movq 0x2502e(%rip), %rsi     # 0x2dfb8
callq 0x21b0
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)