// File: /workspace/github_c_makefile_star2_O1/beejjorgensen[P]conquest/conqmc.c
// Function: move_bc
void move_bc(struct sttf *task, float slist[nstars + 1])
{
    int best_star, top_score, starnum, score, factors;
    struct stplanet *pplanet, *best_planet;

    if ((task->b > 0) || (task->c > 0)) {
        for (starnum = 1; starnum <= nstars; starnum++) {
            if (slist[starnum] > 0) {
                best_star = starnum;
                starnum = nstars + 1;
            };
        };
        best_planet = nil;
        top_score = -1000;
        for (starnum = 1; starnum <= nstars; starnum++) {
            if ((slist[starnum] > 0) || (starnum == task->dest)) {
                pplanet = stars[starnum].first_planet;
                while (pplanet != nil) {
                    score = eval_bc_col(pplanet);
                    if (starnum == task->dest)
                        score += 250;

                    if (tf_stars[starnum][ENEMY] > 0)
                        score -= 150;

                    if (score > top_score) {
                        top_score = score;
                        best_planet = pplanet;
                        best_star = starnum;
                    };
                    pplanet = pplanet->next;
                };
            };
        };
        if (best_star == task->dest) {  /*stay put */
            if (best_planet != nil) {
                if ((best_planet->team == ENEMY)
                    && (best_planet->conquered)
                    && (best_planet->iu < 20)) {
                    factors =
                        weapons[ENEMY] * ((task->c * c_guns) +
                                          (task->b * b_guns));
                    factors = MIN(factors, 4 * best_planet->inhabitants);
                    blast(best_planet, factors);
                    if ((tf_stars[best_planet->pstar][player] > 0) ||
                        (col_stars[best_planet->pstar][player] > 0))
                        best_planet->psee_capacity = best_planet->capacity;
                } else if ((best_planet->team == ENEMY) && (best_planet->conquered)) {  /*decide whether to split */
                    if ((((task->b > 3) || (task->c > 3)) && (rnd(4) == 4))
                        || (task->b > 8))
                        wander_bc(task, slist);
                };
            };
        } else {                /*move */
            tf_stars[task->dest][ENEMY]--;
            depart(task->dest);
            task->dest = best_star;
            task->eta = (int) ((slist[best_star] - 0.01) / vel[ENEMY]) + 1;
        };
    };
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r12
movq %rdi, %r13
cmpl $0x0, 0x1c(%rdi)
jg 0x57b7
cmpl $0x0, 0x18(%r13)
jle 0x596c
movl $0x1, %ecx
xorps %xmm0, %xmm0
movl $0x17, %eax
movl %ecx, %edx
movss (%r12,%rdx,4), %xmm1
ucomiss %xmm0, %xmm1
cmoval %ecx, %r14d
leal 0x1(%rcx), %edx
cmoval %eax, %edx
movl %edx, %ecx
cmpl $0x16, %edx
jl 0x57c4
movl $0xfffffc18, %edx       # imm = 0xFFFFFC18
movl $0x1, %ecx
xorl %ebp, %ebp
leaq 0x843d(%rip), %rsi      # 0xdc30
movq %r12, 0x10(%rsp)
movss (%r12,%rcx,4), %xmm0
ucomiss 0x382b(%rip), %xmm0     # 0x9030
ja 0x5810
movl 0x20(%r13), %eax
cmpq %rax, %rcx
jne 0x5873
leaq (%rcx,%rcx,2), %rax
leaq 0x9c85(%rip), %r8       # 0xf4a0
movq 0x8(%r8,%rax,8), %r12
testq %r12, %r12
je 0x5873
movl %edx, 0xc(%rsp)
movq %r12, %rdi
movq %rsi, %rbx
movq %rcx, %r15
callq 0x5165
movq %rbx, %rsi
movl 0x20(%r13), %ecx
leal 0xfa(%rax), %edx
cmpq %rcx, %r15
movq %r15, %rcx
cmovnel %eax, %edx
cmpl $0x0, (%rbx,%r15,8)
leal -0x96(%rdx), %eax
cmovlel %edx, %eax
movl 0xc(%rsp), %edx
cmpl %edx, %eax
cmovgl %ecx, %r14d
cmovgl %eax, %edx
cmovgq %r12, %rbp
movq 0x38(%r12), %r12
jmp 0x5820
incq %rcx
cmpq $0x16, %rcx
movq 0x10(%rsp), %r12
jne 0x57f8
movslq 0x20(%r13), %rax
cmpl %eax, %r14d
jne 0x5912
testq %rbp, %rbp
je 0x596c
movl 0xc(%rbp), %eax
testl %eax, %eax
jne 0x596c
cmpl $0x0, 0x20(%rbp)
je 0x597b
cmpl $0x13, 0x14(%rbp)
jg 0x597b
leaq 0x9e07(%rip), %rax      # 0xf6c8
movl 0x18(%r13), %ecx
movl 0x1c(%r13), %edx
movq %rsi, %rbx
leal (,%rcx,8), %esi
subl %ecx, %esi
leal (%rdx,%rdx,4), %ecx
leal (%rsi,%rcx,8), %ecx
imull (%rax), %ecx
movl 0x10(%rbp), %esi
shll $0x2, %esi
cmpl %esi, %ecx
cmovll %ecx, %esi
movq %rbp, %rdi
callq 0x3890
movslq 0x30(%rbp), %rax
cmpl $0x0, 0x4(%rbx,%rax,8)
jg 0x590a
leaq 0x83dd(%rip), %rcx      # 0xdce0
cmpl $0x0, 0x4(%rcx,%rax,8)
jle 0x596c
movl 0x4(%rbp), %eax
movl %eax, 0x8(%rbp)
jmp 0x596c
decl (%rsi,%rax,8)
movslq 0x20(%r13), %rax
leaq 0x83c0(%rip), %rcx      # 0xdce0
movl 0x4(%rcx,%rax,8), %ecx
addl 0x4(%rsi,%rax,8), %ecx
jle 0x5938
leaq 0x9ecf(%rip), %rcx      # 0xf800
movl $0x1, (%rcx,%rax,4)
movl %r14d, 0x20(%r13)
movslq %r14d, %rax
xorps %xmm0, %xmm0
cvtss2sd (%r12,%rax,4), %xmm0
addsd 0x3908(%rip), %xmm0     # 0x9258
leaq 0x9d61(%rip), %rax      # 0xf6b8
xorps %xmm1, %xmm1
cvtsi2sdl (%rax), %xmm1
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
incl %eax
movl %eax, 0x24(%r13)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %eax, %eax
jne 0x596c
cmpl $0x0, 0x20(%rbp)
je 0x596c
cmpl $0x3, 0x1c(%r13)
jg 0x5993
cmpl $0x4, 0x18(%r13)
jl 0x59a2
movl $0x4, %edi
callq 0x4fc5
cmpl $0x4, %eax
je 0x59a9
cmpl $0x9, 0x1c(%r13)
jl 0x596c
movq %r13, %rdi
movq %r12, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5036