// File: /workspace/github_c_makefile_star2_O3/singpolyma[P]mnemonicode/mnemonic.c
// Function: mn_encode
int
mn_encode (void *src, int srcsize, char *dest, int destsize, char *format)
{
  int n;
  char *fmt;
  char *destend = dest + destsize;
  const char *word;

  if (format == 0 || format[0] == '\0')
    format = MN_FDEFAULT;
  fmt = format;
  for (n = 0; n < mn_words_required (srcsize); n++)
    {
      while (dest < destend && *fmt != '\0' && !isalpha (*fmt))
	*dest++ = *fmt++;
      if (dest >= destend)
	return MN_EOVERRUN;
      if (*fmt == '\0')
	{
	  if (isalpha (fmt[-1]) && isalpha (format[0]))
	    return MN_EFORMAT;
	  fmt = format;
	  while (dest < destend && *fmt != '\0' && !isalpha (*fmt))
	    *dest++ = *fmt++;
	  if (!isalpha (*fmt))
	    return MN_EFORMAT;
	}
      word = mn_encode_word (src, srcsize, n);
      if (word == 0)
	return MN_EOVERRUN;	/* shouldn't happen, actually */

      while (isalpha (*fmt))
	fmt++;
      while (dest < destend && *word != '\0')
	*dest++ = *word++;
    }
  if (dest < destend)
    *dest++ = '\0';
  else
    return MN_EOVERRUN;
  return MN_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movl %esi, %r15d
movq %rdi, %rbp
movslq %ecx, %r12
testq %r8, %r8
je 0xb677
cmpb $0x0, (%r8)
jne 0xb67e
leaq 0x9c2(%rip), %r8        # 0xc040
addq %rbx, %r12
leal (%r15,%r15,2), %eax
addl $0x3, %eax
leal (%r15,%r15,2), %ecx
addl $0x6, %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
cmpl $0x4, %eax
jl 0xb7c4
sarl $0x2, %ecx
movl $0x0, 0x8(%rsp)
movq %r8, 0x10(%rsp)
movq %r8, %r14
movl %ecx, 0xc(%rsp)
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpq %r12, %rbx
jae 0xb7da
callq 0xb080
movsbq (%r14), %rdx
movq (%rax), %rcx
testq %rdx, %rdx
je 0xb6ec
testb $0x4, 0x1(%rcx,%rdx,2)
jne 0xb743
incq %r14
movb %dl, (%rbx)
incq %rbx
cmpq %r12, %rbx
jb 0xb6c7
jmp 0xb7d5
movsbq -0x1(%r14), %rdx
testb $0x4, 0x1(%rcx,%rdx,2)
movq 0x10(%rsp), %r14
je 0xb70c
movsbq (%r14), %rdx
testb $0x4, 0x1(%rcx,%rdx,2)
jne 0xb7e9
cmpq %r12, %rbx
jae 0xb734
movsbq (%r14), %rdx
movq (%rax), %rcx
testq %rdx, %rdx
je 0xb734
testb $0x4, 0x1(%rcx,%rdx,2)
jne 0xb734
incq %r14
movb %dl, (%rbx)
incq %rbx
cmpq %r12, %rbx
jb 0xb711
movq (%rax), %rcx
movsbq (%r14), %rax
testb $0x4, 0x1(%rcx,%rax,2)
je 0xb7e9
movq %rbp, %r13
movq %rbp, %rdi
movq %r15, %rbp
movl %r15d, %esi
movl 0x8(%rsp), %edx
callq 0xb295
movl %eax, %eax
leaq 0x490f(%rip), %rcx      # 0x10070
movq (%rcx,%rax,8), %r15
testq %r15, %r15
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
je 0xb7da
callq 0xb080
movq (%rax), %rax
decq %r14
movsbq 0x1(%r14), %rcx
incq %r14
testb $0x4, 0x1(%rax,%rcx,2)
jne 0xb77a
cmpq %r12, %rbx
jae 0xb7a8
movl 0xc(%rsp), %ecx
movb (%r15), %al
testb %al, %al
je 0xb7ac
incq %r15
movb %al, (%rbx)
incq %rbx
cmpq %r12, %rbx
jb 0xb792
jmp 0xb7ac
movl 0xc(%rsp), %ecx
movl 0x8(%rsp), %eax
incl %eax
movl %eax, 0x8(%rsp)
cmpl %ecx, %eax
movq %rbp, %r15
movq %r13, %rbp
jne 0xb6b4
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpq %r12, %rbx
jae 0xb7da
movb $0x0, (%rbx)
xorl %eax, %eax
jmp 0xb7da
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xfffffff8, %eax       # imm = 0xFFFFFFF8
jmp 0xb7da