// File: /workspace/github_c_makefile_star2_O2/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 $0x4a48, %rsp           # imm = 0x4A48
xorl %edi, %edi
callq 0x10a0
movq %rax, %r14
leaq 0xe94(%rip), %rdi       # 0x2082
leaq 0xe9a(%rip), %rsi       # 0x208f
callq 0x10b0
testq %rax, %rax
je 0x121f
movq %rax, %r15
leaq 0x540(%rsp), %rdi
pushq $0x1
popq %rsi
movl $0x500, %edx            # imm = 0x500
movq %rax, %rcx
callq 0x1050
testq %rax, %rax
jne 0x1224
callq 0x1030
movq %r15, %rdi
callq 0x1060
xorl %ebx, %ebx
leaq 0x540(%rsp), %r15
cmpq $0x500, %rbx            # imm = 0x500
je 0x1255
leaq (%rsp,%rbx), %rdi
addq $0x40, %rdi
movq %r15, %rsi
callq 0x1902
addq $0x20, %rbx
jmp 0x1236
movsd 0xdab(%rip), %xmm0      # 0x2008
movsd %xmm0, 0x30(%rsp)
movq $0x0, 0x8(%rsp)
cmpq $0x28, 0x8(%rsp)
je 0x13bc
movq 0x8(%rsp), %rax
shlq $0x5, %rax
testb $0x1, 0x58(%rsp,%rax)
jne 0x13b2
leaq (%rsp,%rax), %rbx
addq $0x40, %rbx
leaq 0x540(%rsp,%rax), %rax
movq %rax, 0x18(%rsp)
movl $0x2000, %edx           # imm = 0x2000
leaq 0xa40(%rsp), %rdi
xorl %esi, %esi
callq 0x1080
xorl %eax, %eax
movq %rax, 0x10(%rsp)
cmpq $0x40000, %rax          # imm = 0x40000
je 0x132e
movq 0x18(%rsp), %rdi
callq 0x1997
movq %rax, %r15
movq %rbx, %rdi
movl %r15d, %esi
callq 0x19dc
movl %eax, %r13d
leaq 0xa40(%rsp), %rbp
xorl %r12d, %r12d
cmpq $0x20, %r12
je 0x1324
movl %r15d, %esi
btcl %r12d, %esi
movq %rbx, %rdi
callq 0x19dc
xorl %r13d, %eax
xorl %ecx, %ecx
cmpq $0x20, %rcx
je 0x1318
btl %ecx, %eax
adcq $0x0, (%rbp,%rcx,8)
incq %rcx
jmp 0x1304
incq %r12
addq $0x100, %rbp            # imm = 0x100
jmp 0x12ea
movq 0x10(%rsp), %rax
incq %rax
jmp 0x12b7
xorpd %xmm0, %xmm0
leaq 0xa40(%rsp), %rax
xorl %ecx, %ecx
movsd 0xcd4(%rip), %xmm2      # 0x2018
movsd 0xcc4(%rip), %xmm3      # 0x2010
movq $-0x20000, %rdi         # imm = 0xFFFE0000
cmpq $0x20, %rcx
je 0x138d
xorl %edx, %edx
cmpq $0x20, %rdx
je 0x1382
movq (%rax,%rdx,8), %rsi
addq %rdi, %rsi
cvtsi2sd %rsi, %xmm1
mulsd %xmm3, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm0
incq %rdx
jmp 0x135b
incq %rcx
addq $0x100, %rax            # imm = 0x100
jmp 0x1353
ucomisd 0xca3(%rip), %xmm0      # 0x2038
jb 0x139d
sqrtsd %xmm0, %xmm0
jmp 0x13a2
callq 0x10c0
mulsd 0xc5e(%rip), %xmm0      # 0x2008
movsd %xmm0, (%rbx)
orb $0x1, 0x18(%rbx)
incq 0x8(%rsp)
jmp 0x126c
movq $0x0, 0x8(%rsp)
cmpq $0x28, 0x8(%rsp)
je 0x158c
movq 0x8(%rsp), %rax
shlq $0x5, %rax
testb $0x2, 0x58(%rsp,%rax)
jne 0x1582
leaq (%rsp,%rax), %r12
addq $0x40, %r12
movsd 0xc2b(%rip), %xmm0      # 0x2020
ucomisd (%r12), %xmm0
jbe 0x1582
movl $0x2000, %edx           # imm = 0x2000
leaq 0xa40(%rsp), %rdi
xorl %esi, %esi
callq 0x1080
movl $0x8000000, %eax        # imm = 0x8000000
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
cmpq $0x20, %r13
je 0x14fa
movl $0x2000, %edx           # imm = 0x2000
leaq 0x2a40(%rsp), %rdi
xorl %esi, %esi
callq 0x1080
movq %r13, 0x18(%rsp)
shlq $0x1b, %r13
cmpq 0x10(%rsp), %r13
je 0x14a6
movq %r12, %rdi
movl %r13d, %esi
callq 0x19dc
movl %eax, %r15d
leaq 0x2a40(%rsp), %rbp
xorl %ebx, %ebx
cmpq $0x20, %rbx
je 0x14a1
movl %r13d, %esi
btcl %ebx, %esi
movq %r12, %rdi
callq 0x19dc
xorl %r15d, %eax
xorl %ecx, %ecx
cmpq $0x20, %rcx
je 0x1495
btl %ecx, %eax
adcq $0x0, (%rbp,%rcx,8)
incq %rcx
jmp 0x1481
incq %rbx
addq $0x100, %rbp            # imm = 0x100
jmp 0x1468
incq %r13
jmp 0x1449
leaq 0x2a40(%rsp), %rax
leaq 0xa40(%rsp), %rcx
xorl %edx, %edx
movl $0x100, %r8d            # imm = 0x100
movq 0x18(%rsp), %r13
cmpq $0x20, %rdx
je 0x14e9
xorl %esi, %esi
cmpq $0x20, %rsi
je 0x14de
movq (%rax,%rsi,8), %rdi
addq %rdi, (%rcx,%rsi,8)
incq %rsi
jmp 0x14cb
incq %rdx
addq %r8, %rcx
addq %r8, %rax
jmp 0x14c3
incq %r13
addq $0x8000000, 0x10(%rsp)  # imm = 0x8000000
jmp 0x1422
xorpd %xmm0, %xmm0
leaq 0xa40(%rsp), %rax
xorl %ecx, %ecx
movsd 0xb18(%rip), %xmm2      # 0x2028
movsd 0xb00(%rip), %xmm3      # 0x2018
movq $-0x80000000, %rdi      # imm = 0x80000000
cmpq $0x20, %rcx
je 0x1559
xorl %edx, %edx
cmpq $0x20, %rdx
je 0x154e
movq (%rax,%rdx,8), %rsi
addq %rdi, %rsi
cvtsi2sd %rsi, %xmm1
mulsd %xmm2, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm1, %xmm0
incq %rdx
jmp 0x1527
incq %rcx
addq $0x100, %rax            # imm = 0x100
jmp 0x151f
ucomisd 0xad7(%rip), %xmm0      # 0x2038
jb 0x1569
sqrtsd %xmm0, %xmm0
jmp 0x156e
callq 0x10c0
mulsd 0xa92(%rip), %xmm0      # 0x2008
movsd %xmm0, (%r12)
orb $0x2, 0x18(%r12)
incq 0x8(%rsp)
jmp 0x13c5
leaq 0x40(%rsp), %rdi
pushq $0x28
popq %rsi
pushq $0x20
popq %rdx
leaq 0x3dd(%rip), %rcx       # 0x197b
callq 0x1040
pushq $0x18
popq %r15
cmpq $0x518, %r15            # imm = 0x518
je 0x1621
testb $0x4, 0x40(%rsp,%r15)
jne 0x161b
movsd 0xa70(%rip), %xmm0      # 0x2030
ucomisd 0x28(%rsp,%r15), %xmm0
jbe 0x161b
movq 0x2a10(%rip), %rax      # 0x3fe0
movq (%rax), %rdi
movswl 0x30(%rsp,%r15), %edx
movl 0x38(%rsp,%r15), %ecx
movl 0x3c(%rsp,%r15), %r9d
movswl 0x32(%rsp,%r15), %r8d
movswl 0x34(%rsp,%r15), %eax
movl %eax, (%rsp)
leaq 0xa99(%rip), %rsi       # 0x2092
xorl %eax, %eax
callq 0x1090
movsd 0x28(%rsp,%r15), %xmm0
leaq 0xa6a(%rip), %rdi       # 0x2078
movb $0x1, %al
callq 0x1070
orb $0x4, 0x40(%rsp,%r15)
addq $0x20, %r15
jmp 0x15a7
xorl %edi, %edi
callq 0x10a0
movq %rax, %r15
movsd 0x40(%rsp), %xmm0
movsd 0x30(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1642
movq %r15, %r14
jmp 0x1681
movq %r15, %rax
subq %r14, %rax
cmpq $0x1519, %rax           # imm = 0x1519
jl 0x1687
xorl %ebx, %ebx
cmpq $0x500, %rbx            # imm = 0x500
je 0x1676
leaq (%rsp,%rbx), %rdi
addq $0x40, %rdi
leaq 0x540(%rsp), %rsi
callq 0x1902
addq $0x20, %rbx
jmp 0x1652
movq %r15, %r14
movsd 0x987(%rip), %xmm0      # 0x2008
movsd %xmm0, 0x30(%rsp)
pushq $0x34
popq %rax
movq %rax, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
pushq $0x1
popq %rax
movq %rax, 0x28(%rsp)
pushq $0xa
popq %rax
movl %eax, %r12d
cmpl $0x27, %r12d
jg 0x1782
cmpq $0xa, 0x8(%rsp)
jae 0x1782
movq 0x8(%rsp), %rax
shlq $0x5, %rax
addq %rsp, %rax
addq $0x40, %rax
movq %rax, 0x18(%rsp)
movslq %r12d, %r12
movq %r12, %rbp
shlq $0x5, %rbp
orq $0x18, %rbp
leaq 0x40(%rsp), %r13
movq 0x28(%rsp), %r15
leaq 0x540(%rsp), %rbx
cmpq $0x27, %r12
jg 0x176d
cmpq $0x9, %r15
ja 0x176d
movq %rbx, %rdi
callq 0x1997
movq 0x18(%rsp), %rcx
movapd (%rcx), %xmm0
movapd 0x10(%rcx), %xmm1
movapd %xmm0, -0x18(%r13,%rbp)
movapd %xmm1, -0x8(%r13,%rbp)
testb $0x2, %al
jne 0x1740
movq 0x10(%rsp), %rcx
movl -0x4(%r13,%rcx), %eax
movl %eax, -0x8(%r13,%rbp)
movzwl -0xa(%r13,%rcx), %eax
movw %ax, -0xe(%r13,%rbp)
movq 0x10(%rsp), %rcx
movl (%r13,%rcx), %eax
movl %eax, -0x4(%r13,%rbp)
movzwl -0x8(%r13,%rcx), %eax
movw %ax, -0xc(%r13,%rbp)
andl $0x0, (%r13,%rbp)
incq %r15
addq $0x20, %r13
incq %r12
jmp 0x16f1
incq 0x8(%rsp)
incq 0x28(%rsp)
addq $0x20, 0x10(%rsp)
jmp 0x16a6
pushq $0x27
popq %rax
movq %rax, 0x18(%rsp)
leaq 0x68(%rsp), %rax
movq %rax, 0x8(%rsp)
xorl %eax, %eax
cmpq $0x28, %rax
je 0x1263
leaq 0x1(%rax), %rcx
movq %rcx, 0x28(%rsp)
shlq $0x5, %rax
addq %rsp, %rax
addq $0x40, %rax
movq 0x18(%rsp), %r15
movq 0x8(%rsp), %r12
subq $0x1, %r15
jb 0x18ed
movzwl 0x8(%rax), %r13d
cmpw (%r12), %r13w
jne 0x18e4
movzwl 0xa(%rax), %ebp
cmpw 0x2(%r12), %bp
jne 0x18e4
movzwl 0xc(%rax), %ecx
cmpw 0x4(%r12), %cx
jne 0x18e4
movl 0x10(%rax), %ebx
cmpl 0x8(%r12), %ebx
jne 0x18e4
movl 0x14(%rax), %edx
movq %rdx, 0x10(%rsp)
cmpl 0xc(%r12), %edx
jne 0x18e4
movw %cx, 0x26(%rsp)
movq %rax, 0x38(%rsp)
leaq 0x540(%rsp), %rdi
callq 0x1997
movq %rax, %rcx
xorl %edx, %edx
pushq $0x5
popq %rsi
divq %rsi
shrq $0x3, %rcx
leaq 0x7fa(%rip), %rsi       # 0x2040
movslq (%rsi,%rdx,4), %rax
addq %rsi, %rax
jmpq *%rax
movq %rcx, %rax
xorl %edx, %edx
pushq $0x6
popq %rcx
divq %rcx
movl %edx, %eax
leaq 0x7fd(%rip), %rcx       # 0x2060
addw (%rcx,%rax,4), %r13w
movw %r13w, (%r12)
jmp 0x18d9
movzwl %cx, %eax
movq 0x10(%rsp), %rcx
addl %ecx, %eax
addl $0xffff8000, %eax       # imm = 0xFFFF8000
movl %eax, 0xc(%r12)
jmp 0x18d9
movq %rcx, %rax
xorl %edx, %edx
pushq $0x6
popq %rcx
divq %rcx
movl %edx, %eax
leaq 0x7c7(%rip), %rcx       # 0x2060
movzwl 0x26(%rsp), %edx
addw (%rcx,%rax,4), %dx
movw %dx, 0x4(%r12)
jmp 0x18d9
movzwl %cx, %eax
addl %ebx, %eax
addl $0xffff8000, %eax       # imm = 0xFFFF8000
movl %eax, 0x8(%r12)
jmp 0x18d9
movq %rcx, %rax
xorl %edx, %edx
pushq $0x6
popq %rcx
divq %rcx
movl %edx, %eax
leaq 0x791(%rip), %rcx       # 0x2060
addw (%rcx,%rax,4), %bp
movw %bp, 0x2(%r12)
andl $0x0, 0x10(%r12)
movq 0x38(%rsp), %rax
addq $0x20, %r12
jmp 0x17be
addq $0x20, 0x8(%rsp)
decq 0x18(%rsp)
movq 0x28(%rsp), %rax
jmp 0x1796