// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_tourney.c
// Function: Tourney_Think
void Tourney_Think(edict_t *ent)
{
    int     minutes;
    edict_t *player;
    int     i;
    char    message[MAX_INFO_STRING];

    ent->nextthink = level.time + 1;

    // If game paused, don't keep counting down
    if (GamePaused()) {
        return;
    }

    minutes = ent->count/60;

    if (matchstate == MATCH_OVER) {
        Time_Left = 0;
    } else if (ent->count < 60) {
        Time_Left = ent->count;
    } else {
        Time_Left = minutes + 1;
    }


    if (matchstate == MATCH_COUNTDOWN || matchstate == MATCH_RAILGUN_COUNTDOWN) {
        if(ent->count <= 10) {
            gi.sound (ent, CHAN_CTF, gi.soundindex (CTF_Countdown_Table[ent->count]), 1, ATTN_NONE, 0);
        }

        switch (ent->count) {
        case 60:
            ctf_BSafePrint(PRINT_HIGH, "60 seconds until match begins.\n");
            break;
        case 30:
            ctf_BSafePrint(PRINT_HIGH, "30 seconds until match begins.\n");
            break;
        case 15:
            if (matchstate == MATCH_RAILGUN_COUNTDOWN) {
                ctf_BSafePrint(PRINT_HIGH, "Prepare to annihilate your enemy...\n");

                gi.sound(ent, CHAN_CTF, gi.soundindex ("weapons/bfg__l1a.wav"), 1, ATTN_NONE, 0);
            } else {
                ctf_BSafePrint(PRINT_HIGH, "15 seconds until match begins.\n");
            }
            break;
        case 10:
            ctf_BSafePrint(PRINT_HIGH, "10 seconds until match begins.\n");
            break;
        case 0:
        //    gi.sound (ent, CHAN_CTF, gi.soundindex ("ctf/go.wav"), 1, ATTN_NONE, 0);
            Last_Guy = 0;
            Position_Count = 0;
            Match_Start(ent);
            break;
        }
    } else if (matchstate == MATCH_RAILGUN_INPLAY) {
        edict_t *cl_ent;

        if (++Position_Count == 6) {
            cl_ent = g_edicts + 1 + Last_Guy;

            while (cl_ent->health <= 0) {
                Last_Guy++;

                if (Last_Guy == game.maxclients) {
                    Last_Guy = 0;
                    break;
                }
            }

            cl_ent = g_edicts + 1 + Last_Guy;

            if(cl_ent->health > 0) {
                ForceCommand(cl_ent, "say I am %p");
            }

            Last_Guy++;
            Position_Count = 0;
        }


        if (ent->count == 0 || One_Man_Left()) {
            Railgun_Victor = Declare_Railgun_Victor();
            matchstate = MATCH_RAILGUN_OVER;
        } else if(ent->count <= 15) {
            sprintf(message, "%d\n", ent->count);
            ctf_BSafePrint(PRINT_HIGH, message);

            if (ent->count <= 10) {
                gi.sound (ent, CHAN_CTF, gi.soundindex (CTF_Countdown_Table[ent->count]), 1, ATTN_NONE, 0);
            }
        }

    } else if (matchstate == MATCH_INPLAY) {
        // Start the countdown if we hit the fraglimit
        if (ent->count > 10) {
            for (i=0 ; i<maxclients->value ; i++) {
                player = g_edicts + 1 + i;
                if (!player->inuse) {
                    continue;
                }

                if (fraglimit->value && stats_get(player, STATS_SCORE) >= fraglimit->value) {
                    // Fraglimit was hit
                    ent->count = 10;
                }
            }
        }

        if (ent->count <= 0) { // End match
            Match_End(ent);
            return;
        } else if (!(ent->count % 60)) {
            if (minutes > 1) {
                sprintf(message, "%d minutes until match ends.\n", minutes);
            } else if (minutes == 1) {
                sprintf(message, "%d minute until match ends.\n", minutes);
            } else {
                sprintf(message, "%d frags until match ends.\n", (int)fraglimit->value);
            }
            ctf_BSafePrint(PRINT_HIGH, message);
        } else if(ent->count <= 10) {
            gi.sound (ent, CHAN_CTF, gi.soundindex (CTF_Countdown_Table[ent->count]), 1, ATTN_NONE, 0);
        }
    } else if (matchstate == MATCH_OVER) {
        if (ent->count <= 0) {
            matchstate = MATCH_NONE;
            ent->think = G_FreeEdict;
            tourneyclock = NULL;
        }
    }

    ent->count--;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movq %rdi, -0x8(%rbp)
movss 0x49415(%rip), %xmm0    # 0x6feec
movq 0x5c2c2(%rip), %rax     # 0x82da0
addss 0x4(%rax), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x200(%rax)
callq 0x18160
cmpl $0x0, %eax
je 0x26afe
jmp 0x271a1
movq -0x8(%rbp), %rax
movl 0x290(%rax), %eax
movl $0x3c, %ecx
cltd
idivl %ecx
movl %eax, -0xc(%rbp)
movq 0x5bcbe(%rip), %rax     # 0x827d8
cmpl $0x4, (%rax)
jne 0x26b2e
movq 0x5c0da(%rip), %rax     # 0x82c00
movl $0x0, (%rax)
jmp 0x26b61
movq -0x8(%rbp), %rax
cmpl $0x3c, 0x290(%rax)
jge 0x26b50
movq -0x8(%rbp), %rax
movl 0x290(%rax), %ecx
movq 0x5c0b4(%rip), %rax     # 0x82c00
movl %ecx, (%rax)
jmp 0x26b5f
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movq 0x5c0a3(%rip), %rax     # 0x82c00
movl %ecx, (%rax)
jmp 0x26b61
movq 0x5bc70(%rip), %rax     # 0x827d8
cmpl $0x2, (%rax)
je 0x26b7d
movq 0x5bc64(%rip), %rax     # 0x827d8
cmpl $0x5, (%rax)
jne 0x26d2f
movq -0x8(%rbp), %rax
cmpl $0xa, 0x290(%rax)
jg 0x26bef
movq 0x5ba6f(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x230(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x238(%rbp)
movq 0x5ba52(%rip), %rax     # 0x82600
movq 0x48(%rax), %rax
movq -0x8(%rbp), %rcx
movslq 0x290(%rcx), %rdx
movq 0x5bb4c(%rip), %rcx     # 0x82710
movq (%rcx,%rdx,8), %rdi
callq *%rax
movq -0x238(%rbp), %rdi
movl %eax, %edx
movq -0x230(%rbp), %rax
movl $0x5, %esi
movss 0x49305(%rip), %xmm0    # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm2, %xmm1
callq *%rax
movq -0x8(%rbp), %rax
movl 0x290(%rax), %eax
movl %eax, -0x23c(%rbp)
testl %eax, %eax
je 0x26d09
jmp 0x26c09
movl -0x23c(%rbp), %eax
subl $0xa, %eax
je 0x26cf6
jmp 0x26c1a
movl -0x23c(%rbp), %eax
subl $0xf, %eax
je 0x26c71
jmp 0x26c27
movl -0x23c(%rbp), %eax
subl $0x1e, %eax
je 0x26c5b
jmp 0x26c34
movl -0x23c(%rbp), %eax
subl $0x3c, %eax
jne 0x26d2a
jmp 0x26c45
movl $0x2, %edi
leaq 0x49eb6(%rip), %rsi     # 0x70b07
callq 0x19470
jmp 0x26d2a
movl $0x2, %edi
leaq 0x49ec0(%rip), %rsi     # 0x70b27
callq 0x19470
jmp 0x26d2a
movq 0x5bb60(%rip), %rax     # 0x827d8
cmpl $0x5, (%rax)
jne 0x26ce3
movl $0x2, %edi
leaq 0x49ebe(%rip), %rsi     # 0x70b47
callq 0x19470
movq 0x5b96b(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x248(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x250(%rbp)
leaq 0x49eba(%rip), %rdi     # 0x70b6c
movq 0x5b947(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x250(%rbp), %rdi
movl %eax, %edx
movq -0x248(%rbp), %rax
movl $0x5, %esi
movss 0x49213(%rip), %xmm0    # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm2, %xmm1
callq *%rax
jmp 0x26cf4
movl $0x2, %edi
leaq 0x49e92(%rip), %rsi     # 0x70b81
callq 0x19470
jmp 0x26d2a
movl $0x2, %edi
leaq 0x49e9f(%rip), %rsi     # 0x70ba1
callq 0x19470
jmp 0x26d2a
movq 0x5c108(%rip), %rax     # 0x82e18
movw $0x0, (%rax)
movq 0x5b8b4(%rip), %rax     # 0x825d0
movw $0x0, (%rax)
movq -0x8(%rbp), %rdi
callq 0x189a0
jmp 0x2718e
movq 0x5baa2(%rip), %rax     # 0x827d8
cmpl $0x6, (%rax)
jne 0x26f4c
movq 0x5b88a(%rip), %rax     # 0x825d0
movw (%rax), %ax
addw $0x1, %ax
movq 0x5b87c(%rip), %rcx     # 0x825d0
movw %ax, (%rcx)
cwtl
cmpl $0x6, %eax
jne 0x26e55
movq 0x5b7f0(%rip), %rax     # 0x82558
movq (%rax), %rax
addq $0x4a8, %rax            # imm = 0x4A8
movq 0x5c0a0(%rip), %rcx     # 0x82e18
movswl (%rcx), %ecx
movslq %ecx, %rcx
imulq $0x4a8, %rcx, %rcx      # imm = 0x4A8
addq %rcx, %rax
movq %rax, -0x228(%rbp)
movq -0x228(%rbp), %rax
cmpl $0x0, 0x254(%rax)
jg 0x26de0
movq 0x5c072(%rip), %rax     # 0x82e18
movw (%rax), %cx
addw $0x1, %cx
movq 0x5c064(%rip), %rax     # 0x82e18
movw %cx, (%rax)
movq 0x5c05a(%rip), %rax     # 0x82e18
movswl (%rax), %eax
movq 0x5bf78(%rip), %rcx     # 0x82d40
cmpl 0x610(%rcx), %eax
jne 0x26dde
movq 0x5c041(%rip), %rax     # 0x82e18
movw $0x0, (%rax)
jmp 0x26de0
jmp 0x26d8f
movq 0x5b771(%rip), %rax     # 0x82558
movq (%rax), %rax
addq $0x4a8, %rax            # imm = 0x4A8
movq 0x5c021(%rip), %rcx     # 0x82e18
movswl (%rcx), %ecx
movslq %ecx, %rcx
imulq $0x4a8, %rcx, %rcx      # imm = 0x4A8
addq %rcx, %rax
movq %rax, -0x228(%rbp)
movq -0x228(%rbp), %rax
cmpl $0x0, 0x254(%rax)
jle 0x26e31
movq -0x228(%rbp), %rdi
leaq 0x49d95(%rip), %rsi     # 0x70bc1
callq 0x18d80
movq 0x5bfe0(%rip), %rax     # 0x82e18
movw (%rax), %cx
addw $0x1, %cx
movq 0x5bfd2(%rip), %rax     # 0x82e18
movw %cx, (%rax)
movq 0x5b780(%rip), %rax     # 0x825d0
movw $0x0, (%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x290(%rax)
je 0x26e6c
callq 0x183c0
cmpl $0x0, %eax
je 0x26e90
callq 0x18080
movq %rax, %rcx
movq 0x5b90d(%rip), %rax     # 0x82788
movq %rcx, (%rax)
movq 0x5b953(%rip), %rax     # 0x827d8
movl $0x7, (%rax)
jmp 0x26f47
movq -0x8(%rbp), %rax
cmpl $0xf, 0x290(%rax)
jg 0x26f45
leaq -0x220(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x290(%rax), %edx
leaq 0x4b327(%rip), %rsi     # 0x721e0
movb $0x0, %al
callq 0x19940
leaq -0x220(%rbp), %rsi
movl $0x2, %edi
callq 0x19470
movq -0x8(%rbp), %rax
cmpl $0xa, 0x290(%rax)
jg 0x26f43
movq 0x5b71b(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x258(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x260(%rbp)
movq 0x5b6fe(%rip), %rax     # 0x82600
movq 0x48(%rax), %rax
movq -0x8(%rbp), %rcx
movslq 0x290(%rcx), %rdx
movq 0x5b7f8(%rip), %rcx     # 0x82710
movq (%rcx,%rdx,8), %rdi
callq *%rax
movq -0x260(%rbp), %rdi
movl %eax, %edx
movq -0x258(%rbp), %rax
movl $0x5, %esi
movss 0x48fb1(%rip), %xmm0    # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm2, %xmm1
callq *%rax
jmp 0x26f45
jmp 0x26f47
jmp 0x2718c
movq 0x5b885(%rip), %rax     # 0x827d8
cmpl $0x3, (%rax)
jne 0x27140
movq -0x8(%rbp), %rax
cmpl $0xa, 0x290(%rax)
jle 0x2701d
movl $0x0, -0x1c(%rbp)
cvtsi2ssl -0x1c(%rbp), %xmm1
movq 0x5b5b0(%rip), %rax     # 0x82530
movq (%rax), %rax
movss 0x20(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x2701b
movq 0x5b5c0(%rip), %rax     # 0x82558
movq (%rax), %rax
addq $0x4a8, %rax            # imm = 0x4A8
movslq -0x1c(%rbp), %rcx
imulq $0x4a8, %rcx, %rcx      # imm = 0x4A8
addq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x60(%rax)
jne 0x26fbf
jmp 0x2700d
movq 0x5be3a(%rip), %rax     # 0x82e00
movq (%rax), %rax
movss 0x20(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x26fda
jp 0x26fda
jmp 0x2700b
movq -0x18(%rbp), %rdi
movl $0x3, %esi
callq 0x18030
cvtsi2ss %rax, %xmm0
movq 0x5be0c(%rip), %rax     # 0x82e00
movq (%rax), %rax
ucomiss 0x20(%rax), %xmm0
jb 0x2700b
movq -0x8(%rbp), %rax
movl $0xa, 0x290(%rax)
jmp 0x2700d
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x26f74
jmp 0x2701d
movq -0x8(%rbp), %rax
cmpl $0x0, 0x290(%rax)
jg 0x27038
movq -0x8(%rbp), %rdi
callq 0x18ed0
jmp 0x271a1
movq -0x8(%rbp), %rax
movl 0x290(%rax), %eax
movl $0x3c, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x270c8
cmpl $0x1, -0xc(%rbp)
jle 0x2706f
leaq -0x220(%rbp), %rdi
movl -0xc(%rbp), %edx
leaq 0x49950(%rip), %rsi     # 0x709b6
movb $0x0, %al
callq 0x19940
jmp 0x270b5
cmpl $0x1, -0xc(%rbp)
jne 0x2708f
leaq -0x220(%rbp), %rdi
movl -0xc(%rbp), %edx
leaq 0x49b47(%rip), %rsi     # 0x70bcd
movb $0x0, %al
callq 0x19940
jmp 0x270b3
leaq -0x220(%rbp), %rdi
movq 0x5bd63(%rip), %rax     # 0x82e00
movq (%rax), %rax
cvttss2si 0x20(%rax), %edx
leaq 0x49b3e(%rip), %rsi     # 0x70bea
movb $0x0, %al
callq 0x19940
jmp 0x270b5
leaq -0x220(%rbp), %rsi
movl $0x2, %edi
callq 0x19470
jmp 0x2713c
movq -0x8(%rbp), %rax
cmpl $0xa, 0x290(%rax)
jg 0x2713a
movq 0x5b524(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x268(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x270(%rbp)
movq 0x5b507(%rip), %rax     # 0x82600
movq 0x48(%rax), %rax
movq -0x8(%rbp), %rcx
movslq 0x290(%rcx), %rdx
movq 0x5b601(%rip), %rcx     # 0x82710
movq (%rcx,%rdx,8), %rdi
callq *%rax
movq -0x270(%rbp), %rdi
movl %eax, %edx
movq -0x268(%rbp), %rax
movl $0x5, %esi
movss 0x48dba(%rip), %xmm0    # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm2, %xmm1
callq *%rax
jmp 0x2713c
jmp 0x2713e
jmp 0x2718a
movq 0x5b691(%rip), %rax     # 0x827d8
cmpl $0x4, (%rax)
jne 0x27188
movq -0x8(%rbp), %rax
cmpl $0x0, 0x290(%rax)
jg 0x27186
movq 0x5b678(%rip), %rax     # 0x827d8
movl $0x0, (%rax)
movq -0x8(%rbp), %rax
movq 0x5b2bf(%rip), %rcx     # 0x82430
movq %rcx, 0x210(%rax)
movq 0x5be69(%rip), %rax     # 0x82fe8
movq $0x0, (%rax)
jmp 0x27188
jmp 0x2718a
jmp 0x2718c
jmp 0x2718e
movq -0x8(%rbp), %rax
movl 0x290(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x290(%rax)
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
nopw (%rax,%rax)