// File: /workspace/github_c_makefile_star2_O3/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)
movq 0x45caa(%rip), %rdx     # 0x68d40
cmpl $0x0, 0x610(%rdx)
jle 0x2319e
xorl %r15d, %r15d
movl $0x4a8, %r12d           # imm = 0x4A8
movq 0x454a5(%rip), %r14     # 0x68558
xorl %ebx, %ebx
movq (%r14), %rbp
cmpl $0x0, 0x60(%rbp,%r12)
je 0x23182
movq 0x58(%rbp,%r12), %rax
cmpl $0x0, 0xe04(%rax)
jne 0x23182
leaq (%r12,%rbp), %r13
incl %ebx
movq 0x456f5(%rip), %rax     # 0x687d8
cmpl $0x5, (%rax)
jne 0x23139
movl $0x64, 0x254(%rbp,%r12)
leaq 0x37072(%rip), %rdi     # 0x5a16d
callq 0x189e0
movq 0x58(%rbp,%r12), %rcx
movq %rax, 0x730(%rcx)
movq %rax, 0xe50(%rcx)
leaq 0x33a59(%rip), %rdi     # 0x56b73
callq 0x189e0
movq %r13, %rdi
movq %rax, %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x19230
movq %r13, %rdi
callq 0x187a0
jmp 0x2317b
movl $0x0, 0x254(%rbp,%r12)
movq %r13, %rdi
movq %r13, %rsi
movq %r13, %rdx
movl $0x186a0, %ecx          # imm = 0x186A0
movq 0x4560e(%rip), %r8      # 0x68768
callq 0x19aa0
movq 0x45c3a(%rip), %rax     # 0x68da0
movl (%rax), %eax
movq 0x58(%rbp,%r12), %rcx
movl %eax, 0xdf0(%rcx)
movq %r13, %rdi
callq 0x19260
movq 0x45bbe(%rip), %rdx     # 0x68d40
incq %r15
movslq 0x610(%rdx), %rax
addq $0x4a8, %r12            # imm = 0x4A8
cmpq %rax, %r15
jl 0x230b5
jmp 0x231a0
xorl %ebx, %ebx
movq 0x45631(%rip), %rax     # 0x687d8
cmpl $0x5, (%rax)
jne 0x231e3
movl $0x6, (%rax)
movq 0x45497(%rip), %rax     # 0x68650
movq (%rax), %rax
cvttss2si 0x20(%rax), %edx
movq 0x8(%rsp), %rax
movl %edx, 0x290(%rax)
leaq 0x307d5(%rip), %rsi     # 0x539a8
leaq 0x10(%rsp), %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x196f0
jmp 0x2321c
movl $0x3, (%rax)
movq 0x454c0(%rip), %rax     # 0x686b0
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
movzwl %ax, %edx
imull $0x3c, %edx, %eax
movq 0x8(%rsp), %rcx
movl %eax, 0x290(%rcx)
leaq 0x307c0(%rip), %rsi     # 0x539d0
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x196f0
leaq 0x10(%rsp), %rsi
movl $0x2, %edi
callq 0x19270
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq