// File: /workspace/github_c_makefile_star2_O1/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 0x46bca(%rip), %rdx     # 0x69d40
cmpl $0x0, 0x610(%rdx)
jle 0x2327e
xorl %r15d, %r15d
movl $0x4a8, %r12d           # imm = 0x4A8
movq 0x463c5(%rip), %r14     # 0x69558
xorl %ebx, %ebx
movq (%r14), %rbp
cmpl $0x0, 0x60(%rbp,%r12)
je 0x23262
movq 0x58(%rbp,%r12), %rax
cmpl $0x0, 0xe04(%rax)
jne 0x23262
leaq (%r12,%rbp), %r13
incl %ebx
movq 0x46615(%rip), %rax     # 0x697d8
cmpl $0x5, (%rax)
jne 0x23219
movl $0x64, 0x254(%rbp,%r12)
leaq 0x37cd2(%rip), %rdi     # 0x5aead
callq 0x189e0
movq 0x58(%rbp,%r12), %rcx
movq %rax, 0x730(%rcx)
movq %rax, 0xe50(%rcx)
leaq 0x34885(%rip), %rdi     # 0x57a7f
callq 0x189e0
movq %r13, %rdi
movq %rax, %rsi
movl $0x3e8, %edx            # imm = 0x3E8
callq 0x19230
movq %r13, %rdi
callq 0x187a0
jmp 0x2325b
movl $0x0, 0x254(%rbp,%r12)
movq %r13, %rdi
movq %r13, %rsi
movq %r13, %rdx
movl $0x186a0, %ecx          # imm = 0x186A0
movq 0x4652e(%rip), %r8      # 0x69768
callq 0x19ab0
movq 0x46b5a(%rip), %rax     # 0x69da0
movl (%rax), %eax
movq 0x58(%rbp,%r12), %rcx
movl %eax, 0xdf0(%rcx)
movq %r13, %rdi
callq 0x19260
movq 0x46ade(%rip), %rdx     # 0x69d40
incq %r15
movslq 0x610(%rdx), %rax
addq $0x4a8, %r12            # imm = 0x4A8
cmpq %rax, %r15
jl 0x23195
jmp 0x23280
xorl %ebx, %ebx
movq 0x46551(%rip), %rax     # 0x697d8
cmpl $0x5, (%rax)
jne 0x232c3
movl $0x6, (%rax)
movq 0x463b7(%rip), %rax     # 0x69650
movq (%rax), %rax
cvttss2si 0x20(%rax), %edx
movq 0x8(%rsp), %rax
movl %edx, 0x290(%rax)
leaq 0x316c5(%rip), %rsi     # 0x54978
leaq 0x10(%rsp), %rdi
movl %ebx, %ecx
xorl %eax, %eax
callq 0x19700
jmp 0x232fc
movl $0x3, (%rax)
movq 0x463e0(%rip), %rax     # 0x696b0
movq (%rax), %rax
cvttss2si 0x20(%rax), %eax
movzwl %ax, %edx
imull $0x3c, %edx, %eax
movq 0x8(%rsp), %rcx
movl %eax, 0x290(%rcx)
leaq 0x316b0(%rip), %rsi     # 0x549a0
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x19700
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