// File: /workspace/github_cpp_makefile_star2_O2/rofl0r[P]ascc/cs_parser.cpp
// Function: accept_literal_or_constant_value(int, int&, bool, char const*)
int accept_literal_or_constant_value(int fromSym, int &theValue, bool isNegative, const char *errorMsg) {
  if (sym.get_type(fromSym) == SYM_LITERALVALUE) {

    // Prepend '-' so we can parse -2147483648
    std::string literalStrValue = std::string(sym.get_name(fromSym));
    if (isNegative) {
        literalStrValue = '-' + literalStrValue;
    }

    errno = 0;
    char *endptr = 0;
    const long longValue = strtol(literalStrValue.c_str(), &endptr, 10);

    if ((longValue == LONG_MIN || longValue == LONG_MAX) && errno == ERANGE) {
        cc_error("Could not parse integer symbol '%s' because of overflow.", friendly_int_symbol(fromSym, isNegative).c_str());
        return -1;
    }
    if (endptr[0] != 0) {
        cc_error("Could not parse integer symbol '%s' because the whole buffer wasn't converted.", friendly_int_symbol(fromSym, isNegative).c_str());
        return -1;
    }
    if (longValue > INT_MAX || longValue < INT_MIN) {
        cc_error("Could not parse integer symbol '%s' because of overflow.", friendly_int_symbol(fromSym, isNegative).c_str());
        return -1;
    }

    theValue = static_cast<int>(longValue);
  }
  else if (sym.get_type(fromSym) == SYM_CONSTANT) {
    theValue = sym.entries[fromSym].soffs;
    if (isNegative) {
        theValue = -theValue;
    }
  }
  else {
    cc_error((char*)errorMsg);
    return -1;
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %r14
movl %edi, %ebx
leaq 0x1fb58(%rip), %rdi     # 0x256f0
movl %ebx, %esi
callq 0xfe60
cmpl $0x13, %eax
jne 0x5c5b
leaq 0x1fb41(%rip), %rdi     # 0x256f0
movl %ebx, %esi
callq 0x10b48
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rdx
movq %rax, %rsi
callq 0xe8d6
testb %bpl, %bpl
je 0x5bf9
leaq 0x8(%rsp), %rdi
pushq $0x2d
popq %rsi
leaq 0x30(%rsp), %rdx
callq 0xe911
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x33d0
movq %r15, %rdi
callq 0x31a0
callq 0x3060
movq %rax, %r15
andl $0x0, (%rax)
leaq 0x28(%rsp), %rsi
andq $0x0, (%rsi)
movq 0x30(%rsp), %rdi
pushq $0xa
popq %rdx
callq 0x3460
movabsq $-0x7fffffffffffffff, %rcx # imm = 0x8000000000000001
addq %rax, %rcx
cmpq $0x1, %rcx
ja 0x5c99
cmpl $0x22, (%r15)
jne 0x5c99
movzbl %bpl, %edx
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x5b0f
movq 0x8(%rsp), %rsi
leaq 0x12e7a(%rip), %rdi     # 0x18ac9
xorl %eax, %eax
callq 0xf258
jmp 0x5cff
leaq 0x1fa8e(%rip), %r12     # 0x256f0
movq %r12, %rdi
movl %ebx, %esi
callq 0xfe60
cmpl $0x14, %eax
jne 0x5cc8
movslq %ebx, %rax
movq 0x28(%r12), %rcx
imulq $0xb0, %rax, %rax
movl 0x34(%rcx,%rax), %ecx
movl %ecx, (%r14)
xorl %eax, %eax
testb %bpl, %bpl
je 0x5d16
negl %ecx
movl %ecx, (%r14)
jmp 0x5d16
movq 0x28(%rsp), %rcx
cmpb $0x0, (%rcx)
je 0x5cd4
movzbl %bpl, %edx
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x5b0f
movq 0x8(%rsp), %rsi
leaq 0x12e43(%rip), %rdi     # 0x18b02
xorl %eax, %eax
callq 0xf258
jmp 0x5cff
movq %r15, %rdi
xorl %eax, %eax
callq 0xf258
jmp 0x5d13
movslq %eax, %rcx
cmpq %rax, %rcx
je 0x5d23
movzbl %bpl, %edx
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x5b0f
movq 0x8(%rsp), %rsi
leaq 0x12dd1(%rip), %rdi     # 0x18ac9
xorl %eax, %eax
callq 0xf258
leaq 0x8(%rsp), %rdi
callq 0x31a0
leaq 0x30(%rsp), %rdi
callq 0x31a0
pushq $-0x1
popq %rax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %eax, (%r14)
leaq 0x30(%rsp), %rdi
callq 0x31a0
xorl %eax, %eax
jmp 0x5d16
jmp 0x5d3c
jmp 0x5d4d
jmp 0x5d3c
jmp 0x5d4d
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x31a0
jmp 0x5d50
jmp 0x5d4d
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x31a0
movq %rbx, %rdi
callq 0x3560