// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x128(%rsp)
movq %rsi, 0x120(%rsp)
movq %rdx, 0x118(%rsp)
movq 0x120(%rsp), %rdi
callq 0xb0f00
movq %rax, %rdi
callq 0x7e870
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rax
movq 0x128(%rsp), %rcx
movzbl 0x8(%rcx), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xfd, %eax
jne 0x4e99df
movq 0x118(%rsp), %rdi
movq 0x128(%rsp), %rax
movzbl 0x8(%rax), %edx
leaq 0xd20ce(%rip), %rsi     # 0x5bba96
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x134(%rsp) # imm = 0xFFFFFFFF
jmp 0x4e9cbb
movq 0x110(%rsp), %rax
movq 0x128(%rsp), %rcx
movzbl 0x9(%rcx), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xfd, %eax
jne 0x4e9a32
movq 0x118(%rsp), %rdi
movq 0x128(%rsp), %rax
movzbl 0x9(%rax), %edx
leaq 0xd207b(%rip), %rsi     # 0x5bba96
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x134(%rsp) # imm = 0xFFFFFFFF
jmp 0x4e9cbb
movq 0x110(%rsp), %rax
movq 0x128(%rsp), %rcx
movzbl 0xa(%rcx), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xfd, %eax
jne 0x4e9a85
movq 0x118(%rsp), %rdi
movq 0x128(%rsp), %rax
movzbl 0xa(%rax), %edx
leaq 0xd2028(%rip), %rsi     # 0x5bba96
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x134(%rsp) # imm = 0xFFFFFFFF
jmp 0x4e9cbb
movq 0x110(%rsp), %rax
movq 0x128(%rsp), %rcx
movzbl 0xb(%rcx), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
cmpl $0xfd, %eax
jne 0x4e9ad8
movq 0x118(%rsp), %rdi
movq 0x128(%rsp), %rax
movzbl 0xb(%rax), %edx
leaq 0xd1fd5(%rip), %rsi     # 0x5bba96
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x134(%rsp) # imm = 0xFFFFFFFF
jmp 0x4e9cbb
movl $0x0, 0xc(%rsp)
cmpl $0xff, 0xc(%rsp)
ja 0x4e9b00
movl 0xc(%rsp), %eax
movb $-0x3, 0x10(%rsp,%rax)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x4e9ae0
movq 0x110(%rsp), %rax
movb 0x74(%rax), %cl
movq 0x110(%rsp), %rax
movzbl 0x61(%rax), %eax
movb %cl, 0x10(%rsp,%rax)
movq 0x110(%rsp), %rax
movb 0x67(%rax), %cl
movq 0x110(%rsp), %rax
movzbl 0x63(%rax), %eax
movb %cl, 0x10(%rsp,%rax)
movq 0x110(%rsp), %rax
movb 0x63(%rax), %cl
movq 0x110(%rsp), %rax
movzbl 0x67(%rax), %eax
movb %cl, 0x10(%rsp,%rax)
movq 0x110(%rsp), %rax
movb 0x61(%rax), %cl
movq 0x110(%rsp), %rax
movzbl 0x74(%rax), %eax
movb %cl, 0x10(%rsp,%rax)
movq 0x110(%rsp), %rax
movq 0x128(%rsp), %rcx
movzbl 0x8(%rcx), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movzbl 0x10(%rsp,%rax), %eax
movq 0x110(%rsp), %rcx
movq 0x128(%rsp), %rdx
movzbl 0xb(%rdx), %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
movzbl 0x10(%rsp,%rcx), %ecx
movzbl 0x10(%rsp,%rcx), %ecx
cmpl %ecx, %eax
jne 0x4e9bfa
movq 0x110(%rsp), %rax
movq 0x128(%rsp), %rcx
movzbl 0x9(%rcx), %ecx
movl %ecx, %ecx
movzbl (%rax,%rcx), %eax
movzbl 0x10(%rsp,%rax), %eax
movq 0x110(%rsp), %rcx
movq 0x128(%rsp), %rdx
movzbl 0xa(%rdx), %edx
movl %edx, %edx
movzbl (%rcx,%rdx), %ecx
movzbl 0x10(%rsp,%rcx), %ecx
movzbl 0x10(%rsp,%rcx), %ecx
cmpl %ecx, %eax
je 0x4e9c20
movq 0x118(%rsp), %rdi
leaq 0xd1eca(%rip), %rsi     # 0x5bbad3
movb $0x0, %al
callq 0xd88c0
movl $0xffffffff, 0x134(%rsp) # imm = 0xFFFFFFFF
jmp 0x4e9cbb
movq 0x110(%rsp), %rax
movq 0x128(%rsp), %rcx
movzbl 0x8(%rcx), %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %cl
movq 0x128(%rsp), %rax
movb %cl, 0x8(%rax)
movq 0x110(%rsp), %rax
movq 0x128(%rsp), %rcx
movzbl 0x9(%rcx), %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %cl
movq 0x128(%rsp), %rax
movb %cl, 0x9(%rax)
movq 0x110(%rsp), %rax
movq 0x128(%rsp), %rcx
movzbl 0xa(%rcx), %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %cl
movq 0x128(%rsp), %rax
movb %cl, 0xa(%rax)
movq 0x110(%rsp), %rax
movq 0x128(%rsp), %rcx
movzbl 0xb(%rcx), %ecx
movl %ecx, %ecx
movb (%rax,%rcx), %cl
movq 0x128(%rsp), %rax
movb %cl, 0xb(%rax)
movl $0x0, 0x134(%rsp)
movl 0x134(%rsp), %eax
addq $0x138, %rsp            # imm = 0x138
retq
nopw (%rax,%rax)