// File: /workspace/github_c_makefile_star2_O2/Carton32[P]quectel-CM/atchannel.c
// Function: at_send_command_full_nolock
static int at_send_command_full_nolock (const char *command, ATCommandType type,
                    const char *responsePrefix, const char *smspdu,
                    long long timeoutMsec, ATResponse **pp_outResponse)
{
    int err = 0;

    if (!timeoutMsec)
        timeoutMsec = 15000;

    if(sp_response != NULL) {
        err = AT_ERROR_COMMAND_PENDING;
        goto error;
    }

    if (command != NULL)
        err = writeline (command);

    if (err < 0) {
        printf("%s errno: %d (%s)\n", __func__, errno, strerror(errno));
        goto error;
    }

    s_type = type;
    s_responsePrefix = responsePrefix;
    s_smsPDU = smspdu;
    sp_response = at_response_new();

    while (sp_response->finalResponse == NULL && s_readerClosed == 0) {
        err = pthread_cond_timeout_np(&cm_command_cond, &cm_command_mutex, timeoutMsec);

        if (err == ETIMEDOUT) {
            err = AT_ERROR_TIMEOUT;
            goto error;
        }
    }

    if (pp_outResponse == NULL) {
        at_response_free(sp_response);
    } else {
        /* line reader stores intermediate responses in reverse order */
        reverseIntermediates(sp_response);
        *pp_outResponse = sp_response;
    }

    sp_response = NULL;

    if(s_readerClosed > 0) {
        err = AT_ERROR_CHANNEL_CLOSED;
        goto error;
    }

    err = 0;
error:
    clearPendingCommand();

    return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movq 0x10fac(%rip), %rdi     # 0x2af70
testq %rdi, %rdi
je 0x19fd1
pushq $-0x2
popq %rbp
jmp 0x1a1d7
movq %r9, %r12
movq %r8, %r14
movq %rcx, %r13
movl %esi, 0x4(%rsp)
movq %rdx, 0x20(%rsp)
testq %rbx, %rbx
je 0x1a155
movq %rbx, %rdi
callq 0x5160
cmpl $0x0, 0xf315(%rip)      # 0x29310
pushq $-0x3
popq %rbp
js 0x1a12b
testb $0x1, 0x10f4d(%rip)     # 0x2af58
jne 0x1a12b
movq %rax, %rbp
movq 0xef9d(%rip), %rax      # 0x28fb8
movq (%rax), %r15
callq 0xe343
leaq 0x75e4(%rip), %rsi      # 0x2160e
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0xfc67(%rip), %rax      # 0x29ca8
movq (%rax), %r15
testq %r15, %r15
je 0x1a065
callq 0xe343
leaq 0x75b9(%rip), %rsi      # 0x2160e
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0x10f44(%rip), %rcx     # 0x2afb0
movq %rbp, %r15
cmpq $0x3e, %rbp
movq %r12, 0x18(%rsp)
movq %r13, 0x10(%rsp)
movq %r14, 0x8(%rsp)
ja 0x1a0a5
leaq 0x10f25(%rip), %rdi     # 0x2afb0
movq %rbx, %rsi
callq 0x50a0
leaq 0x10f16(%rip), %rcx     # 0x2afb0
movb $0xd, (%r15,%rcx)
incq %r15
movq %rcx, %rbx
xorl %r13d, %r13d
pushq $-0x1
popq %rbp
movq %r15, %r14
subq %r13, %r15
jbe 0x1a0e8
leaq (%rbx,%r13), %r12
movl 0xf253(%rip), %edi      # 0x29310
movq %r12, %rsi
movq %r15, %rdx
callq 0x5100
testq %rax, %rax
jns 0x1a0d9
callq 0x5070
cmpl $0x4, (%rax)
je 0x1a0b7
jmp 0x1a12b
addq %rax, %r13
movq %r14, %r15
leaq 0x10eca(%rip), %rcx     # 0x2afb0
jmp 0x1a0ab
cmpq %rcx, %rbx
movq 0x18(%rsp), %r12
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r14
je 0x1a155
leaq 0x7518(%rip), %rbx      # 0x2161b
pushq $0x1
popq %r15
movl 0xf203(%rip), %edi      # 0x29310
movq %rbx, %rsi
movq %r15, %rdx
callq 0x5100
testq %rax, %rax
js 0x1a121
je 0x1a107
jmp 0x1a155
callq 0x5070
cmpl $0x4, (%rax)
je 0x1a107
callq 0x5070
movl (%rax), %ebx
movl %ebx, %edi
callq 0x5540
leaq 0x4bd5(%rip), %rdi      # 0x1ed15
leaq 0x74ab(%rip), %rsi      # 0x215f2
movl %ebx, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x51a0
jmp 0x1a1cb
movl 0x4(%rsp), %eax
movl %eax, 0x10e45(%rip)     # 0x2afa4
movq 0x20(%rsp), %rax
movq %rax, 0x10df5(%rip)     # 0x2af60
movq %r13, 0x10df6(%rip)     # 0x2af68
pushq $0x1
popq %rdi
pushq $0x18
popq %rsi
callq 0x5290
testq %r14, %r14
movl $0x3a98, %ebx           # imm = 0x3A98
cmovnel %r14d, %ebx
movq %rax, 0x10de0(%rip)     # 0x2af70
leaq 0xfae1(%rip), %r14      # 0x29c78
leaq 0xfab2(%rip), %r15      # 0x29c50
pushq $-0x4
popq %rbp
movq 0x10dc8(%rip), %rdi     # 0x2af70
cmpq $0x0, 0x8(%rdi)
movb 0x10da5(%rip), %al      # 0x2af58
jne 0x1a205
testb $0x1, %al
jne 0x1a205
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0xe5ba
cmpl $0x6e, %eax
jne 0x1a1a1
movq 0x10d9e(%rip), %rdi     # 0x2af70
testq %rdi, %rdi
je 0x1a1dc
callq 0x19d1e
andq $0x0, 0x10d8c(%rip)     # 0x2af70
andq $0x0, 0x10d74(%rip)     # 0x2af60
andq $0x0, 0x10d74(%rip)     # 0x2af68
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r12, %r12
je 0x1a234
movq 0x10(%rdi), %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
je 0x1a223
movq (%rdx), %rsi
movq %rcx, (%rdx)
movq %rdx, %rcx
movq %rsi, %rdx
jmp 0x1a210
movq %rcx, 0x10(%rdi)
movq 0x10d42(%rip), %rcx     # 0x2af70
movq %rcx, (%r12)
jmp 0x1a23f
callq 0x19d1e
movb 0x10d19(%rip), %al      # 0x2af58
notb %al
movzbl %al, %eax
andl $0x1, %eax
leal (%rax,%rax,2), %ebp
addl $-0x3, %ebp
jmp 0x1a1dc