// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x1, -0x24(%rbp)
movq $0x0, -0x140(%rbp)
movq -0x18(%rbp), %rdi
callq 0x122b0
movq -0x20(%rbp), %rdi
callq 0x122b0
movq -0x8(%rbp), %rdi
leaq 0x9964(%rip), %rsi      # 0x2481d
callq 0x8390
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
je 0x1b0ba
leaq -0x130(%rbp), %rdi
movq -0x8(%rbp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x11bc0
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x144(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x8110
movq %rax, %rcx
movl -0x144(%rbp), %eax
cmpl %ecx, %eax
jge 0x1af34
movslq -0x28(%rbp), %rax
movsbl -0x130(%rbp,%rax), %eax
cmpl $0xd, %eax
jne 0x1af27
movslq -0x28(%rbp), %rax
movb $0x0, -0x130(%rbp,%rax)
jmp 0x1af29
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x1aee8
cmpq $0x0, -0x140(%rbp)
jne 0x1af58
leaq -0x130(%rbp), %rdi
leaq 0xba8f(%rip), %rsi      # 0x269db
callq 0x8390
movq %rax, -0x140(%rbp)
cmpq $0x0, -0x140(%rbp)
jne 0x1af7c
leaq -0x130(%rbp), %rdi
leaq 0xba79(%rip), %rsi      # 0x269e9
callq 0x8390
movq %rax, -0x140(%rbp)
cmpq $0x0, -0x140(%rbp)
jne 0x1afa0
leaq -0x130(%rbp), %rdi
leaq 0xba63(%rip), %rsi      # 0x269f7
callq 0x8390
movq %rax, -0x140(%rbp)
cmpq $0x0, -0x140(%rbp)
je 0x1afc9
movq -0x20(%rbp), %rdi
movq -0x140(%rbp), %rsi
addq $0xd, %rsi
movslq -0xc(%rbp), %rdx
callq 0x11bc0
movl $0x0, -0x24(%rbp)
cmpq $0x0, -0x140(%rbp)
je 0x1b0b8
movq -0x140(%rbp), %rax
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x138(%rbp)
cmpq -0x20(%rbp), %rax
je 0x1b0b6
movq -0x138(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x28, %eax
jne 0x1b0b1
movq -0x138(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x138(%rbp)
movq -0x18(%rbp), %rdi
movq -0x138(%rbp), %rsi
movl $0x42, %edx
callq 0x11bc0
movq -0x18(%rbp), %rdi
callq 0x190a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1b0af
movq -0x18(%rbp), %rdi
movq -0x138(%rbp), %rsi
movl $0x12, %edx
callq 0x11bc0
movq -0x18(%rbp), %rdi
callq 0x190a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1b0ad
movq -0x18(%rbp), %rdi
movq -0x138(%rbp), %rsi
movl $0x11, %edx
callq 0x11bc0
movq -0x18(%rbp), %rdi
callq 0x190a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x1b0ab
movq -0x18(%rbp), %rdi
callq 0x122b0
movl $0x2, -0x24(%rbp)
jmp 0x1b0ad
jmp 0x1b0af
jmp 0x1b0b6
jmp 0x1afe5
jmp 0x1b0b8
jmp 0x1b0ba
movl -0x24(%rbp), %eax
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopw %cs:(%rax,%rax)