// File: /workspace/github_c_makefile_star2_O1/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 0xf02da
movq %rax, %rdi
callq 0xd3700
movzbl 0x8(%r14), %edx
movzbl (%rax,%rdx), %ebp
cmpq $0xfd, %rbp
jne 0x3372a9
leaq 0xb859e(%rip), %rsi     # 0x3ef842
movq %rbx, %rdi
jmp 0x3372cc
movq %rax, %r15
movzbl 0x9(%r14), %r12d
movzbl (%rax,%r12), %r13d
cmpq $0xfd, %r13
jne 0x3372ea
leaq 0xb857c(%rip), %rsi     # 0x3ef842
movq %rbx, %rdi
movl %r12d, %edx
xorl %eax, %eax
callq 0x1019cf
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 0x33729d
movzbl 0xb(%r14), %eax
movzbl (%r15,%rax), %esi
cmpq $0xfd, %rsi
jne 0x33731e
leaq 0xb852b(%rip), %rsi     # 0x3ef842
movq %rbx, %rdi
movl %eax, %edx
jmp 0x3372cc
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 0x3373bf
movb 0x20(%rsp,%r13), %al
movq 0x10(%rsp), %rcx
movzbl 0x20(%rsp,%rcx), %ecx
cmpb 0x20(%rsp,%rcx), %al
jne 0x3373bf
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 0x3372d8
leaq 0xb84b9(%rip), %rsi     # 0x3ef87f
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1019cf
jmp 0x3372d3
nopl (%rax)