// File: /workspace/github_c_makefile_star2_O1/Carton32[P]quectel-CM/atc.c
// Function: requestGetSIMStatus
static int requestGetSIMStatus(SIM_Status *pSIMStatus)
{
    int err;
    ATResponse *p_response = NULL;
    char *cpinLine;
    char *cpinResult;
    int ret = SIM_NOT_READY;

    err = at_send_command_singleline("AT+CPIN?", "+CPIN:", &p_response);
    if (at_response_error(err, p_response))
        goto done;

    switch (at_get_cme_error(p_response))
    {
    case CME_SUCCESS:
        break;

    case CME_SIM_NOT_INSERTED:
    case CME_OPERATION_NOT_ALLOWED:
    case CME_FAILURE:
        ret = SIM_ABSENT;
        goto done;

    default:
        ret = SIM_NOT_READY;
        goto done;
    }

    cpinLine = p_response->p_intermediates->line;
    err = at_tok_start (&cpinLine);

    if (err < 0)
    {
        ret = SIM_NOT_READY;
        goto done;
    }

    err = at_tok_nextstr(&cpinLine, &cpinResult);

    if (err < 0)
    {
        ret = SIM_NOT_READY;
        goto done;
    }

    if (0 == strcmp (cpinResult, "SIM PIN"))
    {
        ret = SIM_PIN;
        goto done;
    }
    else if (0 == strcmp (cpinResult, "SIM PUK"))
    {
        ret = SIM_PUK;
        goto done;
    }
    else if (0 == strcmp (cpinResult, "PH-NET PIN"))
    {
        return SIM_NETWORK_PERSONALIZATION;
    }
    else if (0 != strcmp (cpinResult, "READY"))
    {
        /* we're treating unsupported lock types as "sim absent" */
        ret = SIM_ABSENT;
        goto done;
    }

    ret = SIM_READY;

done:
    safe_at_response_free(p_response);
    *pSIMStatus = ret;
    return err;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %r14
movq $0x0, (%r14)
leaq 0xa253(%rip), %rdi      # 0x2307c
leaq 0xa255(%rip), %rsi      # 0x23085
movq %r14, %rdx
callq 0x1b3c6
movl %eax, %ebp
testl %eax, %eax
setne %al
movq (%r14), %rdi
testq %rdi, %rdi
sete %cl
orb %al, %cl
movl $0x1, %r14d
jne 0x18e84
xorl %ebp, %ebp
cmpq $0x0, 0x8(%rdi)
je 0x18e84
cmpl $0x0, (%rdi)
je 0x18e84
callq 0x1b841
xorl %ebp, %ebp
cmpl $0x9, %eax
jg 0x18e77
testl %eax, %eax
je 0x18eaa
cmpl $0x3, %eax
je 0x18e81
jmp 0x18e84
cmpl $0xa, %eax
je 0x18e81
cmpl $0xd, %eax
jne 0x18e84
xorl %r14d, %r14d
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x18e9c
callq 0x1b2da
movq $0x0, 0x8(%rsp)
movl %r14d, (%rbx)
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
leaq 0x18(%rsp), %rdi
movq %rax, (%rdi)
callq 0x1bcbc
testl %eax, %eax
js 0x18f3b
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1bdae
movl %eax, %ebp
testl %eax, %eax
js 0x18e84
movq 0x10(%rsp), %r14
leaq 0xa1a3(%rip), %rsi      # 0x2308c
movq %r14, %rdi
callq 0x52a0
testl %eax, %eax
je 0x18f42
leaq 0xa198(%rip), %rsi      # 0x23094
movq %r14, %rdi
callq 0x52a0
testl %eax, %eax
je 0x18f4d
leaq 0xa18d(%rip), %rsi      # 0x2309c
movq %r14, %rdi
callq 0x52a0
testl %eax, %eax
je 0x18f58
leaq 0x7a10(%rip), %rsi      # 0x20932
movq %r14, %rdi
callq 0x52a0
xorl %r14d, %r14d
testl %eax, %eax
sete %r14b
addl %r14d, %r14d
jmp 0x18e84
movl %eax, %ebp
jmp 0x18e84
movl $0x3, %r14d
jmp 0x18e84
movl $0x4, %r14d
jmp 0x18e84
movl $0x5, %ebp
jmp 0x18e9f