// File: /workspace/github_c_makefile_star2_O0/smilingthax[P]libfontembed/sfnt_write.c
// Function: otf_tagorder_win_sort
int *otf_tagorder_win_sort(const struct _OTF_WRITE_TABLE *tables,int numTables) // {{{
{
  int *order=malloc(sizeof(int)*numTables);
  if (!order) {
    fprintf(stderr,"Bad alloc: %s\n", strerror(errno));
    return NULL;
  }

  // reverse intersection of both sorted arrays
  int priolist[NUM_PRIO]={0,};
  int iA=numTables-1,iB=sizeof(otf_tagorder_win)/sizeof(otf_tagorder_win[0])-1;
  int ret=numTables-1;
  while ( (iA>=0)&&(iB>=0) ) {
    if (tables[iA].tag==otf_tagorder_win[iB].tag) {
      priolist[otf_tagorder_win[iB--].prio]=1+iA--;
    } else if (tables[iA].tag>otf_tagorder_win[iB].tag) { // no order known: put unchanged at end of result
      order[ret--]=iA--;
    } else { // <
      iB--;
    }
  }
  while (iA>=0) {
    order[ret--]=iA--;
  }
  for (iA=NUM_PRIO-1;iA>=0;iA--) { // pick the matched tables up in sorted order (bucketsort principle)
    if (priolist[iA]) {
      order[ret--]=priolist[iA]-1;
    }
  }
  return order;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movslq -0x14(%rbp), %rdi
shlq $0x2, %rdi
callq 0x21d0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xbcbc
movq 0x735f(%rip), %rax      # 0x12fe0
movq (%rax), %rax
movq %rax, -0x88(%rbp)
callq 0x2040
movl (%rax), %edi
callq 0x2070
movq -0x88(%rbp), %rdi
movq %rax, %rdx
leaq 0x26b4(%rip), %rsi      # 0xe35c
movb $0x0, %al
callq 0x21e0
movq $0x0, -0x8(%rbp)
jmp 0xbe31
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x50, %edx
callq 0x20e0
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x74(%rbp)
movl $0x13, -0x78(%rbp)
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x7c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x74(%rbp)
movb %al, -0x89(%rbp)
jl 0xbd00
cmpl $0x0, -0x78(%rbp)
setge %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
testb $0x1, %al
jne 0xbd0f
jmp 0xbdba
movq -0x10(%rbp), %rax
movslq -0x74(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x78(%rbp), %rdx
leaq 0x4084(%rip), %rcx      # 0xfdb0
movl 0x4(%rcx,%rdx,8), %ecx
cmpq %rcx, %rax
jne 0xbd62
movl -0x74(%rbp), %ecx
movl %ecx, %eax
addl $-0x1, %eax
movl %eax, -0x74(%rbp)
addl $0x1, %ecx
movl -0x78(%rbp), %eax
movl %eax, %edx
addl $-0x1, %edx
movl %edx, -0x78(%rbp)
movslq %eax, %rdx
leaq 0x4058(%rip), %rax      # 0xfdb0
movslq (%rax,%rdx,8), %rax
movl %ecx, -0x70(%rbp,%rax,4)
jmp 0xbdb5
movq -0x10(%rbp), %rax
movslq -0x74(%rbp), %rcx
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movslq -0x78(%rbp), %rdx
leaq 0x4031(%rip), %rcx      # 0xfdb0
movl 0x4(%rcx,%rdx,8), %ecx
cmpq %rcx, %rax
jbe 0xbdaa
movl -0x74(%rbp), %edx
movl %edx, %eax
addl $-0x1, %eax
movl %eax, -0x74(%rbp)
movq -0x20(%rbp), %rax
movl -0x7c(%rbp), %ecx
movl %ecx, %esi
addl $-0x1, %esi
movl %esi, -0x7c(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0xbdb3
movl -0x78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0xbdb5
jmp 0xbce5
jmp 0xbdbc
cmpl $0x0, -0x74(%rbp)
jl 0xbde4
movl -0x74(%rbp), %edx
movl %edx, %eax
addl $-0x1, %eax
movl %eax, -0x74(%rbp)
movq -0x20(%rbp), %rax
movl -0x7c(%rbp), %ecx
movl %ecx, %esi
addl $-0x1, %esi
movl %esi, -0x7c(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0xbdbc
movl $0x13, -0x74(%rbp)
cmpl $0x0, -0x74(%rbp)
jl 0xbe29
movslq -0x74(%rbp), %rax
cmpl $0x0, -0x70(%rbp,%rax,4)
je 0xbe1c
movslq -0x74(%rbp), %rax
movl -0x70(%rbp,%rax,4), %edx
subl $0x1, %edx
movq -0x20(%rbp), %rax
movl -0x7c(%rbp), %ecx
movl %ecx, %esi
addl $-0x1, %esi
movl %esi, -0x7c(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0xbe1e
movl -0x74(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0xbdeb
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nop