// File: /workspace/github_cpp_makefile_star2_O3/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 0x1f6a5(%rip), %rdi     # 0x256e0
movl %ebx, %esi
callq 0x1106e
cmpl $0x13, %eax
jne 0x611a
leaq 0x1f68e(%rip), %rdi     # 0x256e0
movl %ebx, %esi
callq 0x124c6
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %rdx
movq %rax, %rsi
callq 0xf964
testb %bpl, %bpl
je 0x60b0
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rdx
movl $0x2d, %esi
callq 0xf9a1
leaq 0x30(%rsp), %rdi
leaq 0x8(%rsp), %r15
movq %r15, %rsi
callq 0x33f0
movq (%r15), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x60b0
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 0x6159
cmpl $0x22, (%r15)
jne 0x6159
movzbl %bpl, %edx
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x5f4a
movq 0x8(%rsp), %rsi
leaq 0x149db(%rip), %rdi     # 0x1aae9
xorl %eax, %eax
callq 0x102f4
jmp 0x61c4
leaq 0x1f5bf(%rip), %r12     # 0x256e0
movq %r12, %rdi
movl %ebx, %esi
callq 0x1106e
cmpl $0x14, %eax
jne 0x6188
movslq %ebx, %rax
movq 0x28(%r12), %rcx
imulq $0xb0, %rax, %rax
movl 0x34(%rcx,%rax), %eax
movl %eax, (%r14)
testb %bpl, %bpl
je 0x6205
negl %eax
movl %eax, (%r14)
jmp 0x6205
movq 0x28(%rsp), %rcx
cmpb $0x0, (%rcx)
je 0x6199
movzbl %bpl, %edx
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x5f4a
movq 0x8(%rsp), %rsi
leaq 0x149a3(%rip), %rdi     # 0x1ab22
xorl %eax, %eax
callq 0x102f4
jmp 0x61c4
movq %r15, %rdi
xorl %eax, %eax
callq 0x102f4
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x6207
movslq %eax, %rcx
cmpq %rax, %rcx
je 0x6214
movzbl %bpl, %edx
leaq 0x8(%rsp), %rdi
movl %ebx, %esi
callq 0x5f4a
movq 0x8(%rsp), %rsi
leaq 0x1492c(%rip), %rdi     # 0x1aae9
xorl %eax, %eax
callq 0x102f4
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x61df
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3320
xorl %ebx, %ebx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x61fc
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3320
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testb %bl, %bl
je 0x6207
xorl %eax, %eax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %eax, (%r14)
movb $0x1, %bl
jmp 0x61e1
jmp 0x6223
jmp 0x6245
jmp 0x6223
jmp 0x6245
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6248
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x3320
jmp 0x6248
jmp 0x6245
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6263
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x3320
movq %rbx, %rdi
callq 0x3560