// File: evincarofautumn[P]protodata/parse.cpp
// Function: (anonymous namespace)::write_integer_term(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int)
Term write_integer_term(const std::string& token, int base) {
  const bool has_sign = token[0] == '-' || token[0] == '+';
  char* boundary;
  const auto begin = token.c_str(), end = begin + token.size();
  if (has_sign) {
    Term::Signed value = std::strtoll(begin, &boundary, base);
    if (boundary != end)
      throw std::runtime_error(join("Invalid base-", base,
        " signed integer literal: \"", token, "\""));
    return Term::write(value);
  } else {
    Term::Unsigned value = std::strtoull(begin, &boundary, base);
    if (boundary != end)
      throw std::runtime_error(join("Invalid base-", base,
        " unsigned integer literal: \"", token, "\""));
    return Term::write(value);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x18(%rbp)
movl %esi, -0x1c(%rbp)
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4350
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x2d, %ecx
movb %al, -0x9a(%rbp)
je 0x12c0b
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4350
movsbl (%rax), %eax
cmpl $0x2b, %eax
sete %al
movb %al, -0x9a(%rbp)
movb -0x9a(%rbp), %al
andb $0x1, %al
movb %al, -0x1d(%rbp)
movq -0x18(%rbp), %rdi
callq 0x4120
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x41e0
movq %rax, %rcx
movq -0xa8(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x38(%rbp)
testb $0x1, -0x1d(%rbp)
je 0x12d37
movq -0x30(%rbp), %rdi
movl -0x1c(%rbp), %edx
leaq -0x28(%rbp), %rsi
callq 0x4060
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x12d22
movb $0x1, -0x6d(%rbp)
movl $0x10, %edi
callq 0x4150
movq %rax, -0xb0(%rbp)
movq -0x18(%rbp), %r8
leaq 0x7cc3(%rip), %rsi      # 0x1a957
leaq 0x7cca(%rip), %rcx      # 0x1a965
leaq 0x7cdc(%rip), %r9       # 0x1a97e
leaq -0x60(%rbp), %rdi
leaq -0x1c(%rbp), %rdx
callq 0x14700
jmp 0x12cb1
movq -0xb0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x4470
jmp 0x12cc3
movq -0xb0(%rbp), %rdi
movb $0x0, -0x6d(%rbp)
movq 0x1331b(%rip), %rsi     # 0x25ff0
movq 0x132bc(%rip), %rdx     # 0x25f98
callq 0x44b0
jmp 0x12e3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x12d09
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x41a0
testb $0x1, -0x6d(%rbp)
jne 0x12d11
jmp 0x12d1d
movq -0xb0(%rbp), %rdi
callq 0x4200
jmp 0x12e33
movq -0x40(%rbp), %rdi
callq 0xca10
movl %eax, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
jmp 0x12e23
movq -0x30(%rbp), %rdi
movl -0x1c(%rbp), %edx
leaq -0x28(%rbp), %rsi
callq 0x43f0
movq %rax, -0x78(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0x12e13
movb $0x1, -0x99(%rbp)
movl $0x10, %edi
callq 0x4150
movq %rax, -0xb8(%rbp)
movq -0x18(%rbp), %r8
leaq 0x7bdb(%rip), %rsi      # 0x1a957
leaq 0x7bfd(%rip), %rcx      # 0x1a980
leaq 0x7bf4(%rip), %r9       # 0x1a97e
leaq -0x98(%rbp), %rdi
leaq -0x1c(%rbp), %rdx
callq 0x14820
jmp 0x12d9c
movq -0xb8(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x4470
jmp 0x12db1
movq -0xb8(%rbp), %rdi
movb $0x0, -0x99(%rbp)
movq 0x1322a(%rip), %rsi     # 0x25ff0
movq 0x131cb(%rip), %rdx     # 0x25f98
callq 0x44b0
jmp 0x12e3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x12dfa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x41a0
testb $0x1, -0x99(%rbp)
jne 0x12e05
jmp 0x12e11
movq -0xb8(%rbp), %rdi
callq 0x4200
jmp 0x12e33
movq -0x78(%rbp), %rdi
callq 0xc9e0
movl %eax, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
movl -0x10(%rbp), %eax
movq -0x8(%rbp), %rdx
addq $0xc0, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x44d0
nopl (%rax)