// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rdx, %rbx
movl %esi, %r13d
movq %rdi, 0x20(%rsp)
movslq %ecx, %r12
testq %r8, %r8
je 0xb685
cmpb $0x0, (%r8)
jne 0xb68c
leaq 0x9b8(%rip), %r8        # 0xc044
addq %rbx, %r12
leal 0x3(%r13,%r13,2), %eax
leal 0x6(%r13,%r13,2), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
cmpl $0x4, %eax
jl 0xb7ec
sarl $0x2, %ecx
xorl %ebp, %ebp
movq %r8, 0x18(%rsp)
movq %r8, %r14
movq %r13, 0x10(%rsp)
movl %ecx, 0xc(%rsp)
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpq %r12, %rbx
setb %r15b
jae 0xb802
movb (%r14), %r13b
testb %r13b, %r13b
je 0xb709
callq 0xb080
movq (%rax), %rcx
movsbq %r13b, %rdx
testb $0x4, 0x1(%rcx,%rdx,2)
jne 0xb709
movb %r13b, (%rbx)
incq %rbx
cmpq %r12, %rbx
setb %r15b
jae 0xb7fd
movb 0x1(%r14), %r13b
incq %r14
testb %r13b, %r13b
jne 0xb6dc
testb $0x1, %r15b
je 0xb7fd
cmpb $0x0, (%r14)
je 0xb720
movq 0x10(%rsp), %r13
jmp 0xb77f
callq 0xb080
movq (%rax), %rcx
movsbq -0x1(%r14), %rdx
testb $0x4, 0x1(%rcx,%rdx,2)
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %r13
je 0xb74d
movsbq (%r14), %rdx
testb $0x4, 0x1(%rcx,%rdx,2)
jne 0xb811
movsbq (%r14), %rcx
testq %rcx, %rcx
je 0xb76d
movq (%rax), %rdx
testb $0x4, 0x1(%rdx,%rcx,2)
jne 0xb76d
incq %r14
movb %cl, (%rbx)
incq %rbx
cmpq %r12, %rbx
jb 0xb74d
movq (%rax), %rax
movsbq (%r14), %rcx
testb $0x4, 0x1(%rax,%rcx,2)
je 0xb811
movq 0x20(%rsp), %rdi
movl %r13d, %esi
movl %ebp, %edx
callq 0xb291
movl %eax, %eax
leaq 0x48d9(%rip), %rcx      # 0x10070
movq (%rcx,%rax,8), %r15
testq %r15, %r15
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
je 0xb802
callq 0xb080
movq (%rax), %rax
decq %r14
movsbq 0x1(%r14), %rcx
incq %r14
testb $0x4, 0x1(%rax,%rcx,2)
jne 0xb7b0
cmpq %r12, %rbx
jae 0xb7de
movl 0xc(%rsp), %ecx
movb (%r15), %al
testb %al, %al
je 0xb7e2
incq %r15
movb %al, (%rbx)
incq %rbx
cmpq %r12, %rbx
jb 0xb7c8
jmp 0xb7e2
movl 0xc(%rsp), %ecx
incl %ebp
cmpl %ecx, %ebp
jne 0xb6bd
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
cmpq %r12, %rbx
jae 0xb802
movb $0x0, (%rbx)
xorl %eax, %eax
jmp 0xb802
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xfffffff8, %eax       # imm = 0xFFFFFFF8
jmp 0xb802