// File: garrettsickles[P]hgt2png/hgt2png.cpp
// Function: main
int main(int argc, char** argv)
{
    /*
     * Arguement Parsing
     */
    if (argc < 6 || argc > 8 || argc == 7)
    {
        std::printf(HGT2PNG_USAGE_TEXT);
        std::printf("%d\n", argc);
        return 0;
    }

    const auto width = std::atoi(argv[4]);
    const auto height = std::atoi(argv[5]);
    const auto rows = argc == 8 ? std::atoi(argv[6]) : 1;
    const auto cols = argc == 8 ? std::atoi(argv[7]) : 1;
    const auto pixel_count = static_cast<std::size_t>(width * height);

    /*
     * Read in the HGT (.hgt) file
     * 
     * Check that the file opened properly
     */
    char* hgt_filename = argv[2];
    CFile hgt_file = CFile(std::fopen(hgt_filename, "rb"), [](FILE* f)->void { std::fclose(f); });
    if (!hgt_file.get())
    {
        std::printf("Could not open file \"%s\", Exiting...\n", hgt_filename);
        return 1;
    }

    /*
     * Extract the number of samples in the HGT raster
     */
    FSEEK64(hgt_file.get(), 0, SEEK_END);
    const auto hgt_size = FTELL64(hgt_file.get());
    FSEEK64(hgt_file.get(), 0, SEEK_SET);
    std::printf
    (
        "File: \"%s\" (%" PRId64 " bytes)\nSize: %d(w) x %d(h) pixels (%lu samples)\n",
        hgt_filename, hgt_size, width, height, pixel_count
    );

    /*
     * Verify the subdivisions
     */
    if (cols < 1 || rows < 1)
    {
        std::printf("Both row and column must be greater than or equal to 1, Exiting...\n");
        return 1;
    }
    if (cols > 1 && (width - 1) % cols)
    {
        std::printf("One less than the width of %d is not evenly divisible by %d, Exiting...\n", width, cols);
        return 1;
    }
    if (rows > 1 && (height - 1) % rows)
    {
        std::printf("One less than the height of %d is not evenly divisible by %d, Exiting...\n", height, rows);
        return 1;
    }
    const auto subwidth = (width / cols) + (cols > 1 ? 1 : 0);
    const auto subheight = (height / rows) + (rows > 1 ? 1 : 0);

    /*
     * Verify the size of the HGT raster
     */
    const auto data_size   = static_cast<decltype(hgt_size)>(pixel_count * sizeof(std::int16_t));
    if (hgt_size != data_size)
    {
        std::printf("Actual size %" PRId64 ", Expected %" PRId64 ", Exiting...\n", hgt_size, data_size);
        return 1;
    }

    /*
     * Extract the location of the 1 degree raster from the filename
     */
    int  ll[2]       = { -1, -1 };
    char hemi[2]     = {  0,  0 };
    char* last_slash = std::strrchr(argv[2], DIRECTORY_DELIM);
    char* file_name  = last_slash ? last_slash + 1 : hgt_filename;
    std::sscanf(file_name, "%c%2d%c%3d.hgt", &hemi[0], &ll[0], &hemi[1], &ll[1]);
    std::string base_name = std::string(argv[3]) + file_name;
    base_name.erase(base_name.find_last_of("."), std::string::npos);
    
    /*
     * Verify the filename raster coordinates
     */
    const bool valid_hemi[2] = { hemi[0] == 'N' || hemi[0] == 'S', hemi[1] == 'W' || hemi[1] == 'E' };
    if (!valid_hemi[0] || !valid_hemi[1])
    {
        std::printf("Inavlid hemisphere \"%c\" in \"%s\", Exiting...\n", valid_hemi[0] ? hemi[1] : hemi[0], file_name);
        return 1;
    }
    std::printf("Bounds: (%d%c, %d%c) to (%d%c, %d%c)\n",
        ll[0], hemi[0], ll[1], hemi[1], ll[0] + 1, hemi[0], ll[1] + 1, hemi[1]
    );

    /*
     * Extract the raster into memory
     */
    std::vector<std::uint8_t> raster(data_size);
    const auto read_size = std::fread(raster.data(), data_size, 1, hgt_file.get());
    if (read_size != 1)
    {
        std::printf("Read size %" PRId64 ", Expected 1, Exiting...\n", read_size);
        return 1;
    }
    
    /*
     * Swap the byte order from Big to Little Endian
     * if the platform is Little Endian
     */
    if (is_little_endian())
    {
        std::uint8_t swp = 0;
        for (auto i = 0; i < data_size; i += sizeof(std::int16_t))
        {
            swp = raster[i];
            raster[i] = raster[i+1];
            raster[i+1] = swp;
        }
    }

    /*
     * Convert the raster to unsigned 16 bit and
     * accumulate the range of the raster
     */
    int minimum = 32768;
    int maximum = -32768;
    int invalid = 0;

    std::int32_t temp;
    std::int16_t* svalue = nullptr;
    for (auto i = 0; i < data_size; i += sizeof(std::int16_t))
    {
        svalue = reinterpret_cast<std::int16_t*>(raster.data() + i);
        temp = static_cast<std::int32_t>(*svalue);
        if (temp < minimum)
        {
            if (temp != -32768) minimum = temp;
            else invalid++;
        } 
        else if (temp > maximum)
        {
            maximum = temp;
        }
    }
    std::printf("Range: [%d, %d] meters\nMissing: %d pixels\n", minimum, maximum, invalid);

    /*
     *
     */
    double toscale = 0.0;
    const double minf = static_cast<double>(minimum);
    const double deltaf = static_cast<double>(maximum) - minf;

    /*
     * Absolute Mode
     */
    if (argv[1][0] == 'a')
    {
        std::uint16_t* uvalue = nullptr;
        for (auto i = 0; i < data_size; i += sizeof(std::int16_t))
        {
            svalue = reinterpret_cast<std::int16_t*>(raster.data() + i);
            uvalue = reinterpret_cast<std::uint16_t*>(raster.data() + i);
            *uvalue = *svalue == -32768 ? 0xFFFF : static_cast<std::uint16_t>(static_cast<double>(*svalue) + 32767.0);
        }
    }

    /*
     * Relative Mode, By default('r')
     */
    else
    {
        /*
         * Scale the raster to the range such that the minimum height
         * encodes to 0 and the maximum height encodes to 65534
         */
        svalue = nullptr;
        std::uint16_t* uvalue = nullptr;
        for (auto i = 0; i < data_size; i += sizeof(std::int16_t))
        {
            svalue = reinterpret_cast<std::int16_t*>(raster.data() + i);
            uvalue = reinterpret_cast<std::uint16_t*>(raster.data() + i);
            toscale = static_cast<double>(*svalue);
            *uvalue = *svalue == -32768 ? 0xFFFF : static_cast<std::uint16_t>((toscale - minf) * 65534.0 / deltaf);
        }
    }

    /*
     * Swap the byte order from Little to Big Endian
     * if the platform is Little Endian
     */
    if (is_little_endian())
    {
        std::uint8_t swp = 0;
        for (auto i = 0; i < data_size; i += sizeof(std::int16_t))
        {
            swp = raster[i];
            raster[i] = raster[i+1];
            raster[i+1] = swp;
        }
    }

    /*
     * Calculate the physical dimensions of each subraster in radians
     */
    const double upx = deg_to_rad(1.0 / static_cast<double>(subwidth - 1));
    const double upy = deg_to_rad(1.0 / static_cast<double>(subheight - 1));

    /*
     * Write the PNG to a data buffer
     */
    std::vector<std::uint8_t> png_data;
    std::vector<std::uint8_t*> png_rows(subheight);
    size_t total_png_size = 0;

    int row_offset = 0;
    int col_offset = 0;
    for (auto row_index = 0; row_index < rows; row_index++)
    {
        for (auto col_index = 0; col_index < cols; col_index++)
        {
            /*
             * Setup the PNG info
             */
            png_structp png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
            png_infop   info = png_create_info_struct(png);
            png_set_IHDR(png, info,
                static_cast<png_uint_32>(subwidth),
                static_cast<png_uint_32>(subheight),
                sizeof(std::uint16_t) * 8,
                PNG_COLOR_TYPE_GRAY,
                PNG_INTERLACE_NONE,
                PNG_COMPRESSION_TYPE_DEFAULT,
                PNG_FILTER_TYPE_DEFAULT
            );

            /*
             * Set the 'sCAL' (Physical Scale)
             * 
             * The dimensions of each pixel in radians
             */
            png_set_sCAL(png, info, 2, upx, upy);

            /*
             * Set the 'pCAL' (Pixel Calibration)
             * 
             * The 1st order function mapping the encoded PNG values to the physical values
             */
            auto decription = std::string("SRTM-HGT");
            auto units = std::string("m");
            auto p0 = std::to_string(minf);
            auto p1 = std::to_string(deltaf);
            png_charp params[2] = { &p0.at(0), &p1.at(0)};
            png_set_pCAL(png, info, &decription.at(0), -32767, 32767, 0, 2, &units.at(0), params);

            /*
             * Setup a vector of pointers to the beginning of each row
             */
            for (auto row_abs = row_offset; row_abs < (row_offset + subheight); row_abs++)
            {
                png_rows[row_abs - row_offset] =
                    raster.data() +
                    row_abs * width * sizeof(std::uint16_t) +
                    (col_offset - 1) * sizeof(std::uint16_t);
            }
                

            /*
             * Write the PNG to a buffer
             */
            png_set_rows(png, info, png_rows.data());
            png_set_write_fn(png, &(png_data), libpng_write_stdvector, NULL);
            png_write_png(png, info, PNG_TRANSFORM_IDENTITY, NULL);
            png_destroy_write_struct(&png, &info);
            const auto png_size = png_data.size();

            /*
             * Write the PNG buffer out to file
             */
            std::string subname =
                base_name + "." +
                std::to_string(row_offset) + "." + std::to_string(col_offset) + ".png";
            CFile png_file = CFile(std::fopen(subname.c_str(), "wb"), [](FILE* f)->void { std::fclose(f); });
            if (!hgt_file.get())
            {
                std::printf("Could not open file \"%s\", Exiting...\n", subname.c_str());
                return 1;
            }
            const auto write_size = std::fwrite(png_data.data(), png_data.size(), 1, png_file.get());
            png_data.clear();
            
            /*
             * Verify the file write
             */
            if (write_size != 1)
            {
                std::printf("Write size %" PRId64 ", Expected 1, Exiting...\n", write_size);
                return 1;
            }

            total_png_size += png_size;
            col_offset += (subheight - 1);      
        }
        col_offset = 0;
        row_offset += (subwidth - 1);
    }

    /*
     * Show some statistics
     */
    std::printf("Output: Compression: %.2lf%% of original size\n",
        static_cast<double>(total_png_size) / static_cast<double>(data_size) * 100.0
    );
    
    return 0;
}

// Assembly:
subq $0x508, %rsp            # imm = 0x508
movl $0x0, 0x504(%rsp)
movl %edi, 0x500(%rsp)
movq %rsi, 0x4f8(%rsp)
cmpl $0x6, 0x500(%rsp)
jl 0x260f
cmpl $0x8, 0x500(%rsp)
jg 0x260f
cmpl $0x7, 0x500(%rsp)
jne 0x2642
leaq 0x5a4a(%rip), %rdi      # 0x8060
movb $0x0, %al
callq 0x2040
movl 0x500(%rsp), %esi
leaq 0x5cda(%rip), %rdi      # 0x8305
movb $0x0, %al
callq 0x2040
movl $0x0, 0x504(%rsp)
jmp 0x3f08
movq 0x4f8(%rsp), %rax
movq 0x20(%rax), %rdi
callq 0x22f0
movl %eax, 0x4f4(%rsp)
movq 0x4f8(%rsp), %rax
movq 0x28(%rax), %rdi
callq 0x22f0
movl %eax, 0x4f0(%rsp)
cmpl $0x8, 0x500(%rsp)
jne 0x2696
movq 0x4f8(%rsp), %rax
movq 0x30(%rax), %rdi
callq 0x22f0
movl %eax, 0x164(%rsp)
jmp 0x26a4
movl $0x1, %eax
movl %eax, 0x164(%rsp)
jmp 0x26a4
movl 0x164(%rsp), %eax
movl %eax, 0x4ec(%rsp)
cmpl $0x8, 0x500(%rsp)
jne 0x26d6
movq 0x4f8(%rsp), %rax
movq 0x38(%rax), %rdi
callq 0x22f0
movl %eax, 0x160(%rsp)
jmp 0x26e4
movl $0x1, %eax
movl %eax, 0x160(%rsp)
jmp 0x26e4
movl 0x160(%rsp), %eax
movl %eax, 0x4e8(%rsp)
movl 0x4f4(%rsp), %eax
imull 0x4f0(%rsp), %eax
cltq
movq %rax, 0x4e0(%rsp)
movq 0x4f8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x4d8(%rsp)
movq 0x4d8(%rsp), %rdi
leaq 0x5bdb(%rip), %rsi      # 0x8309
callq 0x2280
movq %rax, 0x158(%rsp)
leaq 0x4bf(%rsp), %rdi
callq 0x3f30
movq 0x158(%rsp), %rsi
movq %rax, 0x4c0(%rsp)
leaq 0x4c8(%rsp), %rdi
leaq 0x4c0(%rsp), %rdx
callq 0x40f0
leaq 0x4c8(%rsp), %rdi
callq 0x4130
cmpq $0x0, %rax
jne 0x27cc
movq 0x4d8(%rsp), %rsi
leaq 0x5b7d(%rip), %rdi      # 0x830c
xorl %eax, %eax
callq 0x2040
jmp 0x2798
movl $0x1, 0x504(%rsp)
movl $0x1, 0x4a8(%rsp)
jmp 0x3eea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x3ef9
leaq 0x4c8(%rsp), %rdi
callq 0x4130
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x2, %edx
callq 0x2130
jmp 0x27ec
leaq 0x4c8(%rsp), %rdi
callq 0x4130
movq %rax, %rdi
callq 0x22a0
movq %rax, 0x150(%rsp)
jmp 0x280b
movq 0x150(%rsp), %rax
movq %rax, 0x4a0(%rsp)
leaq 0x4c8(%rsp), %rdi
callq 0x4130
movq %rax, %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x2130
jmp 0x2836
movq 0x4d8(%rsp), %rsi
movq 0x4a0(%rsp), %rdx
movl 0x4f4(%rsp), %ecx
movl 0x4f0(%rsp), %r8d
movq 0x4e0(%rsp), %r9
leaq 0x5ace(%rip), %rdi      # 0x8332
xorl %eax, %eax
callq 0x2040
jmp 0x286d
cmpl $0x1, 0x4e8(%rsp)
jl 0x2881
cmpl $0x1, 0x4ec(%rsp)
jge 0x28ac
leaq 0x5aeb(%rip), %rdi      # 0x8373
xorl %eax, %eax
callq 0x2040
jmp 0x2891
movl $0x1, 0x504(%rsp)
movl $0x1, 0x4a8(%rsp)
jmp 0x3eea
cmpl $0x1, 0x4e8(%rsp)
jle 0x2906
movl 0x4f4(%rsp), %eax
subl $0x1, %eax
cltd
idivl 0x4e8(%rsp)
cmpl $0x0, %edx
je 0x2906
movl 0x4f4(%rsp), %esi
movl 0x4e8(%rsp), %edx
leaq 0x5ad5(%rip), %rdi      # 0x83b7
xorl %eax, %eax
callq 0x2040
jmp 0x28eb
movl $0x1, 0x504(%rsp)
movl $0x1, 0x4a8(%rsp)
jmp 0x3eea
cmpl $0x1, 0x4ec(%rsp)
jle 0x2960
movl 0x4f0(%rsp), %eax
subl $0x1, %eax
cltd
idivl 0x4ec(%rsp)
cmpl $0x0, %edx
je 0x2960
movl 0x4f0(%rsp), %esi
movl 0x4ec(%rsp), %edx
leaq 0x5ac4(%rip), %rdi      # 0x8400
xorl %eax, %eax
callq 0x2040
jmp 0x2945
movl $0x1, 0x504(%rsp)
movl $0x1, 0x4a8(%rsp)
jmp 0x3eea
movl 0x4f4(%rsp), %eax
cltd
idivl 0x4e8(%rsp)
movl 0x4e8(%rsp), %esi
xorl %ecx, %ecx
movl $0x1, %edx
cmpl $0x1, %esi
cmovgl %edx, %ecx
addl %ecx, %eax
movl %eax, 0x49c(%rsp)
movl 0x4f0(%rsp), %eax
cltd
idivl 0x4ec(%rsp)
movl 0x4ec(%rsp), %esi
xorl %ecx, %ecx
movl $0x1, %edx
cmpl $0x1, %esi
cmovgl %edx, %ecx
addl %ecx, %eax
movl %eax, 0x498(%rsp)
movq 0x4e0(%rsp), %rax
shlq %rax
movq %rax, 0x490(%rsp)
movq 0x4a0(%rsp), %rax
cmpq 0x490(%rsp), %rax
je 0x2a18
movq 0x4a0(%rsp), %rsi
movq 0x490(%rsp), %rdx
leaq 0x5a56(%rip), %rdi      # 0x844a
xorl %eax, %eax
callq 0x2040
jmp 0x29fd
movl $0x1, 0x504(%rsp)
movl $0x1, 0x4a8(%rsp)
jmp 0x3eea
movq 0x5619(%rip), %rax      # 0x8038
movq %rax, 0x488(%rsp)
leaq 0x486(%rsp), %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2110
movq 0x4f8(%rsp), %rax
movq 0x10(%rax), %rdi
movl $0x2f, %esi
callq 0x2270
movq %rax, 0x478(%rsp)
cmpq $0x0, 0x478(%rsp)
je 0x2a7a
movq 0x478(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x148(%rsp)
jmp 0x2a8a
movq 0x4d8(%rsp), %rax
movq %rax, 0x148(%rsp)
movq 0x148(%rsp), %rax
movq %rax, 0x470(%rsp)
movq 0x470(%rsp), %rdi
leaq 0x487(%rsp), %r8
leaq 0x48c(%rsp), %r9
leaq 0x59bc(%rip), %rsi      # 0x8475
xorl %eax, %eax
leaq 0x486(%rsp), %rdx
leaq 0x488(%rsp), %rcx
callq 0x2210
movq 0x4f8(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x138(%rsp)
leaq 0x42f(%rsp), %rdi
movq %rdi, 0x140(%rsp)
callq 0x2360
movq 0x138(%rsp), %rsi
movq 0x140(%rsp), %rdx
leaq 0x430(%rsp), %rdi
callq 0x22b0
jmp 0x2b18
movq 0x470(%rsp), %rdx
leaq 0x450(%rsp), %rdi
leaq 0x430(%rsp), %rsi
callq 0x4160
jmp 0x2b37
leaq 0x430(%rsp), %rdi
callq 0x2140
leaq 0x42f(%rsp), %rdi
callq 0x2250
leaq 0x592c(%rip), %rsi      # 0x8484
leaq 0x450(%rsp), %rdi
movq %rdi, 0x128(%rsp)
movq $-0x1, %rdx
movq %rdx, 0x130(%rsp)
callq 0x21f0
movq 0x128(%rsp), %rdi
movq 0x130(%rsp), %rdx
movq %rax, %rsi
callq 0x2060
jmp 0x2b96
movsbl 0x486(%rsp), %ecx
movb $0x1, %al
cmpl $0x4e, %ecx
movb %al, 0x127(%rsp)
je 0x2bc1
movsbl 0x486(%rsp), %eax
cmpl $0x53, %eax
sete %al
movb %al, 0x127(%rsp)
movb 0x127(%rsp), %al
andb $0x1, %al
movb %al, 0x42d(%rsp)
leaq 0x42d(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x118(%rsp)
movsbl 0x487(%rsp), %ecx
movb $0x1, %al
cmpl $0x57, %ecx
movb %al, 0x126(%rsp)
je 0x2c10
movsbl 0x487(%rsp), %eax
cmpl $0x45, %eax
sete %al
movb %al, 0x126(%rsp)
movq 0x118(%rsp), %rax
movb 0x126(%rsp), %cl
andb $0x1, %cl
movb %cl, (%rax)
testb $0x1, 0x42d(%rsp)
je 0x2c3c
testb $0x1, 0x42e(%rsp)
jne 0x2d03
testb $0x1, 0x42d(%rsp)
je 0x2c56
movb 0x487(%rsp), %al
movb %al, 0x117(%rsp)
jmp 0x2c64
movb 0x486(%rsp), %al
movb %al, 0x117(%rsp)
movb 0x117(%rsp), %al
movsbl %al, %esi
movq 0x470(%rsp), %rdx
leaq 0x5809(%rip), %rdi      # 0x8486
xorl %eax, %eax
callq 0x2040
jmp 0x2c86
movl $0x1, 0x504(%rsp)
movl $0x1, 0x4a8(%rsp)
jmp 0x3ecc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x2cd8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
leaq 0x430(%rsp), %rdi
callq 0x2140
leaq 0x42f(%rsp), %rdi
callq 0x2250
jmp 0x3ef9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x3edb
movsbl 0x486(%rsp), %edx
movl 0x488(%rsp), %esi
movl 0x48c(%rsp), %ecx
movsbl 0x487(%rsp), %r8d
movl %esi, %r9d
incl %r9d
movl %ecx, %edi
incl %edi
movq %rsp, %rax
movl %r8d, 0x10(%rax)
movl %edi, 0x8(%rax)
movl %edx, (%rax)
leaq 0x5774(%rip), %rdi      # 0x84b3
xorl %eax, %eax
callq 0x2040
jmp 0x2d48
movq 0x490(%rsp), %rax
movq %rax, 0x100(%rsp)
leaq 0x40f(%rsp), %rdi
movq %rdi, 0x108(%rsp)
callq 0x41b0
movq 0x100(%rsp), %rsi
movq 0x108(%rsp), %rdx
leaq 0x410(%rsp), %rdi
callq 0x41c0
jmp 0x2d8c
leaq 0x40f(%rsp), %rdi
callq 0x4240
leaq 0x410(%rsp), %rdi
callq 0x4250
movq %rax, 0xe8(%rsp)
movq 0x490(%rsp), %rax
movq %rax, 0xf0(%rsp)
leaq 0x4c8(%rsp), %rdi
callq 0x4130
movq 0xe8(%rsp), %rdi
movq 0xf0(%rsp), %rsi
movq %rax, %rcx
movl $0x1, %edx
callq 0x22d0
movq %rax, 0xf8(%rsp)
jmp 0x2df2
movq 0xf8(%rsp), %rax
movq %rax, 0x400(%rsp)
cmpq $0x1, 0x400(%rsp)
je 0x2e7f
movq 0x400(%rsp), %rsi
leaq 0x56bd(%rip), %rdi      # 0x84d9
xorl %eax, %eax
callq 0x2040
jmp 0x2e25
movl $0x1, 0x504(%rsp)
movl $0x1, 0x4a8(%rsp)
jmp 0x3eae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
leaq 0x40f(%rsp), %rdi
callq 0x4240
jmp 0x3edb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x3ebd
callq 0x24f0
testb $0x1, %al
jne 0x2e8d
jmp 0x2f60
movb $0x0, 0x3ff(%rsp)
movl $0x0, 0x3f8(%rsp)
movslq 0x3f8(%rsp), %rax
cmpq 0x490(%rsp), %rax
jge 0x2f5e
movslq 0x3f8(%rsp), %rsi
leaq 0x410(%rsp), %rdi
callq 0x4270
movb (%rax), %al
movb %al, 0x3ff(%rsp)
movl 0x3f8(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
leaq 0x410(%rsp), %rdi
callq 0x4270
movb (%rax), %al
movb %al, 0xe6(%rsp)
movslq 0x3f8(%rsp), %rsi
leaq 0x410(%rsp), %rdi
callq 0x4270
movb 0xe6(%rsp), %cl
movb %cl, (%rax)
movb 0x3ff(%rsp), %al
movb %al, 0xe7(%rsp)
movl 0x3f8(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
leaq 0x410(%rsp), %rdi
callq 0x4270
movb 0xe7(%rsp), %cl
movb %cl, (%rax)
movslq 0x3f8(%rsp), %rax
addq $0x2, %rax
movl %eax, 0x3f8(%rsp)
jmp 0x2ea0
jmp 0x2f60
movl $0x8000, 0x3f4(%rsp) # imm = 0x8000
movl $0xffff8000, 0x3f0(%rsp) # imm = 0xFFFF8000
movl $0x0, 0x3ec(%rsp)
movq $0x0, 0x3e0(%rsp)
movl $0x0, 0x3dc(%rsp)
movslq 0x3dc(%rsp), %rax
cmpq 0x490(%rsp), %rax
jge 0x305a
leaq 0x410(%rsp), %rdi
callq 0x4250
movslq 0x3dc(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x3e0(%rsp)
movq 0x3e0(%rsp), %rax
movswl (%rax), %eax
movl %eax, 0x3e8(%rsp)
movl 0x3e8(%rsp), %eax
cmpl 0x3f4(%rsp), %eax
jge 0x3020
cmpl $0xffff8000, 0x3e8(%rsp) # imm = 0xFFFF8000
je 0x300d
movl 0x3e8(%rsp), %eax
movl %eax, 0x3f4(%rsp)
jmp 0x301e
movl 0x3ec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3ec(%rsp)
jmp 0x3040
movl 0x3e8(%rsp), %eax
cmpl 0x3f0(%rsp), %eax
jle 0x303e
movl 0x3e8(%rsp), %eax
movl %eax, 0x3f0(%rsp)
jmp 0x3040
jmp 0x3042
movslq 0x3dc(%rsp), %rax
addq $0x2, %rax
movl %eax, 0x3dc(%rsp)
jmp 0x2f98
movl 0x3f4(%rsp), %esi
movl 0x3f0(%rsp), %edx
movl 0x3ec(%rsp), %ecx
leaq 0x548a(%rip), %rdi      # 0x8500
xorl %eax, %eax
callq 0x2040
jmp 0x307f
xorps %xmm0, %xmm0
movsd %xmm0, 0x3d0(%rsp)
cvtsi2sdl 0x3f4(%rsp), %xmm0
movsd %xmm0, 0x3c8(%rsp)
cvtsi2sdl 0x3f0(%rsp), %xmm0
subsd 0x3c8(%rsp), %xmm0
movsd %xmm0, 0x3c0(%rsp)
movq 0x4f8(%rsp), %rax
movq 0x8(%rax), %rax
movsbl (%rax), %eax
cmpl $0x61, %eax
jne 0x31b8
movq $0x0, 0x3b8(%rsp)
movl $0x0, 0x3b4(%rsp)
movslq 0x3b4(%rsp), %rax
cmpq 0x490(%rsp), %rax
jge 0x31b3
leaq 0x410(%rsp), %rdi
callq 0x4250
movslq 0x3b4(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x3e0(%rsp)
leaq 0x410(%rsp), %rdi
callq 0x4250
movslq 0x3b4(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x3b8(%rsp)
movq 0x3e0(%rsp), %rax
movswl (%rax), %eax
cmpl $0xffff8000, %eax       # imm = 0xFFFF8000
jne 0x315d
movl $0xffff, %eax           # imm = 0xFFFF
movl %eax, 0xe0(%rsp)
jmp 0x3186
movq 0x3e0(%rsp), %rax
movswl (%rax), %eax
cvtsi2sd %eax, %xmm0
movsd 0x4ebc(%rip), %xmm1     # 0x8030
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movzwl %ax, %eax
movl %eax, 0xe0(%rsp)
movl 0xe0(%rsp), %eax
movw %ax, %cx
movq 0x3b8(%rsp), %rax
movw %cx, (%rax)
movslq 0x3b4(%rsp), %rax
addq $0x2, %rax
movl %eax, 0x3b4(%rsp)
jmp 0x30e7
jmp 0x32dd
movq $0x0, 0x3e0(%rsp)
movq $0x0, 0x3a8(%rsp)
movl $0x0, 0x3a4(%rsp)
movslq 0x3a4(%rsp), %rax
cmpq 0x490(%rsp), %rax
jge 0x32db
leaq 0x410(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
callq 0x4250
movq 0xd8(%rsp), %rdi
movslq 0x3a4(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x3e0(%rsp)
callq 0x4250
movslq 0x3a4(%rsp), %rcx
addq %rcx, %rax
movq %rax, 0x3a8(%rsp)
movq 0x3e0(%rsp), %rax
movswl (%rax), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x3d0(%rsp)
movq 0x3e0(%rsp), %rax
movswl (%rax), %eax
cmpl $0xffff8000, %eax       # imm = 0xFFFF8000
jne 0x3271
movl $0xffff, %eax           # imm = 0xFFFF
movl %eax, 0xd4(%rsp)
jmp 0x32ae
movsd 0x3d0(%rsp), %xmm0
movsd 0x3c8(%rsp), %xmm1
subsd %xmm1, %xmm0
movsd 0x4d89(%rip), %xmm1     # 0x8018
mulsd %xmm1, %xmm0
movsd 0x3c0(%rsp), %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movzwl %ax, %eax
movl %eax, 0xd4(%rsp)
movl 0xd4(%rsp), %eax
movw %ax, %cx
movq 0x3a8(%rsp), %rax
movw %cx, (%rax)
movslq 0x3a4(%rsp), %rax
addq $0x2, %rax
movl %eax, 0x3a4(%rsp)
jmp 0x31db
jmp 0x32dd
callq 0x24f0
testb $0x1, %al
jne 0x32eb
jmp 0x33be
movb $0x0, 0x3a3(%rsp)
movl $0x0, 0x39c(%rsp)
movslq 0x39c(%rsp), %rax
cmpq 0x490(%rsp), %rax
jge 0x33bc
movslq 0x39c(%rsp), %rsi
leaq 0x410(%rsp), %rdi
callq 0x4270
movb (%rax), %al
movb %al, 0x3a3(%rsp)
movl 0x39c(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
leaq 0x410(%rsp), %rdi
callq 0x4270
movb (%rax), %al
movb %al, 0xd2(%rsp)
movslq 0x39c(%rsp), %rsi
leaq 0x410(%rsp), %rdi
callq 0x4270
movb 0xd2(%rsp), %cl
movb %cl, (%rax)
movb 0x3a3(%rsp), %al
movb %al, 0xd3(%rsp)
movl 0x39c(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
leaq 0x410(%rsp), %rdi
callq 0x4270
movb 0xd3(%rsp), %cl
movb %cl, (%rax)
movslq 0x39c(%rsp), %rax
addq $0x2, %rax
movl %eax, 0x39c(%rsp)
jmp 0x32fe
jmp 0x33be
movl 0x49c(%rsp), %eax
decl %eax
cvtsi2sd %eax, %xmm1
movsd 0x4c4d(%rip), %xmm0     # 0x8020
movsd %xmm0, 0xb8(%rsp)
divsd %xmm1, %xmm0
callq 0x2520
movaps %xmm0, %xmm1
movsd 0xb8(%rsp), %xmm0
movsd %xmm1, 0x390(%rsp)
movl 0x498(%rsp), %eax
decl %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x2520
movsd %xmm0, 0x388(%rsp)
leaq 0x370(%rsp), %rdi
callq 0x4290
movslq 0x498(%rsp), %rax
movq %rax, 0xc0(%rsp)
leaq 0x357(%rsp), %rdi
movq %rdi, 0xc8(%rsp)
callq 0x42a0
movq 0xc0(%rsp), %rsi
movq 0xc8(%rsp), %rdx
leaq 0x358(%rsp), %rdi
callq 0x42b0
jmp 0x346a
leaq 0x357(%rsp), %rdi
callq 0x4330
movq $0x0, 0x348(%rsp)
movl $0x0, 0x344(%rsp)
movl $0x0, 0x340(%rsp)
movl $0x0, 0x33c(%rsp)
movl 0x33c(%rsp), %eax
cmpl 0x4ec(%rsp), %eax
jge 0x3e0b
movl $0x0, 0x338(%rsp)
movl 0x338(%rsp), %eax
cmpl 0x4e8(%rsp), %eax
jge 0x3dd2
leaq 0x504d(%rip), %rdi      # 0x852b
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rsi
movq %rcx, %rdx
callq 0x20a0
movq %rax, 0xb0(%rsp)
jmp 0x34f7
movq 0xb0(%rsp), %rax
movq %rax, 0x330(%rsp)
movq 0x330(%rsp), %rdi
callq 0x2340
movq %rax, 0xa8(%rsp)
jmp 0x351e
movq 0xa8(%rsp), %rax
movq %rax, 0x328(%rsp)
movq 0x330(%rsp), %rdi
movq 0x328(%rsp), %rsi
movl 0x49c(%rsp), %edx
movl 0x498(%rsp), %ecx
movq %rsp, %rax
movl $0x0, 0x10(%rax)
movl $0x0, 0x8(%rax)
movl $0x0, (%rax)
movl $0x10, %r8d
xorl %r9d, %r9d
callq 0x2330
jmp 0x3573
movq 0x330(%rsp), %rdi
movq 0x328(%rsp), %rsi
movsd 0x390(%rsp), %xmm0
movsd 0x388(%rsp), %xmm1
movl $0x2, %edx
callq 0x2090
jmp 0x35a1
leaq 0x307(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0x2360
movq 0xa0(%rsp), %rdx
leaq 0x4f6d(%rip), %rsi      # 0x8532
leaq 0x308(%rsp), %rdi
callq 0x22b0
jmp 0x35d4
leaq 0x307(%rsp), %rdi
callq 0x2250
leaq 0x2df(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0x2360
movq 0x98(%rsp), %rdx
leaq 0x4f36(%rip), %rsi      # 0x853b
leaq 0x2e0(%rsp), %rdi
callq 0x22b0
jmp 0x3614
leaq 0x2df(%rsp), %rdi
callq 0x2250
movsd 0x3c8(%rsp), %xmm0
leaq 0x2b8(%rsp), %rdi
callq 0x4340
jmp 0x3639
movsd 0x3c0(%rsp), %xmm0
leaq 0x298(%rsp), %rdi
callq 0x4340
jmp 0x3651
xorl %eax, %eax
movl %eax, %esi
leaq 0x2b8(%rsp), %rdi
callq 0x2390
movq %rax, 0x90(%rsp)
jmp 0x366c
movq 0x90(%rsp), %rax
movq %rax, 0x280(%rsp)
leaq 0x288(%rsp), %rax
movq %rax, 0x80(%rsp)
xorl %eax, %eax
movl %eax, %esi
leaq 0x298(%rsp), %rdi
callq 0x2390
movq %rax, 0x88(%rsp)
jmp 0x36a7
movq 0x80(%rsp), %rax
movq 0x88(%rsp), %rcx
movq %rcx, (%rax)
movq 0x330(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x328(%rsp), %rax
movq %rax, 0x70(%rsp)
xorl %eax, %eax
movl %eax, %esi
leaq 0x308(%rsp), %rdi
callq 0x2390
movq %rax, 0x78(%rsp)
jmp 0x36ec
xorl %eax, %eax
movl %eax, %esi
leaq 0x2e0(%rsp), %rdi
callq 0x2390
movq %rax, 0x60(%rsp)
jmp 0x3704
movq 0x78(%rsp), %rdx
movq 0x70(%rsp), %rsi
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rcx
movq %rsp, %rax
leaq 0x280(%rsp), %r8
movq %r8, 0x10(%rax)
movq %rcx, 0x8(%rax)
movl $0x2, (%rax)
movl $0xffff8001, %ecx       # imm = 0xFFFF8001
movl $0x7fff, %r8d           # imm = 0x7FFF
xorl %r9d, %r9d
callq 0x2190
jmp 0x3746
movl 0x344(%rsp), %eax
movl %eax, 0x27c(%rsp)
movl 0x27c(%rsp), %eax
movl 0x344(%rsp), %ecx
addl 0x498(%rsp), %ecx
cmpl %ecx, %eax
jge 0x38c0
leaq 0x410(%rsp), %rdi
callq 0x4250
movl 0x27c(%rsp), %ecx
imull 0x4f4(%rsp), %ecx
movslq %ecx, %rcx
shlq %rcx
addq %rcx, %rax
movl 0x340(%rsp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq %rcx
addq %rcx, %rax
movq %rax, 0x58(%rsp)
movl 0x27c(%rsp), %eax
subl 0x344(%rsp), %eax
movslq %eax, %rsi
leaq 0x358(%rsp), %rdi
callq 0x4390
movq 0x58(%rsp), %rcx
movq %rcx, (%rax)
movl 0x27c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x27c(%rsp)
jmp 0x3754
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
leaq 0x357(%rsp), %rdi
callq 0x4330
jmp 0x3e9f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x3e92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
leaq 0x307(%rsp), %rdi
callq 0x2250
jmp 0x3e92
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
leaq 0x2df(%rsp), %rdi
callq 0x2250
jmp 0x3dc0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x3db3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x3da6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x3d99
movq 0x330(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x328(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0x358(%rsp), %rdi
callq 0x43b0
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq %rax, %rdx
callq 0x22e0
jmp 0x38fb
movq 0x330(%rsp), %rdi
leaq -0x13ba(%rip), %rdx     # 0x2550
xorl %eax, %eax
movl %eax, %ecx
leaq 0x370(%rsp), %rsi
callq 0x23b0
jmp 0x391d
movq 0x330(%rsp), %rdi
movq 0x328(%rsp), %rsi
xorl %edx, %edx
movl %edx, %ecx
callq 0x20b0
jmp 0x3938
leaq 0x330(%rsp), %rdi
leaq 0x328(%rsp), %rsi
callq 0x21a0
jmp 0x394f
leaq 0x370(%rsp), %rdi
callq 0x43d0
movq %rax, 0x270(%rsp)
leaq 0x4b19(%rip), %rdx      # 0x8484
leaq 0x1d0(%rsp), %rdi
leaq 0x450(%rsp), %rsi
callq 0x44e0
jmp 0x3982
movl 0x344(%rsp), %esi
leaq 0x1b0(%rsp), %rdi
callq 0x4570
jmp 0x3998
leaq 0x1f0(%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x1b0(%rsp), %rdx
callq 0x43f0
jmp 0x39b7
leaq 0x4ac6(%rip), %rdx      # 0x8484
leaq 0x210(%rsp), %rdi
leaq 0x1f0(%rsp), %rsi
callq 0x4160
jmp 0x39d5
movl 0x340(%rsp), %esi
leaq 0x190(%rsp), %rdi
callq 0x4570
jmp 0x39eb
leaq 0x230(%rsp), %rdi
leaq 0x210(%rsp), %rsi
leaq 0x190(%rsp), %rdx
callq 0x43f0
jmp 0x3a0a
leaq 0x4b2c(%rip), %rdx      # 0x853d
leaq 0x250(%rsp), %rdi
leaq 0x230(%rsp), %rsi
callq 0x4160
jmp 0x3a28
leaq 0x230(%rsp), %rdi
callq 0x2140
leaq 0x190(%rsp), %rdi
callq 0x2140
leaq 0x210(%rsp), %rdi
callq 0x2140
leaq 0x1f0(%rsp), %rdi
callq 0x2140
leaq 0x1b0(%rsp), %rdi
callq 0x2140
leaq 0x1d0(%rsp), %rdi
callq 0x2140
leaq 0x250(%rsp), %rdi
callq 0x20e0
movq %rax, %rdi
leaq 0x4ab5(%rip), %rsi      # 0x8542
callq 0x2280
movq %rax, 0x40(%rsp)
jmp 0x3a99
leaq 0x177(%rsp), %rdi
callq 0x3f40
movq 0x40(%rsp), %rsi
movq %rax, 0x178(%rsp)
leaq 0x180(%rsp), %rdi
leaq 0x178(%rsp), %rdx
callq 0x40f0
leaq 0x4c8(%rsp), %rdi
callq 0x4130
cmpq $0x0, %rax
jne 0x3c34
leaq 0x250(%rsp), %rdi
callq 0x20e0
movq %rax, %rsi
leaq 0x4816(%rip), %rdi      # 0x830c
xorl %eax, %eax
callq 0x2040
jmp 0x3aff
movl $0x1, 0x504(%rsp)
movl $0x1, 0x4a8(%rsp)
jmp 0x3d15
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x3be3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x3bd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x3bc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x3bbc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x3baf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
leaq 0x230(%rsp), %rdi
callq 0x2140
leaq 0x190(%rsp), %rdi
callq 0x2140
leaq 0x210(%rsp), %rdi
callq 0x2140
leaq 0x1f0(%rsp), %rdi
callq 0x2140
leaq 0x1b0(%rsp), %rdi
callq 0x2140
leaq 0x1d0(%rsp), %rdi
callq 0x2140
jmp 0x3d99
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
jmp 0x3d8c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4b0(%rsp)
movl %eax, 0x4ac(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x46d0
jmp 0x3d8c
leaq 0x370(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x4250
movq 0x20(%rsp), %rdi
movq %rax, 0x28(%rsp)
callq 0x43d0
movq %rax, 0x30(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x4130
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq %rax, %rcx
movl $0x1, %edx
callq 0x23a0
movq %rax, 0x38(%rsp)
jmp 0x3c85
movq 0x38(%rsp), %rax
movq %rax, 0x168(%rsp)
leaq 0x370(%rsp), %rdi
callq 0x46b0
cmpq $0x1, 0x168(%rsp)
je 0x3cda
movq 0x168(%rsp), %rsi
leaq 0x488c(%rip), %rdi      # 0x8545
xorl %eax, %eax
callq 0x2040
jmp 0x3cc2
movl $0x1, 0x504(%rsp)
movl $0x1, 0x4a8(%rsp)
jmp 0x3d15
movq 0x270(%rsp), %rax
addq 0x348(%rsp), %rax
movq %rax, 0x348(%rsp)
movl 0x498(%rsp), %eax
subl $0x1, %eax
addl 0x340(%rsp), %eax
movl %eax, 0x340(%rsp)
movl $0x0, 0x4a8(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x46d0
leaq 0x250(%rsp), %rdi
callq 0x2140
leaq 0x298(%rsp), %rdi
callq 0x2140
leaq 0x2b8(%rsp), %rdi
callq 0x2140
leaq 0x2e0(%rsp), %rdi
callq 0x2140
leaq 0x308(%rsp), %rdi
callq 0x2140
movl 0x4a8(%rsp), %eax
testl %eax, %eax
jne 0x3e76
jmp 0x3d74
jmp 0x3d76
movl 0x338(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x338(%rsp)
jmp 0x34c3
leaq 0x250(%rsp), %rdi
callq 0x2140
leaq 0x298(%rsp), %rdi
callq 0x2140
leaq 0x2b8(%rsp), %rdi
callq 0x2140
leaq 0x2e0(%rsp), %rdi
callq 0x2140
leaq 0x308(%rsp), %rdi
callq 0x2140
jmp 0x3e92
movl $0x0, 0x340(%rsp)
movl 0x49c(%rsp), %eax
subl $0x1, %eax
addl 0x344(%rsp), %eax
movl %eax, 0x344(%rsp)
movl 0x33c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x33c(%rsp)
jmp 0x34a4
movaps 0x422e(%rip), %xmm1     # 0x8040
movq 0x348(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x4229(%rip), %xmm1     # 0x8050
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
cvtsi2sdq 0x490(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd 0x41dc(%rip), %xmm1     # 0x8028
mulsd %xmm1, %xmm0
leaq 0x4716(%rip), %rdi      # 0x856d
movb $0x1, %al
callq 0x2040
jmp 0x3e60
movl $0x0, 0x504(%rsp)
movl $0x1, 0x4a8(%rsp)
leaq 0x358(%rsp), %rdi
callq 0x4740
leaq 0x370(%rsp), %rdi
callq 0x47a0
jmp 0x3eae
leaq 0x358(%rsp), %rdi
callq 0x4740
leaq 0x370(%rsp), %rdi
callq 0x47a0
jmp 0x3ebd
leaq 0x410(%rsp), %rdi
callq 0x47a0
jmp 0x3ecc
leaq 0x410(%rsp), %rdi
callq 0x47a0
jmp 0x3edb
leaq 0x450(%rsp), %rdi
callq 0x2140
jmp 0x3eea
leaq 0x450(%rsp), %rdi
callq 0x2140
jmp 0x3ef9
leaq 0x4c8(%rsp), %rdi
callq 0x46d0
jmp 0x3f08
leaq 0x4c8(%rsp), %rdi
callq 0x46d0
jmp 0x3f17
movl 0x504(%rsp), %eax
addq $0x508, %rsp            # imm = 0x508
retq
movq 0x4b0(%rsp), %rdi
callq 0x2350
nopw %cs:(%rax,%rax)