// File: /workspace/github_c_makefile_star2_O1/beejjorgensen[P]conquest/conq1.c
// Function: EN2MY_attack
void EN2MY_attack(int starnum)
{
    int attack_factors, def_factors;
    float odds, best_score;
    struct stplanet *pplanet, *best_planet;
    int en_tf, i;
    boolean first[8];
    for (i = 1; i <= 7; i++)
        first[i] = true;
    en_tf = 1;
    while ((tf[ENEMY][en_tf].dest != starnum) ||
           (tf[ENEMY][en_tf].eta != 0))
        en_tf = en_tf + 1;
    do {
        attack_factors = tf[ENEMY][en_tf].c + 6 * tf[ENEMY][en_tf].b;
        best_planet = nil;
        best_score = 1000;
        pplanet = stars[starnum].first_planet;
        while (pplanet != nil) {
            if (pplanet->team == player) {
                def_factors = pplanet->esee_def;
                odds = (float) def_factors / attack_factors;
                if (pplanet->capacity > 30)
                    odds = (odds - 2) * pplanet->capacity;
                else
                    odds = (odds - 1.5) * pplanet->capacity;
                if (odds < best_score) {
                    best_score = odds;
                    best_planet = pplanet;
                };
            };
            pplanet = pplanet->next;
        };
        if (best_score < 0) {
            cle3r_left();
            point(1, 19);
            printw("Enemy attacks: %c%d", starnum + 'A' - 1,
                   best_planet->number);
            point(50, 1);
            pr5nt_star(starnum);
            clear_field();
            pause();
            fire_salvo(ENEMY, &tf[ENEMY][en_tf], 0, best_planet,
                       first[best_planet->number]);
            first[best_planet->number] = false;
            zero_tf(ENEMY, en_tf);
            best_planet->esee_def = best_planet->mb + 6 * best_planet->amb;
            pause();
        };
    }
    while (best_score < 0 && any_bc(ENEMY, starnum));
    revolt(starnum);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edi, %ebx
movl $0x1, %eax
movl $0x1, (%rsp,%rax,4)
incq %rax
cmpq $0x8, %rax
jne 0x2856
leaq 0xc133(%rip), %r14      # 0xe9a0
addq $0x34, %r14
movl $0x1, %ebp
cmpl %ebx, 0x20(%r14)
jne 0x2883
cmpl $0x0, 0x24(%r14)
je 0x288b
incl %ebp
addq $0x34, %r14
jmp 0x2876
movslq %ebx, %r15
leaq (%r15,%r15,2), %rax
leaq 0xcc07(%rip), %rcx      # 0xf4a0
leaq (%rcx,%rax,8), %r12
addq $0x8, %r12
addl $0x40, %r15d
movss 0x677f(%rip), %xmm4     # 0x902c
movsd 0x676b(%rip), %xmm5     # 0x9020
movq (%r12), %rax
testq %rax, %rax
je 0x2948
movl 0x1c(%r14), %ecx
leal (%rcx,%rcx,2), %ecx
addl %ecx, %ecx
addl 0x18(%r14), %ecx
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
xorl %r13d, %r13d
movss 0x6747(%rip), %xmm1     # 0x9028
cmpl $0x1, 0xc(%rax)
jne 0x2934
xorps %xmm3, %xmm3
cvtsi2ssl 0x2c(%rax), %xmm3
divss %xmm0, %xmm3
movl 0x4(%rax), %ecx
cmpl $0x1f, %ecx
jl 0x290c
addss %xmm4, %xmm3
xorps %xmm2, %xmm2
cvtsi2ss %ecx, %xmm2
mulss %xmm3, %xmm2
jmp 0x2929
xorps %xmm2, %xmm2
cvtss2sd %xmm3, %xmm2
xorps %xmm3, %xmm3
cvtsi2sd %ecx, %xmm3
addsd %xmm5, %xmm2
mulsd %xmm2, %xmm3
xorps %xmm2, %xmm2
cvtsd2ss %xmm3, %xmm2
ucomiss %xmm2, %xmm1
jbe 0x2934
movaps %xmm2, %xmm1
movq %rax, %r13
movq 0x38(%rax), %rax
testq %rax, %rax
jne 0x28e1
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
seta %al
jmp 0x294d
xorl %eax, %eax
xorl %r13d, %r13d
testb %al, %al
je 0x2a00
callq 0x7377
movl $0x1, %edi
movl $0x13, %esi
callq 0x4f69
movl (%r13), %edx
leaq 0x67e3(%rip), %rdi      # 0x9157
movl %r15d, %esi
xorl %eax, %eax
callq 0x2030
movl $0x32, %edi
movl $0x1, %esi
callq 0x4f69
movl %ebx, %edi
callq 0x7793
callq 0x731e
callq 0x763e
movslq (%r13), %rax
movl (%rsp,%rax,4), %r8d
xorl %edi, %edi
movq %r14, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x391d
movslq (%r13), %rax
movl $0x0, (%rsp,%rax,4)
xorl %edi, %edi
movl %ebp, %esi
callq 0x3695
movl 0x1c(%r13), %eax
leal (%rax,%rax,2), %eax
addl %eax, %eax
addl 0x18(%r13), %eax
movl %eax, 0x2c(%r13)
callq 0x763e
xorl %edi, %edi
movl %ebx, %esi
callq 0x224c
movsd 0x6630(%rip), %xmm5     # 0x9020
movss 0x6634(%rip), %xmm4     # 0x902c
testl %eax, %eax
jne 0x28b5
movl %ebx, %edi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x43a8
nopl (%rax)