// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, (%r14)
leaq 0x966d(%rip), %rdi      # 0x210bc
leaq 0x966f(%rip), %rsi      # 0x210c5
movq %r14, %rdx
callq 0x19e06
movl %eax, %ebp
testl %eax, %eax
setne %al
movq (%r14), %rdi
testq %rdi, %rdi
sete %cl
pushq $0x1
popq %r14
orb %al, %cl
jne 0x17aa6
xorl %ebp, %ebp
cmpq $0x0, 0x8(%rdi)
je 0x17aa1
cmpl $0x0, (%rdi)
je 0x17aa1
callq 0x1a24f
testl %eax, %eax
je 0x17abe
xorl %ebp, %ebp
cmpl $0x3, %eax
je 0x17a9e
cmpl $0xa, %eax
je 0x17a9e
cmpl $0xd, %eax
jne 0x17aa1
xorl %r14d, %r14d
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x17ab0
callq 0x19d1e
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 0x1a678
testl %eax, %eax
js 0x17b4f
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1a755
movl %eax, %ebp
testl %eax, %eax
js 0x17aa1
movq 0x10(%rsp), %r14
leaq 0x95cf(%rip), %rsi      # 0x210cc
movq %r14, %rdi
callq 0x52a0
testl %eax, %eax
je 0x17b56
leaq 0x95c4(%rip), %rsi      # 0x210d4
movq %r14, %rdi
callq 0x52a0
testl %eax, %eax
je 0x17b5a
leaq 0x95b9(%rip), %rsi      # 0x210dc
movq %r14, %rdi
callq 0x52a0
testl %eax, %eax
je 0x17b63
leaq 0x6df8(%rip), %rsi      # 0x1e92e
movq %r14, %rdi
callq 0x52a0
xorl %r14d, %r14d
testl %eax, %eax
sete %r14b
addl %r14d, %r14d
jmp 0x17aa1
movl %eax, %ebp
jmp 0x17aa1
pushq $0x3
jmp 0x17b5c
pushq $0x4
popq %r14
jmp 0x17aa1
pushq $0x5
popq %rbp
jmp 0x17ab3