// File: /workspace/github_c_makefile_star2_O1/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
movl $0xfffffffe, %r15d      # imm = 0xFFFFFFFE
cmpq $0x0, 0x109e2(%rip)     # 0x2bf70
je 0x1b5ca
movq 0x109d9(%rip), %rdi     # 0x2bf70
testq %rdi, %rdi
je 0x1b5a1
callq 0x1b2da
xorl %eax, %eax
movq %rax, 0x109c6(%rip)     # 0x2bf70
movq %rax, 0x109af(%rip)     # 0x2bf60
movq %rax, 0x109b0(%rip)     # 0x2bf68
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r9, %rbp
movq %r8, %r14
movq %rcx, %rbx
movq %rdi, %r13
movl %esi, 0x14(%rsp)
movq %rdx, 0x20(%rsp)
testq %rdi, %rdi
je 0x1b710
movq %r13, %rdi
callq 0x5160
cmpl $0x0, 0xed19(%rip)      # 0x2a310
movl $0xfffffffd, %r15d      # imm = 0xFFFFFFFD
js 0x1b725
testb $0x1, 0x1094e(%rip)     # 0x2bf58
jne 0x1b725
movq %rax, %r12
movq %rbx, 0x8(%rsp)
movq 0xe9a1(%rip), %rax      # 0x29fc0
movq (%rax), %rbx
callq 0xeb2f
leaq 0x7f6b(%rip), %rsi      # 0x23599
movq %rbx, %rdi
movq %rax, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0xf663(%rip), %rax      # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x1b669
callq 0xeb2f
leaq 0x7f40(%rip), %rsi      # 0x23599
movq %rbx, %rdi
movq %rax, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x52c0
cmpq $0x3e, %r12
movq %rbp, 0x18(%rsp)
ja 0x1b691
leaq 0x10935(%rip), %rbx     # 0x2bfb0
movq %rbx, %rdi
movq %r13, %rsi
callq 0x50a0
movb $0xd, (%r12,%rbx)
incq %r12
movq %rbx, %r13
xorl %ebp, %ebp
movq %r13, %r15
addq %rbp, %r15
movq %r12, %rbx
subq %rbp, %rbx
movl 0xec6b(%rip), %edi      # 0x2a310
movq %r15, %rsi
movq %rbx, %rdx
callq 0x5100
testq %rax, %rax
jns 0x1b6c1
callq 0x5070
cmpl $0x4, (%rax)
je 0x1b69f
jmp 0x1b715
addq %rax, %rbp
cmpq %r12, %rbp
jb 0x1b693
leaq 0x108e0(%rip), %rax     # 0x2bfb0
cmpq %rax, %r13
movq 0x18(%rsp), %rbp
je 0x1b839
leaq 0x7ec1(%rip), %rbx      # 0x235a6
movl 0xec25(%rip), %edi      # 0x2a310
movl $0x1, %edx
movq %rbx, %rsi
callq 0x5100
movq %rax, %r15
testq %rax, %rax
jns 0x1b708
callq 0x5070
cmpl $0x4, (%rax)
je 0x1b6e5
sarq $0x3f, %r15
jmp 0x1b720
xorl %r15d, %r15d
jmp 0x1b725
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq 0x18(%rsp), %rbp
movq 0x8(%rsp), %rbx
testl %r15d, %r15d
js 0x1b7af
movl 0x14(%rsp), %eax
movl %eax, 0x1086c(%rip)     # 0x2bfa4
movq 0x20(%rsp), %rax
movq %rax, 0x1081c(%rip)     # 0x2bf60
movq %rbx, 0x1081d(%rip)     # 0x2bf68
movl $0x1, %edi
movl $0x18, %esi
callq 0x5290
testq %r14, %r14
movq %rax, 0x1080c(%rip)     # 0x2bf70
movl $0x3a98, %ebx           # imm = 0x3A98
cmovnel %r14d, %ebx
leaq 0xf504(%rip), %r14      # 0x2ac78
leaq 0xf4d5(%rip), %r15      # 0x2ac50
movq 0x107ee(%rip), %rdi     # 0x2bf70
cmpq $0x0, 0x8(%rdi)
jne 0x1b7dc
testb $0x1, 0x107c8(%rip)     # 0x2bf58
jne 0x1b7dc
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0xedc5
cmpl $0x6e, %eax
jne 0x1b77b
movl $0xfffffffc, %r15d      # imm = 0xFFFFFFFC
jmp 0x1b590
callq 0x5070
movl (%rax), %ebx
movl %ebx, %edi
callq 0x5530
leaq 0x553f(%rip), %rdi      # 0x20d03
leaq 0x7db2(%rip), %rsi      # 0x2357d
movl %ebx, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x51a0
jmp 0x1b590
testq %rbp, %rbp
je 0x1b7ff
movq 0x10(%rdi), %rax
testq %rax, %rax
je 0x1b806
xorl %edx, %edx
movq %rax, %rcx
movq (%rax), %rax
movq %rdx, (%rcx)
movq %rcx, %rdx
testq %rax, %rax
jne 0x1b7ec
jmp 0x1b808
callq 0x1b2da
jmp 0x1b817
xorl %ecx, %ecx
movq %rcx, 0x10(%rdi)
movq 0x1075d(%rip), %rax     # 0x2bf70
movq %rax, (%rbp)
movq $0x0, 0x1074e(%rip) # 0x2bf70
movzbl 0x1072f(%rip), %eax     # 0x2bf58
xorl $0x1, %eax
leal (%rax,%rax,2), %r15d
addl $-0x3, %r15d
jmp 0x1b590
xorl %r15d, %r15d
jmp 0x1b720