// File: /workspace/github_c_makefile_star2_O2/schroeder-lvb[P]sissm/src/roster.c
// Function: rosterParsePlayerChat
int rosterParsePlayerChat( char *strIn, int maxChars, char *clientID, char *chatLine )
{
    int   errCode = 1, i;
    char  strIn2[256], *p;
    char *chatText = NULL;


    // Clear the return variables in case of parsing error
    //
    strclr( clientID );
    strclr( chatLine );

    // check if this is a valid chat line
    //
    if ( NULL != strstr( strIn, "LogChat: Display:" )) {

        // make a copy and get rid of last carriage return
        //
        strlcpy( strIn2, strIn, 256 );
        for (i = 0; i< (int) strlen( strIn2 ); i++ )
            if ( strIn2[i] == '\015') strIn2[i] = 0;

        // Go find the first character of typed text.  Check 3 cases for a match.
        // if none found, chatText is NULL
        //
        if ( chatText == NULL )  chatText = strstr( strIn2, "Global Chat: " );
        if ( chatText == NULL )  chatText = strstr( strIn2, "Team 0 Chat: " );
        if ( chatText == NULL )  chatText = strstr( strIn2, "Team 1 Chat: " );
        if ( chatText != NULL )  {
            // chatText += 13;
            strlcpy( chatLine, chatText+13, maxChars );
            errCode = 0;
        }

        // Find the steam or EPIC ID of the originator
        // EPIC
        //
        if ( chatText != NULL ) {   // from start of chat text, work backwards to find the "(" symbol

            p = chatText;
            while ( (p--) != chatLine ) {         
                if ( *p == '(' ) {
                    p++;
                    strlcpy( clientID, p, 66 );       // check if this is EPIC ID
                    if ( 0 == rosterIsValidGUID( clientID ) ) {
                        strlcpy( clientID, p, 18 );  // check if this is Steam ID
                        if ( 0 == rosterIsValidGUID( clientID ) ) {
                            strlcpy( clientID, p, 17 );  // check if this is WinGDK ID
                            if ( 0 == rosterIsValidGUID( clientID ) ) {
                                strclr( clientID );      // parse error, no ID
                                errCode = 2;
                           }
                        }
                    }
                    break;
                }
            }
        }        
    }
    return errCode;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rcx, %r14
movq %rdx, %rbx
movl %esi, %r15d
movq %rdi, %r13
movq %rdx, %rdi
callq 0xed98
movq %r14, %rdi
callq 0xed98
leaq 0x71e6(%rip), %rsi      # 0x1b7f5
movq %r13, %rdi
callq 0x83c0
pushq $0x1
popq %rbp
testq %rax, %rax
je 0x1471e
movq %rsp, %r12
movl $0x100, %edx            # imm = 0x100
movq %r12, %rdi
movq %r13, %rsi
callq 0xe97a
xorl %r13d, %r13d
movq %r12, %rdi
callq 0x8120
cltq
cmpq %rax, %r13
jge 0x14659
cmpb $0xd, (%rsp,%r13)
jne 0x14654
movb $0x0, (%rsp,%r13)
incq %r13
jmp 0x14639
leaq 0x9347(%rip), %rsi      # 0x1d9a7
movq %rsp, %rdi
callq 0x83c0
testq %rax, %rax
jne 0x14699
leaq 0x9341(%rip), %rsi      # 0x1d9b5
movq %rsp, %rdi
callq 0x83c0
testq %rax, %rax
jne 0x14699
leaq 0x933b(%rip), %rsi      # 0x1d9c3
movq %rsp, %rdi
callq 0x83c0
testq %rax, %rax
je 0x1471e
movq %rax, %r12
leaq 0xd(%rax), %rsi
movslq %r15d, %rdx
movq %r14, %rdi
callq 0xe97a
xorl %ebp, %ebp
cmpq %r14, %r12
je 0x1471e
leaq -0x1(%r12), %r15
cmpb $0x28, -0x1(%r12)
movq %r15, %r12
jne 0x146ad
incq %r15
pushq $0x42
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe97a
movq %rbx, %rdi
callq 0x13480
testl %eax, %eax
jne 0x1471e
pushq $0x12
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe97a
movq %rbx, %rdi
callq 0x13480
testl %eax, %eax
jne 0x1471e
pushq $0x11
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe97a
movq %rbx, %rdi
callq 0x13480
testl %eax, %eax
jne 0x1471e
movq %rbx, %rdi
callq 0xed98
pushq $0x2
popq %rbp
movl %ebp, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq