// File: /workspace/github_c_makefile_star2_O3/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, %r13
movq 0x10ddf(%rip), %rdi     # 0x2bf70
movl $0xfffffffe, %r15d      # imm = 0xFFFFFFFE
testq %rdi, %rdi
jne 0x1b3ab
movq %r9, %rbp
movq %r8, %r14
movl %esi, 0xc(%rsp)
movq %rdx, 0x18(%rsp)
movq %rcx, 0x20(%rsp)
testq %r13, %r13
je 0x1b2e5
movq %r13, %rdi
callq 0x5160
cmpl $0x0, 0xf144(%rip)      # 0x2a310
movl $0xfffffffd, %r15d      # imm = 0xFFFFFFFD
js 0x1b377
testb $0x1, 0x10d79(%rip)     # 0x2bf58
jne 0x1b377
movq %rax, %r12
movq 0xedd1(%rip), %rax      # 0x29fc0
movq (%rax), %rbx
callq 0xea3b
leaq 0x83b8(%rip), %rsi      # 0x235b6
movq %rbx, %rdi
movq %rax, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x52c0
leaq 0xfa93(%rip), %rax      # 0x2aca8
movq (%rax), %rbx
testq %rbx, %rbx
je 0x1b239
callq 0xea3b
leaq 0x838d(%rip), %rsi      # 0x235b6
movq %rbx, %rdi
movq %rax, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x52c0
cmpq $0x3e, %r12
movq %rbp, 0x10(%rsp)
ja 0x1b261
leaq 0x10d65(%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 0xf09b(%rip), %edi      # 0x2a310
movq %r15, %rsi
movq %rbx, %rdx
callq 0x5100
testq %rax, %rax
jns 0x1b294
callq 0x5070
cmpl $0x4, (%rax)
je 0x1b26f
jmp 0x1b371
addq %rax, %rbp
cmpq %r12, %rbp
jb 0x1b263
leaq 0x10d0d(%rip), %rax     # 0x2bfb0
cmpq %rax, %r13
movq 0x10(%rsp), %rbp
je 0x1b2e5
leaq 0x830f(%rip), %rbx      # 0x235c3
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movl 0xf050(%rip), %edi      # 0x2a310
movl $0x1, %edx
movq %rbx, %rsi
callq 0x5100
testq %rax, %rax
js 0x1b2d6
je 0x1b2ba
jmp 0x1b2e5
callq 0x5070
cmpl $0x4, (%rax)
je 0x1b2ba
jmp 0x1b377
movl 0xc(%rsp), %eax
movl %eax, 0x10cb5(%rip)     # 0x2bfa4
movq 0x18(%rsp), %rax
movq %rax, 0x10c65(%rip)     # 0x2bf60
movq 0x20(%rsp), %rax
movq %rax, 0x10c61(%rip)     # 0x2bf68
movl $0x1, %edi
movl $0x18, %esi
callq 0x5290
testq %r14, %r14
movq %rax, 0x10c50(%rip)     # 0x2bf70
movl $0x3a98, %ebx           # imm = 0x3A98
cmovnel %r14d, %ebx
leaq 0xf948(%rip), %r14      # 0x2ac78
leaq 0xf919(%rip), %r15      # 0x2ac50
movq 0x10c32(%rip), %rdi     # 0x2bf70
cmpq $0x0, 0x8(%rdi)
movb 0x10c0f(%rip), %al      # 0x2bf58
jne 0x1b3d9
testb $0x1, %al
jne 0x1b3d9
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %edx
callq 0xecc5
cmpl $0x6e, %eax
jne 0x1b337
movl $0xfffffffc, %r15d      # imm = 0xFFFFFFFC
jmp 0x1b39f
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
callq 0x5070
movl (%rax), %ebx
movl %ebx, %edi
callq 0x5530
leaq 0x5973(%rip), %rdi      # 0x20cff
leaq 0x8207(%rip), %rsi      # 0x2359a
movl %ebx, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x51a0
movq 0x10bca(%rip), %rdi     # 0x2bf70
testq %rdi, %rdi
je 0x1b3b0
callq 0x1aeb5
xorl %eax, %eax
movq %rax, 0x10bb7(%rip)     # 0x2bf70
movq %rax, 0x10ba0(%rip)     # 0x2bf60
movq %rax, 0x10ba1(%rip)     # 0x2bf68
movl %r15d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rbp, %rbp
je 0x1b403
movq 0x10(%rdi), %rdx
xorl %ecx, %ecx
testq %rdx, %rdx
je 0x1b410
movq %rcx, %rsi
movq %rdx, %rcx
movq (%rdx), %rdx
movq %rsi, (%rcx)
testq %rdx, %rdx
jne 0x1b3e9
movq 0x10b6f(%rip), %rdx     # 0x2bf70
jmp 0x1b413
callq 0x1aeb5
movb 0x10b4a(%rip), %al      # 0x2bf58
jmp 0x1b41b
movq %rdi, %rdx
movq %rcx, 0x10(%rdi)
movq %rdx, (%rbp)
notb %al
movzbl %al, %eax
andl $0x1, %eax
leal (%rax,%rax,2), %r15d
addl $-0x3, %r15d
jmp 0x1b3b0