// File: f18m[P]boost-intrusive-pool/tests/performance_tests.cpp
// Function: do_benchmark(json_ctx*)
static void do_benchmark(json_ctx_t* json_ctx)
{
    typedef struct {
        unsigned int initial_size;
        unsigned int enlarge_step;
        unsigned int num_items;
    } config_t;

    typedef struct {
        BenchPattern_t pattern;
        size_t num_configs;
        config_t config[10]; // max num configs
    } pattern_test_t;

    pattern_test_t testPatterns[] = {
        {
            BENCH_PATTERN_CONTINUOUS_ALLOCATION, // force newline
            4, // force newline

            {
                // run #1 dummy test: a lot of objects and memory pool continuously resizing itself: no gain obtained:
                { 1, 1, (int)1e5 },

                // run #2 slightly better situation: the memory pool has to do 64x less resizings:
                { 128, 64, (int)1e5 }, // force newline

                // run #3 much better real-life example: the memory pool starts small but does only a few resizings
                //        because every time it increases by 1024 items:
                { 1024, 1024, (int)1e5 }, // force newline

                // run #4 optimal example: the memory pool starts bigger and does just 7 resizing steps
                { 16384, 16384, (int)1e5 }, // force newline
            } // force newline
        },

        // another more realistic (???) malloc pattern

        {
            BENCH_PATTERN_MIXED_ALLOC_FREE, // force newline
            3, // force newline

            {
                // run #5 in this test the memory pool begins small and does several resizings
                { 1024, 64, (int)1e5 }, // force newline

                // run #6 in this test the memory pool begins small but does less resizings
                { 1024, 128, (int)1e5 }, // force newline

                // run #7 in this test the memory pool begins with already a lot of items, so it does close-to-zero
                //        resizings:
                { 512 * 1024, 1024, (int)1e6 }, // force newline
            } // force newline
        }
    };

    for (int j = 0; j < sizeof(testPatterns) / sizeof(testPatterns[0]); j++) {
        if (json_ctx) {
            json_attr_object_begin(json_ctx, (std::string("pattern_") + std::to_string(j + 1)).c_str());
            json_attr_string(json_ctx, "desc", BenchPattern2String(testPatterns[j].pattern).c_str());
        }

        for (int i = 0; i < testPatterns[j].num_configs; i++) {
            const config_t& runConfig = testPatterns[j].config[i];

            size_t num_freed[2], max_active[2], ctor_count[2], dtor_count[2], num_resizings;
            struct rusage usage[2];
            timing_t avg_time[2];

            // run the benchmark with boost_intrusive_pool
            {
                LargeObject::reset_counts();

                boost_intrusive_pool<LargeObject> real_pool(
                    runConfig.initial_size /* initial size */, runConfig.enlarge_step /* enlarge step */);

                timing_t start, stop, elapsed, accumulated = 0;
                for (int k = 0; k < NUM_AVERAGING_RUNS; k++) {
                    TIMING_NOW(start);
                    main_benchmark_loop(
                        real_pool, testPatterns[j].pattern, runConfig.num_items, num_freed[0], max_active[0]);
                    TIMING_NOW(stop);
                    TIMING_DIFF(elapsed, start, stop);
                    TIMING_ACCUM(accumulated, elapsed);
                }

                avg_time[0] = accumulated / NUM_AVERAGING_RUNS;
                ctor_count[0] = LargeObject::m_ctor_count;
                dtor_count[0] = LargeObject::m_dtor_count;
                num_resizings = real_pool.enlarge_steps_done();

                getrusage(RUSAGE_SELF, &usage[0]);
            }

            // run the benchmark with NoPool
            {
                LargeObject::reset_counts();

                NoPool comparison_pool;

                timing_t start, stop, elapsed, accumulated = 0;
                for (int k = 0; k < NUM_AVERAGING_RUNS; k++) {
                    TIMING_NOW(start);
                    main_benchmark_loop(
                        comparison_pool, testPatterns[j].pattern, runConfig.num_items, num_freed[1], max_active[1]);
                    TIMING_NOW(stop);
                    TIMING_DIFF(elapsed, start, stop);
                    TIMING_ACCUM(accumulated, elapsed);
                }

                avg_time[1] = accumulated / NUM_AVERAGING_RUNS;
                ctor_count[1] = LargeObject::m_ctor_count;
                dtor_count[1] = LargeObject::m_dtor_count;

                getrusage(RUSAGE_SELF, &usage[1]);
            }

            // output results as JSON:
            if (json_ctx) {
                json_attr_object_begin(json_ctx, ("run_" + std::to_string(i + 1)).c_str());

                // test setup
                json_attr_double(json_ctx, "initial_size", runConfig.initial_size);
                json_attr_double(json_ctx, "enlarge_step", runConfig.enlarge_step);
                json_attr_double(json_ctx, "num_items", runConfig.num_items);

                // test results
                json_attr_object_begin(json_ctx, "boost_intrusive_pool");
                json_attr_double(json_ctx, "duration_nsec", avg_time[0]);
                json_attr_double(json_ctx, "duration_nsec_per_item", (double)avg_time[0] / (double)runConfig.num_items);
                json_attr_double(json_ctx, "num_items_freed", num_freed[0]);
                json_attr_double(json_ctx, "max_active_items", max_active[0]);
                json_attr_double(json_ctx, "max_rss", usage[0].ru_maxrss);
                json_attr_double(json_ctx, "ctor_count", ctor_count[0]);
                json_attr_double(json_ctx, "dtor_count", dtor_count[0]);
                json_attr_double(json_ctx, "num_resizings", num_resizings);
                json_attr_object_end(json_ctx); // boost_intrusive_pool_item

                // test results
                json_attr_object_begin(json_ctx, "plain_malloc");
                json_attr_double(json_ctx, "duration_nsec", avg_time[1]);
                json_attr_double(json_ctx, "duration_nsec_per_item", (double)avg_time[1] / (double)runConfig.num_items);
                json_attr_double(json_ctx, "num_items_freed", num_freed[1]);
                json_attr_double(json_ctx, "max_active_items", max_active[1]);
                json_attr_double(json_ctx, "max_rss", usage[1].ru_maxrss);
                json_attr_double(json_ctx, "ctor_count", ctor_count[1]);
                json_attr_double(json_ctx, "dtor_count", dtor_count[1]);
                json_attr_object_end(json_ctx); // plain_malloc
                json_attr_object_end(json_ctx); // run
            }
        }

        if (json_ctx)
            json_attr_object_end(json_ctx); // run
    }
}

// Assembly:
subq $0x528, %rsp            # imm = 0x528
movq %rdi, 0x520(%rsp)
leaq 0x410(%rsp), %rdi
leaq 0x8492(%rip), %rsi      # 0xaa20
movl $0x110, %edx            # imm = 0x110
callq 0x2170
movl $0x0, 0x40c(%rsp)
movslq 0x40c(%rsp), %rax
cmpq $0x2, %rax
jae 0x3176
cmpq $0x0, 0x520(%rsp)
je 0x27bd
movq 0x520(%rsp), %rax
movq %rax, 0xa8(%rsp)
leaq 0x3c7(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x2270
movq 0xb0(%rsp), %rdx
leaq 0x7a9d(%rip), %rsi      # 0xa095
leaq 0x3c8(%rsp), %rdi
callq 0x2210
jmp 0x2607
movl 0x40c(%rsp), %esi
incl %esi
leaq 0x390(%rsp), %rdi
callq 0x3ef0
jmp 0x261f
leaq 0x3e8(%rsp), %rdi
leaq 0x3c8(%rsp), %rsi
leaq 0x390(%rsp), %rdx
callq 0x3e00
jmp 0x263e
leaq 0x3e8(%rsp), %rdi
callq 0x20c0
movq 0xa8(%rsp), %rdi
movq %rax, %rsi
callq 0x9390
jmp 0x265d
leaq 0x3e8(%rsp), %rdi
callq 0x2110
leaq 0x390(%rsp), %rdi
callq 0x2110
leaq 0x3c8(%rsp), %rdi
callq 0x2110
leaq 0x3c7(%rsp), %rdi
callq 0x21b0
movq 0x520(%rsp), %rax
movq %rax, 0xa0(%rsp)
movslq 0x40c(%rsp), %rcx
movq %rcx, %rax
shlq $0x7, %rax
leaq (%rax,%rcx,8), %rax
movl 0x410(%rsp,%rax), %esi
leaq 0x370(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0x23a0
movq 0x98(%rsp), %rdi
callq 0x20c0
movq 0xa0(%rsp), %rdi
movq %rax, %rdx
leaq 0x79af(%rip), %rsi      # 0xa09e
callq 0x9450
jmp 0x26f6
leaq 0x370(%rsp), %rdi
callq 0x2110
jmp 0x27bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x2785
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x2778
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x276b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
leaq 0x3e8(%rsp), %rdi
callq 0x2110
leaq 0x390(%rsp), %rdi
callq 0x2110
leaq 0x3c8(%rsp), %rdi
callq 0x2110
leaq 0x3c7(%rsp), %rdi
callq 0x21b0
jmp 0x317e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
leaq 0x370(%rsp), %rdi
callq 0x2110
jmp 0x317e
movl $0x0, 0x36c(%rsp)
movslq 0x36c(%rsp), %rax
movslq 0x40c(%rsp), %rdx
leaq 0x410(%rsp), %rcx
imulq $0x88, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
jae 0x3146
movslq 0x40c(%rsp), %rcx
movq %rcx, %rax
shlq $0x7, %rax
leaq (%rax,%rcx,8), %rax
leaq 0x410(%rsp,%rax), %rax
movslq 0x36c(%rsp), %rcx
leaq (%rcx,%rcx,2), %rcx
leaq 0x10(%rax,%rcx,4), %rax
movq %rax, 0x360(%rsp)
callq 0x4030
movq 0x360(%rsp), %rax
movl (%rax), %ecx
movl 0x4(%rax), %eax
movq %rcx, 0x70(%rsp)
movq %rax, 0x78(%rsp)
xorl %eax, %eax
movl %eax, 0x8c(%rsp)
movl %eax, %esi
movq %rsi, 0x80(%rsp)
leaq 0x1b0(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0x4050
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq 0x80(%rsp), %rcx
movl 0x8c(%rsp), %r8d
movq 0x90(%rsp), %r9
leaq 0x1d0(%rsp), %rdi
callq 0x4090
jmp 0x289d
leaq 0x1b0(%rsp), %rdi
callq 0x41a0
movq $0x0, 0x190(%rsp)
movl $0x0, 0x18c(%rsp)
cmpl $0xa, 0x18c(%rsp)
jge 0x2a1c
movl $0x2, %edi
leaq 0x178(%rsp), %rsi
callq 0x2180
movq 0x178(%rsp), %rcx
movq 0x180(%rsp), %rax
imulq $0x3b9aca00, %rcx, %rcx # imm = 0x3B9ACA00
addq %rcx, %rax
movq %rax, 0x1a8(%rsp)
movq %rax, 0x170(%rsp)
movslq 0x40c(%rsp), %rcx
movq %rcx, %rax
shlq $0x7, %rax
leaq (%rax,%rcx,8), %rax
movl 0x410(%rsp,%rax), %esi
movq 0x360(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, %edx
leaq 0x1d0(%rsp), %rdi
leaq 0x350(%rsp), %rcx
leaq 0x340(%rsp), %r8
callq 0x31e0
jmp 0x2951
movl $0x2, %edi
leaq 0x160(%rsp), %rsi
callq 0x2180
movq 0x168(%rsp), %rax
imulq $0x3b9aca00, 0x160(%rsp), %rcx # imm = 0x3B9ACA00
addq %rcx, %rax
movq %rax, 0x1a0(%rsp)
movq %rax, 0x158(%rsp)
movq 0x1a0(%rsp), %rax
subq 0x1a8(%rsp), %rax
movq %rax, 0x198(%rsp)
movq 0x198(%rsp), %rax
addq 0x190(%rsp), %rax
movq %rax, 0x190(%rsp)
movl 0x18c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x18c(%rsp)
jmp 0x28c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
leaq 0x1b0(%rsp), %rdi
callq 0x41a0
jmp 0x317e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x4200
jmp 0x317e
movq 0x190(%rsp), %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
mulq %rcx
shrq $0x3, %rdx
movq %rdx, 0x1e0(%rsp)
leaq 0xc72c(%rip), %rax      # 0xf170
movq (%rax), %rax
movq %rax, 0x330(%rsp)
leaq 0xc722(%rip), %rax      # 0xf178
movq (%rax), %rax
movq %rax, 0x320(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x41b0
movq %rax, 0x68(%rsp)
jmp 0x2a75
movq 0x68(%rsp), %rax
movq %rax, 0x318(%rsp)
leaq 0x1f0(%rsp), %rsi
xorl %edi, %edi
callq 0x20f0
leaq 0x1d0(%rsp), %rdi
callq 0x4200
callq 0x4030
leaq 0x157(%rsp), %rdi
callq 0x4270
movq $0x0, 0x130(%rsp)
movl $0x0, 0x12c(%rsp)
cmpl $0xa, 0x12c(%rsp)
jge 0x2bdb
movl $0x2, %edi
leaq 0x118(%rsp), %rsi
callq 0x2180
movq 0x120(%rsp), %rax
imulq $0x3b9aca00, 0x118(%rsp), %rcx # imm = 0x3B9ACA00
addq %rcx, %rax
movq %rax, 0x148(%rsp)
movq %rax, 0x110(%rsp)
movslq 0x40c(%rsp), %rcx
leaq 0x410(%rsp), %rax
imulq $0x88, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %esi
movq 0x360(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, %edx
leaq 0x350(%rsp), %rcx
addq $0x8, %rcx
leaq 0x340(%rsp), %r8
addq $0x8, %r8
leaq 0x157(%rsp), %rdi
callq 0x3830
movl $0x2, %edi
leaq 0x100(%rsp), %rsi
callq 0x2180
movq 0x108(%rsp), %rax
imulq $0x3b9aca00, 0x100(%rsp), %rcx # imm = 0x3B9ACA00
addq %rcx, %rax
movq %rax, 0x140(%rsp)
movq %rax, 0xf8(%rsp)
movq 0x140(%rsp), %rax
subq 0x148(%rsp), %rax
movq %rax, 0x138(%rsp)
movq 0x138(%rsp), %rax
addq 0x130(%rsp), %rax
movq %rax, 0x130(%rsp)
movl 0x12c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x12c(%rsp)
jmp 0x2ac7
movq 0x130(%rsp), %rax
movl $0xa, %ecx
xorl %edx, %edx
divq %rcx
movq %rax, 0x1e8(%rsp)
leaq 0xc574(%rip), %rax      # 0xf170
movq (%rax), %rax
movq %rax, 0x338(%rsp)
leaq 0xc56a(%rip), %rax      # 0xf178
movq (%rax), %rax
movq %rax, 0x328(%rsp)
leaq 0x1f0(%rsp), %rsi
addq $0x90, %rsi
xorl %edi, %edi
callq 0x20f0
cmpq $0x0, 0x520(%rsp)
je 0x312e
movq 0x520(%rsp), %rax
movq %rax, 0x58(%rsp)
movl 0x36c(%rsp), %esi
incl %esi
leaq 0xb8(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x3ef0
movq 0x60(%rsp), %rdx
leaq 0x7431(%rip), %rsi      # 0xa0a3
leaq 0xd8(%rsp), %rdi
callq 0x4280
jmp 0x2c81
leaq 0xd8(%rsp), %rdi
callq 0x20c0
movq 0x58(%rsp), %rdi
movq %rax, %rsi
callq 0x9390
jmp 0x2c9d
leaq 0xd8(%rsp), %rdi
callq 0x2110
leaq 0xb8(%rsp), %rdi
callq 0x2110
movq 0x520(%rsp), %rdi
movq 0x360(%rsp), %rax
movl (%rax), %eax
cvtsi2sd %rax, %xmm0
leaq 0x73d3(%rip), %rsi      # 0xa0a8
callq 0x95a0
movq 0x520(%rsp), %rdi
movq 0x360(%rsp), %rax
movl 0x4(%rax), %eax
cvtsi2sd %rax, %xmm0
leaq 0x73bc(%rip), %rsi      # 0xa0b5
callq 0x95a0
movq 0x520(%rsp), %rdi
movq 0x360(%rsp), %rax
movl 0x8(%rax), %eax
cvtsi2sd %rax, %xmm0
leaq 0x73a5(%rip), %rsi      # 0xa0c2
callq 0x95a0
movq 0x520(%rsp), %rdi
leaq 0x739b(%rip), %rsi      # 0xa0cc
callq 0x9390
movq 0x520(%rsp), %rdi
movq 0x1e0(%rsp), %xmm0
movaps 0x72c2(%rip), %xmm1     # 0xa010
movaps %xmm1, 0x30(%rsp)
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x72c1(%rip), %xmm1     # 0xa020
movaps %xmm1, 0x40(%rsp)
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
leaq 0x7367(%rip), %rsi      # 0xa0e1
movq %rsi, (%rsp)
callq 0x95a0
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm1
movq 0x520(%rsp), %rdi
movq 0x1e0(%rsp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0x360(%rsp), %rax
movl 0x8(%rax), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
leaq 0x7323(%rip), %rsi      # 0xa0ef
movq %rsi, 0x8(%rsp)
callq 0x95a0
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm1
movq 0x520(%rsp), %rdi
movq 0x350(%rsp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
leaq 0x72fb(%rip), %rsi      # 0xa106
movq %rsi, 0x10(%rsp)
callq 0x95a0
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm1
movq 0x520(%rsp), %rdi
movq 0x340(%rsp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
leaq 0x72cc(%rip), %rsi      # 0xa116
movq %rsi, 0x18(%rsp)
callq 0x95a0
movq 0x520(%rsp), %rdi
cvtsi2sdq 0x210(%rsp), %xmm0
leaq 0x72ba(%rip), %rsi      # 0xa127
movq %rsi, 0x20(%rsp)
callq 0x95a0
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm1
movq 0x520(%rsp), %rdi
movq 0x330(%rsp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
leaq 0x7283(%rip), %rsi      # 0xa12f
movq %rsi, 0x28(%rsp)
callq 0x95a0
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm1
movq 0x520(%rsp), %rdi
movq 0x320(%rsp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
leaq 0x724f(%rip), %rsi      # 0xa13a
callq 0x95a0
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm1
movq 0x520(%rsp), %rdi
movq 0x318(%rsp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
leaq 0x7220(%rip), %rsi      # 0xa145
callq 0x95a0
movq 0x520(%rsp), %rdi
callq 0x9400
movq 0x520(%rsp), %rdi
leaq 0x720d(%rip), %rsi      # 0xa153
callq 0x9390
movq (%rsp), %rsi
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm1
movq 0x520(%rsp), %rdi
movq 0x1e8(%rsp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
callq 0x95a0
movq 0x8(%rsp), %rsi
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm1
movq 0x520(%rsp), %rdi
movq 0x1e8(%rsp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq 0x360(%rsp), %rax
movl 0x8(%rax), %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
callq 0x95a0
movq 0x10(%rsp), %rsi
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm1
movq 0x520(%rsp), %rdi
movq 0x358(%rsp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
callq 0x95a0
movq 0x18(%rsp), %rsi
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm1
movq 0x520(%rsp), %rdi
movq 0x348(%rsp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
callq 0x95a0
movq 0x20(%rsp), %rsi
movq 0x520(%rsp), %rdi
cvtsi2sdq 0x2a0(%rsp), %xmm0
callq 0x95a0
movq 0x28(%rsp), %rsi
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm1
movq 0x520(%rsp), %rdi
movq 0x338(%rsp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
callq 0x95a0
movaps 0x30(%rsp), %xmm2
movaps 0x40(%rsp), %xmm1
movq 0x520(%rsp), %rdi
movq 0x328(%rsp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
leaq 0x7073(%rip), %rsi      # 0xa13a
callq 0x95a0
movq 0x520(%rsp), %rdi
callq 0x9400
movq 0x520(%rsp), %rdi
callq 0x9400
jmp 0x312e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
jmp 0x311f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3b8(%rsp)
movl %eax, 0x3b4(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x2110
leaq 0xb8(%rsp), %rdi
callq 0x2110
jmp 0x317e
jmp 0x3130
movl 0x36c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x36c(%rsp)
jmp 0x27c8
cmpq $0x0, 0x520(%rsp)
je 0x315e
movq 0x520(%rsp), %rdi
callq 0x9400
jmp 0x3160
movl 0x40c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40c(%rsp)
jmp 0x25a3
addq $0x528, %rsp            # imm = 0x528
retq
movq 0x3b8(%rsp), %rdi
callq 0x2260
nopl (%rax,%rax)