// File: /workspace/github_cpp_makefile_star2_O3/phillip-h[P]fractal-gen/fractalgen.cpp
// Function: main
int main(int argc, char** argv)
{
    if (argc < 4) {
        cout << "too few arguments!\n";
        cout << "usage: fractal-gen <width> <height> <scale>\n";
        cout << "                   ";
        cout << "[color A] [color B] [color C]\n";
        cout << "                   ";
        cout << "[cr+ci] [color depth] [offx] [offy]\n";
        return -1;
    }
    
    unsigned width = atoi(argv[1]);
    unsigned height = atoi(argv[2]);
    double size = atof(argv[3]); 
    unsigned color_depth = 255;
    double offx = -0.5;
    double offy = 0.0;
    bool mandel = true;
    complex c_arg(0, 0);
    auto file = "fractal.png";

    auto A_R = 0;
    auto A_G = 0;
    auto A_B = 0;

    auto B_R = 255;
    auto B_G = 255;
    auto B_B = 255;

    auto D_R = 0;
    auto D_G = 0;
    auto D_B = 0;

    if (argc > 4) {
        std::string str(argv[4]);
        if (str.at(0) == '#')
            str = str.substr(1, str.size() - 1);
        if (str.size() != 6) {
            cout << "error -- invalid color!\n";
            cout << "express colors as '#RRGGBB'.\n";
            return -1;
        }

        std::string sub_str = str.substr(0, 2);
        A_R = htoi(sub_str);

        sub_str = str.substr(2, 2);
        A_G = htoi(sub_str);
        
        sub_str = str.substr(4, 2);
        A_B = htoi(sub_str);
    }

    if (argc > 5) {
        std::string str(argv[5]);
        if (str.at(0) == '#')
            str = str.substr(1, str.size() - 1);
        if (str.size() != 6) {
            cout << "error -- invalid color!\n";
            cout << "express colors as '#RRGGBB'.\n";
            return -1;
        }

        std::string sub_str = str.substr(0, 2);
        B_R = htoi(sub_str);

        sub_str = str.substr(2, 2);
        B_G = htoi(sub_str);
        
        sub_str = str.substr(4, 2);
        B_B = htoi(sub_str);
    }
    
    if (argc > 6) {
        std::string str(argv[6]);
        if (str.at(0) == '#')
            str = str.substr(1, str.size() - 1);
        if (str.size() != 6) {
            cout << "error -- invalid color!\n";
            cout << "express colors as '#RRGGBB'.\n";
            return -1;
        }

        std::string sub_str = str.substr(0, 2);
        D_R = htoi(sub_str);

        sub_str = str.substr(2, 2);
        D_G = htoi(sub_str);
        
        sub_str = str.substr(4, 2);
        D_B = htoi(sub_str);
    }

    if (argc > 7 && std::string(argv[7]) != "mandelbrot") {
        mandel = false;
        offx = 0;
        offy = 0;
        std::string str(argv[7]);
        unsigned pos = 0;
        for (unsigned i = 0; i < str.size(); i++)
        {
            if (str.at(i) == '+') {
                pos = i + 1;
                break;
            }
        }
        if (pos == 0) {
            cout << "invalid complex argument!\n";
            return -1;
        }
        double real = atof(str.substr(0, pos - 1).c_str());
        double imag = atof(str.substr(pos, str.size() - pos).c_str());
        c_arg = complex(real, imag);
    }

    if (argc > 8)
        color_depth = atof(argv[8]);
    if (argc > 9)
        offx = atof(argv[9]);
    if (argc > 10)
        offy = atof(argv[10]);
    if (argc > 11)
        cout << "warning -- extra arguments, ignoring them.\n";

    cout << "fractal information:\n\n";
    
    if (mandel) {
        cout << "fractal type -- mandelbrot\n";
    } else {
        cout << "fractal type -- julia\n";
        cout << "complex argument -- " << c_arg.to_str() << "\n";
    }

    cout << "\n";
    cout << "width       -- " << width << "\n";
    cout << "height      -- " << height << "\n";
    cout << "pixels      -- " << (width * height * 4) << "\n";
    cout << "scale       -- " << size << "\n";
    cout << "color A     -- (";
    cout << A_R << ", " << A_G << ", " << A_B << ")\n";
    cout << "color B     -- (";
    cout << B_R << ", " << B_G << ", " << B_B << ")\n";
    cout << "color C     -- (";
    cout << D_R << ", " << D_G << ", " << D_B << ")\n";
    cout << "color depth -- " << color_depth << "\n";
    cout << "offx        -- " << offx << "\n";
    cout << "offy        -- " << offy << "\n";

    vector<unsigned char> image(width * height * 4);

    auto lerp = [&] (double x0, double y0,
                    double x1, double y1,
                    double t)
    {
        double m = (y1 - y0) / (x1 - x0);
        return y0 + t * m;
    };

    auto comp_color_r = [&] (unsigned val)
    {
        if (val == color_depth)
            return D_R;
        double rat = (double) val / color_depth;
        double dc = lerp(0, A_R, 1, B_R, rat);
        return (int) dc;
    };

    auto comp_color_g = [&] (unsigned val)
    {
        if (val == color_depth)
            return D_G;
        double rat = (double) val / color_depth;
        double dc = lerp(0, A_G, 1, B_G, rat);
        return (int) dc;
    };

    auto comp_color_b = [&] (unsigned val)
    {
        if (val == color_depth)
            return D_B;
        double rat = (double) val / color_depth;
        double dc = lerp(0, A_B, 1, B_B, rat);
        return (int) dc;
    };

    double r;
    double i;
    complex c;
    unsigned color;
    for (unsigned x = 0; x < width; x++)
    {
        for (unsigned y = 0; y < height; y++)
        {
            r = offx - size / 2 + size * x / width;
            i = offy - size / 2 + size * y / height;
            c = complex(r, i);
            if (mandel)
                color = eval(c, color_depth, c);
            else
                color = eval(c, color_depth, c_arg);
            set_pixel(comp_color_r(color),
                      comp_color_g(color),
                      comp_color_b(color), 
                      x, y, image, height);
        }
    }

    unsigned error = lodepng::encode(file, image, width, height);
    if (error)
        cout << "error -- " << lodepng_error_text(error) << std::endl;
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
cmpl $0x3, %edi
jg 0x2712
movq 0x14948(%rip), %rbx     # 0x16fd8
leaq 0xe99c(%rip), %rsi      # 0x11033
movl $0x13, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0xe99c(%rip), %rsi      # 0x11047
movl $0x2c, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0xe9b5(%rip), %r14      # 0x11074
movl $0x13, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2190
leaq 0xe9b2(%rip), %rsi      # 0x11088
movl $0x1e, %edx
movq %rbx, %rdi
callq 0x2190
movl $0x13, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2190
leaq 0xe9ad(%rip), %rsi      # 0x110a7
movl $0x24, %edx
movq %rbx, %rdi
callq 0x2190
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x33be
movl %edi, %ebx
movq 0x8(%rsi), %rdi
movq %rsi, %r15
callq 0x2230
movq 0x10(%r15), %rdi
movl %eax, %r14d
callq 0x2230
movq 0x18(%r15), %rdi
movl %eax, 0xa4(%rsp)
callq 0x21d0
vmovsd %xmm0, 0xb8(%rsp)
vxorpd %xmm0, %xmm0, %xmm0
movl $0xff, %r13d
movl $0x0, 0x64(%rsp)
movl %r14d, 0x14(%rsp)
vmovapd %xmm0, 0xe0(%rsp)
cmpl $0x4, %ebx
jne 0x27b9
xorl %r15d, %r15d
movl $0x0, 0x18(%rsp)
movl $0x0, 0x60(%rsp)
movl $0x0, 0xb0(%rsp)
movl $0x0, 0x88(%rsp)
movl $0xff, 0x90(%rsp)
movl $0xff, 0xa8(%rsp)
movl $0xff, 0x98(%rsp)
jmp 0x2ccd
movq 0x20(%r15), %rsi
movl %ebx, 0x1c(%rsp)
movq %r15, 0x78(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x2080
movq 0x28(%rsp), %rbx
testq %rbx, %rbx
je 0x39ea
movq 0x20(%rsp), %rax
cmpb $0x23, (%rax)
jne 0x2830
decq %rbx
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2160
leaq 0x40(%rsp), %rbx
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x21c0
movq (%rbx), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x282b
callq 0x2120
movq 0x28(%rsp), %rbx
cmpq $0x6, %rbx
jne 0x29e9
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x2, %ecx
xorl %edx, %edx
callq 0x2160
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x218(%rsp), %r14
movq %r14, -0x10(%r14)
addq %rsi, %rdx
leaq 0x208(%rsp), %rdi
callq 0x3f06
leaq 0x208(%rsp), %rdi
callq 0x2543
movq 0x208(%rsp), %rdi
movl %eax, %r15d
cmpq %r14, %rdi
je 0x2898
callq 0x2120
leaq 0xc0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x2, %edx
movl $0x2, %ecx
callq 0x2160
leaq 0xc0(%rsp), %r14
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
callq 0x21c0
movq (%r14), %rdi
leaq 0xd0(%rsp), %rbp
cmpq %rbp, %rdi
je 0x28de
callq 0x2120
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x1f8(%rsp), %r12
movq %r12, -0x10(%r12)
addq %rsi, %rdx
leaq 0x1e8(%rsp), %rdi
callq 0x3f06
leaq 0x1e8(%rsp), %rdi
callq 0x2543
movq 0x1e8(%rsp), %rdi
movl %eax, %r14d
cmpq %r12, %rdi
je 0x2927
callq 0x2120
leaq 0xc0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x4, %edx
movl $0x2, %ecx
callq 0x2160
leaq 0xc0(%rsp), %r12
leaq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0x21c0
movq (%r12), %rdi
cmpq %rbp, %rdi
je 0x2966
callq 0x2120
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x1d8(%rsp), %rbp
movq %rbp, -0x10(%rbp)
addq %rsi, %rdx
leaq 0x1c8(%rsp), %rdi
callq 0x3f06
leaq 0x1c8(%rsp), %rdi
callq 0x2543
movq 0x1c8(%rsp), %rdi
movl %eax, %r12d
cmpq %rbp, %rdi
je 0x29ae
callq 0x2120
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x29c1
callq 0x2120
movzbl %r15b, %eax
movl %eax, 0x68(%rsp)
movzbl %r14b, %eax
movl 0x14(%rsp), %r14d
movl %eax, 0xb0(%rsp)
movzbl %r12b, %eax
xorl %r12d, %r12d
movl %eax, 0x88(%rsp)
jmp 0x2a3d
movq 0x145e8(%rip), %rdi     # 0x16fd8
leaq 0xe6e1(%rip), %rsi      # 0x110d8
movl $0x18, %edx
callq 0x2190
movq 0x145d0(%rip), %rdi     # 0x16fd8
leaq 0xe6e2(%rip), %rsi      # 0x110f1
movl $0x1d, %edx
callq 0x2190
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl $0x0, 0x88(%rsp)
movl $0x0, 0xb0(%rsp)
movl $0x0, 0x68(%rsp)
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2a50
callq 0x2120
cmpq $0x6, %rbx
jne 0x33be
cmpl $0x6, 0x1c(%rsp)
jb 0x2c97
movq 0x78(%rsp), %rax
movq 0x28(%rax), %rsi
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x2080
movq 0x28(%rsp), %rbx
testq %rbx, %rbx
je 0x39fc
movq 0x20(%rsp), %rax
cmpb $0x23, (%rax)
jne 0x2ad8
decq %rbx
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2160
leaq 0x40(%rsp), %rbx
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x21c0
movq (%rbx), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x2ad3
callq 0x2120
movq 0x28(%rsp), %rbx
cmpq $0x6, %rbx
jne 0x33d3
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x2, %ecx
xorl %edx, %edx
callq 0x2160
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x1b8(%rsp), %r14
movq %r14, -0x10(%r14)
addq %rsi, %rdx
leaq 0x1a8(%rsp), %rdi
callq 0x3f06
leaq 0x1a8(%rsp), %rdi
callq 0x2543
movq 0x1a8(%rsp), %rdi
movl %eax, %ebp
cmpq %r14, %rdi
je 0x2b3f
callq 0x2120
leaq 0xc0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x2, %edx
movl $0x2, %ecx
callq 0x2160
leaq 0xc0(%rsp), %r14
leaq 0x40(%rsp), %rdi
movb %bpl, 0x18(%rsp)
movq %r14, %rsi
callq 0x21c0
movq (%r14), %rdi
leaq 0xd0(%rsp), %rbp
cmpq %rbp, %rdi
je 0x2b8a
callq 0x2120
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x198(%rsp), %r15
movq %r15, -0x10(%r15)
addq %rsi, %rdx
leaq 0x188(%rsp), %rdi
callq 0x3f06
leaq 0x188(%rsp), %rdi
callq 0x2543
movq 0x188(%rsp), %rdi
movl %eax, %r14d
cmpq %r15, %rdi
je 0x2bd2
callq 0x2120
leaq 0xc0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x4, %edx
movl $0x2, %ecx
callq 0x2160
leaq 0xc0(%rsp), %r15
leaq 0x40(%rsp), %rdi
movq %r15, %rsi
callq 0x21c0
movq (%r15), %rdi
cmpq %rbp, %rdi
je 0x2c10
callq 0x2120
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x178(%rsp), %rbp
movq %rbp, -0x10(%rbp)
addq %rsi, %rdx
leaq 0x168(%rsp), %rdi
callq 0x3f06
leaq 0x168(%rsp), %rdi
callq 0x2543
movq 0x168(%rsp), %rdi
movl %eax, %r15d
cmpq %rbp, %rdi
je 0x2c58
callq 0x2120
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2c6b
callq 0x2120
movzbl 0x18(%rsp), %eax
movl %eax, 0x98(%rsp)
movzbl %r14b, %eax
movl 0x14(%rsp), %r14d
movl %eax, 0xa8(%rsp)
movzbl %r15b, %eax
movl %eax, 0x90(%rsp)
jmp 0x342a
movl $0x0, 0x18(%rsp)
movl $0x0, 0x60(%rsp)
movl $0xff, 0x90(%rsp)
movl $0xff, 0xa8(%rsp)
movl $0xff, 0x98(%rsp)
movl 0x68(%rsp), %r15d
movq 0x14304(%rip), %rdi     # 0x16fd8
leaq 0xe486(%rip), %rsi      # 0x11161
movl $0x16, %edx
callq 0x2190
vmovsd 0xe323(%rip), %xmm1     # 0x11010
vxorpd %xmm0, %xmm0, %xmm0
vmovsd %xmm0, 0x80(%rsp)
vmovsd %xmm1, 0x70(%rsp)
movq 0x142d1(%rip), %rdi     # 0x16fd8
leaq 0xe46a(%rip), %rsi      # 0x11178
movl $0x1b, %edx
callq 0x2190
movl $0x0, 0x1c(%rsp)
movq 0x142b1(%rip), %rbx     # 0x16fd8
leaq 0xe448(%rip), %r12      # 0x11176
movl $0x1, %edx
movq %r12, %rsi
movq %rbx, %rdi
callq 0x2190
leaq 0xe47b(%rip), %rsi      # 0x111c0
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2190
movl %r14d, %esi
movq %rbx, %rdi
callq 0x20d0
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2190
leaq 0xe45c(%rip), %rsi      # 0x111d0
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2190
movl 0xa4(%rsp), %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x20d0
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2190
leaq 0xe437(%rip), %rsi      # 0x111e0
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2190
movl %r14d, %esi
imull %ebp, %esi
movq %rbx, %rdi
shll $0x2, %esi
movq %rsi, 0x78(%rsp)
callq 0x20d0
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2190
leaq 0xe40d(%rip), %rsi      # 0x111f0
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2190
vmovsd 0xb8(%rsp), %xmm0
movq %rbx, %rdi
callq 0x2240
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x2190
leaq 0xe3e8(%rip), %rsi      # 0x11200
movl $0x10, %edx
movq %rbx, %rdi
callq 0x2190
movq %rbx, %rdi
movl %r15d, %esi
movl %r15d, 0x68(%rsp)
callq 0x2280
leaq 0xe3d5(%rip), %r14      # 0x11211
movl $0x2, %edx
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
callq 0x2190
movl 0xb0(%rsp), %esi
movq %r12, %rdi
callq 0x2280
movl $0x2, %edx
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
callq 0x2190
movl 0x88(%rsp), %esi
movq %r12, %rdi
callq 0x2280
leaq 0xe38d(%rip), %rbp      # 0x11214
movl $0x2, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2190
leaq 0xe379(%rip), %rsi      # 0x11217
movl $0x10, %edx
movq %rbx, %rdi
callq 0x2190
movl 0x98(%rsp), %esi
movq %rbx, %rdi
callq 0x2280
movl $0x2, %edx
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
callq 0x2190
movl 0xa8(%rsp), %r15d
movq %r12, %rdi
movl %r15d, %esi
callq 0x2280
movl $0x2, %edx
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
callq 0x2190
movl 0x90(%rsp), %esi
movq %r12, %rdi
callq 0x2280
movl $0x2, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2190
leaq 0xe30f(%rip), %rsi      # 0x11228
movl $0x10, %edx
movq %rbx, %rdi
callq 0x2190
movl 0x64(%rsp), %esi
movq %rbx, %rdi
callq 0x2280
movl $0x2, %edx
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
callq 0x2190
movl 0x18(%rsp), %esi
movq %r12, %rdi
callq 0x2280
movl $0x2, %edx
movq %rax, %r12
movq %rax, %rdi
movq %r14, %rsi
callq 0x2190
movl 0x60(%rsp), %esi
movq %r12, %rdi
callq 0x2280
movl $0x2, %edx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2190
leaq 0xe2b2(%rip), %rsi      # 0x11239
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2190
movl %r13d, %esi
movq %rbx, %rdi
callq 0x20d0
leaq 0xe1d0(%rip), %r14      # 0x11176
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2190
leaq 0xe28c(%rip), %rsi      # 0x11249
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2190
vmovsd 0x70(%rsp), %xmm0
movq %rbx, %rdi
callq 0x2240
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2190
leaq 0xe26a(%rip), %rsi      # 0x11259
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2190
vmovsd 0x80(%rsp), %xmm0
movq %rbx, %rdi
callq 0x2240
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2190
movq 0x78(%rsp), %rsi
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x3dea
movl 0x14(%rsp), %ebp
movl 0xa4(%rsp), %ecx
testl %ebp, %ebp
je 0x32c4
vmovsd 0xb8(%rsp), %xmm0
vmovsd 0x70(%rsp), %xmm1
leaq 0x40(%rsp), %r12
xorl %ebx, %ebx
vmulsd 0xdfb6(%rip), %xmm0, %xmm0 # 0x11018
vcvtsi2sdl 0x68(%rsp), %xmm2, %xmm2
vsubsd %xmm0, %xmm1, %xmm1
vmovsd %xmm1, 0xf8(%rsp)
vcvtusi2sd %ebp, %xmm3, %xmm1
movl $0xff, %ebp
vmovsd %xmm1, 0xf0(%rsp)
vcvtusi2sd %ecx, %xmm3, %xmm1
vmovsd %xmm1, 0x70(%rsp)
vcvtusi2sd %r13d, %xmm3, %xmm1
vmovsd %xmm1, 0x78(%rsp)
vmovsd 0x80(%rsp), %xmm1
vsubsd %xmm0, %xmm1, %xmm0
vmovsd %xmm0, 0x80(%rsp)
vcvtsi2sdl 0x98(%rsp), %xmm3, %xmm0
vmovsd %xmm2, 0x98(%rsp)
vsubsd %xmm2, %xmm0, %xmm0
vcvtsi2sdl 0xb0(%rsp), %xmm3, %xmm2
vmovsd %xmm0, 0x68(%rsp)
vcvtsi2sd %r15d, %xmm3, %xmm0
vcvtsi2sdl 0x88(%rsp), %xmm3, %xmm3
vcvtsi2sdl 0x90(%rsp), %xmm4, %xmm1
vsubsd %xmm2, %xmm0, %xmm0
vmovsd %xmm2, 0xb0(%rsp)
vsubsd %xmm3, %xmm1, %xmm1
vmovsd %xmm0, 0xa8(%rsp)
vmovsd %xmm3, 0x90(%rsp)
vmovsd %xmm1, 0x100(%rsp)
testl %ecx, %ecx
je 0x32b8
vcvtusi2sd %ebx, %xmm6, %xmm0
vmulsd 0xb8(%rsp), %xmm0, %xmm0
xorl %r14d, %r14d
vdivsd 0xf0(%rsp), %xmm0, %xmm0
vaddsd 0xf8(%rsp), %xmm0, %xmm0
vmovsd %xmm0, 0x88(%rsp)
vcvtusi2sd %r14d, %xmm6, %xmm0
vmulsd 0xb8(%rsp), %xmm0, %xmm0
cmpb $0x0, 0x1c(%rsp)
vdivsd 0x70(%rsp), %xmm0, %xmm0
vaddsd 0x80(%rsp), %xmm0, %xmm0
je 0x31d9
testl %r13d, %r13d
je 0x322f
vmovsd 0xe0(%rsp), %xmm1
vmovsd 0xe8(%rsp), %xmm2
vmovsd 0x88(%rsp), %xmm3
xorl %eax, %eax
vmulsd %xmm0, %xmm0, %xmm4
vmovapd %xmm3, %xmm5
vfmadd213sd %xmm4, %xmm3, %xmm5 # xmm5 = (xmm3 * xmm5) + xmm4
vsqrtsd %xmm5, %xmm5, %xmm5
vucomisd 0xde50(%rip), %xmm5     # 0x11008
ja 0x3231
vmulsd %xmm3, %xmm0, %xmm5
vfmsub231sd %xmm3, %xmm3, %xmm4 # xmm4 = (xmm3 * xmm3) - xmm4
incl %eax
vfmadd231sd %xmm3, %xmm0, %xmm5 # xmm5 = (xmm0 * xmm3) + xmm5
vaddsd %xmm4, %xmm1, %xmm3
vaddsd %xmm5, %xmm2, %xmm0
cmpl %eax, %r13d
jne 0x319f
jmp 0x322a
testl %r13d, %r13d
je 0x322f
vmovsd 0x88(%rsp), %xmm2
xorl %eax, %eax
vmovapd %xmm0, %xmm1
vmulsd %xmm1, %xmm1, %xmm3
vmovapd %xmm2, %xmm4
vfmadd213sd %xmm3, %xmm2, %xmm4 # xmm4 = (xmm2 * xmm4) + xmm3
vsqrtsd %xmm4, %xmm4, %xmm4
vucomisd 0xde02(%rip), %xmm4     # 0x11008
ja 0x3231
vmulsd %xmm2, %xmm1, %xmm4
vfmsub231sd %xmm2, %xmm2, %xmm3 # xmm3 = (xmm2 * xmm2) - xmm3
incl %eax
vfmadd231sd %xmm2, %xmm1, %xmm4 # xmm4 = (xmm1 * xmm2) + xmm4
vaddsd 0x88(%rsp), %xmm3, %xmm2
vaddsd %xmm4, %xmm0, %xmm1
cmpl %eax, %r13d
jne 0x31ed
movl %r13d, %eax
jmp 0x3231
xorl %eax, %eax
movl 0x18(%rsp), %esi
movl 0x64(%rsp), %edi
movl 0x60(%rsp), %edx
cmpl %eax, %r13d
je 0x3290
vcvtusi2sd %eax, %xmm6, %xmm0
vdivsd 0x78(%rsp), %xmm0, %xmm0
vmovsd 0x68(%rsp), %xmm1
vmovsd 0xa8(%rsp), %xmm3
vmovsd 0x100(%rsp), %xmm2
vfmadd213sd 0x98(%rsp), %xmm0, %xmm1 # xmm1 = (xmm0 * xmm1) + mem
vfmadd213sd 0xb0(%rsp), %xmm0, %xmm3 # xmm3 = (xmm0 * xmm3) + mem
vfmadd213sd 0x90(%rsp), %xmm2, %xmm0 # xmm0 = (xmm2 * xmm0) + mem
vcvttsd2si %xmm1, %edi
vcvttsd2si %xmm3, %esi
vcvttsd2si %xmm0, %edx
andl %ebp, %edi
andl %ebp, %esi
andl %ebp, %edx
movl %ecx, (%rsp)
movl %ecx, %r15d
movl %ebx, %ecx
movl %r14d, %r8d
movq %r12, %r9
callq 0x249d
incl %r14d
movl %r15d, %ecx
cmpl %r15d, %r14d
jne 0x3154
incl %ebx
cmpl 0x14(%rsp), %ebx
jne 0x311f
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xddf8(%rip), %rsi      # 0x110cc
leaq 0xddfc(%rip), %rdx      # 0x110d7
leaq 0x20(%rsp), %rdi
callq 0x3f9c
movl 0x14(%rsp), %edx
movl 0xa4(%rsp), %ecx
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rsi
movl $0x6, %r8d
movl $0x8, %r9d
callq 0xd887
movq 0x20(%rsp), %rdi
movl %eax, %ebp
cmpq %r14, %rdi
je 0x331c
callq 0x2120
testl %ebp, %ebp
je 0x33ac
movq 0x13cad(%rip), %rbx     # 0x16fd8
leaq 0xdf37(%rip), %rsi      # 0x11269
movl $0x9, %edx
movq %rbx, %rdi
callq 0x2190
movl %ebp, %edi
callq 0xd172
movq %rax, %r14
testq %rax, %rax
je 0x336a
movq %r14, %rdi
callq 0x2090
movq 0x13c7b(%rip), %rdi     # 0x16fd8
movq %r14, %rsi
movq %rax, %rdx
callq 0x2190
jmp 0x3381
movq (%rbx), %rax
movq -0x18(%rax), %rax
movl 0x20(%rbx,%rax), %esi
leaq (%rbx,%rax), %rdi
orl $0x1, %esi
callq 0x2270
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movl $0xa, %esi
movq %rbx, %rdi
callq 0x2130
movq 0x13c3c(%rip), %rdi     # 0x16fd8
movsbl %al, %esi
callq 0x2040
movq %rax, %rdi
callq 0x20e0
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x33bb
callq 0x2120
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x13bfe(%rip), %rdi     # 0x16fd8
leaq 0xdcf7(%rip), %rsi      # 0x110d8
movl $0x18, %edx
callq 0x2190
movq 0x13be6(%rip), %rdi     # 0x16fd8
leaq 0xdcf8(%rip), %rsi      # 0x110f1
movl $0x1d, %edx
callq 0x2190
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl $0xff, 0x90(%rsp)
movl $0xff, 0xa8(%rsp)
movl $0xff, 0x98(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x343e
callq 0x2120
cmpq $0x6, %rbx
jne 0x33be
cmpl $0x6, 0x1c(%rsp)
jne 0x3464
movl $0x0, 0x18(%rsp)
movl $0x0, 0x60(%rsp)
jmp 0x2cc8
movq 0x78(%rsp), %rax
movq 0x30(%rax), %rsi
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x2080
movq 0x28(%rsp), %rbx
testq %rbx, %rbx
je 0x3a0e
movq 0x20(%rsp), %rax
cmpb $0x23, (%rax)
jne 0x34d7
decq %rbx
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x2160
leaq 0x40(%rsp), %rbx
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x21c0
movq (%rbx), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x34d2
callq 0x2120
movq 0x28(%rsp), %rbx
cmpq $0x6, %rbx
jne 0x368e
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x2, %ecx
xorl %edx, %edx
callq 0x2160
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x158(%rsp), %r14
movq %r14, -0x10(%r14)
addq %rsi, %rdx
leaq 0x148(%rsp), %rdi
callq 0x3f06
leaq 0x148(%rsp), %rdi
callq 0x2543
movq 0x148(%rsp), %rdi
movl %eax, %ebp
cmpq %r14, %rdi
je 0x353e
callq 0x2120
leaq 0xc0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x2, %edx
movl $0x2, %ecx
movb %bpl, 0x64(%rsp)
callq 0x2160
leaq 0xc0(%rsp), %r14
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
callq 0x21c0
movq (%r14), %rdi
leaq 0xd0(%rsp), %rbp
cmpq %rbp, %rdi
je 0x3589
callq 0x2120
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x138(%rsp), %r14
movq %r14, -0x10(%r14)
addq %rsi, %rdx
leaq 0x128(%rsp), %rdi
callq 0x3f06
leaq 0x128(%rsp), %rdi
callq 0x2543
movq 0x128(%rsp), %rdi
movl %eax, %r15d
cmpq %r14, %rdi
je 0x35d1
callq 0x2120
leaq 0xc0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
movl $0x4, %edx
movl $0x2, %ecx
callq 0x2160
leaq 0xc0(%rsp), %r14
leaq 0x40(%rsp), %rdi
movq %r14, %rsi
callq 0x21c0
movq (%r14), %rdi
cmpq %rbp, %rdi
je 0x360f
callq 0x2120
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
leaq 0x118(%rsp), %rbp
movq %rbp, -0x10(%rbp)
addq %rsi, %rdx
leaq 0x108(%rsp), %rdi
callq 0x3f06
leaq 0x108(%rsp), %rdi
callq 0x2543
movq 0x108(%rsp), %rdi
movl %eax, %r14d
cmpq %rbp, %rdi
je 0x3657
callq 0x2120
leaq 0x50(%rsp), %rax
movb 0x64(%rsp), %bpl
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x366f
callq 0x2120
movzbl %r14b, %ecx
movl 0x14(%rsp), %r14d
movzbl %bpl, %eax
movzbl %r15b, %edx
movl %eax, 0x64(%rsp)
movl %edx, 0x18(%rsp)
movl %ecx, 0x60(%rsp)
jmp 0x36dc
movq 0x13943(%rip), %rdi     # 0x16fd8
leaq 0xda3c(%rip), %rsi      # 0x110d8
movl $0x18, %edx
callq 0x2190
movq 0x1392b(%rip), %rdi     # 0x16fd8
leaq 0xda3d(%rip), %rsi      # 0x110f1
movl $0x1d, %edx
callq 0x2190
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl $0x0, 0x60(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x0, 0x64(%rsp)
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x36f0
callq 0x2120
cmpq $0x6, %rbx
jne 0x33be
cmpl $0x8, 0x1c(%rsp)
jb 0x2cc8
movq 0x78(%rsp), %r15
leaq 0x20(%rsp), %r14
leaq 0x40(%rsp), %rdx
movq %r14, %rdi
movq 0x38(%r15), %rsi
callq 0x2080
leaq 0xd9e8(%rip), %rsi      # 0x1110f
movq %r14, %rdi
callq 0x2050
movq (%r14), %rdi
movl %eax, %ebx
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x3743
callq 0x2120
testl %ebx, %ebx
je 0x3786
movq 0x38(%r15), %rsi
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x2080
movl 0x14(%rsp), %r14d
movq 0x28(%rsp), %rax
testq %rax, %rax
je 0x37a6
movq 0x20(%rsp), %rcx
movl $0x1, %ebp
xorl %edx, %edx
cmpb $0x2b, (%rcx,%rdx)
je 0x379b
movl %ebp, %edx
incl %ebp
cmpq %rdx, %rax
ja 0x3775
jmp 0x37a6
vmovsd 0xd882(%rip), %xmm0     # 0x11010
movl 0x14(%rsp), %r14d
vmovsd %xmm0, 0x70(%rsp)
jmp 0x37ee
movl %ebp, %eax
subl $0x1, %eax
jae 0x3947
movq 0x1382b(%rip), %rdi     # 0x16fd8
leaq 0xd966(%rip), %rsi      # 0x1111a
movl $0x1a, %edx
callq 0x2190
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movb $0x1, %bpl
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x37db
callq 0x2120
vxorpd %xmm0, %xmm0, %xmm0
vmovsd %xmm0, 0x70(%rsp)
testb %bpl, %bpl
jne 0x33be
movl 0x1c(%rsp), %ebp
vxorpd %xmm0, %xmm0, %xmm0
movl $0xff, %r13d
vmovsd %xmm0, 0x80(%rsp)
cmpl $0x9, %ebp
jl 0x3897
movq 0x78(%rsp), %r12
movq 0x40(%r12), %rdi
callq 0x21d0
movl 0x68(%rsp), %r15d
vcvttsd2usi %xmm0, %r13d
cmpl $0x9, %ebp
je 0x389c
movq 0x48(%r12), %rdi
callq 0x21d0
vmovsd %xmm0, 0x70(%rsp)
cmpl $0xb, %ebp
jb 0x389c
movq 0x50(%r12), %rdi
callq 0x21d0
vmovsd %xmm0, 0x80(%rsp)
cmpl $0xb, %ebp
je 0x389c
movq 0x13777(%rip), %r14     # 0x16fd8
leaq 0xd8cd(%rip), %rsi      # 0x11135
movl $0x2b, %edx
movq %r14, %rdi
callq 0x2190
leaq 0xd8e5(%rip), %rsi      # 0x11161
movl $0x16, %edx
movq %r14, %rdi
callq 0x2190
testl %ebx, %ebx
jne 0x38bc
movl 0x14(%rsp), %r14d
jmp 0x2d00
movl 0x68(%rsp), %r15d
movq 0x13735(%rip), %rdi     # 0x16fd8
leaq 0xd8b7(%rip), %rsi      # 0x11161
movl $0x16, %edx
callq 0x2190
testl %ebx, %ebx
je 0x2d00
movq 0x13715(%rip), %rbx     # 0x16fd8
leaq 0xd8ca(%rip), %rsi      # 0x11194
movl $0x16, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0xd8cd(%rip), %rsi      # 0x111ab
movl $0x14, %edx
movq %rbx, %rdi
callq 0x2190
leaq 0x20(%rsp), %r14
leaq 0xe0(%rsp), %rsi
movq %r14, %rdi
callq 0x3b7e
movq 0x8(%r14), %rdx
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x2190
leaq 0xd860(%rip), %rsi      # 0x11176
movl $0x1, %edx
movq %rax, %rdi
callq 0x2190
movq 0x20(%rsp), %rdi
movl 0x14(%rsp), %r14d
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x393c
callq 0x2120
movb $0x1, %al
movl %eax, 0x1c(%rsp)
jmp 0x2d20
movl %eax, %ecx
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
xorl %edx, %edx
callq 0x2160
leaq 0x50(%rsp), %r15
movq -0x10(%r15), %r14
movq %r14, %rdi
callq 0x21d0
vmovsd %xmm0, 0x70(%rsp)
cmpq %r15, %r14
je 0x397e
movq %r14, %rdi
callq 0x2120
leaq 0x20(%rsp), %rsi
movl %ebp, %edx
movq 0x8(%rsi), %rcx
subq %rdx, %rcx
leaq 0x40(%rsp), %rdi
callq 0x2160
movq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x21d0
vmovapd %xmm0, %xmm1
cmpq %r15, %r14
je 0x39c6
movq %r14, %rdi
vmovsd %xmm1, 0x80(%rsp)
callq 0x2120
vmovsd 0x80(%rsp), %xmm1
vmovsd 0x70(%rsp), %xmm0
movl 0x14(%rsp), %r14d
xorl %ebp, %ebp
vmovsd %xmm0, 0xe0(%rsp)
vmovsd %xmm1, 0xe8(%rsp)
jmp 0x37c7
leaq 0xd8fd(%rip), %rdi      # 0x112ee
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2210
leaq 0xd8eb(%rip), %rdi      # 0x112ee
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2210
leaq 0xd8d9(%rip), %rdi      # 0x112ee
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x2210
jmp 0x3ada
jmp 0x3ada
jmp 0x3ada
jmp 0x3b32
jmp 0x3ada
movq 0x108(%rsp), %rdi
jmp 0x3a6e
jmp 0x3ab0
movq 0x128(%rsp), %rdi
jmp 0x3a98
jmp 0x3ab0
movq 0x148(%rsp), %rdi
jmp 0x3a98
jmp 0x3ada
jmp 0x3ada
jmp 0x3b32
jmp 0x3ab0
movq 0x168(%rsp), %rdi
movq %rax, %rbx
cmpq %rbp, %rdi
jne 0x3aa0
jmp 0x3ab3
jmp 0x3ada
jmp 0x3ab0
movq 0x188(%rsp), %rdi
movq %rax, %rbx
cmpq %r15, %rdi
jne 0x3aa0
jmp 0x3ab3
jmp 0x3ab0
movq 0x1a8(%rsp), %rdi
movq %rax, %rbx
cmpq %r14, %rdi
je 0x3ab3
callq 0x2120
jmp 0x3ab3
jmp 0x3ada
jmp 0x3ada
jmp 0x3b32
movq %rax, %rbx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3add
callq 0x2120
jmp 0x3add
movq 0x1c8(%rsp), %rdi
movq %rax, %rbx
cmpq %rbp, %rdi
jne 0x3b0f
jmp 0x3b3a
movq %rax, %rbx
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
jmp 0x3b5b
jmp 0x3b37
movq 0x1e8(%rsp), %rdi
movq %rax, %rbx
cmpq %r12, %rdi
jne 0x3b0f
jmp 0x3b3a
jmp 0x3b37
movq 0x208(%rsp), %rdi
movq %rax, %rbx
cmpq %r14, %rdi
je 0x3b3a
callq 0x2120
jmp 0x3b3a
jmp 0x3b4f
jmp 0x3b4f
jmp 0x3b32
movq 0x20(%rsp), %rdi
movq %rax, %rbx
cmpq %r14, %rdi
je 0x3b67
callq 0x2120
jmp 0x3b67
jmp 0x3b64
movq %rax, %rbx
jmp 0x3b76
movq %rax, %rbx
leaq 0x50(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3b52
callq 0x2120
jmp 0x3b52
movq %rax, %rbx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x3b71
jmp 0x3b76
jmp 0x3b64
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x3b76
callq 0x2120
movq %rbx, %rdi
callq 0x2290