// File: /workspace/github_cpp_makefile_star2_O2/Erkaman[P]spiky-anim/main.cpp
// Function: makeSpiky(_IO_FILE*, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void makeSpiky(FILE* fp, float rad, string color) {
    int N = 24;

    // spiky center in image center.
    float PX = WIDTH/2;
    float PY = HEIGHT/2;

    vector<vec2> pos(N);

    float SMALLR = rad * 0.20f;
    float R1 = rad - SMALLR;
    float R2 = rad + SMALLR;

    // generate points on circle. But displace the points in direction of normal.
    // so that it becomes spiky.
    for(int i = 0; i < N; i++) {
        float theta = (i / (float)N) * 2.0 * PI;

        float R = i % 2 == 0 ? R1 : R2;

        pos[i].x = PX + R * cos(theta);
        pos[i].y = PY + R * sin(theta);
    }

    string str;

    // now make line paths between the generated points.
    for(int i = 0; i < (N+1); i++) {
        vec2 v = pos[(i) % N];

        if(i == 0) {
            // for first point, we just position the cursor.
            str += "<path d=\"M" + to_string(v.x) + ", " + to_string(v.y);
        } else {
            str += "L " +     to_string(v.x) + " " + to_string(v.y) + " ";
        }
    }

    str += "Z\n"; // close loop. path is now done.
    str += "\" />";

    float strokeWidth = 2.0f + 10.0f * (rad / 100.0f);
    if(strokeWidth > 8.0f) { // clamp stroke-width to max 8.0f
        strokeWidth = 8.0f;
    }

    fprintf(fp,"<g fill=\"none\" stroke=\"%s\"  stroke-width=\"%f\" fill-opacity=\"1.0\">", color.c_str(), strokeWidth);
    fprintf(fp,"%s", str.c_str() );

    fprintf(fp,"</g>");

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rsi, -0x40(%rbp)
movss %xmm0, -0x30(%rbp)
movq %rdi, -0x48(%rbp)
leaq -0x80(%rbp), %rdi
pushq $0x18
popq %rsi
leaq -0x68(%rbp), %rdx
callq 0x2dc2
movss 0x1bec(%rip), %xmm0     # 0x4004
mulss -0x30(%rbp), %xmm0
movaps 0x1c0c(%rip), %xmm1     # 0x4030
movaps %xmm0, -0xf0(%rbp)
xorps %xmm0, %xmm1
movaps %xmm1, -0x100(%rbp)
xorl %ebx, %ebx
cmpq $0x18, %rbx
je 0x24cb
cvtsi2ss %ebx, %xmm0
divss 0x1bbb(%rip), %xmm0     # 0x4008
cvtss2sd %xmm0, %xmm0
addsd %xmm0, %xmm0
mulsd 0x1be3(%rip), %xmm0     # 0x4040
movaps -0x100(%rbp), %xmm1
testb $0x1, %bl
je 0x2470
movaps -0xf0(%rbp), %xmm1
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x34(%rbp)
addss -0x30(%rbp), %xmm1
movss %xmm1, -0x2c(%rbp)
callq 0x20d0
mulss -0x2c(%rbp), %xmm0
movss 0x1b77(%rip), %xmm1     # 0x400c
addss %xmm1, %xmm0
movq -0x80(%rbp), %rax
movss %xmm0, (%rax,%rbx,8)
movss -0x34(%rbp), %xmm0
callq 0x2100
mulss -0x2c(%rbp), %xmm0
addss 0x1b53(%rip), %xmm0     # 0x400c
movq -0x80(%rbp), %rax
movss %xmm0, 0x4(%rax,%rbx,8)
incq %rbx
jmp 0x2437
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x140(%rbp), %r12
leaq -0x160(%rbp), %r14
xorl %r15d, %r15d
cmpl $0x19, %r15d
je 0x2689
cmpl $0x18, %r15d
movl %r15d, %eax
movl $0x0, %ecx
cmovel %ecx, %eax
movq -0x80(%rbp), %rcx
movss (%rcx,%rax,8), %xmm0
movss 0x4(%rcx,%rax,8), %xmm1
movss %xmm1, -0x2c(%rbp)
testl %r15d, %r15d
je 0x25e4
movq %r12, %rdi
callq 0x2edb
leaq -0xe0(%rbp), %r13
movq %r13, %rdi
leaq 0x1b25(%rip), %rsi      # 0x4060
movq %r12, %rdx
callq 0x2ead
leaq -0xa0(%rbp), %rdi
movq %r13, %rsi
leaq 0x1c1c(%rip), %rdx      # 0x4170
callq 0x2e84
leaq -0x120(%rbp), %r13
movq %r13, %rdi
movss -0x2c(%rbp), %xmm0
callq 0x2edb
leaq -0xc0(%rbp), %rbx
movq %rbx, %rdi
leaq -0xa0(%rbp), %rsi
movq %r13, %rdx
callq 0x2e13
movq %r14, %rdi
movq %rbx, %rsi
leaq 0x1bdd(%rip), %rdx      # 0x4170
callq 0x2e84
leaq -0x68(%rbp), %rdi
movq %r14, %rsi
callq 0x2230
movq %r14, %rdi
callq 0x2090
leaq -0xc0(%rbp), %rdi
callq 0x2090
leaq -0x120(%rbp), %rdi
callq 0x2090
leaq -0xa0(%rbp), %rdi
callq 0x2090
leaq -0xe0(%rbp), %rdi
callq 0x2090
movq %r12, %rdi
jmp 0x267c
leaq -0xe0(%rbp), %r13
movq %r13, %rdi
callq 0x2edb
leaq -0xa0(%rbp), %rbx
movq %rbx, %rdi
leaq 0x1a4e(%rip), %rsi      # 0x4052
movq %r13, %rdx
callq 0x2ead
leaq -0xc0(%rbp), %rdi
movq %rbx, %rsi
leaq 0x1a40(%rip), %rdx      # 0x405d
callq 0x2e84
movq %r12, %rdi
movss -0x2c(%rbp), %xmm0
callq 0x2edb
movq %r14, %rdi
leaq -0xc0(%rbp), %rsi
movq %r12, %rdx
callq 0x2e13
leaq -0x68(%rbp), %rdi
movq %r14, %rsi
callq 0x2230
movq %r14, %rdi
callq 0x2090
movq %r12, %rdi
callq 0x2090
leaq -0xc0(%rbp), %rdi
callq 0x2090
leaq -0xa0(%rbp), %rdi
callq 0x2090
leaq -0xe0(%rbp), %rdi
callq 0x2090
incl %r15d
jmp 0x24ec
leaq 0x19d3(%rip), %rsi      # 0x4063
leaq -0x68(%rbp), %rdi
callq 0x2210
leaq 0x19c6(%rip), %rsi      # 0x4066
leaq -0x68(%rbp), %rdi
callq 0x2210
movss -0x30(%rbp), %xmm1
divss 0x195a(%rip), %xmm1     # 0x4010
mulss 0x1956(%rip), %xmm1     # 0x4014
addss 0x1952(%rip), %xmm1     # 0x4018
movss 0x194e(%rip), %xmm0     # 0x401c
minss %xmm1, %xmm0
movq -0x40(%rbp), %rax
movq (%rax), %rdx
cvtss2sd %xmm0, %xmm0
leaq 0x1987(%rip), %rsi      # 0x406b
movq -0x48(%rbp), %r14
movq %r14, %rdi
movb $0x1, %al
callq 0x21b0
leaq -0x68(%rbp), %rbx
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x2150
leaq 0x19a5(%rip), %rdi      # 0x40ad
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x2220
movq %rbx, %rdi
callq 0x2090
leaq -0x80(%rbp), %rdi
callq 0x3252
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2792
movq %rax, %rbx
jmp 0x275b
jmp 0x2792
movq %rax, %rbx
jmp 0x2767
movq %rax, %rbx
jmp 0x2773
movq %rax, %rbx
leaq -0x160(%rbp), %rdi
callq 0x2090
leaq -0x140(%rbp), %rdi
callq 0x2090
leaq -0xc0(%rbp), %rdi
callq 0x2090
leaq -0xa0(%rbp), %rdi
callq 0x2090
jmp 0x2784
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
jmp 0x27f1
movq %rax, %rbx
jmp 0x27d2
movq %rax, %rbx
jmp 0x27f6
movq %rax, %rbx
jmp 0x27c6
movq %rax, %rbx
jmp 0x27ea
movq %rax, %rbx
jmp 0x27ba
movq %rax, %rbx
jmp 0x27de
movq %rax, %rbx
leaq -0x160(%rbp), %rdi
callq 0x2090
leaq -0xc0(%rbp), %rdi
callq 0x2090
leaq -0x120(%rbp), %rdi
callq 0x2090
leaq -0xa0(%rbp), %rdi
callq 0x2090
leaq -0xe0(%rbp), %rdi
callq 0x2090
leaq -0x140(%rbp), %rdi
callq 0x2090
leaq -0x68(%rbp), %rdi
callq 0x2090
leaq -0x80(%rbp), %rdi
callq 0x3252
movq %rbx, %rdi
callq 0x21f0