// File: /workspace/github_c_makefile_star2_O0/smilingthax[P]libfontembed/sfnt.c
// Function: otf_read_table
char *otf_read_table(OTF_FILE *otf,char *buf,const OTF_DIRENT *table) // {{{
{
  char *ours=NULL;

  if (table->length==0) {
    return buf;
  } else if ( (table->compLength<0)||(table->length<table->compLength) ) {
    assert(0);
    return NULL;
  }

  const int pad_len=otf_padded(table->length); // for checksum...
  if (!buf) {
    ours=buf=malloc(sizeof(char)*pad_len);
    if (!buf) {
      fprintf(stderr,"Bad alloc: %s\n", strerror(errno));
      return NULL;
    }
  }

  int res;
  if (table->compLength<table->length) {
    res=otf_read_compressed_raw(otf->f,buf,table->offset,pad_len,table->compLength);
  } else {
    res=otf_read_raw(otf->f,buf,table->offset,pad_len);
  }
  if (res==pad_len) {
    return buf;
  } else if (res==table->length) {
    // (file/uncompressed) length is not a multiple of 4, fill missing padding with zero
    memset(buf+res,0,pad_len-res);
    return buf;
  } else if (res!=-1) {
    fprintf(stderr,"Short read\n");
  }
  free(ours);
  return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x2ec3
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x303d
movq -0x20(%rbp), %rax
cmpl $0x0, 0x10(%rax)
jb 0x2edd
movq -0x20(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jae 0x2efc
leaq 0xbe1c(%rip), %rdi      # 0xed00
leaq 0xbba4(%rip), %rsi      # 0xea8f
movl $0x81, %edx
leaq 0xb428(%rip), %rcx      # 0xe31f
callq 0x2100
jmp 0x2efe
movq -0x20(%rbp), %rax
movl 0xc(%rax), %edi
callq 0x3050
movl %eax, -0x2c(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x2f6e
movslq -0x2c(%rbp), %rdi
shlq $0x0, %rdi
callq 0x21d0
movq %rax, -0x18(%rbp)
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x2f6c
movq 0x100a9(%rip), %rax     # 0x12fe0
movq (%rax), %rax
movq %rax, -0x38(%rbp)
callq 0x2040
movl (%rax), %edi
callq 0x2070
movq -0x38(%rbp), %rdi
movq %rax, %rdx
leaq 0xb404(%rip), %rsi      # 0xe35c
movb $0x0, %al
callq 0x21e0
movq $0x0, -0x8(%rbp)
jmp 0x303d
jmp 0x2f6e
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x2fa8
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %edx
movslq -0x2c(%rbp), %rcx
movq -0x20(%rbp), %rax
movl 0x10(%rax), %r8d
callq 0x3070
movl %eax, -0x30(%rbp)
jmp 0x2fc7
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %edx
movl -0x2c(%rbp), %ecx
callq 0x3190
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x2fd9
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x303d
movl -0x30(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jne 0x300a
movq -0x18(%rbp), %rdi
movslq -0x30(%rbp), %rax
addq %rax, %rdi
movl -0x2c(%rbp), %eax
subl -0x30(%rbp), %eax
movslq %eax, %rdx
xorl %esi, %esi
callq 0x20e0
movq -0x18(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x303d
cmpl $-0x1, -0x30(%rbp)
je 0x3028
movq 0xffc9(%rip), %rax      # 0x12fe0
movq (%rax), %rdi
leaq 0xb34a(%rip), %rsi      # 0xe36b
movb $0x0, %al
callq 0x21e0
jmp 0x302a
jmp 0x302c
movq -0x28(%rbp), %rdi
callq 0x21b0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)