// File: /workspace/github_cpp_makefile_star2_O2/nicklausw[P]snesasm/snesasm.cpp
// Function: directive_arg(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
void directive_arg(string str, int range)
{
  unsigned int label_search;
  int label_count = 0;
  
  pass_counter++;
  
  if (tokens[pass_counter].token_type == tkOP) { // if it's not number
    for (label_search = 0; label_search < labels.size(); label_search++) { // look for a label!
      if (labels[label_search].name == tokens[pass_counter].token_i) {
        tr = labels[label_search].val; // it's a match!
        label_count++; // no need for unsolved.
        break;
      }
    }
    
    if (!label_count) { // if no match was found
      // time for an unsolved!
      new_unsolved(tokens[pass_counter].token_i, org, range-1);
      return;
    }
  } else if (tokens[pass_counter].token_type == tkNUM) {
    tr = parse_num(tokens[pass_counter].token_i);
  } else {
    cerr << "error: " << str << " expects args\n";
    exit(fail);
  }
   
 
  if (range == r8) {
    if (tr > 0xFF) {
      cerr << "error: " << str << " requires 8-bit args\n";
      exit(fail);
    }
  } else if (range == r16) {
    if (tr > 0xFFFF) {
      cerr << "error: " << str << " requires 16-bit args\n";
      exit(fail);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movq 0x6001(%rip), %rax      # 0xc2c0
incq %rax
movq %rax, 0x5ff7(%rip)      # 0xc2c0
movq 0x5f08(%rip), %rsi      # 0xc1d8
imulq $0x28, %rax, %rax
movl (%rsi,%rax), %ecx
cmpl 0x5e9b(%rip), %ecx      # 0xc178
jne 0x6347
xorl %ecx, %ecx
pushq $0x28
popq %r14
movl %ecx, %r15d
movq 0x5f99(%rip), %rax      # 0xc288
movq 0x5f8a(%rip), %rdi      # 0xc280
subq %rdi, %rax
cqto
idivq %r14
cmpq %r15, %rax
jbe 0x63fb
imulq $0x28, %r15, %r12
addq %r12, %rdi
movq 0x5ec3(%rip), %rax      # 0xc1d8
imulq $0x28, 0x5fa3(%rip), %rcx # 0xc2c0
leaq (%rax,%rcx), %rsi
addq $0x8, %rsi
callq 0x6a58
leal 0x1(%r15), %ecx
testb %al, %al
je 0x62e5
movq 0x5f47(%rip), %rax      # 0xc280
movq 0x20(%rax,%r12), %rax
movq %rax, 0x5f1b(%rip)      # 0xc260
jmp 0x637c
cmpl 0x5e23(%rip), %ecx      # 0xc170
jne 0x6449
addq %rax, %rsi
addq $0x8, %rsi
movq %rsp, %r14
movq %r14, %rdi
callq 0x21d0
movq %r14, %rdi
callq 0x6700
movq %rax, 0x5eec(%rip)      # 0xc260
movq %rsp, %rdi
callq 0x22c8
cmpl %ebp, 0x5e0e(%rip)      # 0xc190
jne 0x63bf
cmpq $0x100, 0x5ed1(%rip) # imm = 0x100
jl 0x643c
movq 0x5c54(%rip), %rdi      # 0xbff0
leaq 0x23af(%rip), %rsi      # 0x8752
callq 0x2140
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2120
leaq 0x242b(%rip), %rsi      # 0x87e5
jmp 0x646e
cmpl %ebp, 0x5dcf(%rip)      # 0xc194
jne 0x643c
cmpq $0x10000, 0x5e8e(%rip) # imm = 0x10000
jl 0x643c
movq 0x5c15(%rip), %rdi      # 0xbff0
leaq 0x2370(%rip), %rsi      # 0x8752
callq 0x2140
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2120
leaq 0x240b(%rip), %rsi      # 0x8804
jmp 0x646e
movq 0x5dd6(%rip), %rax      # 0xc1d8
imulq $0x28, 0x5eb6(%rip), %rcx # 0xc2c0
leaq (%rax,%rcx), %rsi
addq $0x8, %rsi
leaq 0x20(%rsp), %r14
movq %r14, %rdi
callq 0x21d0
movq 0x5d82(%rip), %rsi      # 0xc1a8
decl %ebp
movq %r14, %rdi
movl %ebp, %edx
callq 0x6891
leaq 0x20(%rsp), %rdi
callq 0x22c8
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x5ba0(%rip), %rdi      # 0xbff0
leaq 0x22fb(%rip), %rsi      # 0x8752
callq 0x2140
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2120
leaq 0x2204(%rip), %rsi      # 0x8672
movq %rax, %rdi
callq 0x2140
pushq $0x1
popq %rdi
callq 0x2180
jmp 0x6480
movq %rax, %rbx
movq %r14, %rdi
callq 0x22c8
movq %rbx, %rdi
callq 0x2270