// File: /workspace/github_c_makefile_star2_O0/hiperiondev[P]hpsdrsim/src/hpsdr_sim.c
// Function: handler_ep6
void* handler_ep6(void *arg) {
    int i, j, k, n, size;
    int header_offset;
    uint32_t counter;
    uint8_t buffer[1032];
    uint8_t *pointer;
    uint8_t id[4] = { 0xef, 0xfe, 1, 6 };
    uint8_t header[40] = {
         // C0   C1   C2   C3   C4
            127, 127, 127, 0,   0,
            33,  17,  21,  127, 127,
            127, 8,   0,   0,   0,
            0,   127, 127, 127, 16,
            0,   0,   0,   0,   127,
            127, 127, 24,  0,   0,
            0,   0,   127, 127, 127,
            32,  66,  66,  66,  66
    };
    int32_t adc1isample, adc1qsample;
    int32_t adc2isample, adc2qsample;
    int32_t dacisample, dacqsample;
    int32_t myisample, myqsample;

    struct timespec delay;
    long wait;
    int noiseIQpt, toneIQpt, divpt, rxptr;
    double i1, q1, fac1, fac2, fac3, fac4;
    int decimation;  // for converting 1536 kHz samples to 48, 192, 384, ....
    unsigned int seed;
    unsigned int tx_fifo_count;

    fac2 = 0;
    fac4 = 0;

    seed = ((uintptr_t) &seed) & 0xffffff;

    memcpy(buffer, id, 4);

    header_offset = 0;
    counter = 0;

    noiseIQpt = 0;
    toneIQpt = 0;
    divpt = 0;

    // The rxptr should never "overtake" the txptr, but
    // it also must not lag behind by too much. Let's take
    // the typical TX FIFO size
    rxptr = txptr - 4096;
    if (rxptr < 0)
        rxptr += OLDRTXLEN;

    clock_gettime(CLOCK_MONOTONIC, &delay);
    while (1) {
        if (!enable_thread)
            break;

        size = receivers * 6 + 2;
        n = 504 / size;  // number of samples per 512-byte-block
        // Time (in nanosecs) to "collect" the samples sent in one sendmsg
        if ((48 << rate) == 0) {
            wait = (2 * n * 1000000L);
        } else {
            wait = (2 * n * 1000000L) / (48 << rate);

        }

        // plug in sequence numbers
        *(uint32_t*) (buffer + 4) = htonl(counter);
        ++counter;

        // This defines the distortion as well as the amplification
        // Use PA settings such that there is full drive at full power (39 dB)

        //  48 kHz   decimation = 32
        //  96 kHz   decimation = 16
        // 192 kHz   decimation =  8
        // 384 kHz   decimation =  4
        decimation = 32 >> rate;
        for (i = 0; i < 2; ++i) {
            pointer = buffer + i * 516 - i % 2 * 4 + 8;
            memcpy(pointer, header + header_offset, 8);

            switch (header_offset) {
            case 0:
                // do not set PTT and CW in C0
                // do not set ADC overflow in C1
                if (OLDDEVICE == DEVICE_HERMES_LITE2) {
                    // C2/C3 is TX FIFO count
                    tx_fifo_count = txptr - rxptr;
                    if (tx_fifo_count < 0)
                        tx_fifo_count += OLDRTXLEN;
                    *(pointer + 5) = (tx_fifo_count >> 8) & 0x7F;
                    *(pointer + 6) = tx_fifo_count & 0xFF;
                }
                header_offset = 8;
                break;
            case 8:
                if (OLDDEVICE == DEVICE_HERMES_LITE2) {
                    // HL2: temperature
                    *(pointer + 4) = 0;
                    *(pointer + 5) = tx_fifo_count & 0x7F;  // pseudo random number
                } else {
                    // AIN5: Exciter power
                    *(pointer + 4) = 0;  // about 500 mW
                    *(pointer + 5) = txdrive;
                }
                // AIN1: Forward Power
                j = (int) ((4095.0 / c1) * sqrt(100.0 * txlevel * c2));
                *(pointer + 6) = (j >> 8) & 0xFF;
                *(pointer + 7) = (j) & 0xFF;
                header_offset = 16;
                break;
            case 16:
                // AIN2: Reverse power
                // AIN3:
                header_offset = 24;
                break;
            case 24:
                // AIN4:
                // AIN5: supply voltage
                *(pointer + 6) = 0;
                *(pointer + 7) = 63;
                header_offset = 32;
                break;
            case 32:
                header_offset = 0;
                break;
            }

            pointer += 8;
            memset(pointer, 0, 504);
            fac1 = rxatt_dbl[0] * 0.0002239;  // Amplitude of 800-Hz-signal to ADC1
            if (diversity) {
                fac2 = 0.0001 * rxatt_dbl[0];  // Amplitude of broad "man-made" noise to ADC1
                fac4 = 0.0002 * rxatt_dbl[1];  // Amplitude of broad "man-made" noise to ADC2
                // (phase shifted 90 deg., 6 dB stronger)
            }
            for (j = 0; j < n; j++) {
                // ADC1: noise + weak tone on RX, feedback sig. on TX (except STEMlab)
                if (ptt && (OLDDEVICE != DEVICE_C25)) {
                    i1 = isample[rxptr] * txdrv_dbl;
                    q1 = qsample[rxptr] * txdrv_dbl;
                    fac3 = IM3a + IM3b * (i1 * i1 + q1 * q1);
                    adc1isample = (txatt_dbl * i1 * fac3 + noiseItab[noiseIQpt]) * 8388607.0;
                    adc1qsample = (txatt_dbl * q1 * fac3 + noiseItab[noiseIQpt]) * 8388607.0;
                } else if (diversity) {
                    // man made noise only to I samples
                    adc1isample = (noiseItab[noiseIQpt] + toneItab[toneIQpt] * fac1 + divtab[divpt] * fac2) * 8388607.0;
                    adc1qsample = (noiseQtab[noiseIQpt] + toneQtab[toneIQpt] * fac1) * 8388607.0;
                } else {
                    adc1isample = (noiseItab[noiseIQpt] + toneItab[toneIQpt] * fac1) * 8388607.0;
                    adc1qsample = (noiseQtab[noiseIQpt] + toneQtab[toneIQpt] * fac1) * 8388607.0;
                }
                // ADC2: noise RX, feedback sig. on TX (only STEMlab)
                if (ptt && (OLDDEVICE == DEVICE_C25)) {
                    i1 = isample[rxptr] * txdrv_dbl;
                    q1 = qsample[rxptr] * txdrv_dbl;
                    fac3 = IM3a + IM3b * (i1 * i1 + q1 * q1);
                    adc2isample = (txatt_dbl * i1 * fac3 + noiseItab[noiseIQpt]) * 8388607.0;
                    adc2qsample = (txatt_dbl * q1 * fac3 + noiseItab[noiseIQpt]) * 8388607.0;
                } else if (diversity) {
                    // man made noise to Q channel only
                    adc2isample = noiseItab[noiseIQpt] * 8388607.0;  // Noise
                    adc2qsample = (noiseQtab[noiseIQpt] + divtab[divpt] * fac4) * 8388607.0;
                } else {
                    adc2isample = noiseItab[noiseIQpt] * 8388607.0;  // Noise
                    adc2qsample = noiseQtab[noiseIQpt] * 8388607.0;
                }

                // TX signal with peak=0.407
                if (OLDDEVICE == DEVICE_HERMES_LITE2) {
                    dacisample = isample[rxptr] * 0.230 * 8388607.0;
                    dacqsample = qsample[rxptr] * 0.230 * 8388607.0;
                } else {
                    dacisample = isample[rxptr] * 0.407 * 8388607.0;
                    dacqsample = qsample[rxptr] * 0.407 * 8388607.0;
                }

                for (k = 0; k < receivers; k++) {
                    myisample = 0;
                    myqsample = 0;
                    switch (rx_adc[k]) {
                    case 0: // ADC1
                        myisample = adc1isample;
                        myqsample = adc1qsample;
                        break;
                    case 1: // ADC2
                        myisample = adc2isample;
                        myqsample = adc2qsample;
                        break;
                    default:
                        myisample = 0;
                        myqsample = 0;
                        break;
                    }
                    if ((OLDDEVICE == DEVICE_METIS || OLDDEVICE == DEVICE_HERMES_LITE) && ptt && (k == 1)) {
                        // METIS: TX DAC signal goes to RX2 when TXing
                        myisample = dacisample;
                        myqsample = dacqsample;
                    }
                    if ((OLDDEVICE == DEVICE_HERMES || OLDDEVICE == DEVICE_GRIFFIN || OLDDEVICE == DEVICE_C25 || OLDDEVICE == DEVICE_HERMES_LITE2) && ptt
                            && (k == 3)) {
                        // HERMES: TX DAC signal goes to RX4 when TXing
                        myisample = dacisample;
                        myqsample = dacqsample;
                    }
                    if ((OLDDEVICE == DEVICE_ANGELIA || OLDDEVICE == DEVICE_ORION || OLDDEVICE == DEVICE_ORION2) && ptt && (k == 4)) {
                        // ANGELIA and beyond: TX DAC signal goes to RX5 when TXing
                        myisample = dacisample;
                        myqsample = dacqsample;
                    }
                    *pointer++ = (myisample >> 16) & 0xFF;
                    *pointer++ = (myisample >> 8) & 0xFF;
                    *pointer++ = (myisample >> 0) & 0xFF;
                    *pointer++ = (myqsample >> 16) & 0xFF;
                    *pointer++ = (myqsample >> 8) & 0xFF;
                    *pointer++ = (myqsample >> 0) & 0xFF;
                }
                // Microphone samples: silence
                pointer += 2;
                rxptr++;
                if (rxptr >= OLDRTXLEN)
                    rxptr = 0;
                noiseIQpt++;
                if (noiseIQpt >= LENNOISE)
                    noiseIQpt = rand_r(&seed) / NOISEDIV;
                toneIQpt += decimation;
                if (toneIQpt >= LENTONE)
                    toneIQpt = 0;
                divpt += decimation;
                if (divpt >= LENDIV)
                    divpt = 0;
            }
        }

        // Wait until the time has passed for all these samples
        delay.tv_nsec += wait;
        while (delay.tv_nsec >= 1000000000) {
            delay.tv_nsec -= 1000000000;
            delay.tv_sec++;
        }

        clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &delay, NULL);

        if (sock_TCP_Client > -1) {
            if (sendto(sock_TCP_Client, buffer, 1032, 0, (struct sockaddr*) &addr_old, sizeof(addr_old)) < 0) {
                dbg_printf(1, "TCP sendmsg error occurred at sequence number: %u !\n", counter);
            }
        } else {
            sendto(sock_udp, buffer, 1032, 0, (struct sockaddr*) &addr_old, sizeof(addr_old));
        }

    }
    active_thread = 0;
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x510, %rsp            # imm = 0x510
movq %rdi, -0x8(%rbp)
movl 0x2a23(%rip), %eax      # 0xd158
movl %eax, -0x43c(%rbp)
leaq -0x470(%rbp), %rdi
leaq 0x29e7(%rip), %rsi      # 0xd130
movl $0x28, %edx
callq 0x1140
xorps %xmm0, %xmm0
movsd %xmm0, -0x4d8(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x4e8(%rbp)
leaq -0x4f0(%rbp), %rax
andq $0xffffff, %rax         # imm = 0xFFFFFF
movl %eax, -0x4f0(%rbp)
movl -0x43c(%rbp), %eax
movl %eax, -0x430(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x4ac(%rbp)
movl $0x0, -0x4b0(%rbp)
movl $0x0, -0x4b4(%rbp)
movl 0x18cd29e(%rip), %eax   # 0x18d7a58
subl $0x1000, %eax           # imm = 0x1000
movl %eax, -0x4b8(%rbp)
cmpl $0x0, -0x4b8(%rbp)
jge 0xa7df
movl -0x4b8(%rbp), %eax
addl $0xfc00, %eax           # imm = 0xFC00
movl %eax, -0x4b8(%rbp)
movl $0x1, %edi
leaq -0x4a0(%rbp), %rsi
callq 0x1080
cmpl $0x0, 0x18cd281(%rip)   # 0x18d7a78
jne 0xa7fe
jmp 0xb4a9
imull $0x6, 0x598b(%rip), %eax # 0x10190
addl $0x2, %eax
movl %eax, -0x1c(%rbp)
movl $0x1f8, %eax            # imm = 0x1F8
cltd
idivl -0x1c(%rbp)
movl %eax, -0x18(%rbp)
movl 0x594f(%rip), %ecx      # 0x1016c
movl $0x30, %eax
shll %cl, %eax
cmpl $0x0, %eax
jne 0xa840
movl -0x18(%rbp), %eax
shll %eax
cltq
imulq $0xf4240, %rax, %rax    # imm = 0xF4240
movq %rax, -0x4a8(%rbp)
jmp 0xa86c
movl -0x18(%rbp), %eax
shll %eax
cltq
imulq $0xf4240, %rax, %rax    # imm = 0xF4240
movl 0x5918(%rip), %ecx      # 0x1016c
movl $0x30, %edx
shll %cl, %edx
movl %edx, %ecx
movslq %ecx, %rcx
cqto
idivq %rcx
movq %rax, -0x4a8(%rbp)
movl -0x24(%rbp), %edi
callq 0x10e0
movl %eax, -0x42c(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl 0x58e3(%rip), %ecx      # 0x1016c
movl $0x20, %eax
sarl %cl, %eax
movl %eax, -0x4ec(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x2, -0xc(%rbp)
jge 0xb3d0
movl -0xc(%rbp), %ecx
movl %ecx, %edx
movl %ecx, %esi
shll $0x9, %esi
movl %esi, %eax
leal (%rax,%rdx,4), %eax
cltq
leaq -0x430(%rbp,%rax), %rax
movl %ecx, %esi
shrl $0x1f, %esi
movl %ecx, %edx
addl %esi, %edx
andl $0x3ffffffe, %edx       # imm = 0x3FFFFFFE
subl %edx, %ecx
shll $0x2, %ecx
movslq %ecx, %rcx
subq %rcx, %rax
addq $0x8, %rax
movq %rax, -0x438(%rbp)
movq -0x438(%rbp), %rax
movslq -0x20(%rbp), %rcx
movq -0x470(%rbp,%rcx), %rcx
movq %rcx, (%rax)
movl -0x20(%rbp), %eax
movq %rax, -0x500(%rbp)
subq $0x20, %rax
ja 0xaa92
movq -0x500(%rbp), %rax
leaq 0x277b(%rip), %rcx      # 0xd098
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x3ee, 0x5cf4(%rip)    # imm = 0x3EE
jne 0xa98d
movl 0x18cd120(%rip), %eax   # 0x18d7a58
subl -0x4b8(%rbp), %eax
movl %eax, -0x4f4(%rbp)
cmpl $0x0, -0x4f4(%rbp)
jae 0xa95e
movl -0x4f4(%rbp), %eax
addl $0xfc00, %eax           # imm = 0xFC00
movl %eax, -0x4f4(%rbp)
movl -0x4f4(%rbp), %eax
shrl $0x8, %eax
andl $0x7f, %eax
movb %al, %cl
movq -0x438(%rbp), %rax
movb %cl, 0x5(%rax)
movl -0x4f4(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x438(%rbp), %rax
movb %cl, 0x6(%rax)
movl $0x8, -0x20(%rbp)
jmp 0xaa92
cmpl $0x3ee, 0x5c81(%rip)    # imm = 0x3EE
jne 0xa9c7
movq -0x438(%rbp), %rax
movb $0x0, 0x4(%rax)
movl -0x4f4(%rbp), %eax
andl $0x7f, %eax
movb %al, %cl
movq -0x438(%rbp), %rax
movb %cl, 0x5(%rax)
jmp 0xa9e4
movq -0x438(%rbp), %rax
movb $0x0, 0x4(%rax)
movl 0x18cd0d4(%rip), %eax   # 0x18d7aac
movb %al, %cl
movq -0x438(%rbp), %rax
movb %cl, 0x5(%rax)
movsd 0x16fc(%rip), %xmm0     # 0xc0e8
divsd 0x5c44(%rip), %xmm0     # 0x10638
movsd %xmm0, -0x508(%rbp)
movsd 0x16dc(%rip), %xmm0     # 0xc0e0
mulsd 0x18cd064(%rip), %xmm0  # 0x18d7a70
mulsd 0x5c2c(%rip), %xmm0     # 0x10640
callq 0x11f0
movaps %xmm0, %xmm1
movsd -0x508(%rbp), %xmm0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x438(%rbp), %rax
movb %cl, 0x6(%rax)
movl -0x10(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x438(%rbp), %rax
movb %cl, 0x7(%rax)
movl $0x10, -0x20(%rbp)
jmp 0xaa92
movl $0x18, -0x20(%rbp)
jmp 0xaa92
movq -0x438(%rbp), %rax
movb $0x0, 0x6(%rax)
movq -0x438(%rbp), %rax
movb $0x3f, 0x7(%rax)
movl $0x20, -0x20(%rbp)
jmp 0xaa92
movl $0x0, -0x20(%rbp)
movq -0x438(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x438(%rbp)
movq -0x438(%rbp), %rdi
xorl %esi, %esi
movl $0x1f8, %edx            # imm = 0x1F8
callq 0x10f0
movsd 0x15d1(%rip), %xmm0     # 0xc090
mulsd 0x56f9(%rip), %xmm0     # 0x101c0
movsd %xmm0, -0x4d0(%rbp)
cmpl $0x0, 0x5b4a(%rip)      # 0x10620
je 0xab08
movsd 0x15d0(%rip), %xmm0     # 0xc0b0
mulsd 0x56d8(%rip), %xmm0     # 0x101c0
movsd %xmm0, -0x4d8(%rbp)
movsd 0x15c0(%rip), %xmm0     # 0xc0b8
mulsd 0x56c8(%rip), %xmm0     # 0x101c8
movsd %xmm0, -0x4e8(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0xb3c0
cmpl $0x0, 0x18ccf86(%rip)   # 0x18d7aa8
je 0xac5a
cmpl $0x64, 0x5af5(%rip)     # 0x10624
je 0xac5a
movslq -0x4b8(%rbp), %rcx
leaq 0x17d0f0d(%rip), %rax   # 0x17dba50
movsd (%rax,%rcx,8), %xmm0
mulsd 0x5620(%rip), %xmm0     # 0x10170
movsd %xmm0, -0x4c0(%rbp)
movslq -0x4b8(%rbp), %rcx
leaq 0x184eeea(%rip), %rax   # 0x1859a50
movsd (%rax,%rcx,8), %xmm0
mulsd 0x55fd(%rip), %xmm0     # 0x10170
movsd %xmm0, -0x4c8(%rbp)
movsd -0x4c0(%rbp), %xmm0
movsd -0x4c0(%rbp), %xmm2
movsd -0x4c8(%rbp), %xmm1
mulsd -0x4c8(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x14f5(%rip), %xmm1     # 0xc0a0
mulsd %xmm1, %xmm0
movsd 0x14e1(%rip), %xmm1     # 0xc098
addsd %xmm1, %xmm0
movsd %xmm0, -0x4e0(%rbp)
movsd 0x56f5(%rip), %xmm0     # 0x102c0
mulsd -0x4c0(%rbp), %xmm0
movsd -0x4e0(%rbp), %xmm2
movslq -0x4ac(%rbp), %rcx
leaq 0x5a67(%rip), %rax      # 0x10650
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x14c2(%rip), %xmm1     # 0xc0c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x474(%rbp)
movsd 0x56ac(%rip), %xmm0     # 0x102c0
mulsd -0x4c8(%rbp), %xmm0
movsd -0x4e0(%rbp), %xmm2
movslq -0x4ac(%rbp), %rcx
leaq 0x5a1e(%rip), %rax      # 0x10650
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x1479(%rip), %xmm1     # 0xc0c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x478(%rbp)
jmp 0xadc1
cmpl $0x0, 0x59bf(%rip)      # 0x10620
je 0xad27
movslq -0x4ac(%rbp), %rcx
leaq 0x59db(%rip), %rax      # 0x10650
movsd (%rax,%rcx,8), %xmm0
movslq -0x4b0(%rbp), %rcx
leaq 0x17939c8(%rip), %rax   # 0x179e650
movsd (%rax,%rcx,8), %xmm1
movsd -0x4d0(%rbp), %xmm2
mulsd %xmm2, %xmm1
addsd %xmm0, %xmm1
movslq -0x4b4(%rbp), %rcx
leaq 0x17b19a5(%rip), %rax   # 0x17bc650
movsd (%rax,%rcx,8), %xmm0
movsd -0x4d8(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x13f8(%rip), %xmm1     # 0xc0c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x474(%rbp)
movslq -0x4ac(%rbp), %rcx
leaq 0xbbd96c(%rip), %rax    # 0xbc8650
movsd (%rax,%rcx,8), %xmm1
movslq -0x4b0(%rbp), %rcx
leaq 0x1775959(%rip), %rax   # 0x1780650
movsd (%rax,%rcx,8), %xmm0
movsd -0x4d0(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x13ac(%rip), %xmm1     # 0xc0c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x478(%rbp)
jmp 0xadbf
movslq -0x4ac(%rbp), %rcx
leaq 0x591b(%rip), %rax      # 0x10650
movsd (%rax,%rcx,8), %xmm1
movslq -0x4b0(%rbp), %rcx
leaq 0x1793908(%rip), %rax   # 0x179e650
movsd (%rax,%rcx,8), %xmm0
movsd -0x4d0(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x135b(%rip), %xmm1     # 0xc0c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x474(%rbp)
movslq -0x4ac(%rbp), %rcx
leaq 0xbbd8cf(%rip), %rax    # 0xbc8650
movsd (%rax,%rcx,8), %xmm1
movslq -0x4b0(%rbp), %rcx
leaq 0x17758bc(%rip), %rax   # 0x1780650
movsd (%rax,%rcx,8), %xmm0
movsd -0x4d0(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x130f(%rip), %xmm1     # 0xc0c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x478(%rbp)
jmp 0xadc1
cmpl $0x0, 0x18ccce0(%rip)   # 0x18d7aa8
je 0xaf00
cmpl $0x64, 0x584f(%rip)     # 0x10624
jne 0xaf00
movslq -0x4b8(%rbp), %rcx
leaq 0x17d0c67(%rip), %rax   # 0x17dba50
movsd (%rax,%rcx,8), %xmm0
mulsd 0x537a(%rip), %xmm0     # 0x10170
movsd %xmm0, -0x4c0(%rbp)
movslq -0x4b8(%rbp), %rcx
leaq 0x184ec44(%rip), %rax   # 0x1859a50
movsd (%rax,%rcx,8), %xmm0
mulsd 0x5357(%rip), %xmm0     # 0x10170
movsd %xmm0, -0x4c8(%rbp)
movsd -0x4c0(%rbp), %xmm0
movsd -0x4c0(%rbp), %xmm2
movsd -0x4c8(%rbp), %xmm1
mulsd -0x4c8(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x124f(%rip), %xmm1     # 0xc0a0
mulsd %xmm1, %xmm0
movsd 0x123b(%rip), %xmm1     # 0xc098
addsd %xmm1, %xmm0
movsd %xmm0, -0x4e0(%rbp)
movsd 0x544f(%rip), %xmm0     # 0x102c0
mulsd -0x4c0(%rbp), %xmm0
movsd -0x4e0(%rbp), %xmm2
movslq -0x4ac(%rbp), %rcx
leaq 0x57c1(%rip), %rax      # 0x10650
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x121c(%rip), %xmm1     # 0xc0c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x47c(%rbp)
movsd 0x5406(%rip), %xmm0     # 0x102c0
mulsd -0x4c8(%rbp), %xmm0
movsd -0x4e0(%rbp), %xmm2
movslq -0x4ac(%rbp), %rcx
leaq 0x5778(%rip), %rax      # 0x10650
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x11d3(%rip), %xmm1     # 0xc0c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x480(%rbp)
jmp 0xafc8
cmpl $0x0, 0x5719(%rip)      # 0x10620
je 0xaf7c
movslq -0x4ac(%rbp), %rcx
movsd 0x11a8(%rip), %xmm0     # 0xc0c0
leaq 0x5731(%rip), %rax      # 0x10650
mulsd (%rax,%rcx,8), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x47c(%rbp)
movslq -0x4ac(%rbp), %rcx
leaq 0xbbd714(%rip), %rax    # 0xbc8650
movsd (%rax,%rcx,8), %xmm1
movslq -0x4b4(%rbp), %rcx
leaq 0x17b1701(%rip), %rax   # 0x17bc650
movsd (%rax,%rcx,8), %xmm0
movsd -0x4e8(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd 0x1154(%rip), %xmm1     # 0xc0c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x480(%rbp)
jmp 0xafc6
movslq -0x4ac(%rbp), %rcx
movsd 0x1135(%rip), %xmm0     # 0xc0c0
leaq 0x56be(%rip), %rax      # 0x10650
mulsd (%rax,%rcx,8), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x47c(%rbp)
movslq -0x4ac(%rbp), %rcx
movsd 0x1110(%rip), %xmm0     # 0xc0c0
leaq 0xbbd699(%rip), %rax    # 0xbc8650
mulsd (%rax,%rcx,8), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x480(%rbp)
jmp 0xafc8
cmpl $0x3ee, 0x5652(%rip)    # imm = 0x3EE
jne 0xb038
movslq -0x4b8(%rbp), %rcx
movsd 0x2015(%rip), %xmm0     # 0xcff8
leaq 0x17d0a66(%rip), %rax   # 0x17dba50
mulsd (%rax,%rcx,8), %xmm0
movsd 0x10c9(%rip), %xmm1     # 0xc0c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x484(%rbp)
movslq -0x4b8(%rbp), %rcx
movsd 0x1fe4(%rip), %xmm0     # 0xcff8
leaq 0x184ea35(%rip), %rax   # 0x1859a50
mulsd (%rax,%rcx,8), %xmm0
movsd 0x1098(%rip), %xmm1     # 0xc0c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x488(%rbp)
jmp 0xb09a
movslq -0x4b8(%rbp), %rcx
movsd 0x1fa9(%rip), %xmm0     # 0xcff0
leaq 0x17d0a02(%rip), %rax   # 0x17dba50
mulsd (%rax,%rcx,8), %xmm0
movsd 0x1065(%rip), %xmm1     # 0xc0c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x484(%rbp)
movslq -0x4b8(%rbp), %rcx
movsd 0x1f78(%rip), %xmm0     # 0xcff0
leaq 0x184e9d1(%rip), %rax   # 0x1859a50
mulsd (%rax,%rcx,8), %xmm0
movsd 0x1034(%rip), %xmm1     # 0xc0c0
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x488(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x50e6(%rip), %eax      # 0x10190
jge 0xb2f4
movl $0x0, -0x48c(%rbp)
movl $0x0, -0x490(%rbp)
movslq -0x14(%rbp), %rcx
leaq 0x51d1(%rip), %rax      # 0x102a0
movl (%rax,%rcx,4), %eax
movl %eax, -0x50c(%rbp)
testl %eax, %eax
je 0xb0eb
jmp 0xb0de
movl -0x50c(%rbp), %eax
subl $0x1, %eax
je 0xb105
jmp 0xb11f
movl -0x474(%rbp), %eax
movl %eax, -0x48c(%rbp)
movl -0x478(%rbp), %eax
movl %eax, -0x490(%rbp)
jmp 0xb133
movl -0x47c(%rbp), %eax
movl %eax, -0x48c(%rbp)
movl -0x480(%rbp), %eax
movl %eax, -0x490(%rbp)
jmp 0xb133
movl $0x0, -0x48c(%rbp)
movl $0x0, -0x490(%rbp)
cmpl $0x0, 0x54ea(%rip)      # 0x10624
je 0xb145
cmpl $0x6, 0x54e1(%rip)      # 0x10624
jne 0xb16c
cmpl $0x0, 0x18cc95c(%rip)   # 0x18d7aa8
je 0xb16c
cmpl $0x1, -0x14(%rbp)
jne 0xb16c
movl -0x484(%rbp), %eax
movl %eax, -0x48c(%rbp)
movl -0x488(%rbp), %eax
movl %eax, -0x490(%rbp)
cmpl $0x1, 0x54b1(%rip)      # 0x10624
je 0xb193
cmpl $0x2, 0x54a8(%rip)      # 0x10624
je 0xb193
cmpl $0x64, 0x549f(%rip)     # 0x10624
je 0xb193
cmpl $0x3ee, 0x5493(%rip)    # imm = 0x3EE
jne 0xb1ba
cmpl $0x0, 0x18cc90e(%rip)   # 0x18d7aa8
je 0xb1ba
cmpl $0x3, -0x14(%rbp)
jne 0xb1ba
movl -0x484(%rbp), %eax
movl %eax, -0x48c(%rbp)
movl -0x488(%rbp), %eax
movl %eax, -0x490(%rbp)
cmpl $0x4, 0x5463(%rip)      # 0x10624
je 0xb1d5
cmpl $0x5, 0x545a(%rip)      # 0x10624
je 0xb1d5
cmpl $0xa, 0x5451(%rip)      # 0x10624
jne 0xb1fc
cmpl $0x0, 0x18cc8cc(%rip)   # 0x18d7aa8
je 0xb1fc
cmpl $0x4, -0x14(%rbp)
jne 0xb1fc
movl -0x484(%rbp), %eax
movl %eax, -0x48c(%rbp)
movl -0x488(%rbp), %eax
movl %eax, -0x490(%rbp)
movl -0x48c(%rbp), %eax
sarl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x438(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x438(%rbp)
movb %cl, (%rax)
movl -0x48c(%rbp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x438(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x438(%rbp)
movb %cl, (%rax)
movl -0x48c(%rbp), %eax
sarl $0x0, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x438(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x438(%rbp)
movb %cl, (%rax)
movl -0x490(%rbp), %eax
sarl $0x10, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x438(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x438(%rbp)
movb %cl, (%rax)
movl -0x490(%rbp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x438(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x438(%rbp)
movb %cl, (%rax)
movl -0x490(%rbp), %eax
sarl $0x0, %eax
andl $0xff, %eax
movb %al, %cl
movq -0x438(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x438(%rbp)
movb %cl, (%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0xb0a1
movq -0x438(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x438(%rbp)
movl -0x4b8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4b8(%rbp)
cmpl $0xfc00, -0x4b8(%rbp)   # imm = 0xFC00
jl 0xb32b
movl $0x0, -0x4b8(%rbp)
movl -0x4ac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4ac(%rbp)
cmpl $0x177000, -0x4ac(%rbp) # imm = 0x177000
jl 0xb360
leaq -0x4f0(%rbp), %rdi
callq 0x10a0
movl $0xaec, %ecx            # imm = 0xAEC
cltd
idivl %ecx
movl %eax, -0x4ac(%rbp)
movl -0x4ec(%rbp), %eax
addl -0x4b0(%rbp), %eax
movl %eax, -0x4b0(%rbp)
cmpl $0x3c00, -0x4b0(%rbp)   # imm = 0x3C00
jl 0xb388
movl $0x0, -0x4b0(%rbp)
movl -0x4ec(%rbp), %eax
addl -0x4b4(%rbp), %eax
movl %eax, -0x4b4(%rbp)
cmpl $0x3e80, -0x4b4(%rbp)   # imm = 0x3E80
jl 0xb3b0
movl $0x0, -0x4b4(%rbp)
jmp 0xb3b2
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0xab0f
jmp 0xb3c2
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0xa89d
movq -0x4a8(%rbp), %rax
addq -0x498(%rbp), %rax
movq %rax, -0x498(%rbp)
cmpq $0x3b9aca00, -0x498(%rbp) # imm = 0x3B9ACA00
jl 0xb41a
movq -0x498(%rbp), %rax
subq $0x3b9aca00, %rax       # imm = 0x3B9ACA00
movq %rax, -0x498(%rbp)
movq -0x4a0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x4a0(%rbp)
jmp 0xb3e5
movl $0x1, %esi
leaq -0x4a0(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
movl %esi, %edi
callq 0x11e0
cmpl $-0x1, 0x4d30(%rip)     # 0x10168
jle 0xb47e
movl 0x4d28(%rip), %edi      # 0x10168
leaq -0x430(%rbp), %rsi
movl $0x408, %edx            # imm = 0x408
xorl %ecx, %ecx
leaq 0x18cc627(%rip), %r8    # 0x18d7a7c
movl $0x10, %r9d
callq 0x1100
cmpq $0x0, %rax
jge 0xb47c
movl -0x24(%rbp), %edx
movl $0x1, %edi
leaq 0x27b9(%rip), %rsi      # 0xdc2e
movb $0x0, %al
callq 0x1370
jmp 0xb4a4
movl 0x18cc5cc(%rip), %edi   # 0x18d7a50
leaq -0x430(%rbp), %rsi
movl $0x408, %edx            # imm = 0x408
xorl %ecx, %ecx
leaq 0x18cc5e3(%rip), %r8    # 0x18d7a7c
movl $0x10, %r9d
callq 0x1100
jmp 0xa7f0
movl $0x0, 0x18cc5a1(%rip)   # 0x18d7a54
xorl %eax, %eax
addq $0x510, %rsp            # imm = 0x510
popq %rbp
retq