// File: /workspace/github_c_makefile_star2_O0/sonicse[P]dbf2mysql/dbf.c
// Function: dbf_open
dbhead *dbf_open(char *file, int flags)
{
    int			file_no;
    dbhead		*dbh;
    f_descr		*fields;
    dbf_header		*head;
    dbf_field		*fieldc;
    int			t;
    int			i;
    char		*sp;
    int			memofound;
    dbf_memo_header	*dbmh;

    if ((dbh = (dbhead *)calloc(1, sizeof(dbhead))) == NULL) {
	return (dbhead *)DBF_ERROR;
    }

    if ((head = (dbf_header *)malloc(sizeof(dbf_header))) == NULL) {
	free(dbh);
	return (dbhead *)DBF_ERROR;
    }

    if ((fieldc = (dbf_field *)malloc(sizeof(dbf_field))) == NULL) {
	free(head);
	free(dbh);
	return (dbhead *)DBF_ERROR;
    }

    if ((file_no = open(file, flags)) == -1) {
	free(fieldc);
	free(head);
	free(dbh);
	return (dbhead *)DBF_ERROR;
    }

/* read in the disk-header */

    if (read(file_no, head, sizeof(dbf_header)) == -1) {
	close(file_no);
	free(fieldc);
	free(head);
	free(dbh);
	return (dbhead *)DBF_ERROR;
    }

    for (t = 0; t < sizeof(valid_dbf_types)/sizeof(valid_dbf_types[0]); t++)
	if (valid_dbf_types[t].sig == head->dbh_dbt)
	    break;

    if (t == sizeof(valid_dbf_types)/sizeof(valid_dbf_types[0])) {
	close(file_no);
	fprintf(stderr,"Header value %02x not valid\n", head->dbh_dbt);
	free(fieldc);
	free(head);
	free(dbh);
	return (dbhead *)DBF_ERROR;
    }

    dbh->db_description = valid_dbf_types[t].description;

    if (valid_dbf_types[t].hasMemo != DBF_MTYPE_NONE) {
	dbh->db_memo = valid_dbf_types[t].hasMemo;
    } else {
	dbh->db_memo = 0;
    }
    dbh->db_fd = file_no;
    dbh->db_year = head->dbh_year;
    dbh->db_month = head->dbh_month;
    dbh->db_day = head->dbh_day;
    dbh->db_hlen = get_short((u_char *)&head->dbh_hlen);
    dbh->db_records = get_long((u_char *)&head->dbh_records);
    dbh->db_currec = 0;
    dbh->db_rlen = get_short((u_char *)&head->dbh_rlen);
    dbh->db_nfields = (dbh->db_hlen - sizeof(dbf_header)) / sizeof(dbf_field);

    if ((dbh->db_buff = (u_char *)malloc(dbh->db_rlen)) == NULL) {
	close(file_no);
	free(fieldc);
	free(head);
	free(dbh);
	return (dbhead *)DBF_ERROR;
    }

    /* dbh->db_hlen - sizeof(dbf_header) isn't the
       correct size, cos dbh->hlen is in fact
       a little more cos of the 0x0D (and
       possibly another byte, 0x4E, I have
       seen this somewhere). Because of rounding
       everything turns out right :) */

    if ((fields = (f_descr *)calloc(dbh->db_nfields, sizeof(f_descr))) == NULL)
    {
	close(file_no);
	free(fieldc);
	free(head);
	free(dbh);
	return (dbhead *)DBF_ERROR;
    }

    memofound = 0;
    for (t = 0; t < dbh->db_nfields; t++)
    {
	read(file_no, fieldc, sizeof(dbf_field));
	if (fieldc->dbf_type == 0x00)
	{
	    dbh->db_nfields = t;
	    break;
	}
	strncpy(fields[t].db_name, fieldc->dbf_name, DBF_NAMELEN);
	fields[t].db_type = fieldc->dbf_type;	
	fields[t].db_flen = fieldc->dbf_flen;
	fields[t].db_dec  = fieldc->dbf_dec;
	fields[t].db_idx  = fieldc->dbf_isIndexed;
	if (fields[t].db_type == 'M')
	    memofound++;
    }

    dbh->db_offset = dbh->db_hlen;
    dbh->db_fields = fields;

    free(fieldc);
    free(head);

    if (memofound == 0)
    {
	dbh->db_memo = DBF_MTYPE_NONE;
    }
    else
    {
	dbh->mb_blksiz = DBF_DBT_BLOCK_SIZE;
	dbh->mb_bufsiz = dbh->mb_blksiz * 2;
	if ((dbh->mb_buffer = malloc(dbh->mb_bufsiz)) == NULL)
	{
	    perror("malloc");
	    dbf_close(&dbh);
	    return (dbhead *)DBF_ERROR;
	}
	dbmh = (dbf_memo_header *)dbh->mb_buffer;
	sp = strdup(file);
	i = strlen(sp)-1;
	switch (dbh->db_memo)
	{
	  case DBF_MTYPE_FPT:
	    if (isupper(sp[i]))
		strcpy(&sp[i-2],"FPT");
	    else
		strcpy(&sp[i-2],"fpt");
	    if ((dbh->db_memofd = open(sp, flags)) == -1)
	    {
		if (isupper(sp[i]))
		    strcpy(&sp[i-2],"fpt");
		else
		    strcpy(&sp[i-2],"FPT");
		if ((dbh->db_memofd = open(sp, flags)) == -1)
		{
		    char	msg[256];
		    int	saverrno = errno;

		    if (isupper(sp[i]))
			strcpy(&sp[i-2],"fpt");
		    else
			strcpy(&sp[i-2],"FPT");
		    snprintf(msg, sizeof(msg),
			     "couldn't find required memo data file: %s - (%d)",
			     sp,
			     saverrno);
		    msg[sizeof(msg)-1] = 0;
		    errno = saverrno;
		    perror(msg);
		    dbf_close(&dbh);
		    free(sp);
		    return (dbhead *)DBF_ERROR;
		}
	    }
	    if (read(dbh->db_memofd, dbh->mb_buffer, sizeof(dbf_memo_header)) != sizeof(dbf_memo_header))
	    {
		perror("memo file read");
		dbf_close(&dbh);
		free(sp);
		return (dbhead *)DBF_ERROR;
	    }
	    dbh->mb_next_blk = (dbmh->fpt.next_block[0]<<24) + (dbmh->fpt.next_block[1]<<16) +
		(dbmh->fpt.next_block[2]<<8) + (dbmh->fpt.next_block[3]<<0);
	    dbh->mb_blksiz = (dbmh->fpt.blocksize[0]<<8) + dbmh->fpt.blocksize[1];
#if 0
	    fprintf(stderr, "Visual FoxPro memo file block size of %lu, next %lu\n", dbh->mb_blksiz,dbh->mb_next_blk);
#endif
	    if (dbh->mb_blksiz > dbh->mb_bufsiz)
	    {
		int	newsiz = (((dbh->mb_blksiz * 2 + 4095)/4096)+1)*4096-16;
		void	*tmpptr = realloc(dbh->mb_buffer, newsiz);
		if (tmpptr != NULL)
		{
		    dbh->mb_buffer = tmpptr;
		    dbh->mb_bufsiz = newsiz;
		}
	    }
	    break;

	  case DBF_MTYPE_DBT3:
	  case DBF_MTYPE_DBT4:
	    if (isupper(sp[i]))
		strcpy(&sp[i-2],"DBT");
	    else
		strcpy(&sp[i-2],"dbt");
	    if ((dbh->db_memofd = open(sp, flags)) == -1)
	    {
		if (isupper(sp[i]))
		    strcpy(&sp[i-2],"dbt");
		else
		    strcpy(&sp[i-2],"DBT");
		if ((dbh->db_memofd = open(sp, flags)) == -1)
		{
		    char	msg[256];
		    int	saverrno = errno;

		    if (isupper(sp[i]))
			strcpy(&sp[i-2],"dbt");
		    else
			strcpy(&sp[i-2],"DBT");
		    snprintf(msg, sizeof(msg),
			     "couldn't find required memo data file: %s - (%d)",
			     sp,
			     saverrno);
		    msg[sizeof(msg)-1] = 0;
		    errno = saverrno;
		    perror(msg);
		    dbf_close(&dbh);
		    free(sp);
		    return (dbhead *)DBF_ERROR;
		}
	    }
	    if (read(dbh->db_memofd, dbh->mb_buffer, sizeof(dbf_memo_header)) != sizeof(dbf_memo_header))
	    {
		perror("memo file read");
		dbf_close(&dbh);
		free(sp);
		return (dbhead *)DBF_ERROR;
	    }

	    /* Visual FoxPro V6.0 when told to write a DB IV format actually
	       creates a DB III+ file however leaves the version field zero
	       like a DB IV one, try to account for this */
	    if (dbmh->dbiii.version == 0x00 &&
		get_short(dbmh->dbiv.blocklen) == 0 &&
		dbmh->dbiv.filename[0] == '\0')
		dbmh->dbiii.version = 0x03;

	    switch (dbmh->dbiii.version)
	    {
	      case 0x03:
		dbh->db_memo = DBF_MTYPE_DBT3; /* Set the real type */
		dbh->mb_next_blk = get_long(dbmh->dbiii.next_block);
		dbh->mb_blksiz = DBF_DBT_BLOCK_SIZE;
#if 0
		fprintf(stderr, "DB III memo file block size of %lu, next %lu\n", dbh->mb_blksiz, dbh->mb_next_blk);
#endif
		break;

	      case 0x00:
		dbh->db_memo = DBF_MTYPE_DBT4; /* Set the real type */
		dbh->mb_next_blk = get_long(dbmh->dbiv.next_block);
		dbh->mb_blksiz = get_short(dbmh->dbiv.blocklen);
#if 0
		fprintf(stderr, "DB IV memo file block size of %lu, next %lu\n", dbh->mb_blksiz, dbh->mb_next_blk);
#endif
	      break;

	      default:
		fprintf(stderr,"DB III+/DB IV bad memo file version %02x\n",
			dbmh->dbiii.version);
		dbf_close(&dbh);
		free(sp);
		return (dbhead *)DBF_ERROR;
	    }
	    
	    if (dbh->mb_blksiz > dbh->mb_bufsiz)
	    {
		int	newsiz = (((dbh->mb_blksiz * 2 + 4095)/4096)+1)*4096-16;
		void	*tmpptr = realloc(dbh->mb_buffer, newsiz);
		if (tmpptr != NULL)
		{
		    dbh->mb_buffer = tmpptr;
		    dbh->mb_bufsiz = newsiz;
		}
	    }
	    break;

	  case DBF_MTYPE_NONE:
	  default:
	    fprintf(stderr,"Found memo field in table of type (%s) which isn't supported yet\n",
		    dbh->db_description);
	    dbf_close(&dbh);
	    free(sp);
	    return (dbhead *)DBF_ERROR;
	    break;
	}
	free(sp);
    }
    
    
    return dbh;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x1, %edi
movl $0x88, %esi
callq 0x2130
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
jne 0x43fb
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
movl $0x20, %edi
callq 0x2260
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x4428
movq -0x20(%rbp), %rdi
callq 0x2210
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
movl $0x20, %edi
callq 0x2260
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0x445e
movq -0x30(%rbp), %rdi
callq 0x2210
movq -0x20(%rbp), %rdi
callq 0x2210
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movb $0x0, %al
callq 0x2140
movl %eax, -0x18(%rbp)
cmpl $-0x1, %eax
jne 0x449f
movq -0x38(%rbp), %rdi
callq 0x2210
movq -0x30(%rbp), %rdi
callq 0x2210
movq -0x20(%rbp), %rdi
callq 0x2210
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
movl -0x18(%rbp), %edi
movq -0x30(%rbp), %rsi
movl $0x20, %edx
callq 0x22a0
cmpq $-0x1, %rax
jne 0x44e9
movl -0x18(%rbp), %edi
callq 0x2380
movq -0x38(%rbp), %rdi
callq 0x2210
movq -0x30(%rbp), %rdi
callq 0x2210
movq -0x20(%rbp), %rdi
callq 0x2210
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
movl $0x0, -0x3c(%rbp)
movslq -0x3c(%rbp), %rax
cmpq $0x9, %rax
jae 0x4529
movslq -0x3c(%rbp), %rcx
leaq 0x6cfb(%rip), %rax      # 0xb200
shlq $0x4, %rcx
addq %rcx, %rax
movzbl (%rax), %eax
movq -0x30(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x451c
jmp 0x4529
jmp 0x451e
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x44f0
movslq -0x3c(%rbp), %rax
cmpq $0x9, %rax
jne 0x4585
movl -0x18(%rbp), %edi
callq 0x2380
movq 0x6a96(%rip), %rax      # 0xafd8
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movzbl (%rax), %edx
leaq 0x4631(%rip), %rsi      # 0x8b84
movb $0x0, %al
callq 0x2290
movq -0x38(%rbp), %rdi
callq 0x2210
movq -0x30(%rbp), %rdi
callq 0x2210
movq -0x20(%rbp), %rdi
callq 0x2210
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
movslq -0x3c(%rbp), %rcx
leaq 0x6c70(%rip), %rax      # 0xb200
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x48(%rax)
movslq -0x3c(%rbp), %rcx
leaq 0x6c52(%rip), %rax      # 0xb200
shlq $0x4, %rcx
addq %rcx, %rax
movzbl 0x1(%rax), %eax
cmpl $0x0, %eax
je 0x45dc
movslq -0x3c(%rbp), %rcx
leaq 0x6c37(%rip), %rax      # 0xb200
shlq $0x4, %rcx
addq %rcx, %rax
movb 0x1(%rax), %cl
movq -0x20(%rbp), %rax
movb %cl, 0x10(%rax)
jmp 0x45e4
movq -0x20(%rbp), %rax
movb $0x0, 0x10(%rax)
movl -0x18(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movb 0x1(%rax), %cl
movq -0x20(%rbp), %rax
movb %cl, 0x11(%rax)
movq -0x30(%rbp), %rax
movb 0x2(%rax), %cl
movq -0x20(%rbp), %rax
movb %cl, 0x12(%rax)
movq -0x30(%rbp), %rax
movb 0x3(%rax), %cl
movq -0x20(%rbp), %rax
movb %cl, 0x13(%rax)
movq -0x30(%rbp), %rdi
addq $0x8, %rdi
callq 0x7070
movswq %ax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x30(%rbp), %rdi
addq $0x4, %rdi
callq 0x6f70
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x28(%rax)
movq -0x30(%rbp), %rdi
addq $0xa, %rdi
callq 0x7070
movw %ax, %cx
movq -0x20(%rbp), %rax
movw %cx, 0x30(%rax)
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rax
subq $0x20, %rax
shrq $0x5, %rax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x32(%rax)
movq -0x20(%rbp), %rax
movzwl 0x30(%rax), %eax
movl %eax, %edi
callq 0x2260
movq -0x20(%rbp), %rcx
movq %rax, 0x38(%rcx)
cmpq $0x0, %rax
jne 0x46d5
movl -0x18(%rbp), %edi
callq 0x2380
movq -0x38(%rbp), %rdi
callq 0x2210
movq -0x30(%rbp), %rdi
callq 0x2210
movq -0x20(%rbp), %rdi
callq 0x2210
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
movq -0x20(%rbp), %rax
movzbl 0x32(%rax), %eax
movl %eax, %edi
movl $0xf, %esi
callq 0x2130
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x4726
movl -0x18(%rbp), %edi
callq 0x2380
movq -0x38(%rbp), %rdi
callq 0x2210
movq -0x30(%rbp), %rdi
callq 0x2210
movq -0x20(%rbp), %rdi
callq 0x2210
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x20(%rbp), %rcx
movzbl 0x32(%rcx), %ecx
cmpl %ecx, %eax
jge 0x4828
movl -0x18(%rbp), %edi
movq -0x38(%rbp), %rsi
movl $0x20, %edx
callq 0x22a0
movq -0x38(%rbp), %rax
movzbl 0xb(%rax), %eax
cmpl $0x0, %eax
jne 0x4776
movl -0x3c(%rbp), %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x32(%rax)
jmp 0x4828
movq -0x28(%rbp), %rdi
movslq -0x3c(%rbp), %rax
imulq $0xf, %rax, %rax
addq %rax, %rdi
movq -0x38(%rbp), %rsi
movl $0xb, %edx
callq 0x2100
movq -0x38(%rbp), %rax
movb 0xb(%rax), %cl
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rdx
imulq $0xf, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0xb(%rax)
movq -0x38(%rbp), %rax
movb 0x10(%rax), %cl
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rdx
imulq $0xf, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0xc(%rax)
movq -0x38(%rbp), %rax
movb 0x11(%rax), %cl
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rdx
imulq $0xf, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0xd(%rax)
movq -0x38(%rbp), %rax
movb 0x1f(%rax), %cl
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rdx
imulq $0xf, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0xe(%rax)
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
imulq $0xf, %rcx, %rcx
addq %rcx, %rax
movzbl 0xb(%rax), %eax
cmpl $0x4d, %eax
jne 0x4818
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x481a
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x4734
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x38(%rbp), %rdi
callq 0x2210
movq -0x30(%rbp), %rdi
callq 0x2210
cmpl $0x0, -0x4c(%rbp)
jne 0x4869
movq -0x20(%rbp), %rax
movb $0x0, 0x10(%rax)
jmp 0x500e
movq -0x20(%rbp), %rax
movq $0x200, 0x68(%rax)      # imm = 0x200
movq -0x20(%rbp), %rax
movq 0x68(%rax), %rcx
shlq %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rdi
callq 0x2260
movq -0x20(%rbp), %rcx
movq %rax, 0x58(%rcx)
cmpq $0x0, %rax
jne 0x48c8
leaq 0x42f7(%rip), %rdi      # 0x8ba1
callq 0x2160
leaq -0x20(%rbp), %rdi
callq 0x5030
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2350
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x20c0
decl %eax
movl %eax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movzbl 0x10(%rax), %eax
movl %eax, -0x284(%rbp)
testl %eax, %eax
je 0x4fc4
jmp 0x4907
movl -0x284(%rbp), %eax
decl %eax
subl $0x2, %eax
jb 0x4c29
jmp 0x491a
movl -0x284(%rbp), %eax
subl $0x4, %eax
jne 0x4fc6
jmp 0x492b
callq 0x21e0
movq (%rax), %rax
movq -0x48(%rbp), %rcx
movslq -0x40(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x496d
movq -0x48(%rbp), %rdi
movl -0x40(%rbp), %eax
subl $0x2, %eax
cltq
addq %rax, %rdi
leaq 0x4242(%rip), %rsi      # 0x8ba8
callq 0x2190
jmp 0x4988
movq -0x48(%rbp), %rdi
movl -0x40(%rbp), %eax
subl $0x2, %eax
cltq
addq %rax, %rdi
leaq 0x4229(%rip), %rsi      # 0x8bac
callq 0x2190
movq -0x48(%rbp), %rdi
movl -0x14(%rbp), %esi
movb $0x0, %al
callq 0x2140
movq -0x20(%rbp), %rcx
movl %eax, 0x50(%rcx)
cmpl $-0x1, %eax
jne 0x4afd
callq 0x21e0
movq (%rax), %rax
movq -0x48(%rbp), %rcx
movslq -0x40(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x49e8
movq -0x48(%rbp), %rdi
movl -0x40(%rbp), %eax
subl $0x2, %eax
cltq
addq %rax, %rdi
leaq 0x41cb(%rip), %rsi      # 0x8bac
callq 0x2190
jmp 0x4a03
movq -0x48(%rbp), %rdi
movl -0x40(%rbp), %eax
subl $0x2, %eax
cltq
addq %rax, %rdi
leaq 0x41aa(%rip), %rsi      # 0x8ba8
callq 0x2190
movq -0x48(%rbp), %rdi
movl -0x14(%rbp), %esi
movb $0x0, %al
callq 0x2140
movq -0x20(%rbp), %rcx
movl %eax, 0x50(%rcx)
cmpl $-0x1, %eax
jne 0x4afb
callq 0x2040
movl (%rax), %eax
movl %eax, -0x164(%rbp)
callq 0x21e0
movq (%rax), %rax
movq -0x48(%rbp), %rcx
movslq -0x40(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x4a70
movq -0x48(%rbp), %rdi
movl -0x40(%rbp), %eax
subl $0x2, %eax
cltq
addq %rax, %rdi
leaq 0x4143(%rip), %rsi      # 0x8bac
callq 0x2190
jmp 0x4a8b
movq -0x48(%rbp), %rdi
movl -0x40(%rbp), %eax
subl $0x2, %eax
cltq
addq %rax, %rdi
leaq 0x4122(%rip), %rsi      # 0x8ba8
callq 0x2190
leaq -0x160(%rbp), %rdi
movq -0x48(%rbp), %rcx
movl -0x164(%rbp), %r8d
movl $0x100, %esi            # imm = 0x100
leaq 0x4107(%rip), %rdx      # 0x8bb0
movb $0x0, %al
callq 0x2300
movb $0x0, -0x61(%rbp)
movl -0x164(%rbp), %eax
movl %eax, -0x288(%rbp)
callq 0x2040
movl -0x288(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x160(%rbp), %rdi
callq 0x2160
leaq -0x20(%rbp), %rdi
callq 0x5030
movq -0x48(%rbp), %rdi
callq 0x2210
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
jmp 0x4afd
movq -0x20(%rbp), %rax
movl 0x50(%rax), %edi
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rsi
movl $0x16, %edx
callq 0x22a0
cmpq $0x16, %rax
je 0x4b4a
leaq 0x40be(%rip), %rdi      # 0x8be1
callq 0x2160
leaq -0x20(%rbp), %rdi
callq 0x5030
movq -0x48(%rbp), %rdi
callq 0x2210
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
movq -0x58(%rbp), %rax
movzbl (%rax), %eax
shll $0x18, %eax
movq -0x58(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
shll $0x10, %ecx
addl %ecx, %eax
movq -0x58(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
shll $0x8, %ecx
addl %ecx, %eax
movq -0x58(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
shll $0x0, %ecx
addl %ecx, %eax
movslq %eax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x58(%rbp), %rax
movzbl 0x6(%rax), %eax
shll $0x8, %eax
movq -0x58(%rbp), %rcx
movzbl 0x7(%rcx), %ecx
addl %ecx, %eax
movslq %eax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x68(%rax)
movq -0x20(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x60(%rcx), %rax
jbe 0x4c24
movq -0x20(%rbp), %rax
movq 0x68(%rax), %rax
shlq %rax
addq $0xfff, %rax            # imm = 0xFFF
shrq $0xc, %rax
addq $0x1, %rax
shlq $0xc, %rax
subq $0x10, %rax
movl %eax, -0x168(%rbp)
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rdi
movslq -0x168(%rbp), %rsi
callq 0x2320
movq %rax, -0x170(%rbp)
cmpq $0x0, -0x170(%rbp)
je 0x4c22
movq -0x170(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x58(%rax)
movslq -0x168(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x60(%rax)
jmp 0x4c24
jmp 0x5005
callq 0x21e0
movq (%rax), %rax
movq -0x48(%rbp), %rcx
movslq -0x40(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x4c6b
movq -0x48(%rbp), %rdi
movl -0x40(%rbp), %eax
subl $0x2, %eax
cltq
addq %rax, %rdi
leaq 0x3f8c(%rip), %rsi      # 0x8bf0
callq 0x2190
jmp 0x4c86
movq -0x48(%rbp), %rdi
movl -0x40(%rbp), %eax
subl $0x2, %eax
cltq
addq %rax, %rdi
leaq 0x3f73(%rip), %rsi      # 0x8bf4
callq 0x2190
movq -0x48(%rbp), %rdi
movl -0x14(%rbp), %esi
movb $0x0, %al
callq 0x2140
movq -0x20(%rbp), %rcx
movl %eax, 0x50(%rcx)
cmpl $-0x1, %eax
jne 0x4dfe
callq 0x21e0
movq (%rax), %rax
movq -0x48(%rbp), %rcx
movslq -0x40(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x4ce6
movq -0x48(%rbp), %rdi
movl -0x40(%rbp), %eax
subl $0x2, %eax
cltq
addq %rax, %rdi
leaq 0x3f15(%rip), %rsi      # 0x8bf4
callq 0x2190
jmp 0x4d01
movq -0x48(%rbp), %rdi
movl -0x40(%rbp), %eax
subl $0x2, %eax
cltq
addq %rax, %rdi
leaq 0x3ef4(%rip), %rsi      # 0x8bf0
callq 0x2190
movq -0x48(%rbp), %rdi
movl -0x14(%rbp), %esi
movb $0x0, %al
callq 0x2140
movq -0x20(%rbp), %rcx
movl %eax, 0x50(%rcx)
cmpl $-0x1, %eax
jne 0x4dfc
callq 0x2040
movl (%rax), %eax
movl %eax, -0x274(%rbp)
callq 0x21e0
movq (%rax), %rax
movq -0x48(%rbp), %rcx
movslq -0x40(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x4d6e
movq -0x48(%rbp), %rdi
movl -0x40(%rbp), %eax
subl $0x2, %eax
cltq
addq %rax, %rdi
leaq 0x3e8d(%rip), %rsi      # 0x8bf4
callq 0x2190
jmp 0x4d89
movq -0x48(%rbp), %rdi
movl -0x40(%rbp), %eax
subl $0x2, %eax
cltq
addq %rax, %rdi
leaq 0x3e6c(%rip), %rsi      # 0x8bf0
callq 0x2190
leaq -0x270(%rbp), %rdi
movq -0x48(%rbp), %rcx
movl -0x274(%rbp), %r8d
movl $0x100, %esi            # imm = 0x100
leaq 0x3e09(%rip), %rdx      # 0x8bb0
movb $0x0, %al
callq 0x2300
movb $0x0, -0x171(%rbp)
movl -0x274(%rbp), %eax
movl %eax, -0x28c(%rbp)
callq 0x2040
movl -0x28c(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x270(%rbp), %rdi
callq 0x2160
leaq -0x20(%rbp), %rdi
callq 0x5030
movq -0x48(%rbp), %rdi
callq 0x2210
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
jmp 0x4dfe
movq -0x20(%rbp), %rax
movl 0x50(%rax), %edi
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rsi
movl $0x16, %edx
callq 0x22a0
cmpq $0x16, %rax
je 0x4e4b
leaq 0x3dbd(%rip), %rdi      # 0x8be1
callq 0x2160
leaq -0x20(%rbp), %rdi
callq 0x5030
movq -0x48(%rbp), %rdi
callq 0x2210
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
movq -0x58(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x0, %eax
jne 0x4e80
movq -0x58(%rbp), %rdi
addq $0x14, %rdi
callq 0x7070
cwtl
cmpl $0x0, %eax
jne 0x4e80
movq -0x58(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl $0x0, %eax
jne 0x4e80
movq -0x58(%rbp), %rax
movb $0x3, 0x10(%rax)
movq -0x58(%rbp), %rax
movzbl 0x10(%rax), %eax
movl %eax, -0x290(%rbp)
testl %eax, %eax
je 0x4ecb
jmp 0x4e94
movl -0x290(%rbp), %eax
subl $0x3, %eax
jne 0x4f02
jmp 0x4ea1
movq -0x20(%rbp), %rax
movb $0x1, 0x10(%rax)
movq -0x58(%rbp), %rdi
callq 0x6f70
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x20(%rbp), %rax
movq $0x200, 0x68(%rax)      # imm = 0x200
jmp 0x4f44
movq -0x20(%rbp), %rax
movb $0x2, 0x10(%rax)
movq -0x58(%rbp), %rdi
callq 0x6f70
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x58(%rbp), %rdi
addq $0x14, %rdi
callq 0x7070
movswq %ax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x68(%rax)
jmp 0x4f44
movq 0x60cf(%rip), %rax      # 0xafd8
movq (%rax), %rdi
movq -0x58(%rbp), %rax
movzbl 0x10(%rax), %edx
leaq 0x3cdd(%rip), %rsi      # 0x8bf8
movb $0x0, %al
callq 0x2290
leaq -0x20(%rbp), %rdi
callq 0x5030
movq -0x48(%rbp), %rdi
callq 0x2210
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
movq -0x20(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x60(%rcx), %rax
jbe 0x4fc2
movq -0x20(%rbp), %rax
movq 0x68(%rax), %rax
shlq %rax
addq $0xfff, %rax            # imm = 0xFFF
shrq $0xc, %rax
addq $0x1, %rax
shlq $0xc, %rax
subq $0x10, %rax
movl %eax, -0x278(%rbp)
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rdi
movslq -0x278(%rbp), %rsi
callq 0x2320
movq %rax, -0x280(%rbp)
cmpq $0x0, -0x280(%rbp)
je 0x4fc0
movq -0x280(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x58(%rax)
movslq -0x278(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x60(%rax)
jmp 0x4fc2
jmp 0x5005
jmp 0x4fc6
movq 0x600b(%rip), %rax      # 0xafd8
movq (%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rdx
leaq 0x3c43(%rip), %rsi      # 0x8c22
movb $0x0, %al
callq 0x2290
leaq -0x20(%rbp), %rdi
callq 0x5030
movq -0x48(%rbp), %rdi
callq 0x2210
movq $-0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x5016
movq -0x48(%rbp), %rdi
callq 0x2210
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
nopw %cs:(%rax,%rax)