// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa50, %rsp            # imm = 0xA50
movl $0x0, -0x4(%rbp)
movl $0x1, -0x8(%rbp)
movsd 0x1e17(%rip), %xmm0     # 0x3008
movsd %xmm0, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x10a0
movq %rax, -0x18(%rbp)
leaq -0x520(%rbp), %rdi
movl $0x500, %esi            # imm = 0x500
callq 0x16a0
movl $0x0, -0xa24(%rbp)
cmpl $0x28, -0xa24(%rbp)
jge 0x1259
leaq -0xa20(%rbp), %rdi
movslq -0xa24(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
leaq -0x520(%rbp), %rsi
callq 0x1710
movl -0xa24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa24(%rbp)
jmp 0x121e
jmp 0x125b
movl $0x0, -0xa28(%rbp)
cmpl $0x28, -0xa28(%rbp)
jge 0x130e
movslq -0xa28(%rbp), %rcx
leaq -0xa20(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x12f8
leaq -0xa20(%rbp), %rdi
movslq -0xa28(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
movslq -0xa28(%rbp), %rax
leaq -0x520(%rbp), %rsi
shlq $0x5, %rax
addq %rax, %rsi
callq 0x17e0
movslq -0xa28(%rbp), %rcx
leaq -0xa20(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movslq -0xa28(%rbp), %rcx
leaq -0xa20(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
orl $0x1, %ecx
movl %ecx, 0x18(%rax)
jmp 0x12fa
movl -0xa28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa28(%rbp)
jmp 0x1265
movl $0x0, -0xa2c(%rbp)
cmpl $0x28, -0xa2c(%rbp)
jge 0x13cf
movslq -0xa2c(%rbp), %rcx
leaq -0xa20(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x13b9
movslq -0xa2c(%rbp), %rcx
leaq -0xa20(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x1cb6(%rip), %xmm0     # 0x3018
ucomisd (%rax), %xmm0
jbe 0x13b9
leaq -0xa20(%rbp), %rdi
movslq -0xa2c(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
callq 0x1a50
movslq -0xa2c(%rbp), %rcx
leaq -0xa20(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movsd %xmm0, (%rax)
movslq -0xa2c(%rbp), %rcx
leaq -0xa20(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
orl $0x2, %ecx
movl %ecx, 0x18(%rax)
jmp 0x13bb
movl -0xa2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa2c(%rbp)
jmp 0x1318
leaq -0xa20(%rbp), %rdi
movl $0x28, %esi
movl $0x20, %edx
leaq 0x989(%rip), %rcx       # 0x1d70
callq 0x1040
cmpl $0x0, -0x8(%rbp)
je 0x14d5
movl $0x0, -0xa30(%rbp)
cmpl $0x28, -0xa30(%rbp)
jge 0x14d3
movslq -0xa30(%rbp), %rcx
leaq -0xa20(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x14bd
movslq -0xa30(%rbp), %rcx
leaq -0xa20(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movsd 0x1bc2(%rip), %xmm0     # 0x3010
ucomisd (%rax), %xmm0
jbe 0x14bd
leaq -0xa20(%rbp), %rdi
movslq -0xa30(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
movq 0x3b70(%rip), %rax      # 0x4fe0
movq (%rax), %rsi
callq 0x1de0
movslq -0xa30(%rbp), %rcx
leaq -0xa20(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movsd (%rax), %xmm0
leaq 0x1be0(%rip), %rdi      # 0x3078
movb $0x1, %al
callq 0x1070
movslq -0xa30(%rbp), %rcx
leaq -0xa20(%rbp), %rax
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x18(%rax), %ecx
orl $0x4, %ecx
movl %ecx, 0x18(%rax)
jmp 0x14bf
movl -0xa30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa30(%rbp)
jmp 0x1400
jmp 0x14d5
xorl %eax, %eax
movl %eax, %edi
callq 0x10a0
movq %rax, -0xa38(%rbp)
movsd -0xa20(%rbp), %xmm1
movsd -0x10(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1512
movsd -0xa20(%rbp), %xmm0
movsd %xmm0, -0x10(%rbp)
movq -0xa38(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x1586
movq -0xa38(%rbp), %rax
subq -0x18(%rbp), %rax
cmpq $0x1518, %rax           # imm = 0x1518
jle 0x1584
movsd 0x1adb(%rip), %xmm0     # 0x3008
movsd %xmm0, -0x10(%rbp)
movq -0xa38(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0xa3c(%rbp)
cmpl $0x28, -0xa3c(%rbp)
jge 0x1582
leaq -0xa20(%rbp), %rdi
movslq -0xa3c(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdi
leaq -0x520(%rbp), %rsi
callq 0x1710
movl -0xa3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa3c(%rbp)
jmp 0x1547
jmp 0x1584
jmp 0x1586
movl $0xa, -0xa40(%rbp)
movl $0x0, -0xa44(%rbp)
xorl %eax, %eax
cmpl $0x28, -0xa40(%rbp)
movb %al, -0xa49(%rbp)
jge 0x15bb
cmpl $0xa, -0xa44(%rbp)
setl %al
movb %al, -0xa49(%rbp)
movb -0xa49(%rbp), %al
testb $0x1, %al
jne 0x15ca
jmp 0x1687
movl -0xa44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa48(%rbp)
xorl %eax, %eax
cmpl $0x28, -0xa40(%rbp)
movb %al, -0xa4a(%rbp)
jge 0x15fa
cmpl $0xa, -0xa48(%rbp)
setl %al
movb %al, -0xa4a(%rbp)
movb -0xa4a(%rbp), %al
testb $0x1, %al
jne 0x1606
jmp 0x1671
leaq -0xa20(%rbp), %rdi
movl -0xa40(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xa40(%rbp)
cltq
shlq $0x5, %rax
addq %rax, %rdi
leaq -0xa20(%rbp), %rsi
movslq -0xa44(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
leaq -0xa20(%rbp), %rdx
movslq -0xa48(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rdx
leaq -0x520(%rbp), %rcx
callq 0x1e40
movl -0xa48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa48(%rbp)
jmp 0x15d9
jmp 0x1673
movl -0xa44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa44(%rbp)
jmp 0x159a
leaq -0xa20(%rbp), %rdi
leaq -0x520(%rbp), %rsi
callq 0x1ef0
jmp 0x125b
nop