// File: /workspace/github_c_makefile_star2_O2/QwazyWabbitWOS[P]lmctf60/g_tourney.c
// Function: Match_Start
void Match_Start(edict_t *ent)
{
    int i;
    edict_t *player;
    char message[MAX_INFO_STRING];
    int player_count = 0;
    gitem_t *Item;
    //edict_t    *Item_ent;

    // Blank all players' stats, and respawn them
    for (i=0 ; i < game.maxclients ; i++) {
        player = g_edicts + 1 + i;

        // Don't bother killing them if they are an observer
        if (player->inuse && !player->client->resp.spectator) {
            player_count++;

            if(matchstate != MATCH_RAILGUN_COUNTDOWN) {
                player->health = 0;
                player_die (player, player, player, 100000, vec3_origin);
                // don't even bother waiting for death frames

                // Start our time over so we respawn on team spawn point
                player->client->resp.enterframe = level.framenum;

                //bat force them to hit the button to respawn.
                //took out respawn() and added a second to the respawn time
                //Too Many overflows!!!!!
                //respawn (player);
                //This is in seconds!!!

                //Let's try this in the respawn instead;
                //player->client->respawn_time = level.time + (0.2 * player_count);

                stats_clear(player); // Blank all our stats, whether we are here or not
            } else {
                player->health = 100;
                player->client->pers.weapon = FindItem ("railgun");;
                player->client->newweapon = player->client->pers.weapon;
                Item = FindItem("slugs");
                Add_Ammo(player, Item, 1000);
                ChangeWeapon(player);
            }
        }
    }

    if(matchstate == MATCH_RAILGUN_COUNTDOWN) {
        matchstate = MATCH_RAILGUN_INPLAY;
        ent->count = railtime->value;
        sprintf(message, "%d seconds. %d men enter 1 man leaves \n", ent->count, player_count);
        ctf_BSafePrint(PRINT_HIGH, message);
    } else {
        matchstate = MATCH_INPLAY;
        ent->count = ((unsigned short)timelimit->value) * 60;
        sprintf(message, "%d minutes until match ends.\n", ent->count/60);
        ctf_BSafePrint(PRINT_HIGH, message);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rdi, 0x8(%rsp)
xorl %r14d, %r14d
movl $0x4a8, %r15d           # imm = 0x4A8
movq 0x4589d(%rip), %rsi     # 0x66d40
movq 0x450ae(%rip), %rdi     # 0x66558
movq 0x45327(%rip), %rdx     # 0x667d8
xorl %ebx, %ebx
movslq 0x610(%rsi), %rax
cmpq %rax, %r14
jge 0x215a2
movq (%rdi), %rbp
cmpl $0x0, 0x60(%rbp,%r15)
je 0x21593
movq 0x58(%rbp,%r15), %rax
cmpl $0x0, 0xe04(%rax)
jne 0x21593
leaq (%r15,%rbp), %r13
incl %ebx
movq %rdx, %r12
cmpl $0x5, (%rdx)
jne 0x21543
movl $0x64, 0x254(%rbp,%r15)
leaq 0x34c58(%rip), %rdi     # 0x5615d
callq 0x18a80
movq 0x58(%rbp,%r15), %rcx
movq %rax, 0x730(%rcx)
movq %rax, 0xe50(%rcx)
leaq 0x3162f(%rip), %rdi     # 0x52b53
callq 0x18a80
movq %r13, %rdi
movq %rax, %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x193b0
movq %r13, %rdi
callq 0x18800
jmp 0x21582
andl $0x0, 0x254(%rbp,%r15)
movq %r13, %rdi
movq %r13, %rsi
movq %r13, %rdx
movl $0x186a0, %ecx          # imm = 0x186A0
movq 0x45207(%rip), %r8      # 0x66768
callq 0x19ca8
movq 0x45833(%rip), %rax     # 0x66da0
movl (%rax), %eax
movq 0x58(%rbp,%r15), %rcx
movl %eax, 0xdf0(%rcx)
movq %r13, %rdi
callq 0x193e0
movq %r12, %rdx
movq 0x457b4(%rip), %rsi     # 0x66d40
movq 0x44fc5(%rip), %rdi     # 0x66558
incq %r14
addq $0x4a8, %r15            # imm = 0x4A8
jmp 0x214b3
cmpl $0x5, (%rdx)
jne 0x215de
movl $0x6, (%rdx)
movq 0x4509c(%rip), %rax     # 0x66650
movq (%rax), %rax
cvttss2si 0x20(%rax), %edx
movq 0x8(%rsp), %rax
movl %edx, 0x290(%rax)
leaq 0x2e3da(%rip), %rsi     # 0x4f9a8
leaq 0x10(%rsp), %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x198c0
jmp 0x21617
movl $0x3, (%rdx)
movq 0x450c5(%rip), %rax     # 0x666b0
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
movzwl %ax, %edx
imull $0x3c, %edx, %eax
movq 0x8(%rsp), %rcx
movl %eax, 0x290(%rcx)
leaq 0x2e3c5(%rip), %rsi     # 0x4f9d0
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x198c0
pushq $0x2
popq %rdi
leaq 0x10(%rsp), %rsi
callq 0x193f0
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq