// File: /workspace/github_c_makefile_star2_O3/beejjorgensen[P]conquest/conq1.c
// Function: check_game_over
void check_game_over(void)
{
    boolean dead[2];
    boolean quit_game;
    int total[2], transports[2], inhabs[2];
    tteam team;
    int tfnum, starnum;
    struct stplanet *pplan;
    quit_game = game_over;
    for (team = ENEMY; team <= player; team++) {
        transports[team] = 0;
        inhabs[team] = 0;
        for (tfnum = 1; tfnum <= 26; tfnum++) {
            if (tf[team][tfnum].dest != 0)
                transports[team] = transports[team]
                    + tf[team][tfnum].t;
        };
    };
    for (starnum = 1; starnum <= nstars; starnum++) {
        pplan = stars[starnum].first_planet;
        while (pplan != nil) {
            switch (pplan->team) {
            case player:
                inhabs[player] = inhabs[player] + pplan->iu;
                break;
            case ENEMY:
                inhabs[ENEMY] = inhabs[ENEMY] + pplan->iu;
                break;
            };                  /*switch ( */
            pplan = pplan->next;
        };
    };
    for (team = ENEMY; team <= player; team++) {
        total[team] = inhabs[team] + transports[team];
        dead[team] = total[team] == 0;
    };
    if ((!dead[player]) && (!dead[ENEMY]) && (turn >= 40)) {
        dead[ENEMY] = total[player] / total[ENEMY] >= 8;
        dead[player] = total[ENEMY] / total[player] >= 8;
    };
    game_over = dead[player] || dead[ENEMY] || (turn > 100) || quit_game;
    if (game_over) {
        cle2r_screen();
        printw("*** Game over ***\n");
        printw("Player: Population in transports:%3d", transports[player]);
        printw("  IU's on colonies: %3d  TOTAL: %3d\n", inhabs[player],
               total[player]);
        addch('\n');
        printw("Enemy:  Population in transports:%3d", transports[ENEMY]);
        printw("  IU's on colonies: %3d  TOTAL: %3d\n",
               inhabs[ENEMY], total[ENEMY]);
        if ((total[ENEMY] > total[player]) || quit_game)
            printw("**** THE ENEMY HAS CONQUERED THE GALAXY ***\n");
        else if ((total[player] > total[ENEMY]))
            printw("*** PLAYER WINS- YOU HAVE SAVED THE GALAXY! ***\n");
        else
            printw("*** DRAWN ***\n");
    };
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
leaq 0xd5a3(%rip), %rdi      # 0xf8a8
movl (%rdi), %r12d
leaq 0xc(%rsp), %r9
leaq 0x4(%rsp), %r10
movb $0x1, %cl
xorl %eax, %eax
leaq 0xc673(%rip), %rdx      # 0xe990
leaq 0x8(%rsp), %rsi
movq %rsp, %r8
xorl %r11d, %r11d
movl %eax, (%r9)
movl %eax, (%r10)
imulq $0x57c, %r11, %r10      # imm = 0x57C
addq %rdx, %r10
movl $0x54, %r11d
xorl %ebx, %ebx
cmpl $0x0, (%r10,%r11)
je 0x234f
addl -0xc(%r10,%r11), %ebx
movl %ebx, (%r9)
addq $0x34, %r11
cmpq $0x59c, %r11            # imm = 0x59C
jne 0x2340
movl $0x1, %r11d
movq %r8, %r10
movq %rsi, %r9
testb $0x1, %cl
movl $0x0, %ecx
jne 0x2328
movl 0x4(%rsp), %ebx
movl $0x1, %eax
movl (%rsp), %ebp
leaq 0xd10b(%rip), %rcx      # 0xf490
leaq (%rax,%rax,2), %rdx
movq 0x8(%rcx,%rdx,8), %rdx
testq %rdx, %rdx
je 0x23ad
movl 0xc(%rdx), %esi
testl %esi, %esi
je 0x23a4
cmpl $0x1, %esi
jne 0x23a7
addl 0x14(%rdx), %ebp
jmp 0x23a7
addl 0x14(%rdx), %ebx
movq 0x38(%rdx), %rdx
jmp 0x238e
incq %rax
cmpq $0x16, %rax
jne 0x2385
movl %ebp, (%rsp)
movl %ebx, 0x4(%rsp)
xorl %r8d, %r8d
movl 0xc(%rsp), %eax
addl %ebx, %eax
movl %eax, 0x14(%rsp)
sete %r8b
movl %r8d, 0x1c(%rsp)
xorl %ecx, %ecx
movl 0x8(%rsp), %eax
addl %ebp, %eax
movl %eax, 0x10(%rsp)
sete %cl
movl %ecx, 0x18(%rsp)
movl %r8d, %eax
orl %ecx, %eax
sete %al
leaq 0xd38f(%rip), %rdx      # 0xf784
movl (%rdx), %r9d
cmpl $0x28, %r9d
setge %dl
testb %dl, %al
je 0x2427
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %esi
movl %ecx, %eax
cltd
idivl %esi
xorl %r8d, %r8d
cmpl $0x8, %eax
setge %r8b
movl %esi, %eax
cltd
idivl %ecx
xorl %ecx, %ecx
cmpl $0x8, %eax
setge %cl
orl %ecx, %r8d
cmpl $0x65, %r9d
setge %al
orl %r12d, %r8d
setne %cl
orb %al, %cl
movzbl %cl, %eax
movl %eax, (%rdi)
cmpb $0x1, %al
jne 0x24fb
callq 0x736e
leaq 0x6c2a(%rip), %rdi      # 0x907c
xorl %eax, %eax
callq 0x2030
movl 0x8(%rsp), %esi
leaq 0x6c2b(%rip), %rdi      # 0x908f
xorl %eax, %eax
callq 0x2030
movl 0x10(%rsp), %r14d
leaq 0x6c3d(%rip), %r15      # 0x90b4
movq %r15, %rdi
movl %ebp, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x2030
movq 0xab5b(%rip), %rax      # 0xcfe8
movq (%rax), %rdi
movl $0xa, %esi
callq 0x20a0
movl 0xc(%rsp), %esi
leaq 0x6c34(%rip), %rdi      # 0x90d9
xorl %eax, %eax
callq 0x2030
movl 0x14(%rsp), %ebp
movq %r15, %rdi
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2030
cmpl %ebp, %r14d
leaq 0x6c63(%rip), %rax      # 0x912b
leaq 0x6c8d(%rip), %rdi      # 0x915c
cmovgq %rax, %rdi
testl %r12d, %r12d
leaq 0x6c21(%rip), %rax      # 0x90fe
cmovneq %rax, %rdi
cmpl %r14d, %ebp
cmovgq %rax, %rdi
xorl %eax, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2030
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq