// File: /workspace/github_c_makefile_star2_O3/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
xorl %eax, %eax
movdqa 0x67ca(%rip), %xmm0     # 0x9030
movdqa 0x67d2(%rip), %xmm1     # 0x9040
movdqa 0x67da(%rip), %xmm2     # 0x9050
movdqa 0x67e2(%rip), %xmm3     # 0x9060
pshufd $0xf5, %xmm3, %xmm4     # xmm4 = xmm3[1,1,3,3]
movq %rax, %xmm5
pshufd $0x44, %xmm5, %xmm5     # xmm5 = xmm5[0,1,0,1]
movdqa %xmm5, %xmm6
por %xmm1, %xmm6
pxor %xmm2, %xmm6
movdqa %xmm3, %xmm7
pcmpgtd %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm6     # xmm6 = xmm6[1,1,3,3]
pcmpeqd %xmm4, %xmm6
pand %xmm7, %xmm6
movd %xmm6, %ecx
testb $0x1, %cl
je 0x28bf
movl $0x1, 0x4(%rsp,%rax,4)
pextrw $0x4, %xmm6, %ecx
testb $0x1, %cl
je 0x28d1
movl $0x1, 0x8(%rsp,%rax,4)
por %xmm0, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm3, %xmm6
pcmpgtd %xmm5, %xmm6
pshufd $0xf5, %xmm5, %xmm5     # xmm5 = xmm5[1,1,3,3]
pcmpeqd %xmm4, %xmm5
pand %xmm6, %xmm5
pextrw $0x0, %xmm5, %ecx
testb $0x1, %cl
je 0x2900
movl $0x1, 0xc(%rsp,%rax,4)
pextrw $0x4, %xmm5, %ecx
testb $0x1, %cl
je 0x2912
movl $0x1, 0x10(%rsp,%rax,4)
addq $0x4, %rax
cmpq $0x8, %rax
jne 0x2883
leaq 0xc069(%rip), %r14      # 0xe990
addq $0x34, %r14
movl $0x1, %ebp
cmpl %ebx, 0x20(%r14)
jne 0x293d
cmpl $0x0, 0x24(%r14)
je 0x2945
incl %ebp
addq $0x34, %r14
jmp 0x2930
movslq %ebx, %r15
leaq (%r15,%r15,2), %rax
leaq 0xcb3d(%rip), %rcx      # 0xf490
leaq (%rcx,%rax,8), %r12
addq $0x8, %r12
addl $0x40, %r15d
movss 0x670d(%rip), %xmm4     # 0x9074
movsd 0x66b1(%rip), %xmm5     # 0x9020
movq (%r12), %rax
testq %rax, %rax
je 0x2aae
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 0x66d5(%rip), %xmm1     # 0x9070
cmpl $0x1, 0xc(%rax)
jne 0x29ee
xorps %xmm3, %xmm3
cvtsi2ssl 0x2c(%rax), %xmm3
divss %xmm0, %xmm3
movl 0x4(%rax), %ecx
cmpl $0x1f, %ecx
jl 0x29c6
addss %xmm4, %xmm3
xorps %xmm2, %xmm2
cvtsi2ss %ecx, %xmm2
mulss %xmm3, %xmm2
jmp 0x29e3
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 0x29ee
movaps %xmm2, %xmm1
movq %rax, %r13
movq 0x38(%rax), %rax
testq %rax, %rax
jne 0x299b
xorps %xmm0, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2aae
callq 0x7322
movl $0x1, %edi
movl $0x13, %esi
callq 0x4f79
movl (%r13), %edx
leaq 0x677d(%rip), %rdi      # 0x919f
movl %r15d, %esi
xorl %eax, %eax
callq 0x2030
movl $0x32, %edi
movl $0x1, %esi
callq 0x4f79
movl %ebx, %edi
callq 0x7730
callq 0x72c9
callq 0x75db
movslq (%r13), %rax
movl (%rsp,%rax,4), %r8d
xorl %edi, %edi
movq %r14, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x398d
movslq (%r13), %rax
movl $0x0, (%rsp,%rax,4)
xorl %edi, %edi
movl %ebp, %esi
callq 0x36f5
movl 0x1c(%r13), %eax
leal (%rax,%rax,2), %eax
addl %eax, %eax
addl 0x18(%r13), %eax
movl %eax, 0x2c(%r13)
callq 0x75db
xorl %edi, %edi
movl %ebx, %esi
callq 0x223c
movsd 0x6582(%rip), %xmm5     # 0x9020
movss 0x65ce(%rip), %xmm4     # 0x9074
testl %eax, %eax
jne 0x296f
movl %ebx, %edi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x43f0
nop