// File: /workspace/github_c_makefile_star2_O1/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 %rbx
subq $0x28, %rsp
leaq 0xd5a6(%rip), %rdi      # 0xf8b8
movl (%rdi), %r15d
leaq 0xc684(%rip), %rax      # 0xe9a0
xorl %ecx, %ecx
xorl %edx, %edx
movl %ecx, 0x18(%rsp,%rdx,4)
movl %ecx, 0x8(%rsp,%rdx,4)
movl $0x54, %esi
cmpl $0x0, (%rax,%rsi)
je 0x233d
movl -0xc(%rax,%rsi), %r8d
addl %r8d, 0x18(%rsp,%rdx,4)
addq $0x34, %rsi
cmpq $0x59c, %rsi            # imm = 0x59C
jne 0x232d
leaq 0x1(%rdx), %rsi
addq $0x57c, %rax            # imm = 0x57C
testq %rdx, %rdx
movq %rsi, %rdx
je 0x2320
movl 0x8(%rsp), %eax
movl 0xc(%rsp), %ecx
movl $0x1, %edx
leaq 0xd130(%rip), %rsi      # 0xf4a0
leaq (%rdx,%rdx,2), %r8
movq 0x8(%rsi,%r8,8), %r8
testq %r8, %r8
je 0x239d
movl 0xc(%r8), %r9d
testl %r9d, %r9d
je 0x2393
cmpl $0x1, %r9d
jne 0x2397
addl 0x14(%r8), %ecx
jmp 0x2397
addl 0x14(%r8), %eax
movq 0x38(%r8), %r8
jmp 0x2379
incq %rdx
cmpq $0x16, %rdx
jne 0x2370
movl %ecx, 0xc(%rsp)
movl %eax, 0x8(%rsp)
xorl %eax, %eax
movl 0x18(%rsp,%rax,4), %ecx
xorl %edx, %edx
addl 0x8(%rsp,%rax,4), %ecx
movl %ecx, 0x20(%rsp,%rax,4)
sete %dl
movl %edx, 0x10(%rsp,%rax,4)
incq %rax
cmpq $0x1, %rax
je 0x23b0
movl 0x10(%rsp), %eax
orl 0x14(%rsp), %eax
sete %al
leaq 0xd3b4(%rip), %rcx      # 0xf794
movl (%rcx), %r8d
cmpl $0x28, %r8d
setge %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x241b
movl 0x20(%rsp), %ecx
movl 0x24(%rsp), %esi
movl %esi, %eax
cltd
idivl %ecx
xorl %edx, %edx
cmpl $0x8, %eax
setge %dl
movl %edx, 0x10(%rsp)
movl %ecx, %eax
cltd
idivl %esi
xorl %ecx, %ecx
cmpl $0x8, %eax
setge %cl
movl %ecx, 0x14(%rsp)
movl 0x10(%rsp), %eax
orl 0x14(%rsp), %eax
cmpl $0x65, %r8d
setge %cl
orl %r15d, %eax
setne %al
orb %cl, %al
movzbl %al, %eax
movl %eax, (%rdi)
cmpb $0x1, %al
jne 0x24f2
callq 0x73c3
leaq 0x6be9(%rip), %rdi      # 0x9034
xorl %eax, %eax
callq 0x2030
movl 0x1c(%rsp), %esi
leaq 0x6bea(%rip), %rdi      # 0x9047
xorl %eax, %eax
callq 0x2030
movl 0xc(%rsp), %esi
movl 0x24(%rsp), %ebx
leaq 0x6bf9(%rip), %r14      # 0x906c
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2030
movq 0xab62(%rip), %rax      # 0xcfe8
movq (%rax), %rdi
movl $0xa, %esi
callq 0x20a0
movl 0x18(%rsp), %esi
leaq 0x6bf3(%rip), %rdi      # 0x9091
xorl %eax, %eax
callq 0x2030
movl 0x8(%rsp), %esi
movl 0x20(%rsp), %ebp
movq %r14, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2030
cmpl %ebp, %ebx
leaq 0x6c21(%rip), %rax      # 0x90e3
leaq 0x6c4b(%rip), %rdi      # 0x9114
cmovgq %rax, %rdi
testl %r15d, %r15d
leaq 0x6bdf(%rip), %rax      # 0x90b6
cmovneq %rax, %rdi
cmpl %ebx, %ebp
cmovgq %rax, %rdi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2030
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq