// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/ltr/ltr_four_char_motif.c
// Function: gt_ltr_four_char_motif_encode
int gt_ltr_four_char_motif_encode (GtLTRFourCharMotif *motif,
                                   const GtEncseq *encseq,
                                   GtError *err)
{
  const GtUchar *symbolmap;
  GtUchar c_tab[UCHAR_MAX+1];
  unsigned int i;

  symbolmap = gt_alphabet_symbolmap(gt_encseq_alphabet(encseq));
  if ( symbolmap[(unsigned int)motif->firstleft] == (GtUchar) GT_UNDEFCHAR)
  {
    gt_error_set(err,"Illegal nucleotide character %c "
                      "as argument to option -motif", motif->firstleft);
    return -1;
  }
  if ( symbolmap[(unsigned int)motif->secondleft] == (GtUchar) GT_UNDEFCHAR )
  {
    gt_error_set(err,"Illegal nucleotide character %c "
                      "as argument to option -motif", motif->secondleft);
    return -1;
  }
  if ( symbolmap[(unsigned int)motif->firstright] == (GtUchar) GT_UNDEFCHAR )
  {
    gt_error_set(err,"Illegal nucleotide character %c "
                      "as argument to option -motif", motif->firstright);
    return -1;
  }
  if ( symbolmap[(unsigned int)motif->secondright] == (GtUchar) GT_UNDEFCHAR )
  {
    gt_error_set(err,"Illegal nucleotide character %c "
                      "as argument to option -motif", motif->secondright);
    return -1;
  }

  for (i=0; i<=(unsigned int) UCHAR_MAX; i++)
  {
    c_tab[i] = (GtUchar) GT_UNDEFCHAR;
  }
  /* define complementary symbols */
  c_tab[symbolmap['a']] = symbolmap['t'];
  c_tab[symbolmap['c']] = symbolmap['g'];
  c_tab[symbolmap['g']] = symbolmap['c'];
  c_tab[symbolmap['t']] = symbolmap['a'];

  /* if motif is not palindromic */
  if ( (c_tab[symbolmap[(unsigned int)motif->firstleft]] !=
       c_tab[c_tab[symbolmap[(unsigned int)motif->secondright]]])
           ||
      (c_tab[symbolmap[(unsigned int)motif->secondleft]] !=
       c_tab[c_tab[symbolmap[(unsigned int)motif->firstright]]]) )
  {
    gt_error_set(err, "Illegal motif, motif not palindromic");
    return -1;
  }

  /* encode the symbols */
  motif->firstleft = symbolmap[(unsigned int)motif->firstleft];
  motif->secondleft = symbolmap[(unsigned int)motif->secondleft];
  motif->firstright = symbolmap[(unsigned int)motif->firstright];
  motif->secondright = symbolmap[(unsigned int)motif->secondright];

  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rdx, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x754dd
movq %rax, %rdi
callq 0x56c48
movzbl 0x8(%r14), %edx
movzbl (%rax,%rdx), %esi
cmpq $0xfd, %rsi
je 0x2ce23a
movzbl 0x9(%r14), %edx
movzbl (%rax,%rdx), %edi
cmpq $0xfd, %rdi
jne 0x2ce25f
leaq 0xb81ee(%rip), %rsi     # 0x38642f
movq %rbx, %rdi
xorl %eax, %eax
callq 0x89dbb
pushq $-0x1
popq %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movzbl 0xa(%r14), %ecx
movzbl (%rax,%rcx), %r9d
cmpq $0xfd, %r9
jne 0x2ce280
leaq 0xb81b6(%rip), %rsi     # 0x38642f
movq %rbx, %rdi
movl %ecx, %edx
jmp 0x2ce244
movzbl 0xb(%r14), %r8d
movzbl (%rax,%r8), %r10d
cmpq $0xfd, %r10
jne 0x2ce2a2
leaq 0xb8195(%rip), %rsi     # 0x38642f
movq %rbx, %rdi
movl %r8d, %edx
jmp 0x2ce244
xorl %r11d, %r11d
cmpq $0x100, %r11            # imm = 0x100
je 0x2ce2b8
movb $-0x3, (%rsp,%r11)
incq %r11
jmp 0x2ce2a5
movzbl 0x74(%rax), %r11d
movzbl 0x61(%rax), %r15d
movb %r11b, (%rsp,%r15)
movzbl 0x67(%rax), %r12d
movzbl 0x63(%rax), %r13d
movb %r12b, (%rsp,%r13)
movb %r13b, (%rsp,%r12)
movb %r15b, (%rsp,%r11)
movb (%rsp,%rsi), %r11b
movzbl (%rsp,%r10), %r10d
cmpb (%rsp,%r10), %r11b
jne 0x2ce31b
movb (%rsp,%rdi), %dil
movzbl (%rsp,%r9), %r9d
cmpb (%rsp,%r9), %dil
jne 0x2ce31b
movb %sil, 0x8(%r14)
movb (%rax,%rdx), %dl
movb %dl, 0x9(%r14)
movb (%rax,%rcx), %cl
movb %cl, 0xa(%r14)
movb (%rax,%r8), %al
movb %al, 0xb(%r14)
xorl %eax, %eax
jmp 0x2ce24e
leaq 0xb814a(%rip), %rsi     # 0x38646c
movq %rbx, %rdi
xorl %eax, %eax
callq 0x89dbb
jmp 0x2ce24b
nopl (%rax)