// File: /workspace/github_c_makefile_star2_O0/schroeder-lvb[P]sissm/src/rdrv.c
// Function: rdrvCommand
static int _rdrvCommand( rdrvObj *rPtr, int msgType, char *rconCmd, char *rconResp, int *bytesRead )
{
    int n, exitFlag = 0, retryCount = 0, errCode = 0;

    *bytesRead = 0;

    while ( !exitFlag ) {

        // if no handle (initial or reset condition)
        // try to open the connection.
        //
        if ( rPtr->isConnected == 0 ) {

            // (re-)connect
            //
            rdrvConnect( rPtr );             // ignore the return error
            usleep( RDRV_DELAY_CONN2XMT );
        }

        if ( rPtr->isConnected ) {
            errCode = rdrvSend( rPtr, msgType, rconCmd );
            usleep( RDRV_DELAY_XMT2RCV );
            if ( 0 == errCode ) {
                n = rdrvReceive( rPtr, rconResp );
                if (n > 0)  {
                    *bytesRead = n;
                    exitFlag = 1;
                }
                else {
                    *bytesRead = 0;
                    errCode = 1;
                }
            }
            if ( 0 != errCode ) {
                // disconnect and reconnect
                //
                logPrintf( LOG_LEVEL_CRITICAL, "rdrv", "Warning: RCON comms lost - re-opening with new channel");
                rdrvDisconnect( rPtr );  // ignore this error
                usleep( RDRV_DELAY_RETRY_DISC2CONN );
                rdrvConnect( rPtr );     // ignore this error
                usleep( RDRV_DELAY_RETRY_CONN2XMT );
            }
        }

        ++retryCount;
        if ( retryCount > 3 ) {
            exitFlag = 1;
        }
    }
    if ( retryCount > 3 ) errCode = 2;
    return( errCode );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
cmpl $0x0, -0x30(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xa07c
jmp 0xa16d
movq -0x8(%rbp), %rax
cmpl $0x0, 0x16c(%rax)
jne 0xa09c
movq -0x8(%rbp), %rdi
callq 0x9ad0
movl $0x3d090, %edi          # imm = 0x3D090
callq 0x83c0
movq -0x8(%rbp), %rax
cmpl $0x0, 0x16c(%rax)
je 0xa152
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
callq 0x9900
movl %eax, -0x38(%rbp)
movl $0x2710, %edi           # imm = 0x2710
callq 0x83c0
xorl %eax, %eax
cmpl -0x38(%rbp), %eax
jne 0xa10c
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x9a10
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jle 0xa0f9
movl -0x2c(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x30(%rbp)
jmp 0xa10a
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movl $0x1, -0x38(%rbp)
jmp 0xa10c
xorl %eax, %eax
cmpl -0x38(%rbp), %eax
je 0xa150
xorl %edi, %edi
leaq 0x1948e(%rip), %rsi     # 0x235aa
leaq 0x19585(%rip), %rdx     # 0x236a8
movb $0x0, %al
callq 0x21bf0
movq -0x8(%rbp), %rdi
callq 0x9e10
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x83c0
movq -0x8(%rbp), %rdi
callq 0x9ad0
movl $0xf4240, %edi          # imm = 0xF4240
callq 0x83c0
jmp 0xa152
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl $0x3, -0x34(%rbp)
jle 0xa168
movl $0x1, -0x30(%rbp)
jmp 0xa06a
cmpl $0x3, -0x34(%rbp)
jle 0xa17a
movl $0x2, -0x38(%rbp)
movl -0x38(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)