// File: /workspace/github_c_makefile_star2_O0/42Bastian[P]lyxass/mnemonics.c
// Function: opc
int opc(int op)
{
  int err;
  int32_t l;
  int saveCYCLES;
  int saveOp;

  saveOp = op;
  saveCYCLES = CYCLES;
  SavePosition();

  if ( TestAtom('(') ){
    if ( (err = Expression( &l )) == EXPR_ERROR ) return 1;
    if ( l < 0 || l > 65535 ) return Error(WORD_ERR,"");
    op |= 0x20;
    if ( TestAtom(',') ){
      if ( !TestAtomOR('x','X') ) return Error(SYNTAX_ERR,"");
      op |= 0x10;
    }
    if ( !TestAtom(')') ) return Error(SYNTAX_ERR,"");
    KillSpace();
    if ( atom == 0 ){
      CYCLES += 6;
      writeConstByte(op);
      writeWordLittle((short)l);
      if ( err == EXPR_UNSOLVED ) saveCurrentLine();
      return 0;
    } else {
      // Possible not indirect but expression with braces
      op = saveOp;
      CYCLES = saveCYCLES;
      RestorePosition();
    }
  }
  if ( (err = Expression( &l )) == EXPR_ERROR ) return 1;
  if ( l < 0 || l > 65535 ) return Error(WORD_ERR,"");
  if ( err != EXPR_UNSOLVED ){
    int dist = Global.pc - l - 2;
    if ( dist >= -128 && dist <= 127 ) Warning("JMP can be changed into BRA !\n");
  }
  CYCLES += 3;

  writeConstByte(op);
  writeWordLittle((short)l);
  if ( err == EXPR_UNSOLVED ) saveCurrentLine();
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x18(%rbp)
leaq 0xd790(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x14(%rbp)
callq 0x5a50
movl $0x28, %edi
callq 0x5a90
cmpl $0x0, %eax
je 0xb182
leaq -0x10(%rbp), %rdi
callq 0xc920
movl %eax, -0xc(%rbp)
cmpl $0x1, %eax
jne 0xb075
movl $0x1, -0x4(%rbp)
jmp 0xb231
cmpl $0x0, -0x10(%rbp)
jl 0xb084
cmpl $0xffff, -0x10(%rbp)    # imm = 0xFFFF
jle 0xb09d
movl $0x1b, %edi
leaq 0x5fcd(%rip), %rsi      # 0x1105d
callq 0xd130
movl %eax, -0x4(%rbp)
jmp 0xb231
movl -0x8(%rbp), %eax
orl $0x20, %eax
movl %eax, -0x8(%rbp)
movl $0x2c, %edi
callq 0x5a90
cmpl $0x0, %eax
je 0xb0eb
movl $0x78, %edi
movl $0x58, %esi
callq 0x5af0
cmpl $0x0, %eax
jne 0xb0e2
movl $0x12, %edi
leaq 0x5f88(%rip), %rsi      # 0x1105d
callq 0xd130
movl %eax, -0x4(%rbp)
jmp 0xb231
movl -0x8(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x8(%rbp)
movl $0x29, %edi
callq 0x5a90
cmpl $0x0, %eax
jne 0xb113
movl $0x12, %edi
leaq 0x5f57(%rip), %rsi      # 0x1105d
callq 0xd130
movl %eax, -0x4(%rbp)
jmp 0xb231
movb $0x0, %al
callq 0x5ad0
leaq 0x15dff(%rip), %rax     # 0x20f20
cmpl $0x0, (%rax)
jne 0xb166
leaq 0xd69b(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl (%rax), %ecx
addl $0x6, %ecx
movl %ecx, (%rax)
movl -0x8(%rbp), %eax
movsbl %al, %edi
callq 0x3340
movl -0x10(%rbp), %eax
movswl %ax, %edi
callq 0x3670
cmpl $0x2, -0xc(%rbp)
jne 0xb15a
movb $0x0, %al
callq 0xcfe0
movl $0x0, -0x4(%rbp)
jmp 0xb231
movl -0x18(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x14(%rbp), %ecx
leaq 0xd652(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl %ecx, (%rax)
callq 0x5a70
jmp 0xb182
leaq -0x10(%rbp), %rdi
callq 0xc920
movl %eax, -0xc(%rbp)
cmpl $0x1, %eax
jne 0xb19f
movl $0x1, -0x4(%rbp)
jmp 0xb231
cmpl $0x0, -0x10(%rbp)
jl 0xb1ae
cmpl $0xffff, -0x10(%rbp)    # imm = 0xFFFF
jle 0xb1c4
movl $0x1b, %edi
leaq 0x5ea3(%rip), %rsi      # 0x1105d
callq 0xd130
movl %eax, -0x4(%rbp)
jmp 0xb231
cmpl $0x2, -0xc(%rbp)
je 0xb1f6
leaq 0xd1cf(%rip), %rax      # 0x183a0
movl (%rax), %eax
subl -0x10(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x1c(%rbp)
cmpl $-0x80, -0x1c(%rbp)
jl 0xb1f4
cmpl $0x7f, -0x1c(%rbp)
jg 0xb1f4
leaq 0x633b(%rip), %rdi      # 0x1152a
callq 0xd910
jmp 0xb1f6
leaq 0xd5cb(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl (%rax), %ecx
addl $0x3, %ecx
movl %ecx, (%rax)
movl -0x8(%rbp), %eax
movsbl %al, %edi
callq 0x3340
movl -0x10(%rbp), %eax
movswl %ax, %edi
callq 0x3670
cmpl $0x2, -0xc(%rbp)
jne 0xb22a
movb $0x0, %al
callq 0xcfe0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)