// File: /workspace/github_c_makefile_star2_O3/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 0xa4e6(%rip), %rdi      # 0x2309c
leaq 0xa4e8(%rip), %rsi      # 0x230a5
movq %r14, %rdx
callq 0x1afa9
movl %eax, %ebp
testl %eax, %eax
setne %al
movq (%r14), %rdi
testq %rdi, %rdi
sete %cl
movl $0x1, %r14d
orb %al, %cl
jne 0x18c16
xorl %ebp, %ebp
cmpq $0x0, 0x8(%rdi)
je 0x18c11
cmpl $0x0, (%rdi)
je 0x18c11
callq 0x1b42d
xorl %ebp, %ebp
cmpl $0x9, %eax
jg 0x18c04
testl %eax, %eax
je 0x18c2e
cmpl $0x3, %eax
je 0x18c0e
jmp 0x18c11
cmpl $0xa, %eax
je 0x18c0e
cmpl $0xd, %eax
jne 0x18c11
xorl %r14d, %r14d
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x18c20
callq 0x1aeb5
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 0x1b96c
testl %eax, %eax
js 0x18cbf
leaq 0x18(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1ba5e
movl %eax, %ebp
testl %eax, %eax
js 0x18c11
movq 0x10(%rsp), %r14
leaq 0xa43f(%rip), %rsi      # 0x230ac
movq %r14, %rdi
callq 0x52a0
testl %eax, %eax
je 0x18cc6
leaq 0xa434(%rip), %rsi      # 0x230b4
movq %r14, %rdi
callq 0x52a0
testl %eax, %eax
je 0x18cd1
leaq 0xa429(%rip), %rsi      # 0x230bc
movq %r14, %rdi
callq 0x52a0
testl %eax, %eax
je 0x18cdc
leaq 0x7c88(%rip), %rsi      # 0x2092e
movq %r14, %rdi
callq 0x52a0
xorl %r14d, %r14d
testl %eax, %eax
sete %r14b
addl %r14d, %r14d
jmp 0x18c11
movl %eax, %ebp
jmp 0x18c11
movl $0x3, %r14d
jmp 0x18c11
movl $0x4, %r14d
jmp 0x18c11
movl $0x5, %ebp
jmp 0x18c23