// File: /workspace/github_c_makefile_star2_O1/skeeto[P]hash-prospector/genetic.c
// Function: main
int
main(void)
{
    int verbose = 1;
    double best = 1000.0;
    time_t best_time = time(0);
    uint64_t rng[POOL][4];
    struct gene pool[POOL];

    rng_init(rng, sizeof(rng));
    for (int i = 0; i < POOL; i++)
        gene_gen(pool + i, rng[0]);

    for (;;) {
        #pragma omp parallel for schedule(dynamic)
        for (int i = 0; i < POOL; i++) {
            if (!(pool[i].flags & FLAG_SCORED)) {
                pool[i].score = estimate_bias32(pool + i, rng[i]);
                pool[i].flags |= FLAG_SCORED;
            }
        }
        for (int i = 0; i < POOL; i++) {
            if (!(pool[i].flags & FLAG_EXACT) && pool[i].score < THRESHOLD) {
                pool[i].score = exact_bias32(pool + i);
                pool[i].flags |= FLAG_EXACT;
            }
        }

        qsort(pool, POOL, sizeof(*pool), cmp);
        if (verbose) {
            for (int i = 0; i < POOL; i++) {
                if (!(pool[i].flags & FLAG_PRINTED) &&
                      pool[i].score < DONTCARE) {
                    gene_print(pool + i, stdout);
                    printf(" = %.17g\n", pool[i].score);
                    pool[i].flags |= FLAG_PRINTED;
                }
            }
        }

        time_t now = time(0);
        if (pool[0].score < best) {
            best = pool[0].score;
            best_time = now;
        } else if (now - best_time > RESETMINS * 60) {
            best = 1000.0;
            best_time = now;
            for (int i = 0; i < POOL; i++)
                gene_gen(pool + i, rng[0]);
        }

        int c = POOL / 4;
        for (int a = 0; c < POOL && a < POOL / 4; a++)
            for (int b = a + 1; c < POOL && b < POOL / 4; b++)
                gene_cross(pool + c++, pool + a, pool + b, rng[0]);
        undup(pool, rng[0]);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4a38, %rsp           # imm = 0x4A38
xorl %edi, %edi
callq 0x10a0
movq %rax, %rbx
leaq 0xe94(%rip), %rdi       # 0x2082
leaq 0xe9a(%rip), %rsi       # 0x208f
callq 0x10b0
testq %rax, %rax
je 0x1221
movq %rax, %r14
leaq 0x530(%rsp), %rdi
movl $0x1, %esi
movl $0x500, %edx            # imm = 0x500
movq %rax, %rcx
callq 0x1050
testq %rax, %rax
jne 0x1226
callq 0x1030
movq %r14, %rdi
callq 0x1060
xorl %r15d, %r15d
leaq 0x530(%rsp), %r14
leaq (%rsp,%r15), %rdi
addq $0x30, %rdi
movq %r14, %rsi
callq 0x1a53
addq $0x20, %r15
cmpq $0x500, %r15            # imm = 0x500
jne 0x1239
movsd 0xdaa(%rip), %xmm0      # 0x2008
movsd %xmm0, 0x28(%rsp)
movq $0x0, 0x8(%rsp)
movq 0x8(%rsp), %rax
shlq $0x5, %rax
testb $0x1, 0x48(%rsp,%rax)
jne 0x13f7
leaq (%rsp,%rax), %r14
addq $0x30, %r14
leaq 0x530(%rsp,%rax), %rax
movq %rax, 0x18(%rsp)
movl $0x2000, %edx           # imm = 0x2000
leaq 0xa30(%rsp), %rdi
xorl %esi, %esi
callq 0x1080
movzwl 0x8(%r14), %ebp
movl 0x10(%r14), %r15d
movl 0x14(%r14), %r12d
movzwl 0xa(%r14), %r13d
movq %r14, 0x20(%rsp)
movzwl 0xc(%r14), %r14d
movq $0x0, 0x10(%rsp)
movq 0x18(%rsp), %rdi
callq 0x1b16
movl %eax, %esi
movl %ebp, %ecx
shrl %cl, %esi
xorl %eax, %esi
imull %r15d, %esi
movl %esi, %edx
movl %r13d, %ecx
shrl %cl, %edx
xorl %esi, %edx
imull %r12d, %edx
leaq 0xa30(%rsp), %rsi
xorl %edi, %edi
movl %eax, %r8d
btcl %edi, %r8d
movl %r8d, %r9d
movl %ebp, %ecx
shrl %cl, %r9d
xorl %r8d, %r9d
imull %r15d, %r9d
movl %r9d, %r10d
movl %r13d, %ecx
shrl %cl, %r10d
xorl %r9d, %r10d
imull %r12d, %r10d
xorl %edx, %r10d
movl %r10d, %r8d
movl %r14d, %ecx
shrl %cl, %r8d
xorl %r10d, %r8d
xorl %ecx, %ecx
btl %ecx, %r8d
adcq $0x0, (%rsi,%rcx,8)
incq %rcx
cmpq $0x20, %rcx
jne 0x1333
incq %rdi
addq $0x100, %rsi            # imm = 0x100
cmpq $0x20, %rdi
jne 0x12fc
movq 0x10(%rsp), %rcx
incq %rcx
movq %rcx, 0x10(%rsp)
cmpq $0x40000, %rcx          # imm = 0x40000
jne 0x12cf
xorpd %xmm0, %xmm0
leaq 0xa30(%rsp), %rax
xorl %ecx, %ecx
movq $-0x20000, %rdi         # imm = 0xFFFE0000
movsd 0xc84(%rip), %xmm2      # 0x2010
movsd 0xc84(%rip), %xmm3      # 0x2018
xorl %edx, %edx
movq (%rax,%rdx,8), %rsi
addq %rdi, %rsi
xorps %xmm1, %xmm1
cvtsi2sd %rsi, %xmm1
mulsd %xmm2, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm1, %xmm0
incq %rdx
cmpq $0x20, %rdx
jne 0x1396
incq %rcx
addq $0x100, %rax            # imm = 0x100
cmpq $0x20, %rcx
jne 0x1394
ucomisd 0xc63(%rip), %xmm0      # 0x2038
jb 0x13dd
sqrtsd %xmm0, %xmm0
jmp 0x13e2
callq 0x10c0
mulsd 0xc1e(%rip), %xmm0      # 0x2008
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
orb $0x1, 0x18(%rax)
movq 0x8(%rsp), %rcx
incq %rcx
movq %rcx, 0x8(%rsp)
cmpq $0x28, %rcx
jne 0x126d
movq $0x0, 0x8(%rsp)
movq 0x8(%rsp), %r13
shlq $0x5, %r13
testb $0x2, 0x48(%rsp,%r13)
jne 0x1616
leaq (%rsp,%r13), %rax
addq $0x30, %rax
movsd 0xbe4(%rip), %xmm0      # 0x2020
movq %rax, 0x20(%rsp)
ucomisd (%rax), %xmm0
jbe 0x1616
movl $0x2000, %edx           # imm = 0x2000
leaq 0xa30(%rsp), %rdi
xorl %esi, %esi
callq 0x1080
movzwl 0x38(%rsp,%r13), %r12d
movl 0x40(%rsp,%r13), %r14d
movl 0x44(%rsp,%r13), %r15d
movzwl 0x3a(%rsp,%r13), %ebp
movzwl 0x3c(%rsp,%r13), %r13d
movl $0x8000000, %eax        # imm = 0x8000000
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
leaq 0x2a30(%rsp), %rdi
movl $0x2000, %edx           # imm = 0x2000
xorl %esi, %esi
callq 0x1080
leaq 0x2a30(%rsp), %rdi
movq 0x18(%rsp), %rax
shlq $0x1b, %rax
movl %eax, %esi
movl %r12d, %ecx
shrl %cl, %esi
xorl %eax, %esi
imull %r14d, %esi
movl %esi, %edx
movl %ebp, %ecx
shrl %cl, %edx
xorl %esi, %edx
imull %r15d, %edx
movq %rdi, %rsi
xorl %r11d, %r11d
movl %eax, %r8d
btcl %r11d, %r8d
movl %r8d, %r9d
movl %r12d, %ecx
shrl %cl, %r9d
xorl %r8d, %r9d
imull %r14d, %r9d
movl %r9d, %r10d
movl %ebp, %ecx
shrl %cl, %r10d
xorl %r9d, %r10d
imull %r15d, %r10d
xorl %edx, %r10d
movl %r10d, %r8d
movl %r13d, %ecx
shrl %cl, %r8d
xorl %r10d, %r8d
xorl %ecx, %ecx
btl %ecx, %r8d
adcq $0x0, (%rsi,%rcx,8)
incq %rcx
cmpq $0x20, %rcx
jne 0x1509
incq %r11
addq $0x100, %rsi            # imm = 0x100
cmpq $0x20, %r11
jne 0x14d2
incq %rax
cmpq 0x10(%rsp), %rax
jne 0x14b3
movq %rdi, %rax
leaq 0xa30(%rsp), %rcx
xorl %edx, %edx
movl $0x100, %r9d            # imm = 0x100
movq 0x18(%rsp), %r10
xorl %esi, %esi
movq (%rax,%rsi,8), %r8
addq %r8, (%rcx,%rsi,8)
incq %rsi
cmpq $0x20, %rsi
jne 0x1553
incq %rdx
addq %r9, %rcx
addq %r9, %rax
cmpq $0x20, %rdx
jne 0x1551
incq %r10
movq %r10, 0x18(%rsp)
addq $0x8000000, 0x10(%rsp)  # imm = 0x8000000
cmpq $0x20, %r10
jne 0x1496
xorpd %xmm0, %xmm0
leaq 0xa30(%rsp), %rax
xorl %ecx, %ecx
movsd 0xa74(%rip), %xmm2      # 0x2018
movq $-0x80000000, %rdi      # imm = 0x80000000
movsd 0xa75(%rip), %xmm3      # 0x2028
xorl %edx, %edx
movq (%rax,%rdx,8), %rsi
addq %rdi, %rsi
xorps %xmm1, %xmm1
cvtsi2sd %rsi, %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm0
incq %rdx
cmpq $0x20, %rdx
jne 0x15b5
incq %rcx
addq $0x100, %rax            # imm = 0x100
cmpq $0x20, %rcx
jne 0x15b3
ucomisd 0xa44(%rip), %xmm0      # 0x2038
jb 0x15fc
sqrtsd %xmm0, %xmm0
jmp 0x1601
callq 0x10c0
mulsd 0x9ff(%rip), %xmm0      # 0x2008
movq 0x20(%rsp), %rax
movsd %xmm0, (%rax)
orb $0x2, 0x18(%rax)
movq 0x8(%rsp), %rcx
incq %rcx
movq %rcx, 0x8(%rsp)
cmpq $0x28, %rcx
jne 0x1417
movl $0x28, %esi
movl $0x20, %edx
leaq 0x30(%rsp), %rdi
leaq 0x4b5(%rip), %rcx       # 0x1af8
callq 0x1040
movl $0x18, %r14d
testb $0x4, 0x30(%rsp,%r14)
jne 0x16b9
movsd 0x9d2(%rip), %xmm0      # 0x2030
ucomisd 0x18(%rsp,%r14), %xmm0
jbe 0x16b9
movq 0x2972(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
movswl 0x20(%rsp,%r14), %edx
movl 0x28(%rsp,%r14), %ecx
movl 0x2c(%rsp,%r14), %r9d
movswl 0x22(%rsp,%r14), %r8d
movswl 0x24(%rsp,%r14), %eax
movl %eax, (%rsp)
leaq 0x9fb(%rip), %rsi       # 0x2092
xorl %eax, %eax
callq 0x1090
movsd 0x18(%rsp,%r14), %xmm0
leaq 0x9cc(%rip), %rdi       # 0x2078
movb $0x1, %al
callq 0x1070
orb $0x4, 0x30(%rsp,%r14)
addq $0x20, %r14
cmpq $0x518, %r14            # imm = 0x518
jne 0x164e
xorl %edi, %edi
callq 0x10a0
movq %rax, %r14
movsd 0x30(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x16e7
movq %r14, %rbx
jmp 0x1724
movq %r14, %rax
subq %rbx, %rax
cmpq $0x1519, %rax           # imm = 0x1519
jl 0x172a
xorl %ebx, %ebx
leaq (%rsp,%rbx), %rdi
addq $0x30, %rdi
leaq 0x530(%rsp), %rsi
callq 0x1a53
addq $0x20, %rbx
cmpq $0x500, %rbx            # imm = 0x500
jne 0x16f7
movq %r14, %rbx
movsd 0x8e4(%rip), %xmm0      # 0x2008
movsd %xmm0, 0x28(%rsp)
movq 0x530(%rsp), %rsi
movq 0x538(%rsp), %r8
movq 0x540(%rsp), %rdi
movl $0xa, %r10d
movl $0x1, %eax
movl $0x34, %ecx
movq 0x548(%rsp), %r9
xorl %edx, %edx
cmpq $0x8, %rdx
ja 0x181e
movq %rdx, %r11
shlq $0x5, %r11
addq %rsp, %r11
addq $0x30, %r11
movslq %r10d, %r13
movq %r13, %r14
shlq $0x5, %r14
orq $0x18, %r14
leaq 0x30(%rsp), %r15
movq %rax, %r12
leaq (%r8,%r8,4), %r10
movapd (%r11), %xmm0
movapd 0x10(%r11), %xmm1
movapd %xmm1, -0x8(%r15,%r14)
movapd %xmm0, -0x18(%r15,%r14)
btq $0x3a, %r10
jb 0x17c4
movl -0x4(%r15,%rcx), %r10d
movl %r10d, -0x8(%r15,%r14)
movzwl -0xa(%r15,%rcx), %r10d
movw %r10w, -0xe(%r15,%r14)
movq %r8, %r10
shlq $0x11, %r10
xorq %rsi, %rdi
xorq %r8, %r9
xorq %rdi, %r8
xorq %r9, %rsi
rolq $0x2d, %r9
xorq %r10, %rdi
movl (%r15,%rcx), %r10d
movl %r10d, -0x4(%r15,%r14)
movzwl -0x8(%r15,%rcx), %r10d
movw %r10w, -0xc(%r15,%r14)
movl $0x0, (%r15,%r14)
leaq 0x1(%r13), %r10
cmpq $0x26, %r13
jg 0x181e
leaq 0x1(%r12), %rbp
addq $0x20, %r15
movq %r10, %r13
cmpq $0x9, %r12
movq %rbp, %r12
jb 0x178a
cmpl $0x27, %r10d
jg 0x183c
leaq 0x1(%rdx), %r11
incq %rax
addq $0x20, %rcx
cmpq $0x9, %rdx
movq %r11, %rdx
jb 0x175c
movq %r8, 0x538(%rsp)
movq %rdi, 0x540(%rsp)
movq %r9, 0x548(%rsp)
movq %rsi, 0x530(%rsp)
movl $0x27, %eax
movq %rax, 0x18(%rsp)
leaq 0x58(%rsp), %rax
movq %rax, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
cmpq $0x26, 0x10(%rsp)
ja 0x1a0c
movq 0x10(%rsp), %rax
shlq $0x5, %rax
leaq (%rsp,%rax), %r12
addq $0x30, %r12
movq 0x8(%rsp), %r13
movq 0x18(%rsp), %rbp
movzwl (%r13), %r15d
cmpw %r15w, 0x8(%r12)
jne 0x19ff
movzwl 0x2(%r13), %r10d
cmpw %r10w, 0xa(%r12)
jne 0x19ff
movzwl 0x4(%r13), %r11d
cmpw %r11w, 0xc(%r12)
jne 0x19ff
movl 0x8(%r13), %r14d
cmpl %r14d, 0x10(%r12)
jne 0x19ff
movl 0xc(%r13), %eax
movq %rax, 0x20(%rsp)
cmpl %eax, 0x14(%r12)
jne 0x19ff
leaq (%r8,%r8,4), %rax
rolq $0x7, %rax
leaq (%rax,%rax,8), %rcx
movq %rcx, %rax
movabsq $-0x3333333333333333, %rdx # imm = 0xCCCCCCCCCCCCCCCD
mulq %rdx
shrq $0x2, %rdx
leaq (%rdx,%rdx,4), %rax
movq %rcx, %rdx
subq %rax, %rdx
shrq $0x3, %rcx
leaq 0x715(%rip), %rax       # 0x2040
movslq (%rax,%rdx,4), %rax
leaq 0x70a(%rip), %rdx       # 0x2040
addq %rdx, %rax
jmpq *%rax
movq %rcx, %rax
movabsq $0x2aaaaaaaaaaaaaab, %rdx # imm = 0x2AAAAAAAAAAAAAAB
mulq %rdx
addl %edx, %edx
leal (%rdx,%rdx,2), %eax
subl %eax, %ecx
leaq 0x707(%rip), %rax       # 0x2060
addw (%rax,%rcx,4), %r15w
movw %r15w, (%r13)
jmp 0x19dd
movzwl %cx, %eax
movq 0x20(%rsp), %rcx
addl %ecx, %eax
addl $0xffff8000, %eax       # imm = 0xFFFF8000
movl %eax, 0xc(%r13)
jmp 0x19dd
movq %rcx, %rax
movabsq $0x2aaaaaaaaaaaaaab, %rdx # imm = 0x2AAAAAAAAAAAAAAB
mulq %rdx
addl %edx, %edx
leal (%rdx,%rdx,2), %eax
subl %eax, %ecx
leaq 0x6c8(%rip), %rax       # 0x2060
addw (%rax,%rcx,4), %r11w
movw %r11w, 0x4(%r13)
jmp 0x19dd
movzwl %cx, %eax
addl %r14d, %eax
addl $0xffff8000, %eax       # imm = 0xFFFF8000
movl %eax, 0x8(%r13)
jmp 0x19dd
movq %rcx, %rax
movabsq $0x2aaaaaaaaaaaaaab, %rdx # imm = 0x2AAAAAAAAAAAAAAB
mulq %rdx
addl %edx, %edx
leal (%rdx,%rdx,2), %eax
subl %eax, %ecx
leaq 0x68d(%rip), %rax       # 0x2060
addw (%rax,%rcx,4), %r10w
movw %r10w, 0x2(%r13)
movq %r8, %rax
shlq $0x11, %rax
xorq %rsi, %rdi
xorq %r8, %r9
xorq %rdi, %r8
xorq %r9, %rsi
xorq %rax, %rdi
rolq $0x2d, %r9
movl $0x0, 0x10(%r13)
addq $0x20, %r13
decq %rbp
jne 0x18a0
movq 0x10(%rsp), %rcx
incq %rcx
decq 0x18(%rsp)
addq $0x20, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
cmpq $0x28, %rcx
jne 0x1879
movq %r8, 0x538(%rsp)
movq %rdi, 0x540(%rsp)
movq %r9, 0x548(%rsp)
movq %rsi, 0x530(%rsp)
jmp 0x1264