// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_tourney.c
// Function: Victory
void Victory()
{
    long i;
    edict_t *ent=NULL;
    long redscore, bluescore;
    long temp, oscore, dscore;
    char victory_buf[MAX_INFO_STRING];
    char temp_buf[MAX_INFO_STRING];
    char teambuf[MAX_INFO_STRING];

    bluescore = redscore = 0;
    oscore = dscore = 0;
    dmvp = omvp = NULL;

    strcpy(victory_buf,"");

    for (i=0 ; i<game.maxclients ; i++) {
        ent = g_edicts + 1 + i;

        if (!ent->inuse) {
            continue;
        }

        if (ent->client->ctf.teamnum == CTF_TEAM_RED) { // RED TEAM
            redscore += stats_get(ent, STATS_SCORE);
        } else if (ent->client->ctf.teamnum == CTF_TEAM_BLUE) { // BLUE TEAM
            bluescore += stats_get(ent, STATS_SCORE);
        }
    }

    // Find the dmvp
    for (i=0 ; i<game.maxclients ; i++) {
        ent = g_edicts + 1 + i;

        temp = 4*stats_get(ent, STATS_OFFENSE_CARRIER) +
            3*stats_get(ent, STATS_DEFENSE_FLAG) +
            2*stats_get(ent, STATS_RETURNS) +
            stats_get(ent, STATS_DEFENSE_CARRIER) +
            stats_get(ent, STATS_DEFENSE_BASE);

        if (temp > dscore) {
            dscore = temp;
            dmvp = ent;
        }
    }

    // Find the omvp
    for (i=0 ; i<game.maxclients ; i++) {
        ent = g_edicts + 1 + i;

        // Exclude dmvp
        if (ent == dmvp) {
            continue;
        }

        temp = 8*stats_get(ent, STATS_CAPTURES) + 4*stats_get(ent, STATS_DEFENSE_CARRIER)
            + stats_get(ent, STATS_ASSISTS);

        if (temp > oscore) {
            oscore = temp;
            omvp = ent;
        }
    }

    if (dmvp) {
        strcpy(teambuf,"");
        ctf_teamstring(teambuf,dmvp->client->ctf.teamnum,CTF_TEAM_MATCHING);

        Com_sprintf(temp_buf, sizeof temp_buf, "Defense MVP: %s (%s)!\n",
            dmvp->client->pers.netname,
            teambuf);
        strcat(victory_buf,temp_buf);
    }

    if (omvp) {
        strcpy(teambuf,"");
        ctf_teamstring(teambuf,omvp->client->ctf.teamnum,CTF_TEAM_MATCHING);

        Com_sprintf(temp_buf, sizeof temp_buf, "Offense MVP: %s (%s)!\n",
            omvp->client->pers.netname,
            teambuf);
        strcat(victory_buf, temp_buf);
    }

    if (bluescore > redscore) {
        gi.sound (ent, CHAN_CTF, gi.soundindex ("ctf/end_blue.wav"), 1, ATTN_NONE, 0);
        sprintf(temp_buf, "Blue: %ld beats red: %ld!\n", bluescore,redscore);
        strcat(victory_buf, temp_buf);
    } else if (redscore > bluescore) {
        gi.sound (ent, CHAN_CTF, gi.soundindex ("ctf/end_red.wav"), 1, ATTN_NONE, 0);
        sprintf(temp_buf, "Red: %ld beats blue: %ld!\n", redscore,bluescore);
        strcat(victory_buf, temp_buf);
    } else {
        gi.sound (ent, CHAN_CTF, gi.soundindex ("ctf/end_tie.wav"), 1, ATTN_NONE, 0);
        sprintf(temp_buf, "Tie game at %ld!\n", redscore);
        strcat(victory_buf, temp_buf);
    }

    ctf_BSafePrint(PRINT_HIGH, victory_buf);
    ctf_SetLogName(); //automated log rename check each level
    //sl_Logging( gi, NULL );
    //this will cause the name of the log to change when the day number changes
    //which hypothetically would be midnight
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6a0, %rsp            # imm = 0x6A0
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq 0x5c58e(%rip), %rax     # 0x82838
movq $0x0, (%rax)
movq 0x5c298(%rip), %rax     # 0x82550
movq $0x0, (%rax)
leaq -0x240(%rbp), %rdi
leaq 0x4acb3(%rip), %rsi     # 0x70f80
callq 0x182c0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x5ca5b(%rip), %rcx     # 0x82d40
movslq 0x610(%rcx), %rcx
cmpq %rcx, %rax
jge 0x26385
movq 0x5c25c(%rip), %rax     # 0x82558
movq (%rax), %rax
addq $0x4a8, %rax            # imm = 0x4A8
imulq $0x4a8, -0x8(%rbp), %rcx # imm = 0x4A8
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x60(%rax)
jne 0x26320
jmp 0x26374
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x1, 0x1100(%rax)
jne 0x26349
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x18030
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x26372
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
cmpl $0x2, 0x1100(%rax)
jne 0x26370
movq -0x10(%rbp), %rdi
movl $0x3, %esi
callq 0x18030
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x26372
jmp 0x26374
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x262da
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x5c9a8(%rip), %rcx     # 0x82d40
movslq 0x610(%rcx), %rcx
cmpq %rcx, %rax
jge 0x2649f
movq 0x5c1a9(%rip), %rax     # 0x82558
movq (%rax), %rax
addq $0x4a8, %rax            # imm = 0x4A8
imulq $0x4a8, -0x8(%rbp), %rcx # imm = 0x4A8
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0xd, %esi
callq 0x18030
shlq $0x2, %rax
movq %rax, -0x660(%rbp)
movq -0x10(%rbp), %rdi
movl $0x7, %esi
callq 0x18030
movq %rax, %rcx
movq -0x660(%rbp), %rax
imulq $0x3, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x658(%rbp)
movq -0x10(%rbp), %rdi
movl $0xb, %esi
callq 0x18030
movq %rax, %rcx
movq -0x658(%rbp), %rax
shlq %rcx
addq %rcx, %rax
movq %rax, -0x650(%rbp)
movq -0x10(%rbp), %rdi
movl $0x9, %esi
callq 0x18030
movq %rax, %rcx
movq -0x650(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x648(%rbp)
movq -0x10(%rbp), %rdi
movl $0x8, %esi
callq 0x18030
movq %rax, %rcx
movq -0x648(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x38(%rbp), %rax
jle 0x2648c
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rcx
movq 0x5c0c7(%rip), %rax     # 0x82550
movq %rcx, (%rax)
jmp 0x2648e
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x2638d
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x5c88e(%rip), %rcx     # 0x82d40
movslq 0x610(%rcx), %rcx
cmpq %rcx, %rax
jge 0x26587
movq 0x5c08f(%rip), %rax     # 0x82558
movq (%rax), %rax
addq $0x4a8, %rax            # imm = 0x4A8
imulq $0x4a8, -0x8(%rbp), %rcx # imm = 0x4A8
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x5c064(%rip), %rcx     # 0x82550
cmpq (%rcx), %rax
jne 0x264f6
jmp 0x26576
movq -0x10(%rbp), %rdi
movl $0x4, %esi
callq 0x18030
shlq $0x3, %rax
movq %rax, -0x670(%rbp)
movq -0x10(%rbp), %rdi
movl $0x9, %esi
callq 0x18030
movq %rax, %rcx
movq -0x670(%rbp), %rax
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x668(%rbp)
movq -0x10(%rbp), %rdi
movl $0xa, %esi
callq 0x18030
movq %rax, %rcx
movq -0x668(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jle 0x26574
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rcx
movq 0x5c2c7(%rip), %rax     # 0x82838
movq %rcx, (%rax)
jmp 0x26576
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x264a7
movq 0x5bfc2(%rip), %rax     # 0x82550
cmpq $0x0, (%rax)
je 0x26620
leaq -0x640(%rbp), %rdi
leaq 0x4a9da(%rip), %rsi     # 0x70f80
callq 0x182c0
leaq -0x640(%rbp), %rdi
movq 0x5bf97(%rip), %rax     # 0x82550
movq (%rax), %rax
movq 0x58(%rax), %rax
movl 0x1100(%rax), %esi
movl $0xfffffff9, %edx       # imm = 0xFFFFFFF9
callq 0x18210
leaq -0x440(%rbp), %rdi
movq 0x5bf72(%rip), %rax     # 0x82550
movq (%rax), %rax
movq 0x58(%rax), %rcx
addq $0xc0, %rcx
addq $0x200, %rcx            # imm = 0x200
leaq -0x640(%rbp), %r8
movl $0x200, %esi            # imm = 0x200
leaq 0x4a3ce(%rip), %rdx     # 0x709d4
movb $0x0, %al
callq 0x18f90
leaq -0x240(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x19880
movq 0x5c211(%rip), %rax     # 0x82838
cmpq $0x0, (%rax)
je 0x266b9
leaq -0x640(%rbp), %rdi
leaq 0x4a941(%rip), %rsi     # 0x70f80
callq 0x182c0
leaq -0x640(%rbp), %rdi
movq 0x5c1e6(%rip), %rax     # 0x82838
movq (%rax), %rax
movq 0x58(%rax), %rax
movl 0x1100(%rax), %esi
movl $0xfffffff9, %edx       # imm = 0xFFFFFFF9
callq 0x18210
leaq -0x440(%rbp), %rdi
movq 0x5c1c1(%rip), %rax     # 0x82838
movq (%rax), %rax
movq 0x58(%rax), %rcx
addq $0xc0, %rcx
addq $0x200, %rcx            # imm = 0x200
leaq -0x640(%rbp), %r8
movl $0x200, %esi            # imm = 0x200
leaq 0x4a34c(%rip), %rdx     # 0x709eb
movb $0x0, %al
callq 0x18f90
leaq -0x240(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x19880
movq -0x20(%rbp), %rax
cmpq -0x18(%rbp), %rax
jle 0x2674f
movq 0x5bf32(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x678(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x680(%rbp)
leaq 0x4a317(%rip), %rdi     # 0x70a02
movq 0x5bf0e(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x680(%rbp), %rdi
movl %eax, %edx
movq -0x678(%rbp), %rax
movl $0x5, %esi
movss 0x497da(%rip), %xmm0    # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm2, %xmm1
callq *%rax
leaq -0x440(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rcx
leaq 0x4a2e3(%rip), %rsi     # 0x70a13
movb $0x0, %al
callq 0x19940
leaq -0x240(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x19880
jmp 0x26863
movq -0x18(%rbp), %rax
cmpq -0x20(%rbp), %rax
jle 0x267e2
movq 0x5be9c(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x688(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x690(%rbp)
leaq 0x4a2ad(%rip), %rdi     # 0x70a2e
movq 0x5be78(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x690(%rbp), %rdi
movl %eax, %edx
movq -0x688(%rbp), %rax
movl $0x5, %esi
movss 0x49744(%rip), %xmm0    # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm2, %xmm1
callq *%rax
leaq -0x440(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
leaq 0x4a278(%rip), %rsi     # 0x70a3e
movb $0x0, %al
callq 0x19940
leaq -0x240(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x19880
jmp 0x26861
movq 0x5be17(%rip), %rax     # 0x82600
movq 0x20(%rax), %rax
movq %rax, -0x698(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x6a0(%rbp)
leaq 0x4a253(%rip), %rdi     # 0x70a59
movq 0x5bdf3(%rip), %rax     # 0x82600
callq *0x48(%rax)
movq -0x6a0(%rbp), %rdi
movl %eax, %edx
movq -0x698(%rbp), %rax
movl $0x5, %esi
movss 0x496bf(%rip), %xmm0    # 0x6feec
xorps %xmm2, %xmm2
movaps %xmm2, %xmm1
callq *%rax
leaq -0x440(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq 0x4a222(%rip), %rsi     # 0x70a69
movb $0x0, %al
callq 0x19940
leaq -0x240(%rbp), %rdi
leaq -0x440(%rbp), %rsi
callq 0x19880
jmp 0x26863
leaq -0x240(%rbp), %rsi
movl $0x2, %edi
callq 0x19470
movb $0x0, %al
callq 0x194c0
addq $0x6a0, %rsp            # imm = 0x6A0
popq %rbp
retq
nopw %cs:(%rax,%rax)