// File: /workspace/github_c_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdx, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0xebcd9
movq %rax, %rdi
callq 0xd11ab
movzbl 0x8(%r14), %edx
movzbl (%rax,%rdx), %ebp
cmpq $0xfd, %rbp
jne 0x32c639
leaq 0xb99fb(%rip), %rsi     # 0x3e602f
movq %rbx, %rdi
jmp 0x32c65c
movq %rax, %r15
movzbl 0x9(%r14), %r12d
movzbl (%rax,%r12), %r13d
cmpq $0xfd, %r13
jne 0x32c67a
leaq 0xb99d9(%rip), %rsi     # 0x3e602f
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0xfcb67
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzbl 0xa(%r14), %edx
movzbl (%r15,%rdx), %ecx
cmpq $0xfd, %rcx
je 0x32c62d
movzbl 0xb(%r14), %eax
movzbl (%r15,%rax), %esi
cmpq $0xfd, %rsi
jne 0x32c6ae
leaq 0xb9988(%rip), %rsi     # 0x3e602f
movq %rbx, %rdi
movl %eax, %edx
jmp 0x32c65c
movq %rcx, 0x10(%rsp)
movq %rax, (%rsp)
movq %rdx, 0x8(%rsp)
leaq 0x20(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
movq %rsi, 0x18(%rsp)
movl $0xfd, %esi
callq 0x173a0
movzbl 0x74(%r15), %eax
movzbl 0x61(%r15), %ecx
movb %al, 0x20(%rsp,%rcx)
movzbl 0x67(%r15), %edx
movzbl 0x63(%r15), %esi
movb %dl, 0x20(%rsp,%rsi)
movb %sil, 0x20(%rsp,%rdx)
movb %cl, 0x20(%rsp,%rax)
movb 0x20(%rsp,%rbp), %al
movq 0x18(%rsp), %rcx
movzbl 0x20(%rsp,%rcx), %ecx
cmpb 0x20(%rsp,%rcx), %al
jne 0x32c74f
movb 0x20(%rsp,%r13), %al
movq 0x10(%rsp), %rcx
movzbl 0x20(%rsp,%rcx), %ecx
cmpb 0x20(%rsp,%rcx), %al
jne 0x32c74f
movb %bpl, 0x8(%r14)
movb (%r15,%r12), %al
movb %al, 0x9(%r14)
movq 0x8(%rsp), %rax
movb (%r15,%rax), %al
movb %al, 0xa(%r14)
movq (%rsp), %rax
movb (%r15,%rax), %al
movb %al, 0xb(%r14)
xorl %eax, %eax
jmp 0x32c668
leaq 0xb9916(%rip), %rsi     # 0x3e606c
movq %rbx, %rdi
xorl %eax, %eax
callq 0xfcb67
jmp 0x32c663
nopl (%rax)