LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/pipde[P]deos-songlib/lib/rra.c
// Function: skipRRAHeaderFD
off_t
skipRRAHeaderFD(int fd)
    {
    off_t index;
    char buffer[10];
    //find start
    lseek(fd,0,SEEK_SET);
    read(fd,buffer,sizeof(buffer));
    buffer[7] = '\0';
    if (strcmp(buffer,"RRAUDIO") != 0) return -1;

    index = 0;
    lseek(fd,0,SEEK_SET);
    read(fd,buffer,2);
    while (buffer[0] != '%' || buffer[1] != '%')
        {
        ++index;
        lseek(fd,index,SEEK_SET);
        read(fd,buffer,2);
        }

    return index + 2;
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebx
xorl %esi, %esi
xorl %edx, %edx
callq 0x10c0
leaq 0xe(%rsp), %r14
pushq $0xa
popq %rdx
movl %ebx, %edi
movq %r14, %rsi
callq 0x1110
movb $0x0, 0x7(%r14)
movabsq $0x4f494455415252, %rax # imm = 0x4F494455415252
cmpq %rax, (%r14)
je 0x27cc
pushq $-0x1
popq %r14
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl %ebx, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10c0
leaq 0xe(%rsp), %r15
pushq $0x2
popq %r12
movl %ebx, %edi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1110
movq %r12, %r14
cmpb $0x25, 0xe(%rsp)
jne 0x27fe
cmpb $0x25, 0xf(%rsp)
je 0x27bd
leaq -0x1(%r14), %rsi
movl %ebx, %edi
xorl %edx, %edx
callq 0x10c0
movl %ebx, %edi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1110
incq %r14
jmp 0x27f0
// File: /workspace/github_c_makefile_star2_O2/pipde[P]deos-songlib/lib/rra.c
// Function: updateRRAHeader
void
updateRRAHeader(FILE *fp, int samples)
    {
    char *attribute;
    int digits;
    long tmp = ftell(fp);
    fseek(fp,0L,SEEK_SET);
    fprintf(stderr,"fp = %ld \n",ftell(fp));

    attribute = readAttribute(fp);
    fprintf(stderr,"attribute : %s\n",attribute);

    if(!strcmp(attribute,"RRAUDIO"))
        fprintf(stderr,"Its an RRA file \n");
    

    attribute = readAttribute(fp);
    fprintf(stderr,"attribute : %s\n",attribute);
    while(attribute != 0)
        {
        if(strcmp(attribute,"samples") == 0)
            {
            fprintf(fp,": 000000000000000\n");
            digits = determineDigits(samples);
            fseek(fp,-digits-1,SEEK_CUR);
            fprintf(fp,"%d\n",samples);
            fseek(fp,-1,SEEK_CUR);
            attribute = readAttribute(fp);
            fprintf(stderr,"attribute : %s\n",attribute);
            if(!strcmp(attribute,"samples"))
                continue;
            break;
            }
        fprintf(stderr,"attribute : %s\n",attribute);
        attribute = readAttribute(fp);
        }
    fseek(fp,tmp,SEEK_SET);         
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
callq 0x1150
movq %rax, (%rsp)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x11a0
movq 0x376e(%rip), %r15      # 0x5ff8
movq (%r15), %r14
movq %rbx, %rdi
callq 0x1150
leaq 0xbac(%rip), %rsi       # 0x3448
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1140
movq %rbx, %rdi
callq 0x1eb5
movq %rax, %r14
movq (%r15), %rdi
leaq 0xb95(%rip), %rsi       # 0x3453
movq %rax, %rdx
xorl %eax, %eax
callq 0x1140
leaq 0x939(%rip), %rsi       # 0x3208
movq %r14, %rdi
callq 0x1120
testl %eax, %eax
jne 0x28f0
movq (%r15), %rcx
leaq 0xb7e(%rip), %rdi       # 0x3463
pushq $0x11
popq %rsi
pushq $0x1
popq %rdx
callq 0x1210
movq %rbx, %rdi
callq 0x1eb5
movq %rax, %r13
movq (%r15), %rdi
leaq 0xb4e(%rip), %rsi       # 0x3453
movq %rax, %rdx
xorl %eax, %eax
callq 0x1140
leaq 0x97b(%rip), %r12       # 0x3291
pushq $0x1
popq %r14
testq %r13, %r13
je 0x29e0
movq %r13, %rdi
movq %r12, %rsi
callq 0x1120
testl %eax, %eax
jne 0x29bc
leaq 0xb38(%rip), %rdi       # 0x3475
pushq $0x12
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x1210
movl %ebp, %edi
callq 0x2763
notl %eax
movslq %eax, %rsi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x11a0
movq %rbx, %rdi
leaq 0x841(%rip), %rsi       # 0x31ad
movl %ebp, %edx
xorl %eax, %eax
callq 0x1140
movq %rbx, %rdi
pushq $-0x1
popq %rsi
movl %r14d, %edx
callq 0x11a0
movq %rbx, %rdi
callq 0x1eb5
movq %rax, %r13
movq (%r15), %rdi
leaq 0xabb(%rip), %rsi       # 0x3453
movq %rax, %rdx
xorl %eax, %eax
callq 0x1140
movq %r13, %rdi
movq %r12, %rsi
callq 0x1120
testq %r13, %r13
je 0x29e0
testl %eax, %eax
je 0x2923
jmp 0x29e0
movq (%r15), %rdi
leaq 0xa8d(%rip), %rsi       # 0x3453
movq %r13, %rdx
xorl %eax, %eax
callq 0x1140
movq %rbx, %rdi
callq 0x1eb5
movq %rax, %r13
jmp 0x291a
movq %rbx, %rdi
movq (%rsp), %rsi
xorl %edx, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11a0
// File: /workspace/github_c_makefile_star2_O2/pipde[P]deos-songlib/lib/rra.c
// Function: rra2fft
double *
rra2fft(RRA *h,int channel,int *length)
    {
    int i;
    double *data = 0;
    double max;

    if (channel >= h->channels)
        Fatal("not enough channels (channel zero is the first channel)\n");

    *length = (int) pow(2,ceil(log((double)h->samples)/log(2.0)));
    //printf("h->channels is %d\n",h->channels);
    //printf("samples is %d\n",h->samples);
    //printf("fftLength is %d\n",*length);

    /* fft uses one-based counting! */

    data = (double *) New(2*((*length)+1) * sizeof(double));

    /* fill the data array data here */

    max = pow(2,h->bitsPerSample - 1);
    //printf("max is %f\n",max);

    for (i = 0; i < h->samples && i < *length; ++i)
        {
        data[i * 2 + 1] = h->data[channel][i] / max;
        data[i * 2 + 2] = 0.0;
        }

    /* fill the remainder of the data array with zeros */

    for ( ; i < *length; ++i)
        {
        data[i * 2 + 1] = 0.0;
        data[i * 2 + 2] = 0.0;
        }

    /* call the fft */

    fft(data,*length,1);

    return data;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %rbx
cmpl %esi, (%rdi)
jg 0x2a1d
leaq 0xa72(%rip), %rdi       # 0x3488
xorl %eax, %eax
callq 0x1490
cvtsi2sdl 0xc(%rbx), %xmm0
callq 0x10f0
divsd 0x731(%rip), %xmm0      # 0x3160
callq 0x1230
callq 0x1030
cvttsd2si %xmm0, %edi
movl %edi, (%r15)
shll $0x4, %edi
addl $0x10, %edi
callq 0x1645
movq %rax, %r14
movl 0x8(%rbx), %edi
decl %edi
movsd 0x6f5(%rip), %xmm0      # 0x3150
callq 0x1050
movl 0xc(%rbx), %eax
leaq 0x10(%r14), %rcx
movslq %ebp, %rdi
xorl %edx, %edx
testl %eax, %eax
cmovlel %edx, %eax
movslq (%r15), %rsi
cmpq %rdx, %rax
je 0x2aa5
cmpq %rsi, %rdx
jge 0x2aa2
movq 0x18(%rbx), %r8
movq (%r8,%rdi,8), %r8
cvtsi2sdl (%r8,%rdx,4), %xmm1
divsd %xmm0, %xmm1
movsd %xmm1, -0x8(%rcx)
andq $0x0, (%rcx)
incq %rdx
addq $0x10, %rcx
jmp 0x2a74
movq %rdx, %rax
movq %rax, %rcx
shlq $0x4, %rcx
addq %r14, %rcx
addq $0x8, %rcx
xorpd %xmm0, %xmm0
cmpq %rsi, %rax
jge 0x2ac9
movupd %xmm0, (%rcx)
incq %rax
addq $0x10, %rcx
jmp 0x2ab7
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x2ae2
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/pipde[P]deos-songlib/lib/rra.c
// Function: fft2rra
void
fft2rra(RRA *h,int channel,double *data,int length)
    {
    int i;
    double max;

    /* call the inverse fft */

    fft(data,length,-1);

    /* normalize the result */

    for(i = 0; i < length; ++i)
        {
        data[2*i+1] /= length;
        data[2*i+2] /= length;
        }

    /* now place back into RRA object */

    max = pow(2,h->bitsPerSample - 1);

    for (i = 0; i < length; i += 2)
        {
        h->data[channel][i / 2] = (int) (max * data[i + 1]);
        }
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, %rbx
movl %esi, %r15d
movq %rdi, %r14
pushq $-0x1
popq %rdx
movq %rbx, %rdi
movl %ecx, %esi
callq 0x2ae2
cvtsi2sd %ebp, %xmm0
xorl %eax, %eax
testl %ebp, %ebp
movl $0x0, %ecx
cmovgl %ebp, %ecx
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
shlq $0x4, %rcx
cmpq %rax, %rcx
je 0x2d0b
movupd 0x8(%rbx,%rax), %xmm1
divpd %xmm0, %xmm1
movupd %xmm1, 0x8(%rbx,%rax)
addq $0x10, %rax
jmp 0x2cf0
movl 0x8(%r14), %edi
decl %edi
movsd 0x437(%rip), %xmm0      # 0x3150
callq 0x1050
movslq %r15d, %rax
movslq %ebp, %rcx
xorl %edx, %edx
cmpq %rcx, %rdx
jge 0x2d4a
movsd 0x8(%rbx,%rdx,8), %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %esi
movq 0x18(%r14), %rdi
movq (%rdi,%rax,8), %rdi
movl %esi, (%rdi,%rdx,2)
addq $0x2, %rdx
jmp 0x2d26
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/pipde[P]deos-songlib/lib/rra.c
// Function: readToken
static char *
readToken(FILE *in,int ch)
    {
    int index;
    char buffer[1024];

    buffer[0] = ch;

    ch = fgetc(in);

    index = 1;
    while (ch != EOF && !isspace(ch) && ch != '\"' && ch != ':')
        {
        if (index == sizeof(buffer) - 1)
            {
            buffer[sizeof(buffer)-1] = '\0';
            Fatal("file %s,line %s, token too long: %s\n",buffer);
            }
        buffer[index++] = ch;
        ch = fgetc(in);
        }

    buffer[index] = '\0';

    ungetc(ch,in);

    return StringDup(buffer);
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x400, %rsp            # imm = 0x400
movq %rdi, %rbx
movq %rsp, %r14
movb %sil, (%r14)
callq 0x10e0
movl %eax, %ebp
pushq $0x1
popq %r12
leaq 0x742(%rip), %r15       # 0x34c1
cmpl $-0x1, %ebp
je 0x2dd4
callq 0x1240
movq (%rax), %rax
movslq %ebp, %rcx
movzwl (%rax,%rcx,2), %eax
btl $0xd, %eax
jb 0x2dd4
cmpl $0x22, %ebp
je 0x2dd4
cmpl $0x3a, %ebp
je 0x2dd4
cmpq $0x3ff, %r12            # imm = 0x3FF
jne 0x2dc1
movb $0x0, 0x3ff(%rsp)
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1490
movb %bpl, (%rsp,%r12)
incq %r12
movq %rbx, %rdi
callq 0x10e0
movl %eax, %ebp
jmp 0x2d7f
movl %r12d, %eax
movb $0x0, (%rsp,%rax)
movl %ebp, %edi
movq %rbx, %rsi
callq 0x1190
movq %rsp, %rdi
callq 0x1628
addq $0x400, %rsp            # imm = 0x400
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/./embed.h
// Function: emb_get
static inline unsigned short emb_get(EMB_PARAMS *emb,int unicode) // {{{ gid
{
  const unsigned short gid=otf_from_unicode(emb->font->sfnt,unicode);
  emb_set(emb,unicode,gid);
  return gid;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rax
movq (%rax), %rdi
callq 0x42a4
movq 0x20(%rbx), %rdx
testq %rdx, %rdx
je 0x2add
testb $0x1, 0xc(%rbx)
je 0x2add
movzwl %ax, %esi
pushq $0x1
popq %rdi
movl %eax, %ecx
shll %cl, %edi
shrq $0x5, %rsi
orl %edi, (%rdx,%rsi,4)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/sfnt.c
// Function: otf_read_raw
static int otf_read_raw(FILE *f,char *buf,long pos,int length) // {{{
{
  const int res=fseek(f,pos,SEEK_SET);
  if (res==-1) {
    fprintf(stderr,"Seek failed: %s\n", strerror(errno));
    return -1;
  }
  return fread(buf,1,length,f);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %ecx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movq %rdx, %rsi
xorl %edx, %edx
callq 0x2170
cmpl $-0x1, %eax
je 0x2d82
movslq %ebp, %rdx
pushq $0x1
popq %rsi
movq %r14, %rdi
movq %rbx, %rcx
callq 0x21f0
popq %rbx
popq %r14
popq %rbp
retq
movq 0xc257(%rip), %rax      # 0xefe0
movq (%rax), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x2070
leaq 0x79a3(%rip), %rsi      # 0xa742
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x21e0
pushq $-0x1
popq %rax
jmp 0x2d7d
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/sfnt.c
// Function: otf_close
void otf_close(OTF_FILE *otf) // {{{
{
  assert(otf);
  if (otf) {
    if (otf->flags&OTF_F_CACHE_GLYF) {
      free(otf->glyf);
    } else {
      free(otf->gly);
    }
    free(otf->cmap);
    free(otf->name);
    free(otf->hmtx);
    free(otf->glyphOffsets);
    fclose(otf->f);
    free(otf->tables);
    free(otf);
  }
}

// Assembly:
pushq %rbx
testq %rdi, %rdi
je 0x351b
movq %rdi, %rbx
movl 0x8(%rdi), %eax
andl $0x1, %eax
shll $0x4, %eax
movq 0x80(%rdi,%rax), %rdi
callq 0x21b0
movq 0x70(%rbx), %rdi
callq 0x21b0
movq 0x68(%rbx), %rdi
callq 0x21b0
movq 0x60(%rbx), %rdi
callq 0x21b0
movq 0x50(%rbx), %rdi
callq 0x21b0
movq (%rbx), %rdi
callq 0x2140
movq 0x40(%rbx), %rdi
callq 0x21b0
movq %rbx, %rdi
popq %rbx
jmp 0x21b0
leaq 0x6b16(%rip), %rdi      # 0xa038
leaq 0x7526(%rip), %rsi      # 0xaa4f
leaq 0x6e7c(%rip), %rcx      # 0xa3ac
movl $0x1d6, %edx            # imm = 0x1D6
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/sfnt.c
// Function: otf_load_header
static int otf_load_header(OTF_FILE *otf,int pos) // {{{
{
  char buf[12];
  if (!otf_read(otf,buf,pos,12)) {
    fprintf(stderr,"Not a ttf font\n");
    return -1;
  }
  otf->version=get_ULONG(buf);
  otf->numTables=get_USHORT(buf+4);
  // don't need the other fields...
  pos+=12;
  return pos;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %esi, %ebx
movq %rdi, %r14
movl %esi, %edx
leaq 0xc(%rsp), %rsi
pushq $0xc
popq %rcx
callq 0x3480
testq %rax, %rax
je 0x3584
movl 0xc(%rsp), %eax
bswapl %eax
movl %eax, 0x14(%r14)
movzwl 0x10(%rsp), %eax
rolw $0x8, %ax
movw %ax, 0x38(%r14)
addl $0xc, %ebx
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
retq
movq 0xba55(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x7241(%rip), %rdi      # 0xa7d6
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
callq 0x2280
pushq $-0x1
popq %rbx
jmp 0x357a
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/sfnt.c
// Function: otf_load
OTF_FILE *otf_load(const char *file) // {{{
{
  FILE *f;
  int use_ttc=-1;

  if ((f=fopen(file,"rb"))==NULL) {
    // check for TTC
    char *tmp=strrchr(file,'/'),*end;
    if (tmp) {
      use_ttc=strtoul(tmp+1,&end,10);
      if (!*end) {
        end=malloc((tmp-file+1)*sizeof(char));
        if (!end) {
          fprintf(stderr,"Bad alloc: %s\n", strerror(errno));
          return NULL;
        }
        strncpy(end,file,tmp-file);
        end[tmp-file]=0;
        f=fopen(end,"rb");
        free(end);
      }
    }
    if (!f) {
      fprintf(stderr,"Could not open \"%s\": %s\n", file, strerror(errno));
      return NULL;
    }
  }
  return otf_load2(f,use_ttc);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x6dd9(%rip), %rsi      # 0xa390
callq 0x21a0
testq %rax, %rax
je 0x35ca
movq %rax, %r15
pushq $-0x1
popq %r14
jmp 0x3641
pushq $0x2f
popq %rsi
movq %rbx, %rdi
callq 0x2160
testq %rax, %rax
je 0x3657
movq %rax, %r15
leaq 0x1(%rax), %rdi
movq %rsp, %r12
pushq $0xa
popq %rdx
movq %r12, %rsi
callq 0x2060
movq %rax, %r14
movq (%r12), %rax
cmpb $0x0, (%rax)
jne 0x3657
subq %rbx, %r15
leaq 0x1(%r15), %rdi
callq 0x21d0
testq %rax, %rax
je 0x3686
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x20b0
movb $0x0, (%r12,%r15)
leaq 0x6d67(%rip), %rsi      # 0xa390
movq %r12, %rdi
callq 0x21a0
movq %rax, %r15
movq %r12, %rdi
callq 0x21b0
testq %r15, %r15
je 0x3657
movq %r15, %rdi
movl %r14d, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2db1
movq 0xb982(%rip), %rax      # 0xefe0
movq (%rax), %r14
callq 0x2040
movl (%rax), %edi
callq 0x2070
leaq 0x6d1f(%rip), %rsi      # 0xa393
movq %r14, %rdi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x21e0
jmp 0x36b0
movq 0xb953(%rip), %rax      # 0xefe0
movq (%rax), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x2070
leaq 0x6cb6(%rip), %rsi      # 0xa359
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x21e0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/sfnt.c
// Function: otf_get_table
char *otf_get_table(OTF_FILE *otf,unsigned int tag,int *ret_len) // {{{
{
  assert(otf);
  assert(ret_len);

  const int idx=otf_find_table(otf,tag);
  if (idx==-1) {
    return NULL;
  }
  const OTF_DIRENT *table=otf->tables+idx;

  char *ret=otf_read_table(otf,NULL,table);
  if (!ret) {
    return NULL;
  }
  if (otf->flags&OTF_F_DO_CHECKSUM) {
    unsigned int csum=otf_checksum(ret,table->length);
    if (tag==OTF_TAG('h','e','a','d')) { // special case
      csum-=get_ULONG(ret+8);
    }
    if (csum!=table->checkSum) {
      fprintf(stderr,"Wrong checksum for %c%c%c%c\n",OTF_UNTAG(tag));
      free(ret);
      return NULL;
    }
  }
  *ret_len=table->length;
  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x3803
movq %rdx, %r14
testq %rdx, %rdx
je 0x3822
movl %esi, %ebx
movq %rdi, %r13
callq 0x36be
cmpl $-0x1, %eax
je 0x37ab
cltq
imulq $0x14, %rax, %r12
addq 0x40(%r13), %r12
xorl %ebp, %ebp
movq %r13, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x2b30
testq %rax, %rax
je 0x37ad
movq %rax, %r15
testb $0x4, 0xa(%r13)
movl 0xc(%r12), %ebp
je 0x37a3
movq %r15, %rdi
movl %ebp, %esi
callq 0x3841
movl %eax, %r13d
cmpl $0x68656164, %ebx       # imm = 0x68656164
jne 0x379c
movq %r15, %rdi
addq $0x8, %rdi
callq 0x353a
subl %eax, %r13d
cmpl 0x4(%r12), %r13d
jne 0x37bf
movl %ebp, (%r14)
movq %r15, %rbp
jmp 0x37ad
xorl %ebp, %ebp
movq %rbp, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xb81a(%rip), %rax      # 0xefe0
movq (%rax), %rdi
movl %ebx, %edx
shrl $0x18, %edx
movl %ebx, %ecx
shrl $0x10, %ecx
movl $0xff, %eax
andl %eax, %ecx
movl %ebx, %r8d
shrl $0x8, %r8d
andl %eax, %r8d
andl %eax, %ebx
leaq 0x6c17(%rip), %rsi      # 0xa404
xorl %ebp, %ebp
movl %ebx, %r9d
xorl %eax, %eax
callq 0x21e0
movq %r15, %rdi
callq 0x21b0
jmp 0x37ad
leaq 0x682e(%rip), %rdi      # 0xa038
leaq 0x723e(%rip), %rsi      # 0xaa4f
leaq 0x6baf(%rip), %rcx      # 0xa3c7
movl $0x226, %edx            # imm = 0x226
callq 0x20f0
leaq 0x6bd3(%rip), %rdi      # 0xa3fc
leaq 0x721f(%rip), %rsi      # 0xaa4f
leaq 0x6b90(%rip), %rcx      # 0xa3c7
movl $0x227, %edx            # imm = 0x227
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/./sfnt_int.h
// Function: otf_checksum
static inline unsigned int otf_checksum(const char *buf, unsigned int len) // {{{
{
  unsigned int ret=0;
  for (len=(len+3)/4;len>0;len--,buf+=4) {
    ret+=get_ULONG(buf);
  }
  return ret;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
addl $0x3, %ebx
shrl $0x2, %ebx
xorl %ebp, %ebp
subl $0x1, %ebx
jb 0x3867
movq %r14, %rdi
callq 0x353a
addl %eax, %ebp
addq $0x4, %r14
jmp 0x3852
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/sfnt.c
// Function: otf_get_width
int otf_get_width(OTF_FILE *otf,unsigned short gid) // {{{  -1 on error
{
  assert(otf);

  if (gid>=otf->numGlyphs) {
    return -1;
  }

  // ensure hmtx is there
  if (!otf->hmtx) {
    if (otf_load_more(otf)!=0) {
      assert(0);
      return -1;
    }
  }

  return get_width_fast(otf,gid);
#if 0
  if (gid>=otf->numberOfHMetrics) {
    return get_USHORT(otf->hmtx+(otf->numberOfHMetrics-1)*2);
    // TODO? lsb=get_SHORT(otf->hmtx+otf->numberOfHMetrics*2+gid*2);  // lsb: left_side_bearing (also in table)
  }
  return get_USHORT(otf->hmtx+gid*4);
  // TODO? lsb=get_SHORT(otf->hmtx+gid*4+2);
#endif
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x3fb5
movl %esi, %ebp
movq %rdi, %rbx
cmpw %bp, 0x4c(%rdi)
jbe 0x3fab
movq 0x60(%rbx), %rax
testq %rax, %rax
jne 0x3f79
movq %rbx, %rdi
callq 0x3b7f
testl %eax, %eax
jne 0x3fd4
movq 0x60(%rbx), %rax
movzwl %bp, %ecx
movzwl 0x58(%rbx), %edx
cmpw %cx, %dx
leaq (%rax,%rcx,4), %rsi
leaq 0x1(%rax,%rcx,4), %rcx
leaq -0x3(%rax,%rdx,4), %rdi
cmovaq %rcx, %rdi
leaq -0x4(%rax,%rdx,4), %rax
cmovaq %rsi, %rax
movzbl (%rax), %ecx
shll $0x8, %ecx
movzbl (%rdi), %eax
orl %ecx, %eax
jmp 0x3fae
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x607c(%rip), %rdi      # 0xa038
leaq 0x6a8c(%rip), %rsi      # 0xaa4f
leaq 0x65e1(%rip), %rcx      # 0xa5ab
movl $0x317, %edx            # imm = 0x317
callq 0x20f0
leaq 0x6ce5(%rip), %rdi      # 0xacc0
leaq 0x6a6d(%rip), %rsi      # 0xaa4f
leaq 0x65c2(%rip), %rcx      # 0xa5ab
movl $0x320, %edx            # imm = 0x320
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/sfnt.c
// Function: otf_get_name
const char *otf_get_name(OTF_FILE *otf,int platformID,int encodingID,int languageID,int nameID,int *ret_len) // {{{
{
  assert(otf);
  assert(ret_len);

  // ensure name is there
  if (!otf->name) {
    if (otf_load_more(otf)!=0) {
      *ret_len=-1;
      assert(0);
      return NULL;
    }
  }

  char key[8];
  set_USHORT(key,platformID);
  set_USHORT(key+2,encodingID);
  set_USHORT(key+4,languageID);
  set_USHORT(key+6,nameID);

  char *res=bsearch(key,otf->name+6,get_USHORT(otf->name+2),12,otf_name_compare);
  if (res) {
    *ret_len=get_USHORT(res+8);
    int npos=get_USHORT(res+10);
    const char *nstore=otf->name+get_USHORT(otf->name+4);
    return nstore+npos;
  }
  *ret_len=0;
  return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x40ce
movq %r9, %r15
testq %r9, %r9
je 0x40ed
movl %r8d, %eax
movl %esi, %ebx
movq %rdi, %r14
movq 0x68(%rdi), %rsi
testq %rsi, %rsi
jne 0x4048
movl %edx, %r13d
movl %ecx, %r12d
movl %eax, %ebp
movq %r14, %rdi
callq 0x3b7f
testl %eax, %eax
jne 0x410c
movq 0x68(%r14), %rsi
movl %ebp, %eax
movl %r12d, %ecx
movl %r13d, %edx
movb %bh, (%rsp)
movq %rsp, %rdi
movb %bl, 0x1(%rdi)
movb %dh, 0x2(%rsp)
movb %dl, 0x3(%rdi)
movb %ch, 0x4(%rsp)
movb %cl, 0x5(%rdi)
movb %ah, 0x6(%rsp)
movb %al, 0x7(%rdi)
movzwl 0x2(%rsi), %eax
addq $0x6, %rsi
rolw $0x8, %ax
movzwl %ax, %edx
leaq 0xb3(%rip), %r8         # 0x412f
pushq $0xc
popq %rcx
callq 0x21c0
testq %rax, %rax
je 0x40b9
movzwl 0x8(%rax), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, (%r15)
movzwl 0xa(%rax), %eax
rolw $0x8, %ax
movq 0x68(%r14), %rcx
movzwl 0x4(%rcx), %edx
rolw $0x8, %dx
movzwl %ax, %esi
movzwl %dx, %eax
addq %rcx, %rax
addq %rsi, %rax
jmp 0x40bf
andl $0x0, (%r15)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5f63(%rip), %rdi      # 0xa038
leaq 0x6973(%rip), %rsi      # 0xaa4f
leaq 0x64f6(%rip), %rcx      # 0xa5d9
movl $0x339, %edx            # imm = 0x339
callq 0x20f0
leaq 0x6308(%rip), %rdi      # 0xa3fc
leaq 0x6954(%rip), %rsi      # 0xaa4f
leaq 0x64d7(%rip), %rcx      # 0xa5d9
movl $0x33a, %edx            # imm = 0x33A
callq 0x20f0
orl $-0x1, (%r15)
leaq 0x6ba9(%rip), %rdi      # 0xacc0
leaq 0x6931(%rip), %rsi      # 0xaa4f
leaq 0x64b4(%rip), %rcx      # 0xa5d9
movl $0x340, %edx            # imm = 0x340
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/sfnt.c
// Function: otf_get_glyph
int otf_get_glyph(OTF_FILE *otf,unsigned short gid) // {{{ result in >otf->gly, returns length, -1 on error
{
  assert(otf);
  assert(!is_CFF(otf)); // not for CFF

  if (gid>=otf->numGlyphs) {
    return -1;
  }

  // ensure >glyphOffsets is there
  if (!otf->glyphOffsets) {
    if (otf_load_more(otf)!=0) {
      assert(0);
      return -1;
    }
  }

  const int len=otf->glyphOffsets[gid+1]-otf->glyphOffsets[gid];
  if (len==0) {
    return 0;
  }

  assert(otf->glyfTable->length>=otf->glyphOffsets[gid+1]);
  if (otf->glyf) { // i.e. OTF_F_CACHE_GLYF
    otf->gly=otf->glyf+otf->glyphOffsets[gid];
  } else if (otf->gly) {
    if (otf->flags&OTF_F_WOFF) {
      fprintf(stderr,"OTF_F_CACHE_GLYF is needed to read glyphs from wOFF files\n");
      return -1;
    }
    if (!otf_read_raw(otf->f,otf->gly,
                  otf->glyfTable->offset+otf->glyphOffsets[gid],len)) {
      return -1;
    }
  } else {
    assert(0);
    return -1;
  }

  return len;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x4209
movq %rdi, %r14
testb $0x1, 0xa(%rdi)
jne 0x4228
movl %esi, %ebp
pushq $-0x1
popq %rbx
cmpw %bp, 0x4c(%r14)
jbe 0x41e4
movq 0x50(%r14), %rax
testq %rax, %rax
jne 0x417e
movq %r14, %rdi
callq 0x3b7f
testl %eax, %eax
jne 0x4266
movq 0x50(%r14), %rax
movzwl %bp, %ecx
movl (%rax,%rcx,4), %edx
movl 0x4(%rax,%rcx,4), %ecx
movl %ecx, %ebp
subl %edx, %ebp
je 0x41b6
movq 0x88(%r14), %rax
cmpl %ecx, 0xc(%rax)
jb 0x4247
movq 0x90(%r14), %rcx
testq %rcx, %rcx
je 0x41ba
addq %rdx, %rcx
movq %rcx, 0x80(%r14)
jmp 0x41e2
xorl %ebx, %ebx
jmp 0x41e4
movq 0x80(%r14), %rsi
testq %rsi, %rsi
je 0x4285
testb $-0x80, 0x9(%r14)
jne 0x41eb
movq (%r14), %rdi
addl 0x8(%rax), %edx
movl %ebp, %ecx
callq 0x2d51
testl %eax, %eax
je 0x41e4
movl %ebp, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq 0xadee(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x647c(%rip), %rdi      # 0xa678
pushq $0x3a
popq %rsi
pushq $0x1
popq %rdx
callq 0x2280
jmp 0x41e4
leaq 0x5e28(%rip), %rdi      # 0xa038
leaq 0x6838(%rip), %rsi      # 0xaa4f
leaq 0x63fb(%rip), %rcx      # 0xa619
movl $0x359, %edx            # imm = 0x359
callq 0x20f0
leaq 0x61f2(%rip), %rdi      # 0xa421
leaq 0x6819(%rip), %rsi      # 0xaa4f
leaq 0x63dc(%rip), %rcx      # 0xa619
movl $0x35a, %edx            # imm = 0x35A
callq 0x20f0
leaq 0x63f9(%rip), %rdi      # 0xa647
leaq 0x67fa(%rip), %rsi      # 0xaa4f
leaq 0x63bd(%rip), %rcx      # 0xa619
movl $0x36d, %edx            # imm = 0x36D
callq 0x20f0
leaq 0x6a53(%rip), %rdi      # 0xacc0
leaq 0x67db(%rip), %rsi      # 0xaa4f
leaq 0x639e(%rip), %rcx      # 0xa619
movl $0x363, %edx            # imm = 0x363
callq 0x20f0
leaq 0x6a34(%rip), %rdi      # 0xacc0
leaq 0x67bc(%rip), %rsi      # 0xaa4f
leaq 0x637f(%rip), %rcx      # 0xa619
movl $0x37a, %edx            # imm = 0x37A
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/embed.c
// Function: emb_close
void emb_close(EMB_PARAMS *emb) // {{{
{
  if (emb) {
    free(emb->subset);
    if (emb->plan&EMB_A_CLOSE_FONTFILE) {
      fontfile_close(emb->font);
    }
    free(emb);
  }
}

// Assembly:
testq %rdi, %rdi
je 0x4748
pushq %rbx
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
callq 0x21b0
testb $-0x80, 0xd(%rbx)
je 0x473f
movq 0x10(%rbx), %rdi
callq 0x7568
movq %rbx, %rdi
popq %rbx
jmp 0x21b0
retq
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/embed.c
// Function: copy_otf
static inline int copy_otf(OTF_FILE *otf,OUTPUT_FN output,void *context) // {{{
{
  if (otf->flags&OTF_F_WOFF) {
    return otf_copy_sfnt(otf,NULL,output,context);
  } else {
    return copy_file(otf->f,output,context);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1008, %rsp           # imm = 0x1008
movq %rdx, %rbx
movq %rsi, %r14
testb $-0x80, 0x9(%rdi)
jne 0x4a4e
movq (%rdi), %r15
testq %r15, %r15
je 0x4a6c
testq %r14, %r14
je 0x4a85
movq %r15, %rdi
callq 0x2050
xorl %ebp, %ebp
movq %rsp, %r12
movl $0x1000, %edx           # imm = 0x1000
movq %r12, %rdi
pushq $0x1
popq %rsi
movq %r15, %rcx
callq 0x21f0
movq %rax, %r13
movq %r12, %rdi
movl %r13d, %esi
movq %rbx, %rdx
callq *%r14
addl %r13d, %ebp
testl %r13d, %r13d
jg 0x4a10
movl %ebp, %eax
addq $0x1008, %rsp           # imm = 0x1008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %esi, %esi
movq %r14, %rdx
movq %rbx, %rcx
addq $0x1008, %rsp           # imm = 0x1008
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x76f8
leaq 0x55f2(%rip), %rdi      # 0xa065
leaq 0x5e1a(%rip), %rsi      # 0xa894
leaq 0x5f6f(%rip), %rcx      # 0xa9f0
pushq $0xc
jmp 0x4a9c
leaq 0x5f8d(%rip), %rdi      # 0xaa19
leaq 0x5e01(%rip), %rsi      # 0xa894
leaq 0x5f56(%rip), %rcx      # 0xa9f0
pushq $0xd
popq %rdx
callq 0x20f0
nop
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/embed_sfnt.c
// Function: emb_otf_get_rights
EMB_RIGHT_TYPE emb_otf_get_rights(OTF_FILE *otf) // {{{
{
  EMB_RIGHT_TYPE ret=EMB_RIGHT_FULL;

  int len;
  char *os2=otf_get_table(otf,OTF_TAG('O','S','/','2'),&len);
  if (os2) {
    const unsigned short os2_version=get_USHORT(os2);
    // check len
    assert( (os2_version!=0x0000)||(len==78) );
    assert( (os2_version!=0x0001)||(len==86) );
    assert( (os2_version<0x0002)||(os2_version>0x0004)||(len==96) );
    if (os2_version<=0x0004) {
      // get rights
      unsigned short fsType=get_USHORT(os2+8);
      // from Adobe's Fontpolicies_v9.pdf, pg 13:
      if (fsType==0x0002) {
        ret=EMB_RIGHT_NONE;
      } else {
        ret=fsType&0x0300; // EMB_RIGHT_BITMAPONLY, EMB_RIGHT_NO_SUBSET
        if ((fsType&0x000c)==0x0004) {
          ret|=EMB_RIGHT_READONLY;
        }
      }
    }
    free(os2);
  }
  return ret;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
leaq 0xc(%rsp), %rdx
movl $0x4f532f32, %esi       # imm = 0x4F532F32
callq 0x371c
testq %rax, %rax
je 0x4b20
movzwl (%rax), %ecx
rolw $0x8, %cx
testw %cx, %cx
setne %sil
movl 0xc(%rsp), %edx
cmpl $0x4e, %edx
sete %dil
orb %sil, %dil
je 0x4b4b
cmpw $0x1, %cx
setne %sil
cmpl $0x56, %edx
sete %dil
orb %sil, %dil
je 0x4b64
leal -0x5(%rcx), %esi
cmpw $-0x3, %si
setb %sil
cmpl $0x60, %edx
sete %dl
orb %sil, %dl
je 0x4b7d
xorl %ebx, %ebx
cmpw $0x4, %cx
ja 0x4b3b
movzwl 0x8(%rax), %ecx
rolw $0x8, %cx
cmpw $0x2, %cx
jne 0x4b24
pushq $0x2
popq %rbx
jmp 0x4b3b
xorl %ebx, %ebx
jmp 0x4b43
movzwl %cx, %ecx
movl %ecx, %edx
andl $0x300, %edx            # imm = 0x300
andl $0xc, %ecx
leal 0x4(%rdx), %ebx
cmpl $0x4, %ecx
cmovnel %edx, %ebx
movq %rax, %rdi
callq 0x21b0
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
retq
leaq 0x5ed6(%rip), %rdi      # 0xaa28
leaq 0x5ef0(%rip), %rsi      # 0xaa49
leaq 0x5ef6(%rip), %rcx      # 0xaa56
pushq $0x14
jmp 0x4b94
leaq 0x5f19(%rip), %rdi      # 0xaa84
leaq 0x5ed7(%rip), %rsi      # 0xaa49
leaq 0x5edd(%rip), %rcx      # 0xaa56
pushq $0x15
jmp 0x4b94
leaq 0x5f21(%rip), %rdi      # 0xaaa5
leaq 0x5ebe(%rip), %rsi      # 0xaa49
leaq 0x5ec4(%rip), %rcx      # 0xaa56
pushq $0x16
popq %rdx
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/embed_sfnt.c
// Function: emb_otf_get_fontname
const char *emb_otf_get_fontname(OTF_FILE *otf) // {{{
{
  static char fontname[64];

  int len;
  const char *fname=otf_get_name(otf,3,1,0x409,6,&len); // microsoft
  if (fname) {
    int iA,iB=0;
    for (iA=0;(iA<63)&&(iA*2<len);iA++) {
      if ( (fname[2*iA]==0)&&
           (fname[2*iA+1]>=33)&&(fname[2*iA+1]<=126)&&
           (!strchr("[](){}<>/%",fname[iA*2+1])) ) {
        fontname[iB++]=fname[iA*2+1];
      }
    }
    fontname[iB]=0;
  } else if ((fname=otf_get_name(otf,1,0,0,6,&len))) { // mac
    int iA,iB=0;
    for (iA=0;(iA<63)&&(iA<len);iA++) {
      if ( (fname[iA]>=33)&&(fname[iA]<=126)&&
           (!strchr("[](){}<>/%",fname[iA])) ) {
        fontname[iB++]=fname[iA];
      }
    }
    fontname[iB]=0;
  } else {
    fontname[0]=0;
  }
  if (!*fontname) {
    // TODO construct a fontname, eg from */*/*/4
    fprintf(stderr,"WARNING: no fontName\n");
  }
  return fontname;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
pushq $0x3
popq %rsi
pushq $0x1
popq %rdx
pushq $0x6
popq %r8
leaq 0x4(%rsp), %r9
movl $0x409, %ecx            # imm = 0x409
callq 0x3ff3
testq %rax, %rax
je 0x4c2e
movq %rax, %rbx
movslq 0x4(%rsp), %r13
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %r12d, %r12d
cmpq $0x3e, %r14
ja 0x4ca5
cmpq %r13, %rbp
jge 0x4ca5
cmpb $0x0, (%rbx,%rbp)
jne 0x4c25
movb 0x1(%rbx,%rbp), %r15b
leal -0x7f(%r15), %eax
cmpb $-0x5e, %al
jb 0x4c25
movzbl %r15b, %esi
leaq 0x5ed4(%rip), %rdi      # 0xaadb
pushq $0xb
popq %rdx
callq 0x2180
testq %rax, %rax
jne 0x4c25
movslq %r12d, %rax
incl %r12d
leaq 0xa54f(%rip), %rcx      # 0xf170
movb %r15b, (%rax,%rcx)
incq %r14
addq $0x2, %rbp
jmp 0x4bd6
pushq $0x1
popq %rsi
xorl %r12d, %r12d
pushq $0x6
popq %r8
leaq 0x4(%rsp), %r9
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x3ff3
testq %rax, %rax
je 0x4cd2
movq %rax, %rbx
movslq 0x4(%rsp), %r13
pushq $0xb
popq %r15
xorl %ebp, %ebp
cmpq $0x3e, %rbp
ja 0x4ca5
cmpq %r13, %rbp
jge 0x4ca5
movb (%rbx,%rbp), %r14b
leal -0x7f(%r14), %eax
cmpb $-0x5e, %al
jb 0x4ca0
movzbl %r14b, %esi
leaq 0x5e59(%rip), %rdi      # 0xaadb
movq %r15, %rdx
callq 0x2180
testq %rax, %rax
jne 0x4ca0
movslq %r12d, %rax
incl %r12d
leaq 0xa4d4(%rip), %rcx      # 0xf170
movb %r14b, (%rax,%rcx)
incq %rbp
jmp 0x4c60
movslq %r12d, %rax
leaq 0xa4c1(%rip), %rcx      # 0xf170
movb $0x0, (%rax,%rcx)
cmpb $0x0, 0xa4b6(%rip)      # 0xf170
je 0x4cd9
leaq 0xa4ad(%rip), %rax      # 0xf170
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x0, 0xa497(%rip)      # 0xf170
movq 0xa300(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x5dfc(%rip), %rdi      # 0xaae6
pushq $0x15
popq %rsi
pushq $0x1
popq %rdx
callq 0x2280
jmp 0x4cbc
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/embed_sfnt.c
// Function: emb_otf_get_pdf_cidwidths
EMB_PDF_FONTWIDTHS *emb_otf_get_pdf_cidwidths(OTF_FILE *otf,const BITSET glyphs) // {{{ // glyphs==NULL -> output all
{
  assert(otf);

  // ensure hmtx is there
  if (!otf->hmtx) {
    if (otf_load_more(otf)!=0) {
      assert(0);
      return NULL;
    }
  }
//  int dw=emb_otf_pdf_glyphwidth(otf,0); // e.g.
  int dw=-1; // let them estimate

  return emb_pdf_fw_cidwidths(glyphs,otf->numGlyphs,dw,emb_otf_pdf_glyphwidth,otf);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x552d
movq %rsi, %r14
movq %rdi, %rbx
cmpq $0x0, 0x60(%rdi)
jne 0x550d
movq %rbx, %rdi
callq 0x3b7f
testl %eax, %eax
jne 0x554c
movzwl 0x4c(%rbx), %esi
leaq 0x53(%rip), %rcx        # 0x556b
pushq $-0x1
popq %rdx
movq %r14, %rdi
movq %rbx, %r8
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x642b
leaq 0x4b04(%rip), %rdi      # 0xa038
leaq 0x550e(%rip), %rsi      # 0xaa49
leaq 0x580f(%rip), %rcx      # 0xad51
movl $0x129, %edx            # imm = 0x129
callq 0x20f0
leaq 0x576d(%rip), %rdi      # 0xacc0
leaq 0x54ef(%rip), %rsi      # 0xaa49
leaq 0x57f0(%rip), %rcx      # 0xad51
movl $0x12e, %edx            # imm = 0x12E
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/embed_sfnt.c
// Function: get_glyphname
static const char *get_glyphname(const char *post,unsigned short *to_unicode,int charcode,unsigned short gid) // {{{ if charcode==0 -> force gid to be used
{
  if (gid==0) {
    return ".notdef";
  }
  const char *postName=emb_otf_get_post_name(post,gid);
  if (postName) {
    return postName;
  }
  static char ret[255];
  if (charcode) {
    if (to_unicode) { // i.e. encoding was there
      charcode=to_unicode[charcode];
      // TODO!? to_unicode should be able to represent more than one unicode character?
      // TODO for additional credit: for ligatures, etc  create /f_f /uni12341234  or the like
    }
    const char *aglname=aglfn13(charcode); // TODO? special case ZapfDingbats?
    if (aglname) {
      return aglname;
    }
    snprintf(ret,250,"uni%04X",charcode); // allows extraction
  } else {
    snprintf(ret,250,"c%d",gid);  // last resort: only by gid
  }
  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebp
movl %edx, %ebx
movq %rsi, %r14
testq %rdi, %rdi
je 0x5dbf
movq %rdi, %r15
callq 0x528a
cmpl $0x20000, %eax          # imm = 0x20000
jne 0x5dbf
movzwl 0x20(%r15), %ecx
rolw $0x8, %cx
cmpw %bp, %cx
jbe 0x5dbf
movzwl %bp, %eax
movzbl 0x22(%r15,%rax,2), %edx
shll $0x8, %edx
movzbl 0x23(%r15,%rax,2), %eax
orl %edx, %eax
cmpw $0x102, %ax             # imm = 0x102
setb %sil
testw %dx, %dx
sets %dl
orb %sil, %dl
jne 0x5dbf
movzwl %cx, %ecx
addq $0x22, %r15
leaq (%r15,%rcx,2), %rsi
addl $0xfffffefe, %eax       # imm = 0xFFFFFEFE
movzbl (%rsi), %ebx
subw $0x1, %ax
jb 0x5e27
addq %rbx, %rsi
incq %rsi
jmp 0x5dae
testl %ebx, %ebx
je 0x5dfa
testq %r14, %r14
je 0x5dd0
movslq %ebx, %rax
movzwl (%r14,%rax,2), %ebx
movzwl %bx, %edi
callq 0x758c
movq %rax, %r14
testq %rax, %rax
jne 0x5e19
leaq 0x93c9(%rip), %r14      # 0xf1b0
leaq 0x51fb(%rip), %rdx      # 0xafe9
movl $0xfa, %esi
movq %r14, %rdi
movl %ebx, %ecx
jmp 0x5e12
leaq 0x93af(%rip), %r14      # 0xf1b0
leaq 0x51e9(%rip), %rdx      # 0xaff1
movl $0xfa, %esi
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x2220
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
incq %rsi
leaq 0x947f(%rip), %r14      # 0xf2b0
movq %r14, %rdi
movq %rbx, %rdx
callq 0x2110
movb $0x0, (%rbx,%r14)
jmp 0x5e19
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/embed_sfnt.c
// Function: outfilter_ascii_ps
static void outfilter_ascii_ps(const char *buf,int len,void *context)  // {{{
{
  struct OUTFILTER_PS *of=context;
  OUTPUT_FN out=of->out;
  int iA;

  (*out)("<",1,of->ctx);
  of->len++;

  const char *last=buf;
  char tmp[256];
  while (len>0) {
    for (iA=0;(iA<76)&&(len>0);iA+=2,len--) {
      const unsigned char ch=buf[iA>>1];
      tmp[iA]="0123456789abcdef"[ch>>4];
      tmp[iA+1]="0123456789abcdef"[ch&0x0f];
    }
    buf+=iA>>1;
    if (buf<last+64000) {
      if (len>0) {
        tmp[iA++]='\n';
      }
      (*out)(tmp,iA,of->ctx);
    } else {
      last=buf;
      strcpy(tmp+iA,"00>\n<");
      iA+=5;
      (*out)(tmp,iA,of->ctx);
    }
    of->len+=iA;
  }

  (*out)("00>\n",4,of->ctx);
  of->len+=4;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r13
movq (%rdx), %rax
movq 0x8(%rdx), %rdx
leaq 0x51a0(%rip), %rdi      # 0xb00a
pushq $0x1
popq %rsi
movq %rax, 0x8(%rsp)
callq *%rax
incl 0x10(%rbx)
leaq 0x5177(%rip), %r15      # 0xaff5
movq %r13, %r14
testl %ebp, %ebp
jle 0x5f18
xorl %r12d, %r12d
movl %ebp, %eax
addl $-0x1, %eax
setb %cl
cmpq $0x4b, %r12
ja 0x5ec7
testb %cl, %cl
je 0x5ec7
movzbl (%r14), %ecx
movl %ecx, %edx
shrl $0x4, %edx
movb (%rdx,%r15), %dl
movb %dl, 0x10(%rsp,%r12)
andl $0xf, %ecx
movb (%rcx,%r15), %cl
movb %cl, 0x11(%rsp,%r12)
addq $0x2, %r12
incq %r14
movl %eax, %ebp
jmp 0x5e8e
leaq 0xfa00(%r13), %rax
cmpq %rax, %r14
jae 0x5ee7
testl %ebp, %ebp
je 0x5eff
movb $0xa, 0x10(%rsp,%r12)
leal 0x1(%r12), %eax
movl %eax, %r12d
jmp 0x5eff
movw $0x3c, 0x14(%rsp,%r12)
movl $0xa3e3030, 0x10(%rsp,%r12) # imm = 0xA3E3030
addl $0x5, %r12d
movq %r14, %r13
movq 0x8(%rbx), %rdx
leaq 0x10(%rsp), %rdi
movl %r12d, %esi
callq *0x8(%rsp)
addl %r12d, 0x10(%rbx)
jmp 0x5e81
movq 0x8(%rbx), %rdx
leaq 0x50e9(%rip), %rdi      # 0xb00c
pushq $0x4
popq %rsi
callq *0x8(%rsp)
addl $0x4, 0x10(%rbx)
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/embed_pdf.c
// Function: emb_pdf_fw_new
EMB_PDF_FONTWIDTHS *emb_pdf_fw_new(int datasize) // {{{
{
  assert(datasize>=0);
  EMB_PDF_FONTWIDTHS *ret=calloc(1,sizeof(EMB_PDF_FONTWIDTHS)+datasize*sizeof(int));
  if (!ret) {
    fprintf(stderr,"Bad alloc: %s\n", strerror(errno));
    assert(0);
    return NULL;
  }
  return ret;
}

// Assembly:
pushq %rbx
testl %edi, %edi
js 0x63c3
movl %edi, %eax
leaq 0x20(,%rax,4), %rsi
pushq $0x1
popq %rdi
callq 0x2100
testq %rax, %rax
je 0x63e2
popq %rbx
retq
leaq 0x4d49(%rip), %rdi      # 0xb113
leaq 0x4c57(%rip), %rsi      # 0xb028
leaq 0x4d47(%rip), %rcx      # 0xb11f
movl $0xcf, %edx
callq 0x20f0
movq 0x8bf7(%rip), %rax      # 0xefe0
movq (%rax), %rbx
callq 0x2040
movl (%rax), %edi
callq 0x2070
leaq 0x3f5a(%rip), %rsi      # 0xa359
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x21e0
leaq 0x48ad(%rip), %rdi      # 0xacc0
leaq 0x4c0e(%rip), %rsi      # 0xb028
leaq 0x4cfe(%rip), %rcx      # 0xb11f
movl $0xd3, %edx
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/embed_pdf.c
// Function: emb_pdf_fontwidths
EMB_PDF_FONTWIDTHS *emb_pdf_fontwidths(EMB_PARAMS *emb) // {{{
{
  assert(emb);

  if ( (emb->intype==EMB_FMT_TTF)||(emb->intype==EMB_FMT_OTF) ) {
    assert(emb->font->sfnt);
    if (emb->plan&EMB_A_MULTIBYTE) {
      return emb_otf_get_pdf_cidwidths(emb->font->sfnt,emb->subset);
    } else {
      return emb_otf_get_pdf_widths(emb->font->sfnt,/*encoding*/NULL,emb->font->sfnt->numGlyphs,emb->subset); // TODO: encoding
    }
  } else {
    fprintf(stderr,"NOT IMPLEMENTED\n");
    assert(0);
    return NULL;
  }
}

// Assembly:
pushq %rax
testq %rdi, %rdi
je 0x6753
movl (%rdi), %eax
decl %eax
cmpl $0x1, %eax
ja 0x6772
movq 0x10(%rdi), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x67ad
testb $0x1, 0xc(%rdi)
jne 0x6746
movzwl 0x4c(%rax), %edx
movq 0x20(%rdi), %rcx
movq %rax, %rdi
xorl %esi, %esi
popq %rax
jmp 0x5294
movq 0x20(%rdi), %rsi
movq %rax, %rdi
popq %rax
jmp 0x54eb
leaq 0x3b7a(%rip), %rdi      # 0xa2d4
leaq 0x48c7(%rip), %rsi      # 0xb028
leaq 0x4a5c(%rip), %rcx      # 0xb1c4
movl $0x151, %edx            # imm = 0x151
callq 0x20f0
movq 0x8867(%rip), %rax      # 0xefe0
movq (%rax), %rcx
leaq 0x425c(%rip), %rdi      # 0xa9df
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
callq 0x2280
leaq 0x452b(%rip), %rdi      # 0xacc0
leaq 0x488c(%rip), %rsi      # 0xb028
leaq 0x4a21(%rip), %rcx      # 0xb1c4
movl $0x15c, %edx            # imm = 0x15C
callq 0x20f0
leaq 0x421b(%rip), %rdi      # 0xa9cf
leaq 0x486d(%rip), %rsi      # 0xb028
leaq 0x4a02(%rip), %rcx      # 0xb1c4
movl $0x154, %edx            # imm = 0x154
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/embed_pdf.c
// Function: emb_pdf_escape_name
static const char *emb_pdf_escape_name(const char *name,int len) // {{{ // - statically allocated buffer
{
  assert(name);
  if (len==-1) {
    len=strlen(name);
  }
  assert(len<=127); // pdf implementation limit

  static char buf[128*3];
  int iA,iB;
  const char hex[]="0123456789abcdef";

  for (iA=0,iB=0;iA<len;iA++,iB++) {
    if ( ((unsigned char)name[iA]<33)||((unsigned char)name[iA]>126)||
         (strchr("#()<>[]{}/%",name[iA])) ) {
      buf[iB]='#';
      buf[++iB]=hex[(name[iA]>>4)&0x0f];
      buf[++iB]=hex[name[iA]&0xf];
    } else {
      buf[iB]=name[iA];
    }
  }
  buf[iB]=0;
  return buf;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x6c62
movq %rdi, %rbx
callq 0x2090
movq %rax, %rbp
cmpl $0x7f, %ebp
jg 0x6c7b
xorl %r13d, %r13d
testl %ebp, %ebp
cmovlel %r13d, %ebp
leaq 0x87ed(%rip), %rdx      # 0xf3c0
xorl %r15d, %r15d
movq %rbx, (%rsp)
movslq %r15d, %r12
cmpq %r13, %rbp
je 0x6c4e
movb (%rbx,%r13), %r14b
leal -0x7f(%r14), %eax
cmpb $-0x5e, %al
jb 0x6c10
movzbl %r14b, %esi
leaq 0x4afb(%rip), %rdi      # 0xb6f4
movq %rdx, %rbx
pushq $0xc
popq %rdx
callq 0x2180
movq %rbx, %rdx
movq (%rsp), %rbx
testq %rax, %rax
je 0x6c3f
movb $0x23, (%r12,%rdx)
movzbl (%rbx,%r13), %eax
shrl $0x4, %eax
leaq 0x4adc(%rip), %rsi      # 0xb700
movb (%rax,%rsi), %al
movb %al, 0x1(%r12,%rdx)
movzbl (%rbx,%r13), %eax
andl $0xf, %eax
movb (%rax,%rsi), %r14b
addl $0x2, %r12d
movl %r12d, %r15d
movslq %r15d, %r15
movb %r14b, (%r15,%rdx)
incq %r13
incl %r15d
jmp 0x6bda
movb $0x0, (%r12,%rdx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4924(%rip), %rdi      # 0xb58d
leaq 0x43b8(%rip), %rsi      # 0xb028
leaq 0x4a41(%rip), %rcx      # 0xb6b8
pushq $0x29
jmp 0x6c92
leaq 0x4a69(%rip), %rdi      # 0xb6eb
leaq 0x439f(%rip), %rsi      # 0xb028
leaq 0x4a28(%rip), %rcx      # 0xb6b8
pushq $0x2d
popq %rdx
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/embed_pdf.c
// Function: emb_pdf_simple_cidfont
char *emb_pdf_simple_cidfont(EMB_PARAMS *emb,const char *fontname,int descendant_obj_ref) // {{{ - to be freed by user
{
  assert(emb);
  assert(fontname);

  char *ret=NULL,*pos;
  int len,size;

  size=250;
  pos=ret=malloc(size);
  if (!ret) {
    fprintf(stderr,"Bad alloc: %s\n", strerror(errno));
    return NULL;
  }
     // for CFF: one of:
     // UniGB-UCS2-H, UniCNS-UCS2-H, UniJIS-UCS2-H, UniKS-UCS2-H
  const char *encoding="Identity-H",*addenc="-";
  if (emb->outtype==EMB_FMT_TTF) { // !=CidType0
    addenc="";
  }

  len=snprintf(pos,size,
               "<</Type /Font\n"
               "  /Subtype /Type0\n"
               "  /BaseFont /%s%s%s\n"
               "  /Encoding /%s\n"
               "  /DescendantFonts [%d 0 R]\n",
//               "  /ToUnicode ?\n" // TODO
               emb_pdf_escape_name(fontname,-1),
               addenc,((addenc[0])?encoding:""),
               encoding,
               descendant_obj_ref);
  NEXT;

  len=snprintf(pos,size,">>\n");
  NEXT;

  return ret;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x7083
movq %rsi, %r15
testq %rsi, %rsi
je 0x70a2
movl %edx, %r14d
movq %rdi, %r12
movl $0xfa, %edi
callq 0x21d0
movq %rax, %rbx
testq %rax, %rax
je 0x7057
cmpl $0x1, 0x4(%r12)
leaq 0x3581(%rip), %r12      # 0xa547
leaq 0x4524(%rip), %r13      # 0xb4f1
cmoveq %r12, %r13
movq %r15, %rdi
callq 0x6b9b
cmpb $0x0, (%r13)
leaq 0x4501(%rip), %r10      # 0xb4e6
cmovneq %r10, %r12
leaq 0x4503(%rip), %rdx      # 0xb4f3
leaq 0x83c9(%rip), %rcx      # 0xf3c0
movl $0xfa, %esi
movq %rbx, %rdi
movq %r13, %r8
movq %r12, %r9
xorl %eax, %eax
pushq %r14
pushq %r10
callq 0x2220
addq $0x10, %rsp
cmpl $0xfa, %eax
jae 0x70c1
movl %eax, %ecx
movq %rbx, %rdi
addq %rcx, %rdi
movl $0xfa, %r14d
subl %eax, %r14d
leaq 0x42ef(%rip), %rdx      # 0xb326
movq %r14, %rsi
xorl %eax, %eax
callq 0x2220
cmpl %r14d, %eax
jae 0x70e0
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x7f82(%rip), %rax      # 0xefe0
movq (%rax), %r14
callq 0x2040
movl (%rax), %edi
callq 0x2070
leaq 0x32e5(%rip), %rsi      # 0xa359
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x21e0
jmp 0x704a
leaq 0x324a(%rip), %rdi      # 0xa2d4
leaq 0x3f97(%rip), %rsi      # 0xb028
leaq 0x4407(%rip), %rcx      # 0xb49f
movl $0x212, %edx            # imm = 0x212
callq 0x20f0
leaq 0x4434(%rip), %rdi      # 0xb4dd
leaq 0x3f78(%rip), %rsi      # 0xb028
leaq 0x43e8(%rip), %rcx      # 0xb49f
movl $0x213, %edx            # imm = 0x213
callq 0x20f0
leaq 0x3bf8(%rip), %rdi      # 0xacc0
leaq 0x3f59(%rip), %rsi      # 0xb028
leaq 0x43c9(%rip), %rcx      # 0xb49f
movl $0x230, %edx            # imm = 0x230
callq 0x20f0
leaq 0x3bd9(%rip), %rdi      # 0xacc0
leaq 0x3f3a(%rip), %rsi      # 0xb028
leaq 0x43aa(%rip), %rcx      # 0xb49f
movl $0x233, %edx            # imm = 0x233
callq 0x20f0
// File: /workspace/github_c_makefile_star2_O2/smilingthax[P]libfontembed/embed_pdf.c
// Function: emb_pdf_simple_stdfont
char *emb_pdf_simple_stdfont(EMB_PARAMS *emb) // {{{ - to be freed by user
{
  assert(emb);
  assert(emb->font->stdname);

  char *ret=NULL,*pos;
  int len,size;

  size=300;
  pos=ret=malloc(size);
  if (!ret) {
    fprintf(stderr,"Bad alloc: %s\n", strerror(errno));
    return NULL;
  }

  len=snprintf(pos,size,
               "<</Type/Font\n"
               "  /Subtype /Type1\n"
               "  /BaseFont /%s\n"
               ">>\n",
//               emb_pdf_get_font_subtype(emb),
               emb->font->stdname);
  NEXT;

  return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x7182
movq 0x10(%rdi), %rax
movq 0x8(%rax), %r14
testq %r14, %r14
je 0x71a1
movl $0x12c, %edi            # imm = 0x12C
callq 0x21d0
movq %rax, %rbx
testq %rax, %rax
je 0x7156
leaq 0x4460(%rip), %rdx      # 0xb592
movl $0x12c, %esi            # imm = 0x12C
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2220
cmpl $0x12c, %eax            # imm = 0x12C
jae 0x71c0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x7e83(%rip), %rax      # 0xefe0
movq (%rax), %r14
callq 0x2040
movl (%rax), %edi
callq 0x2070
leaq 0x31e6(%rip), %rsi      # 0xa359
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x21e0
jmp 0x714b
leaq 0x314b(%rip), %rdi      # 0xa2d4
leaq 0x3e98(%rip), %rsi      # 0xb028
leaq 0x43bd(%rip), %rcx      # 0xb554
movl $0x23b, %edx            # imm = 0x23B
callq 0x20f0
leaq 0x43d7(%rip), %rdi      # 0xb57f
leaq 0x3e79(%rip), %rsi      # 0xb028
leaq 0x439e(%rip), %rcx      # 0xb554
movl $0x23c, %edx            # imm = 0x23C
callq 0x20f0
leaq 0x3af9(%rip), %rdi      # 0xacc0
leaq 0x3e5a(%rip), %rsi      # 0xb028
leaq 0x437f(%rip), %rcx      # 0xb554
movl $0x24f, %edx            # imm = 0x24F
callq 0x20f0
nop