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

  if ( ! KillSpace() ){
    return Error(SYNTAX_ERR,"");
  }

  // immediate

  if ( TestAtom('#') ){

    if ( (err = Expression(&l)) == EXPR_ERR) return 1;

    if ( l < -128 || l > 255 ) return Error(BYTE_ERR,"");
    if ( op == 0x81 ) return Error(SYNTAX_ERR,""); // STA #0 not possible
    writeConstByte(op | 0x08);
    if ( Current.needsReloc ){
      writeRelocByte((char)l,RELOC_LOBY);
    } else {
      writeConstByte((char)l);
    }
    if ( err == EXPR_UNSOLVED ) saveCurrentLine();

    CYCLES += 2;

    if ( (Global.pc & 255) == 1) ++CYCLES;

    return 0;
  }

  // indirect

  SavePosition();
  saveCYCLES = CYCLES;
  saveOp = op;
  if ( TestAtom('(') ){

    if ( (err = Expression(&l)) == EXPR_ERR) return 1;
    if ( l < 0 || l > 255 ) return Error(BYTE_ERR,"");

    if ( TestAtom(',') ){
      if ( !TestAtomOR('x','X') ) return Error(SYNTAX_ERR,"");
      komma = 1;
      CYCLES += 6;
    }
    if ( !TestAtom(')') ) return Error(SYNTAX_ERR,"Missing ')'");

    if ( !komma ) {
      if ( TestAtom(',') ){
	CYCLES += 5;
	if ( !TestAtomOR('y','Y') ) return Error(SYNTAX_ERR,"");
	op |= 0x10;
      } else {
	op |= 0x12;
	--op;
	CYCLES++;
      }
    }
    KillSpace();
    if ( atom == 0 ){
      if ( op == 0x91 ) ++CYCLES;
      writeConstByte(op);
      writeByte((char)l);
      if ( err == EXPR_UNSOLVED ) saveCurrentLine();
      return 0;
    } else {
      // Possible not indirect but expression with braces
      RestorePosition();
      op = saveOp;
      CYCLES = saveCYCLES;
    }
  }

  // absolute

  if ( (err = Expression(&l)) == EXPR_ERR) return 1;

  if ( TestAtom(',') ){
    CYCLES += 4;

    if ( TestAtomOR('X','x') ){
      op |= 0x14;
    } else if ( TestAtomOR('Y','y') ) {
      op |= 0x18;
      writeConstByte(op);
      writeWordLittle((short)l);
      if ( err == EXPR_UNSOLVED ) saveCurrentLine();
      return 0;
    } else return Error(SYNTAX_ERR,"");
  } else {
    op |= 0x04;
  }

  if ( l < 0 || l > 65535 ) Error(WORD_ERR,"");

  if ( l > 255 || err == EXPR_UNSOLVED || Current.pass2) {
    CYCLES+=4;
    op |= 0x08;
    writeConstByte(op);
    writeWordLittle((short)l);
  } else {
    CYCLES+=3;
    writeConstByte(op);
    writeByte((char)l);
  }
  if ( op == 0x99 || op == 0x9d ) ++CYCLES;

  if ( err == EXPR_UNSOLVED ) saveCurrentLine();
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movl $0x0, -0x14(%rbp)
movb $0x0, %al
callq 0x5ad0
cmpl $0x0, %eax
jne 0xa1a7
movl $0x12, %edi
leaq 0x6ec3(%rip), %rsi      # 0x1105d
callq 0xd130
movl %eax, -0x4(%rbp)
jmp 0xa632
movl $0x23, %edi
callq 0x5a90
cmpl $0x0, %eax
je 0xa2aa
leaq -0x10(%rbp), %rdi
callq 0xc920
movl %eax, -0xc(%rbp)
cmpl $0x11, %eax
jne 0xa1d7
movl $0x1, -0x4(%rbp)
jmp 0xa632
cmpl $-0x80, -0x10(%rbp)
jl 0xa1e6
cmpl $0xff, -0x10(%rbp)
jle 0xa1ff
movl $0x1a, %edi
leaq 0x6e6b(%rip), %rsi      # 0x1105d
callq 0xd130
movl %eax, -0x4(%rbp)
jmp 0xa632
cmpl $0x81, -0x8(%rbp)
jne 0xa221
movl $0x12, %edi
leaq 0x6e49(%rip), %rsi      # 0x1105d
callq 0xd130
movl %eax, -0x4(%rbp)
jmp 0xa632
movl -0x8(%rbp), %eax
orl $0x8, %eax
movsbl %al, %edi
callq 0x3340
leaq 0xe3c2(%rip), %rax      # 0x185f8
cmpl $0x0, 0x1bc(%rax)
je 0xa251
movl -0x10(%rbp), %eax
movl $0x2, %esi
movsbl %al, %edi
callq 0x33d0
jmp 0xa25c
movl -0x10(%rbp), %eax
movsbl %al, %edi
callq 0x3340
cmpl $0x2, -0xc(%rbp)
jne 0xa269
movb $0x0, %al
callq 0xcfe0
leaq 0xe558(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl (%rax), %ecx
addl $0x2, %ecx
movl %ecx, (%rax)
leaq 0xe11f(%rip), %rax      # 0x183a0
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
jne 0xa29e
leaq 0xe534(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xa632
callq 0x5a50
leaq 0xe512(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl $0x28, %edi
callq 0x5a90
cmpl $0x0, %eax
je 0xa493
leaq -0x10(%rbp), %rdi
callq 0xc920
movl %eax, -0xc(%rbp)
cmpl $0x11, %eax
jne 0xa2f4
movl $0x1, -0x4(%rbp)
jmp 0xa632
cmpl $0x0, -0x10(%rbp)
jl 0xa303
cmpl $0xff, -0x10(%rbp)
jle 0xa31c
movl $0x1a, %edi
leaq 0x6d4e(%rip), %rsi      # 0x1105d
callq 0xd130
movl %eax, -0x4(%rbp)
jmp 0xa632
movl $0x2c, %edi
callq 0x5a90
cmpl $0x0, %eax
je 0xa370
movl $0x78, %edi
movl $0x58, %esi
callq 0x5af0
cmpl $0x0, %eax
jne 0xa358
movl $0x12, %edi
leaq 0x6d12(%rip), %rsi      # 0x1105d
callq 0xd130
movl %eax, -0x4(%rbp)
jmp 0xa632
movl $0x1, -0x14(%rbp)
leaq 0xe462(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl (%rax), %ecx
addl $0x6, %ecx
movl %ecx, (%rax)
movl $0x29, %edi
callq 0x5a90
cmpl $0x0, %eax
jne 0xa398
movl $0x12, %edi
leaq 0x70f2(%rip), %rsi      # 0x1147d
callq 0xd130
movl %eax, -0x4(%rbp)
jmp 0xa632
cmpl $0x0, -0x14(%rbp)
jne 0xa41b
movl $0x2c, %edi
callq 0x5a90
cmpl $0x0, %eax
je 0xa3f6
leaq 0xe414(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl (%rax), %ecx
addl $0x5, %ecx
movl %ecx, (%rax)
movl $0x79, %edi
movl $0x59, %esi
callq 0x5af0
cmpl $0x0, %eax
jne 0xa3eb
movl $0x12, %edi
leaq 0x6c7f(%rip), %rsi      # 0x1105d
callq 0xd130
movl %eax, -0x4(%rbp)
jmp 0xa632
movl -0x8(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x8(%rbp)
jmp 0xa419
movl -0x8(%rbp), %eax
orl $0x12, %eax
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
leaq 0xe3b9(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0xa41b
movb $0x0, %al
callq 0x5ad0
leaq 0x16af7(%rip), %rax     # 0x20f20
cmpl $0x0, (%rax)
jne 0xa477
cmpl $0x91, -0x8(%rbp)
jne 0xa448
leaq 0xe38a(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x8(%rbp), %eax
movsbl %al, %edi
callq 0x3340
movl -0x10(%rbp), %eax
movsbl %al, %edi
callq 0x3470
cmpl $0x2, -0xc(%rbp)
jne 0xa46b
movb $0x0, %al
callq 0xcfe0
movl $0x0, -0x4(%rbp)
jmp 0xa632
callq 0x5a70
movl -0x1c(%rbp), %eax
movl %eax, -0x8(%rbp)
movl -0x18(%rbp), %ecx
leaq 0xe33c(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl %ecx, (%rax)
jmp 0xa493
leaq -0x10(%rbp), %rdi
callq 0xc920
movl %eax, -0xc(%rbp)
cmpl $0x11, %eax
jne 0xa4b0
movl $0x1, -0x4(%rbp)
jmp 0xa632
movl $0x2c, %edi
callq 0x5a90
cmpl $0x0, %eax
je 0xa55a
leaq 0xe2fe(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl (%rax), %ecx
addl $0x4, %ecx
movl %ecx, (%rax)
movl $0x58, %edi
movl $0x78, %esi
callq 0x5af0
cmpl $0x0, %eax
je 0xa4f3
movl -0x8(%rbp), %eax
orl $0x14, %eax
movl %eax, -0x8(%rbp)
jmp 0xa558
movl $0x59, %edi
movl $0x79, %esi
callq 0x5af0
cmpl $0x0, %eax
je 0xa53f
movl -0x8(%rbp), %eax
orl $0x18, %eax
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %eax
movsbl %al, %edi
callq 0x3340
movl -0x10(%rbp), %eax
movswl %ax, %edi
callq 0x3670
cmpl $0x2, -0xc(%rbp)
jne 0xa533
movb $0x0, %al
callq 0xcfe0
movl $0x0, -0x4(%rbp)
jmp 0xa632
movl $0x12, %edi
leaq 0x6b12(%rip), %rsi      # 0x1105d
callq 0xd130
movl %eax, -0x4(%rbp)
jmp 0xa632
jmp 0xa563
movl -0x8(%rbp), %eax
orl $0x4, %eax
movl %eax, -0x8(%rbp)
cmpl $0x0, -0x10(%rbp)
jl 0xa572
cmpl $0xffff, -0x10(%rbp)    # imm = 0xFFFF
jle 0xa583
movl $0x1b, %edi
leaq 0x6adf(%rip), %rsi      # 0x1105d
callq 0xd130
cmpl $0xff, -0x10(%rbp)
jg 0xa5a2
cmpl $0x2, -0xc(%rbp)
je 0xa5a2
leaq 0xe05f(%rip), %rax      # 0x185f8
cmpl $0x0, 0xe4(%rax)
je 0xa5d4
leaq 0xe21f(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl (%rax), %ecx
addl $0x4, %ecx
movl %ecx, (%rax)
movl -0x8(%rbp), %eax
orl $0x8, %eax
movl %eax, -0x8(%rbp)
movl -0x8(%rbp), %eax
movsbl %al, %edi
callq 0x3340
movl -0x10(%rbp), %eax
movswl %ax, %edi
callq 0x3670
jmp 0xa5fb
leaq 0xe1ed(%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
movsbl %al, %edi
callq 0x3470
cmpl $0x99, -0x8(%rbp)
je 0xa60d
cmpl $0x9d, -0x8(%rbp)
jne 0xa61e
leaq 0xe1b4(%rip), %rax      # 0x187c8
movq (%rax), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
cmpl $0x2, -0xc(%rbp)
jne 0xa62b
movb $0x0, %al
callq 0xcfe0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)