// File: /workspace/github_c_makefile_star2_O2/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 0xe5bf(%rip), %rdi      # 0x108a8
movl (%rdi), %r12d
leaq 0xd69d(%rip), %rax      # 0xf990
xorl %ecx, %ecx
pushq $0x54
popq %rdx
cmpq $0x2, %rcx
je 0x2336
andl $0x0, 0x8(%rsp,%rcx,4)
andl $0x0, (%rsp,%rcx,4)
xorl %esi, %esi
movq %rdx, %r8
cmpq $0x59c, %r8             # imm = 0x59C
je 0x232b
cmpl $0x0, (%rax,%r8)
je 0x2325
addl -0xc(%rax,%r8), %esi
movl %esi, 0x8(%rsp,%rcx,4)
addq $0x34, %r8
jmp 0x230c
incq %rcx
addq $0x57c, %rax            # imm = 0x57C
jmp 0x22f8
movl (%rsp), %ebx
movl 0x4(%rsp), %ebp
pushq $0x1
popq %rax
leaq 0xe149(%rip), %rcx      # 0x10490
cmpq $0x16, %rax
je 0x237f
imulq $0x18, %rax, %rdx
addq %rcx, %rdx
addq $0x8, %rdx
movq (%rdx), %rdx
testq %rdx, %rdx
je 0x237a
movl 0xc(%rdx), %esi
testl %esi, %esi
je 0x2371
cmpl $0x1, %esi
jne 0x2374
addl 0x14(%rdx), %ebp
jmp 0x2374
addl 0x14(%rdx), %ebx
addq $0x38, %rdx
jmp 0x2358
incq %rax
jmp 0x2347
movl %ebx, (%rsp)
movl %ebp, 0x4(%rsp)
xorl %eax, %eax
cmpq $0x2, %rax
je 0x23a7
movl 0x8(%rsp,%rax,4), %ecx
xorl %edx, %edx
addl (%rsp,%rax,4), %ecx
movl %ecx, 0x10(%rsp,%rax,4)
sete %dl
movl %edx, 0x18(%rsp,%rax,4)
incq %rax
jmp 0x2388
movl 0x18(%rsp), %r8d
movl 0x1c(%rsp), %ecx
movl %r8d, %eax
orl %ecx, %eax
sete %al
leaq 0xe3c5(%rip), %rdx      # 0x10784
movl (%rdx), %r9d
cmpl $0x28, %r9d
setge %dl
andb %al, %dl
cmpb $0x1, %dl
jne 0x23f4
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %esi
movl %esi, %eax
cltd
idivl %ecx
xorl %r8d, %r8d
cmpl $0x8, %eax
setge %r8b
movl %ecx, %eax
cltd
idivl %esi
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 0x24c6
callq 0x6f9d
leaq 0x6c15(%rip), %rdi      # 0x9034
xorl %eax, %eax
callq 0x2030
movl 0xc(%rsp), %esi
leaq 0x6c16(%rip), %rdi      # 0x9047
xorl %eax, %eax
callq 0x2030
movl 0x14(%rsp), %r14d
leaq 0x6c28(%rip), %r15      # 0x906c
movq %r15, %rdi
movl %ebp, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x2030
movq 0xbb8e(%rip), %rax      # 0xdfe8
movq (%rax), %rdi
pushq $0xa
popq %rsi
callq 0x2090
movl 0x8(%rsp), %esi
leaq 0x6c21(%rip), %rdi      # 0x9091
xorl %eax, %eax
callq 0x2030
movl 0x10(%rsp), %ebp
movq %r15, %rdi
movl %ebx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2030
cmpl %ebp, %r14d
leaq 0x6c50(%rip), %rax      # 0x90e3
leaq 0x6c7a(%rip), %rdi      # 0x9114
cmovgq %rax, %rdi
testl %r12d, %r12d
leaq 0x6c0e(%rip), %rax      # 0x90b6
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