// File: /workspace/github_cpp_makefile_star2_O1/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 0x1f61b(%rip), %rdi     # 0x256e0
movl %ebx, %esi
callq 0x111aa
cmpl $0x13, %eax
jne 0x61a4
leaq 0x1f604(%rip), %rdi     # 0x256e0
movl %ebx, %esi
callq 0x1263e
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rdx
movq %rax, %rsi
callq 0xfa64
testb %bpl, %bpl
je 0x613a
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rdx
movl $0x2d, %esi
callq 0xfaa1
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x33f0
movq (%r15), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x613a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3320
callq 0x3070
movq %rax, %r15
movl $0x0, (%rax)
leaq 0x28(%rsp), %rsi
movq $0x0, (%rsi)
movq 0x30(%rsp), %rdi
movl $0xa, %edx
callq 0x3460
movabsq $-0x7fffffffffffffff, %rcx # imm = 0x8000000000000001
addq %rax, %rcx
cmpq $0x1, %rcx
ja 0x61e3
cmpl $0x22, (%r15)
jne 0x61e3
movzbl %bpl, %edx
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x5fd4
movq 0x8(%rsp), %rsi
leaq 0x14951(%rip), %rdi     # 0x1aae9
xorl %eax, %eax
callq 0x10418
jmp 0x624e
leaq 0x1f535(%rip), %r12     # 0x256e0
movq %r12, %rdi
movl %ebx, %esi
callq 0x111aa
cmpl $0x14, %eax
jne 0x6212
movslq %ebx, %rax
movq 0x28(%r12), %rcx
imulq $0xb0, %rax, %rax
movl 0x34(%rcx,%rax), %eax
movl %eax, (%r14)
testb %bpl, %bpl
je 0x628f
negl %eax
movl %eax, (%r14)
jmp 0x628f
movq 0x28(%rsp), %rcx
cmpb $0x0, (%rcx)
je 0x6223
movzbl %bpl, %edx
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x5fd4
movq 0x8(%rsp), %rsi
leaq 0x14919(%rip), %rdi     # 0x1ab22
xorl %eax, %eax
callq 0x10418
jmp 0x624e
movq %r15, %rdi
xorl %eax, %eax
callq 0x10418
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x6291
movslq %eax, %rcx
cmpq %rax, %rcx
je 0x629e
movzbl %bpl, %edx
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x5fd4
movq 0x8(%rsp), %rsi
leaq 0x148a2(%rip), %rdi     # 0x1aae9
xorl %eax, %eax
callq 0x10418
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6269
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3320
xorl %ebx, %ebx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6286
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3320
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %bl, %bl
je 0x6291
xorl %eax, %eax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %eax, (%r14)
movb $0x1, %bl
jmp 0x626b
jmp 0x62ad
jmp 0x62cf
jmp 0x62ad
jmp 0x62cf
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x62d2
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3320
jmp 0x62d2
jmp 0x62cf
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x62ed
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3320
movq %rbx, %rdi
callq 0x3560