// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x20(%rbp)
movl $0x1, -0x34(%rbp)
leaq 0xc80a(%rip), %rdi      # 0x3031c
leaq 0xc80c(%rip), %rsi      # 0x30325
leaq -0x20(%rbp), %rdx
callq 0x26e80
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x23b46
cmpq $0x0, -0x20(%rbp)
je 0x23b46
movq -0x20(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x23b46
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x23b4b
jmp 0x23c6e
movq -0x20(%rbp), %rdi
callq 0x27390
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0xd, %eax
ja 0x23b81
movq -0x40(%rbp), %rax
leaq 0xc63e(%rip), %rcx      # 0x301a8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x23b8d
movl $0x0, -0x34(%rbp)
jmp 0x23c6e
movl $0x1, -0x34(%rbp)
jmp 0x23c6e
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x284e0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x23bbb
movl $0x1, -0x34(%rbp)
jmp 0x23c6e
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x286d0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jge 0x23bdd
movl $0x1, -0x34(%rbp)
jmp 0x23c6e
movq -0x30(%rbp), %rdi
leaq 0xc744(%rip), %rsi      # 0x3032c
callq 0x52a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x23bfe
movl $0x3, -0x34(%rbp)
jmp 0x23c6e
movq -0x30(%rbp), %rdi
leaq 0xc72b(%rip), %rsi      # 0x30334
callq 0x52a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x23c1f
movl $0x4, -0x34(%rbp)
jmp 0x23c6e
movq -0x30(%rbp), %rdi
leaq 0xc712(%rip), %rsi      # 0x3033c
callq 0x52a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x23c40
movl $0x5, -0x4(%rbp)
jmp 0x23c95
movq -0x30(%rbp), %rdi
leaq 0x9ec3(%rip), %rsi      # 0x2db0e
callq 0x52a0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x23c61
movl $0x0, -0x34(%rbp)
jmp 0x23c6e
jmp 0x23c63
jmp 0x23c65
jmp 0x23c67
movl $0x2, -0x34(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x23c86
movq -0x20(%rbp), %rdi
callq 0x26d20
movq $0x0, -0x20(%rbp)
movl -0x34(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nop