LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/JimKent[P]linearSat/lib/mime.c
// Function: getMimeHeaderMainVal
char *getMimeHeaderMainVal(char *header)
/* Parse a typical mime header line returning the first
 * main value up to whitespace, punctuation, or end. 
 * freeMem the returned string when done */
{
char value[1024]; 
char *h = header;
int i = 0;
char *puncChars = ",;: \t\r\n"; /* punctuation chars */
i=0;
/* The header should have already been trimmed of leading and trailing spaces */
while(TRUE)
    {
    char c = *h++;
    if (c==0 || strchr(puncChars,c))
	break;
    value[i++] = c;
    if (i >= sizeof(value))
	errAbort("error: main value too long (>%lu) in MIME header Content-type:%s",(unsigned long)sizeof(value),header);
    }
value[i] = 0;    

return cloneString(value);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rdi, %rbx
leaq 0x599c(%rip), %r14      # 0x1a4ba
pushq $0x8
popq %r15
leaq 0x5999(%rip), %r12      # 0x1a4c2
xorl %r13d, %r13d
movsbl (%rbx,%r13), %ebp
testl %ebp, %ebp
je 0x14b6b
movq %r14, %rdi
movl %ebp, %esi
movq %r15, %rdx
callq 0x33c0
testq %rax, %rax
jne 0x14b6b
movb %bpl, (%rsp,%r13)
cmpq $0x3fe, %r13            # imm = 0x3FE
jbe 0x14b66
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xa61f
incq %r13
jmp 0x14b2c
movl %r13d, %eax
movb $0x0, (%rsp,%rax)
movq %rsp, %rdi
callq 0x5ede
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/JimKent[P]linearSat/lib/mime.c
// Function: getMimeHeaderFieldVal
char *getMimeHeaderFieldVal(char *header, char *field)
/* Parse a typical mime header line looking for field=
 * and return the value which may be quoted.
 * freeMem the returned string when done */
{
char value[1024]; 
char *fld = header;
int i = 0;
char *puncChars = ",;: \t\r\n"; /* punctuation chars */
while (TRUE)
    {
    fld = strstr(fld,field);
    if (!fld)
	return NULL;
    if (fld > header && strchr(puncChars,fld[-1]))
	{
	fld+=strlen(field);
	if (*fld == '=')
	    {
	    ++fld;
	    break;
	    }
	}    
    else
	{
	++fld;
	}
    }	
if (*fld == '"')
    {
    puncChars = "\"";  /* quoted */
    ++fld;
    }
i=0;
while(TRUE)
    {
    char c = *fld++;
    if (c==0 || strchr(puncChars,c))
	break;
    value[i++] = c;
    if (i >= sizeof(value))
	errAbort("error: %s= value too long (>%lu) in MIME header Content-type:%s",field,(unsigned long)sizeof(value),header);
    }
value[i] = 0;    

return cloneString(value);

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rsi, %rbx
movq %rdi, %r14
xorl %r12d, %r12d
leaq 0x590d(%rip), %r15      # 0x1a4ba
pushq $0x8
popq %r13
movq %rbx, %rsi
callq 0x3760
testq %rax, %rax
je 0x14c71
movq %rax, %rbp
cmpq %r14, %rax
jbe 0x14bf5
movsbl -0x1(%rbp), %esi
movq %r15, %rdi
movq %r13, %rdx
callq 0x33c0
testq %rax, %rax
je 0x14bf5
movq %rbx, %rdi
callq 0x3200
movq %rbp, %rdi
addq %rax, %rdi
cmpb $0x3d, (%rbp,%rax)
jne 0x14bb1
jmp 0x14bfd
incq %rbp
movq %rbp, %rdi
jmp 0x14bb1
leaq 0x1(%rdi), %r13
cmpb $0x22, 0x1(%rdi)
leaq 0x2(%rdi), %rax
cmoveq %rax, %r13
leaq 0x4d06(%rip), %rax      # 0x1991a
cmoveq %rax, %r15
xorl %r12d, %r12d
movsbl (%r13,%r12), %ebp
testl %ebp, %ebp
je 0x14c5f
movq %r15, %rdi
movl %ebp, %esi
callq 0x3260
testq %rax, %rax
jne 0x14c5f
movb %bpl, (%rsp,%r12)
cmpq $0x3fe, %r12            # imm = 0x3FE
jbe 0x14c5a
movl $0x400, %edx            # imm = 0x400
leaq 0x58b6(%rip), %rdi      # 0x1a503
movq %rbx, %rsi
movq %r14, %rcx
xorl %eax, %eax
callq 0xa61f
incq %r12
jmp 0x14c1b
movl %r12d, %eax
movb $0x0, (%rsp,%rax)
movq %rsp, %rdi
callq 0x5ede
movq %rax, %r12
movq %r12, %rax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/JimKent[P]linearSat/lib/mime.c
// Function: getLineMB
static char *getLineMB(struct mimeBuf *b)
/* Reads one line up to CRLF, returned string does not include CRLF however. 
   Use freeMem when done with string. */
{
char line[MAXPARTLINESIZE];
int i = 0;
char c = 0;
line[0]=0;
while(TRUE)
    {
    c =getcMB(b);
    if ((c == 0x0d) || (c == 0x0a))  /* CR or LF is end of line */
	break;
    line[i++] = c;
    if (i >= MAXPARTLINESIZE)
	errAbort("getLineMB error - MIME input header too long, "
		    "greater than %d chars",MAXPARTLINESIZE);
    }
line[i] = 0; /* terminate string */ 
if (nlType == nlt_undet)  /* determine newline type */
    {
    if (c == 0x0d)
	{
	nlType = nlt_mac;
	c = getcMB(b);
	if (c == 0x0a)
	    nlType = nlt_dos;
	else
    	    putBackMB(b);
	}
    else
	{
	nlType = nlt_unix;
	}
    }
else if (nlType == nlt_dos)
    {
    if (c == 0x0d)
    	getcMB(b); /* just waste the LF */
    else
	nlType = nlt_unix;
    }
return cloneString(line);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x400, %rsp            # imm = 0x400
movq %rdi, %rbx
movb $0x0, (%rsp)
leaq 0x52b3(%rip), %r14      # 0x1a7a4
xorl %r15d, %r15d
movq %rbx, %rdi
callq 0x155f6
cmpb $0xa, %al
je 0x15529
movzbl %al, %ecx
cmpl $0xd, %ecx
je 0x15529
movb %al, (%rsp,%r15)
cmpq $0x3ff, %r15            # imm = 0x3FF
jb 0x15524
movq %r14, %rdi
movl $0x400, %esi            # imm = 0x400
xorl %eax, %eax
callq 0xa61f
incq %r15
jmp 0x154f4
movl %r15d, %ecx
movb $0x0, (%rsp,%rcx)
movl 0x21fe6(%rip), %ecx     # 0x3751c
cmpl $0x2, %ecx
je 0x15565
testl %ecx, %ecx
jne 0x1557d
cmpb $0xd, %al
jne 0x15573
movl $0x3, 0x21fcf(%rip)     # 0x3751c
movq %rbx, %rdi
callq 0x155f6
cmpb $0xa, %al
jne 0x15592
movl $0x2, 0x21fb9(%rip)     # 0x3751c
jmp 0x1557d
cmpb $0xd, %al
jne 0x15573
movq %rbx, %rdi
callq 0x155f6
jmp 0x1557d
movl $0x1, 0x21f9f(%rip)     # 0x3751c
movq %rsp, %rdi
callq 0x5ede
addq $0x400, %rsp            # imm = 0x400
popq %rbx
popq %r14
popq %r15
retq
movq 0x8008(%rbx), %rax
leaq 0x4(%rbx), %rcx
cmpq %rcx, %rax
jne 0x155b7
leaq 0x523f(%rip), %rdi      # 0x1a7e8
xorl %eax, %eax
callq 0xa61f
movq 0x8008(%rbx), %rax
decq %rax
movq %rax, 0x8008(%rbx)
jmp 0x1557d
// File: /workspace/github_c_makefile_star2_O2/JimKent[P]linearSat/lib/mime.c
// Function: setBoundaryMB
static void setBoundaryMB(struct mimeBuf *b, char *boundary)
/* set boundary in b */
{
b->boundary = boundary;
b->blen = boundary ? strlen(b->boundary) : 0;
setEopMB(b);
setEodMB(b);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq %rsi, 0x8018(%rdi)
testq %rsi, %rsi
je 0x155dd
movq %rsi, %rdi
callq 0x3200
jmp 0x155df
xorl %eax, %eax
movl %eax, 0x8020(%rbx)
movq %rbx, %rdi
callq 0x15662
movq %rbx, %rdi
popq %rbx
jmp 0x156f0
// File: /workspace/github_c_makefile_star2_O2/JimKent[P]linearSat/lib/mime.c
// Function: getcMB
static char getcMB(struct mimeBuf *b)
/* read just one char from MIME buffer */
{
if (b->i >= b->eoi && b->eoi < b->eom)  /* at end of input */
    errAbort("getcMB error - requested input beyond end of MIME input.");
if (b->i >= b->eod && b->eoi == b->eom) /* at end of buffer */
    moreMimeBuf(b);
    
//fprintf(stderr,"b->buf:%lu b->i:%lu %c \n",
//    (unsigned long) b->buf,
//    (unsigned long) b->i,
//    *b->i
//    );
//fprintf(stderr,"%c",*b->i);
//fflush(stderr); 
return *b->i++;    
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x8008(%rdi), %rax
movq 0x8030(%rdi), %rcx
cmpq %rcx, %rax
jb 0x1562b
cmpq 0x8038(%rbx), %rcx
jae 0x1562b
leaq 0x5255(%rip), %rdi      # 0x1a872
xorl %eax, %eax
callq 0xa61f
movq 0x8008(%rbx), %rax
cmpq 0x8028(%rbx), %rax
jb 0x15653
movq 0x8030(%rbx), %rcx
cmpq 0x8038(%rbx), %rcx
jne 0x15653
movq %rbx, %rdi
callq 0x14a51
movq 0x8008(%rbx), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8008(%rbx)
movb (%rax), %al
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/JimKent[P]linearSat/lib/mime.c
// Function: getChunkMB
static void getChunkMB(struct mimeBuf *b, char **address, int *size, boolean *hasZeros)
/* Pass back address and size of chunk, and whether it contains embedded zeros.
   The chunk is the largest piece of data left in the buffer up to the eod or eop. */
{
char *eoc = b->eop ? b->eop : b->eod; /* end of chunk */
//debug
//fprintf(stderr,"pre-getChunkMB dumpMB: ");
//dumpMB(b);  //debug
*address=b->i;
*size=eoc - b->i;
*hasZeros = (memMatch("", 1,*address, *size) != NULL);
b->i = eoc;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rcx, %rbx
movq %rdi, %r14
movq 0x8010(%rdi), %r15
testq %r15, %r15
jne 0x156b6
movq 0x8028(%r14), %r15
movq 0x8008(%r14), %rax
movq %rax, (%rsi)
movl %r15d, %ecx
subl %eax, %ecx
movl %ecx, (%rdx)
leaq 0x2604(%rip), %rdi      # 0x17cd2
pushq $0x1
popq %rsi
movq %rax, %rdx
callq 0x79ed
xorl %ecx, %ecx
testq %rax, %rax
setne %cl
movl %ecx, (%rbx)
movq %r15, 0x8008(%r14)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/JimKent[P]linearSat/lib/portimpl.c
// Function: envUpdate
void envUpdate(char *name, char *value)
/* Update an environment string */
{
int size = strlen(name) + strlen(value) + 2;
char *s = needMem(size);
safef(s, size, "%s=%s", name, value);
putenv(s);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
callq 0x3200
movq %rax, %r15
movq %rbx, %rdi
callq 0x3200
addl %r15d, %eax
addl $0x2, %eax
movslq %eax, %r15
movq %r15, %rdi
callq 0xd87c
movq %rax, %r12
leaq 0x5129(%rip), %rdx      # 0x1a8ab
movq %rax, %rdi
movl %r15d, %esi
movq %r14, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x939d
movq %r12, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3420
// File: /workspace/github_c_makefile_star2_O2/JimKent[P]linearSat/lib/portimpl.c
// Function: mkdirTrashDirectory
void mkdirTrashDirectory(char *prefix)
/*	create the specified trash directory if it doesn't exist */
{
struct stat buf;
char trashDirName[128];
safef(trashDirName, sizeof(trashDirName), "%s/%s", trashDir(), prefix);
if (stat(trashDirName,&buf))
    {
    int result = mkdir (trashDirName, S_IRWXU | S_IRWXG | S_IRWXO);
    if (0 != result)
	errnoAbort("failed to create directory %s", trashDirName);
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdi, %rbx
leaq 0x10e34(%rip), %rcx     # 0x265f0
xorl %eax, %eax
callq *0x20(%rcx)
leaq 0x50e9(%rip), %rdx      # 0x1a8b1
movq %rsp, %r14
movq %r14, %rdi
movl $0x80, %esi
movq %rax, %rcx
movq %rbx, %r8
xorl %eax, %eax
callq 0x939d
leaq 0x88(%rsp), %rsi
movq %r14, %rdi
callq 0x3250
testl %eax, %eax
je 0x15816
movq %rsp, %rdi
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x30f0
testl %eax, %eax
je 0x15816
leaq 0x50ab(%rip), %rdi      # 0x1a8b7
movq %rsp, %rsi
xorl %eax, %eax
callq 0xa721
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/JimKent[P]linearSat/lib/portimpl.c
// Function: makeDirsOnPath
void makeDirsOnPath(char *pathName)
/* Create directory specified by pathName.  If pathName contains
 * slashes, create directory at each level of path if it doesn't
 * already exist.  Abort with error message if there's a problem.
 * (It's not considered a problem for the directory to already
 * exist. ) */
{

/* shortcut for paths that already exist */
if (fileExists(pathName))
    return;

/* Make local copy of pathName. */
int len = strlen(pathName);
char pathCopy[len+1];
strcpy(pathCopy, pathName);

/* Tolerate double-slashes in path, everyone else does it. */

/* Start at root if it's an absolute path name. */
char *s = pathCopy, *e;
while (*s++ == '/')
    /* do nothing */;

/* Step through it one slash at a time 
 * making directory if possible, else dying. */
for (; !isEmpty(s); s = e)
    {
    /* Find end of this section and terminate string there. */
    e = strchr(s, '/');
    if (e != NULL)
	*e = 0;
    makeDir(pathCopy);
    if (e != NULL)
	*e++ = '/';
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %r14
callq 0x91b9
testl %eax, %eax
jne 0x158b1
movq %r14, %rdi
callq 0x3200
movq %rsp, %r12
incl %eax
movq %rsp, %rbx
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
movq %rbx, %rdi
movq %r14, %rsi
callq 0x30e0
movq %rbx, %rdi
cmpb $0x2f, (%rdi)
leaq 0x1(%rdi), %rdi
je 0x15864
pushq $0x2f
popq %r14
testq %rdi, %rdi
je 0x158ae
cmpb $0x0, (%rdi)
je 0x158ae
movl %r14d, %esi
callq 0x3260
testq %rax, %rax
je 0x158a2
movq %rax, %r15
movb $0x0, (%rax)
movq %rbx, %rdi
callq 0xf870
movq %r15, %rdi
incq %rdi
movb $0x2f, (%r15)
jmp 0x15871
movq %rbx, %rdi
callq 0xf870
xorl %edi, %edi
jmp 0x15871
movq %r12, %rsp
leaq -0x20(%rbp), %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/abdalazizrashid[P]st-HiDPI/x.c
// Function: mouseaction
int
mouseaction(XEvent *e, uint release)
{
	MouseShortcut *ms;

	for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
		if (ms->release == release &&
		    ms->button == e->xbutton.button &&
		    (!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) &&
		    (match(ms->mod, e->xbutton.state) ||  /* exact or forced */
		     match(ms->mod, e->xbutton.state & ~forcemousemod))) {
			ms->func(&(ms->arg));
			return 1;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %r14
xorl %ebx, %ebx
leaq 0x87e3(%rip), %r15      # 0x15710
xorl %r12d, %r12d
cmpq $0x9f, %r12
ja 0xcfa3
cmpl %ebp, 0x18(%r12,%r15)
jne 0xcf8f
movl 0x4(%r12,%r15), %eax
cmpl 0x54(%r14), %eax
jne 0xcf8f
movl 0x1c(%r12,%r15), %r13d
testl %r13d, %r13d
je 0xcf6c
callq 0x7173
cmpl $0x1, %eax
movl $0x0, %eax
sbbl %eax, %eax
orl $0x1, %eax
cmpl %eax, %r13d
jne 0xcf8f
movl (%r12,%r15), %eax
cmpl $-0x1, %eax
je 0xcf95
movl 0x50(%r14), %ecx
movl %ecx, %edx
andl $0xffffdfef, %edx       # imm = 0xFFFFDFEF
cmpl %eax, %edx
je 0xcf95
andl $0xffffdfee, %ecx       # imm = 0xFFFFDFEE
cmpl %eax, %ecx
je 0xcf95
addq $0x20, %r12
jmp 0xcf30
leaq (%r12,%r15), %rdi
addq $0x10, %rdi
callq *-0x8(%rdi)
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Joy-Division[P]tools-zoe/mdx-parser.c
// Function: snap0
unsigned int snap0(unsigned int data) {
	if(data < 26) return 5*data+0x80;
	else if(data < 52) return 5*data+0x8100;
	else if(data < 76) return 5*data+0x8180;
	else if(data < 102) return 5*data+0x8200;
	else if(data < 127) return 5*data+0x8280;
	else if(data < 153) return 5*data+0x8300;
	else if(data < 179) return 5*data+0x8380;
	else if(data < 205) return 5*data+0x8400;
	else if(data < 283) return 5*data+0x8480;
	else {
		printf("snap0: data is %d\n", data);
		return 0;
	}
}

// Assembly:
pushq %rbx
movl %edi, %esi
cmpl $0x19, %edi
ja 0x24d2
leal (%rsi,%rsi,4), %ebx
addl $0x80, %ebx
jmp 0x2571
cmpl $0x33, %esi
ja 0x24e5
leal (%rsi,%rsi,4), %ebx
addl $0x8100, %ebx           # imm = 0x8100
jmp 0x2571
cmpl $0x4b, %esi
ja 0x24f5
leal (%rsi,%rsi,4), %ebx
addl $0x8180, %ebx           # imm = 0x8180
jmp 0x2571
cmpl $0x65, %esi
ja 0x2505
leal (%rsi,%rsi,4), %ebx
addl $0x8200, %ebx           # imm = 0x8200
jmp 0x2571
cmpl $0x7e, %esi
ja 0x2515
leal (%rsi,%rsi,4), %ebx
addl $0x8280, %ebx           # imm = 0x8280
jmp 0x2571
cmpl $0x98, %esi
ja 0x2528
leal (%rsi,%rsi,4), %ebx
addl $0x8300, %ebx           # imm = 0x8300
jmp 0x2571
cmpl $0xb2, %esi
ja 0x253b
leal (%rsi,%rsi,4), %ebx
addl $0x8380, %ebx           # imm = 0x8380
jmp 0x2571
cmpl $0xcc, %esi
ja 0x254e
leal (%rsi,%rsi,4), %ebx
addl $0x8400, %ebx           # imm = 0x8400
jmp 0x2571
cmpl $0x11a, %esi            # imm = 0x11A
ja 0x2561
leal (%rsi,%rsi,4), %ebx
addl $0x8480, %ebx           # imm = 0x8480
jmp 0x2571
leaq 0xd91(%rip), %rdi       # 0x32f9
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x2070
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/./conio.h
// Function: reset_terminal_mode_ex
void reset_terminal_mode_ex()
{
	reset_terminal_mode();
	printf("\x1b[0m");                               // Reset colors
	fflush(stdout);
	printf("\n");
}

// Assembly:
pushq %rax
callq 0x24cc
leaq 0xd867(%rip), %rdi      # 0xfd50
xorl %eax, %eax
callq 0x2100
movq 0x10ad9(%rip), %rax     # 0x12fd0
movq (%rax), %rdi
callq 0x2290
pushq $0xa
popq %rdi
popq %rax
jmp 0x2060
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/./conio.h
// Function: set_conio_terminal_mode
void set_conio_terminal_mode()
{
    struct termios new_termios;

    /* take two copies - one for now, one for later */
    tcgetattr(0, &orig_termios);
    memcpy(&new_termios, &orig_termios, sizeof(new_termios));

    /* register cleanup handler, and set the new terminal mode */
    atexit(reset_terminal_mode_ex);
    cfmakeraw(&new_termios);
    tcsetattr(0, TCSANOW, &new_termios);
}

// Assembly:
pushq %rbx
subq $0x40, %rsp
leaq 0x10d4c(%rip), %rsi     # 0x13260
xorl %edi, %edi
callq 0x2300
movups 0x10d3e(%rip), %xmm0    # 0x13260
movq %rsp, %rbx
movaps %xmm0, (%rbx)
movups 0x10d41(%rip), %xmm0    # 0x13270
movaps %xmm0, 0x10(%rbx)
movups 0x10d46(%rip), %xmm0    # 0x13280
movaps %xmm0, 0x20(%rbx)
movups 0x10d47(%rip), %xmm0    # 0x1328c
movups %xmm0, 0x2c(%rbx)
leaq -0x74(%rip), %rdi       # 0x24dc
callq 0xb1e0
movq %rbx, %rdi
callq 0x22f0
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2310
addq $0x40, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/./conio.h
// Function: kbhit
int kbhit()
{
    struct timeval tv = { 0L, 0L };
    fd_set fds;
    FD_ZERO(&fds);
    FD_SET(0, &fds);
    return select(1, &fds, NULL, NULL, &tv);
}

// Assembly:
subq $0x98, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
xorl %eax, %eax
cmpq $0x10, %rax
je 0x2590
andq $0x0, 0x18(%rsp,%rax,8)
incq %rax
jmp 0x257f
leaq 0x18(%rsp), %rsi
orb $0x1, (%rsi)
pushq $0x1
popq %rdi
movq %rsp, %r8
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2260
addq $0x98, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/./conio.h
// Function: getch
int getch()
{
    int r;
    unsigned char c;
    fflush(stdout);
    if ((r = read(0, &c, sizeof(c))) < 0) {
        return r;
    } else {
        if (r==0) 
		return -1;
	else
		return c;
    }
}

// Assembly:
pushq %rax
movq 0x10a19(%rip), %rax     # 0x12fd0
movq (%rax), %rdi
callq 0x2290
leaq 0x7(%rsp), %rsi
pushq $0x1
popq %rdx
xorl %edi, %edi
callq 0x21c0
testl %eax, %eax
js 0x25de
je 0x25db
movzbl 0x7(%rsp), %eax
jmp 0x25de
pushq $-0x1
popq %rax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/./cpu.h
// Function: Z80reset
void Z80reset(void) {
	PC = 0;
	IFF = 0;
	IR = 0;
	Status = 0;
	Debug = 0;
	Break = -1;
	Step = -1;
}

// Assembly:
andl $0x0, 0x110c5d(%rip)    # 0x1132c4
andl $0x0, 0x110c5a(%rip)    # 0x1132c8
andl $0x0, 0x110c57(%rip)    # 0x1132cc
andl $0x0, 0x110c3c(%rip)    # 0x1132b8
andl $0x0, 0x110c39(%rip)    # 0x1132bc
orl $-0x1, 0x10b7e(%rip)    # 0x13208
orl $-0x1, 0x10b7b(%rip)    # 0x1320c
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: io_output
void io_output( int add, int data) {
	int p,i;
	DEBUGOUT( stderr, "ERROR: i/o write port:%04x <- %02x\n", add, data);
 	switch (add) {
 		case 0xf9:  mem=&mem1024[(data & 0x0f) * 0x10000];
			 		goto ori128;
 		case 0xfb:  if (data & 0x80) {
 			            dispatcher=TRUE;
 						mem16=&mem1024[((int)data & 0x0f)<<6];
 					}
		 			else mem16=mem;
 					fullram=data & 0x20;
 					int50hz=data & 0x40;
 		case 0xf8:
 		case 0xfa:  
ori128:				if (orion128==FALSE) {		/* Switch to Orion128 mode and init F800 ROM area */
 	 					orion128=TRUE;
						p = ROM_ORG;
						for ( i = 0; i < ROM_CNT; i++) {
							mem1024[ p++] = 0xC3;
							setword( mem1024[ p++], 3*ROM_CNT+ROM_ORG);	    /*   JP MMMM */
						}
						mem1024[ p++] = 0xED; mem1024[ p++] = 0xED;         /* SPECIAL OPCODE */
						mem1024[ p++] = 0xC9;				          		/*   RET */
 					}
 					break;
 		default: exit( -1);
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %r14d
cmpl $0x0, 0x10c0d4(%rip)    # 0x113314
jne 0x7315
addl $0xffffff08, %r14d      # imm = 0xFFFFFF08
cmpl $0x3, %r14d
ja 0x7337
leaq 0x5c3e(%rip), %rax      # 0xce9c
movslq (%rax,%r14,4), %rcx
addq %rax, %rcx
jmpq *%rcx
andl $0xf, %ebx
shll $0x10, %ebx
leaq 0xc02c(%rip), %rax      # 0x132a0
addq %rbx, %rax
movq %rax, 0xbf7a(%rip)      # 0x131f8
jmp 0x72c4
testb %bl, %bl
js 0x728d
movq 0xbf6d(%rip), %rax      # 0x131f8
jmp 0x72a9
movl $0x1, 0x10c009(%rip)    # 0x1132a0
movl %ebx, %ecx
andl $0xf, %ecx
shll $0x6, %ecx
leaq 0xbffa(%rip), %rax      # 0x132a0
addq %rcx, %rax
movq %rax, 0xbf50(%rip)      # 0x13200
movl %ebx, %eax
andl $0x20, %eax
movl %eax, 0x10bfe9(%rip)    # 0x1132a4
andl $0x40, %ebx
movl %ebx, 0x10bfe4(%rip)    # 0x1132a8
cmpl $0x0, 0x10bfe1(%rip)    # 0x1132ac
jne 0x730d
movl $0x1, 0x10bfd5(%rip)    # 0x1132ac
xorl %eax, %eax
leaq 0xbfc0(%rip), %rcx      # 0x132a0
cmpl $0x42, %eax
je 0x72fd
movw $0x42c3, 0xf800(%rax,%rcx) # imm = 0x42C3
movb $-0x8, 0xf802(%rax,%rcx)
addq $0x3, %rax
jmp 0x72e0
movw $0xeded, 0x1b7dc(%rip)  # imm = 0xEDED
movb $-0x37, 0x1b7d7(%rip)   # 0x22ae4
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0xbcdc(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x8a4a(%rip), %rsi      # 0xfd70
movl %r14d, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2200
jmp 0x7246
pushq $-0x1
popq %rdi
callq 0x23a0
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: setup_disk_vct
void setup_disk_vct( void)
{
    int i;
    char envname[ 8];

    cpm_disk_vct = 3;
    for ( i = 2; i < MAXDRV; i++) {
	if ( cpm_drive[ i]) continue;
	sprintf( envname, "CPM%c", i + 'A');
	if (( cpm_drive[ i] = getenv( envname)) != NULL) {
	    cpm_disk_vct |= (word)( 1 << i);
	}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movw $0x3, 0x10bed9(%rip)    # 0x11331a
pushq $0x2
popq %rbx
leaq 0x10bff5(%rip), %r12    # 0x113440
leaq 0x894c(%rip), %r14      # 0xfd9e
movq %rsp, %r15
pushq $0x1
popq %rbp
cmpq $0x10, %rbx
je 0x74a1
cmpq $0x0, (%r12,%rbx,8)
jne 0x749c
leaq (,%rbx,8), %r13
leal 0x41(%rbx), %edx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x2390
movq %r15, %rdi
callq 0x2040
movq %rax, (%r13,%r12)
testq %rax, %rax
je 0x749c
movl %ebp, %eax
movl %ebx, %ecx
shll %cl, %eax
orw %ax, 0x10be7e(%rip)     # 0x11331a
incq %rbx
jmp 0x7458
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: CharUpperX
char* CharUpperX(char* st)
{
  char* ss=st;
  if (st==NULL) 
		return st;
  while (*ss) {
    *ss=toupper(*ss);
    ss++;
  }
  return st;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
testq %rdi, %rdi
je 0x74dd
movq %rbx, %r14
movsbq (%r14), %r15
testq %r15, %r15
je 0x74dd
callq 0x2030
movq (%rax), %rax
movb (%rax,%r15,4), %al
movb %al, (%r14)
incq %r14
jmp 0x74c0
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: splitpath
void _splitpath(char *path, char *drive, char *dir, char *name, char *ext)
{
	char* cc, sz;
	void* pp;
	*dir=0; *name=0; *ext=0;
	pp=malloc((sz=strlen(path))+1);
	strncpy(pp,path,sz);										/* because dirname flushes `path` */
	strncpy(name, (cc=basename(path)) ? cc: "", _MAX_FNAME);
	strncpy(dir,  (cc=dirname(path)) ? cc: "", _MAX_DIR);
	if ((strcmp(dir,".")==0)&&(*path!='.'))
		*dir=0;								
	if ((cc=strstr(name, "."))!=NULL) {
		strncpy(ext, &cc[1], _MAX_EXT);
		*cc='\0';
	}
	strncpy(path,pp,sz);
	free(pp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r13
movq %rdx, %rbp
movq %rdi, %rbx
xorl %eax, %eax
movb %al, (%rdx)
movb %al, (%rcx)
movq %r8, (%rsp)
movb %al, (%r8)
callq 0x20e0
movsbq %al, %r15
leaq 0x1(%r15), %rdi
callq 0x2280
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2070
movq %rbx, %rdi
callq 0x2240
testq %rax, %rax
leaq 0x89ad(%rip), %r14      # 0xfee9
cmoveq %r14, %rax
movl $0x100, %edx            # imm = 0x100
movq %r13, %rdi
movq %rax, %rsi
callq 0x2070
movq %rbx, %rdi
callq 0x2130
testq %rax, %rax
cmovneq %rax, %r14
movl $0x100, %edx            # imm = 0x100
movq %rbp, %rdi
movq %r14, %rsi
callq 0x2070
cmpb $0x2e, (%rbp)
jne 0x7584
cmpb $0x0, 0x1(%rbp)
jne 0x7584
cmpb $0x2e, (%rbx)
je 0x7584
movb $0x0, (%rbp)
pushq $0x2e
popq %rsi
movq %r13, %rdi
callq 0x20f0
testq %rax, %rax
je 0x75b0
movq %rax, %r13
movq %rax, %rsi
incq %rsi
movl $0x100, %edx            # imm = 0x100
movq (%rsp), %rdi
callq 0x2070
movb $0x0, (%r13)
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x2070
movq %r12, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: buildname
char *buildname(char* dirnm, char* filenm)
{
	char *cp;
	static char buf[_MAX_DIR];

	if ((dirnm == NULL) || (*dirnm == '\0'))
		return filenm;
	if (filenm == NULL)
		return dirnm;
	if ((cp = strrchr(filenm, '/')) != NULL)
		filenm = cp + 1;
	strcpy(buf, dirnm);
	strcat(buf, "/");
	strcat(buf, filenm);
	return buf;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
testq %rdi, %rdi
je 0x7637
movq %rdi, %r14
cmpb $0x0, (%rdi)
je 0x7637
testq %rbx, %rbx
je 0x7634
pushq $0x2f
popq %rsi
movq %rbx, %rdi
callq 0x2110
leaq 0x1(%rax), %r15
testq %rax, %rax
cmoveq %rbx, %r15
leaq 0x10beb5(%rip), %rbx    # 0x1134c0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2090
movq %rbx, %rdi
callq 0x20e0
movw $0x2f, (%rax,%rbx)
movq %rbx, %rdi
movq %r15, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x2380
movq %r14, %rbx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: makepath
void _makepath(char *path, char *drive, char *dir, char *name, char *ext)
{
  char *cc;
  if (path) {
	*path=0; 
	if ((name==NULL)&&(ext==NULL))
	   strncpy(path, dir, _MAX_DIR);
    else {
		cc=buildname(dir,name);
	    if (cc) strncpy(path, cc, _MAX_DIR);
	}
	if (ext) {
		if (*ext!='.')
			strcat(path, ".");
		strncat(path, ext, 4);		/* CPM have 3-char ext + dot */
	}
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x76bf
movq %r8, %r14
movq %rdx, %rsi
movq %rdi, %rbx
movb $0x0, (%rdi)
movq %rcx, %rax
orq %r8, %rax
jne 0x7671
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2070
movq %rsi, %rdi
movq %rcx, %rsi
callq 0x75d4
testq %rax, %rax
je 0x7691
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2070
testq %r14, %r14
je 0x76bf
cmpb $0x2e, (%r14)
je 0x76aa
movq %rbx, %rdi
callq 0x20e0
movw $0x2e, (%rbx,%rax)
pushq $0x4
popq %rdx
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2180
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: findPath
char* findPath(char* path, char* env)
{
	char *p, *envp;
	static char name[_MAX_PATH+1];

	if (*path == '/' ||   	/* qualified name */
	    *path == '.')
		return path;
	if ((envp = getenv(env)) != NULL)   /* lookup all pathes */
	  while (*envp) {
		p = name;
		while (*envp && (*p = *envp++) != ':') {
			if ((uint)(p - name) >= sizeof(name))
				break;
			++p;
		}
		if (*--p != '/')
			*++p = '/';
		++p;
		if ((p - name) + strlen(path) >= sizeof(name))
			break;
		strcpy(p, path);
		if (access(name, F_OK) == 0)
			return name;
	  }
    /* search within startdir */
	p=buildname(StartDir, path);
	if (access(p, F_OK) == 0)	/* file exist in current dir */
		return p;
	return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb (%rdi), %al
andb $-0x2, %al
cmpb $0x2e, %al
je 0x779c
movq %rsi, %rdi
callq 0x2040
testq %rax, %rax
je 0x7778
movq %rax, %r14
leaq 0x10bec7(%rip), %r15    # 0x1135c0
movb (%r14), %cl
testb %cl, %cl
je 0x7778
incq %r14
xorl %eax, %eax
movq %r15, %r12
testb %cl, %cl
je 0x7729
movb %cl, (%r12)
cmpb $0x3a, %cl
je 0x772c
cmpl $0x104, %eax            # imm = 0x104
ja 0x772c
incq %r12
movb (%r14), %cl
incl %eax
incq %r14
jmp 0x7708
decq %r14
cmpb $0x2f, -0x1(%r12)
jne 0x7739
decq %r12
jmp 0x773e
movb $0x2f, (%r12)
movq %rbx, %rdi
callq 0x20e0
subq %r15, %rax
addq %r12, %rax
incq %rax
cmpq $0x104, %rax            # imm = 0x104
ja 0x7778
incq %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2090
movq %r15, %rdi
xorl %esi, %esi
callq 0x2330
testl %eax, %eax
jne 0x76f9
movq %r15, %rbx
jmp 0x779c
leaq 0x10bf51(%rip), %rdi    # 0x1136d0
movq %rbx, %rsi
callq 0x75d4
movq %rax, %r14
xorl %ebx, %ebx
movq %rax, %rdi
xorl %esi, %esi
callq 0x2330
testl %eax, %eax
cmoveq %r14, %rbx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: mkFCB
void mkFCB( byte *p, char *s)
{
    int i, c;

    *p = 0;
    if ( s[ 1] == ':') {
        if (( c = *s) >= 'a') c &= 0x5f;
        *p = (byte)( c - 'A' + 1); s += 2;
    }
    p++;
    for ( i = 0; i < 8; i++) {
        c = ( *s && *s != '.') ? *s++ : ' ';
//	if ( c >= 'a' && c <= 'z') c &= 0x5f;
        *p++ = (byte)c;
    }
    while ( *s && *s != '.') s++;
    if ( *s) s++;
    for ( i = 0; i < 3; i++) {
        c = ( *s) ? *s++ : ' ';
//	if ( c >= 'a' && c <= 'z') c &= 0x5f;
        *p++ = (byte)c;
    }
}

// Assembly:
movb $0x0, (%rdi)
cmpb $0x3a, 0x1(%rsi)
jne 0x7bc3
movzbl (%rsi), %eax
movl %eax, %ecx
andb $0x5f, %cl
cmpb $0x61, %al
movzbl %cl, %ecx
cmovll %eax, %ecx
addb $-0x40, %cl
movb %cl, (%rdi)
addq $0x2, %rsi
xorl %eax, %eax
cmpl $0x8, %eax
je 0x7be9
movzbl (%rsi), %edx
movb $0x20, %cl
testl %edx, %edx
je 0x7bdd
cmpl $0x2e, %edx
je 0x7bdd
incq %rsi
movl %edx, %ecx
movb %cl, 0x1(%rdi,%rax)
incq %rax
jmp 0x7bc5
incq %rsi
movzbl (%rsi), %ecx
testl %ecx, %ecx
je 0x7bf5
cmpl $0x2e, %ecx
jne 0x7be6
cmpb $0x1, %cl
sbbq $-0x1, %rsi
pushq $0x1
popq %rcx
pushq $0x20
popq %rdx
cmpl $0x4, %ecx
je 0x7c29
leaq (%rdi,%rcx), %r8
movzbl (%rsi), %r9d
xorl %r10d, %r10d
testb %r9b, %r9b
cmovel %edx, %r9d
setne %r10b
addq %r10, %rsi
movb %r9b, (%r8,%rax)
incq %rcx
jmp 0x7c02
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: mk_filename
char *mk_filename( char *s, byte *fcb)
{
    int i, j;
    char *dir;
#ifdef __linux__
    char *dot=NULL;
#endif
    i = fcb[ 0];
    if ( i == '?' || i == 0) i = cpm_disk_no;
    else i--;
    if ( i >= MAXDRV) return NULL;
    if ( cpm_drive[ i] == NULL) {
	if ( cpm_disk_vct == 0) setup_disk_vct();
	if ( cpm_drive[ i] == NULL) return NULL;
    }
    strcpy( s, cpm_drive[ i]);
    s += i = strlen( s);
    if ( i && s[ -1] != CH_SLASH && s[ -1] != '/' && s[ -1] != ':') *s++ = '/';
    dir = s;

    for ( j = 8; j >= 1 && fcb[ j] == '?'; j--);
    j++;
    for ( i = 1; i < j; i++) {
		if ( fcb[ i] == ' ') break;
		*s++ = fcb[ i];
    }
    if ( i == j && i <= 8) *s++ = '*';

#ifdef __linux__
	dot=s;
#endif
    *s++ = '.';

    for ( j = 11; j >= 9 && fcb[ j] == '?'; j--);
    j++;
    for ( i = 9; i < j; i++) {
	if ( fcb[ i] == ' ') break;
		*s++ = fcb[ i];
#ifdef __linux__
		dot=NULL;
#endif
    }
    if ( i == j && i <= 11) *s++ = '*';
#ifdef __linux__
	if (dot) s=dot;
#endif
	*s = '\0';
    return dir;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movzbl (%rsi), %eax
cmpl $0x3f, %eax
je 0x7c44
testl %eax, %eax
jne 0x7c4d
movzbl 0xb5c5(%rip), %eax      # 0x13210
jmp 0x7c4f
decl %eax
cmpl $0xf, %eax
jbe 0x7c5b
xorl %ebx, %ebx
jmp 0x7d8b
movl %eax, %r15d
leaq 0x10b7db(%rip), %r12    # 0x113440
movq (%r12,%r15,8), %rsi
testq %rsi, %rsi
je 0x7cd8
movq %rbx, %rdi
callq 0x2090
movq %rbx, %rdi
callq 0x20e0
cltq
addq %rax, %rbx
testl %eax, %eax
je 0x7c9b
movzbl -0x1(%rbx), %eax
cmpl $0x2f, %eax
je 0x7c9b
cmpl $0x3a, %eax
je 0x7c9b
movb $0x2f, (%rbx)
incq %rbx
pushq $0x8
popq %rcx
testl %ecx, %ecx
je 0x7cb0
movl %ecx, %eax
cmpb $0x3f, (%r14,%rax)
jne 0x7cb0
decq %rcx
jmp 0x7c9e
leaq 0x1(%rcx), %rsi
pushq $0x1
popq %rdx
movq %rcx, %rdi
movq %rbx, %rax
subq $0x1, %rdi
jb 0x7cfd
movb (%r14,%rdx), %r8b
cmpb $0x20, %r8b
je 0x7cff
movb %r8b, (%rax)
incq %rax
incq %rdx
jmp 0x7cbd
cmpw $0x0, 0x10b63a(%rip)    # 0x11331a
jne 0x7c54
callq 0x742d
movq (%r12,%r15,8), %rsi
testq %rsi, %rsi
jne 0x7c6e
jmp 0x7c54
movl %esi, %edx
subl %edx, %ecx
cmpl $-0x1, %ecx
setne %cl
cmpl $0x9, %edx
setae %dl
orb %cl, %dl
jne 0x7d17
movb $0x2a, (%rax)
incq %rax
movb $0x2e, (%rax)
pushq $0x3
popq %rdx
pushq $0x8
popq %rcx
leaq 0x8(%rdx), %rsi
cmpl $0x9, %esi
jb 0x7d3a
movl %esi, %esi
cmpb $0x3f, (%r14,%rsi)
jne 0x7d37
decq %rdx
jmp 0x7d20
leal 0x8(%rdx), %ecx
incl %ecx
addq $0x9, %r14
leaq 0x1(%rax), %rsi
leaq 0x9(%rdx), %r8
pushq $0x9
popq %rdi
subq $0x1, %rdx
jb 0x7d69
movb (%r14), %r9b
cmpb $0x20, %r9b
je 0x7d6c
movb %r9b, (%rsi)
incl %edi
incq %r14
incq %rsi
xorl %eax, %eax
jmp 0x7d4b
movl %r8d, %edi
cmpl %ecx, %edi
setne %cl
cmpl $0xc, %edi
setae %dl
orb %cl, %dl
jne 0x7d81
movb $0x2a, (%rsi)
incq %rsi
testq %rax, %rax
cmovneq %rax, %rsi
movb $0x0, (%rsi)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: FindNextFile
int FindNextFile(
    DIR *hFndFile,				    	// handle to search  
    WIN32_FIND_DATA *lpFindFileData) 	// pointer to structure for data on found file  
{
    struct dirent *pDirent;
    struct stat statbuf;
	if (hFndFile==INVALID_HANDLE_VALUE)
		return 0;
    while ((pDirent = readdir(hFndFile)) != NULL) {
       	strncpy(lpFindFileData->cFileName, pDirent->d_name, _MAX_PATH-1);
		if (fnmatch(ffName, CharUpperX(pDirent->d_name), FNM_CASEFOLD)==0) {
			if (stat(buildname(ffDir,lpFindFileData->cFileName), &statbuf)!=0) { 
				DEBUGOUT(stderr, "FindNext ERROR: failed while stat file `%s`\n",lpFindFileData->cFileName);
				break;
			}
			if (!(statbuf.st_mode & S_IFDIR)) {
				lpFindFileData->cAlternateFileName[0]=0;
				lpFindFileData->dwFileAttributes=(*(lpFindFileData->cFileName)=='.' ? FILE_ATTRIBUTE_HIDDEN : 0);	
				lpFindFileData->nFileSizeHigh=0;
				lpFindFileData->nFileSizeLow=(DWORD)statbuf.st_size;
				return 1;
			}
		}
    }
//    if (hFndFile!=INVALID_HANDLE_VALUE) closedir(hFndFile);
//    hFindFile=INVALID_HANDLE_VALUE;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x8048
movq %rdi, %r12
movq %rsi, (%rsp)
leaq 0x18(%rsi), %r15
leaq 0x10d064(%rip), %r13    # 0x115000
pushq $0x10
popq %rbp
leaq 0x8(%rsp), %r14
movq %r12, %rdi
callq 0x2270
testq %rax, %rax
je 0x8036
movq %rax, %rbx
addq $0x13, %rbx
movl $0x103, %edx            # imm = 0x103
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2070
movq %rbx, %rdi
callq 0x74b0
movq %r13, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x2140
testl %eax, %eax
jne 0x7fa4
leaq 0x10cf04(%rip), %rdi    # 0x114ef0
movq %r15, %rsi
callq 0x75d4
movq %rax, %rdi
movq %r14, %rsi
callq 0x2230
testl %eax, %eax
jne 0x803a
testb $0x40, 0x21(%rsp)
jne 0x7fa4
movq (%rsp), %rcx
movb $0x0, 0x11c(%rcx)
xorl %eax, %eax
cmpb $0x2e, 0x18(%rcx)
sete %al
addl %eax, %eax
movq %rax, (%rcx)
andq $0x0, 0x8(%rcx)
movq 0x38(%rsp), %rax
movq %rax, 0x10(%rcx)
pushq $0x1
popq %rbx
jmp 0x8048
xorl %ebx, %ebx
jmp 0x8048
cmpl $0x0, 0x10b2d3(%rip)    # 0x113314
movl $0x0, %ebx
jne 0x805c
movl %ebx, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xaf95(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x7d88(%rip), %rsi      # 0xfdf5
xorl %ebx, %ebx
movq %r15, %rdx
xorl %eax, %eax
callq 0x2200
jmp 0x8048
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: FindClose
int FindClose(
    DIR *hFndFile 					// file search handle 
   )
{
	int res;
	if (hFndFile && (hFndFile!=INVALID_HANDLE_VALUE)) {
		res=closedir(hFndFile);
		hFindFile=INVALID_HANDLE_VALUE;
		return res==0;
	}
	return TRUE;
}

// Assembly:
testq %rdi, %rdi
je 0x809c
pushq %rax
callq 0x21a0
andq $0x0, 0x10ce52(%rip)    # 0x114ee0
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
sete %al
addq $0x8, %rsp
retq
pushq $0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: GetDiskFreeSpace
int GetDiskFreeSpace(
    char* lpRootPathName,			// address of root path 
    DWORD *lpSectorsPerCluster,		// address of sectors per cluster 
    DWORD *lpBytesPerSector,		// address of bytes per sector 
    DWORD *lpNumberOfFreeClusters,	// address of number of free clusters  
    DWORD *lpTotalNumberOfClusters 	// address of total number of clusters  
   )	
{ 
  struct statvfs stat;
  if (statvfs(lpRootPathName, &stat) != 0) {
    // error happens, just quits here
    return 0;
  }
  *lpTotalNumberOfClusters=stat.f_blocks;
  *lpNumberOfFreeClusters=stat.f_bavail;
  *lpBytesPerSector=stat.f_bsize;
  *lpSectorsPerCluster=stat.f_frsize/stat.f_bsize;
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r8, %r12
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %rbx
leaq 0x8(%rsp), %rsi
callq 0x22e0
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
jne 0x80f2
movq 0x18(%rsp), %rax
movq %rax, (%r12)
movq 0x28(%rsp), %rax
movq %rax, (%r15)
movq 0x8(%rsp), %rcx
movq %rcx, (%r14)
movq 0x10(%rsp), %rax
xorl %edx, %edx
divq %rcx
movq %rax, (%rbx)
pushq $0x1
popq %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: cpm_findnext
byte cpm_findnext( void)
{
    WIN32_FIND_DATA aFindData;
    char *p;
    struct FCB *fcb = (struct FCB *)(mem + cpm_dma_addr);

    if ( hFindFile == INVALID_HANDLE_VALUE) return 0xff;

    while ( FindNextFile( hFindFile, &aFindData)) {
	p = aFindData.cAlternateFileName;
	if ( !*p) p = aFindData.cFileName;
	if (( aFindData.dwFileAttributes & 
		(FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_HIDDEN)) == 0) {
	    DWORD l = aFindData.nFileSizeLow;
	    if ( aFindData.nFileSizeHigh || l > 0x7fff80) l = 0x7fff80;
	    l = (l + 0x7f) >> 7;
	    fcb->ex = (byte)(l >> 7);
	    fcb->rc = (byte)(l & 0x7f);
	    mkFCB( mem + cpm_dma_addr, p);
	    return 0;
	}
    }
    FindClose( hFindFile); 
    hFindFile = INVALID_HANDLE_VALUE;
    return 0xff;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movb $-0x1, %bl
cmpq $0x0, 0x10cdca(%rip)    # 0x114ee0
je 0x81c2
movq 0xb0d5(%rip), %r15      # 0x131f8
movzwl 0xb0e7(%rip), %r12d     # 0x13212
leaq 0x8(%rsp), %r14
movq 0x10cda9(%rip), %rdi    # 0x114ee0
movq %r14, %rsi
callq 0x7f6e
testl %eax, %eax
je 0x81ae
movzwl 0x8(%rsp), %eax
testw $0x4002, %ax            # imm = 0x4002
jne 0x8130
leaq 0x124(%rsp), %rsi
cmpb $0x0, (%rsi)
leaq 0x20(%rsp), %rax
cmoveq %rax, %rsi
movq -0x8(%rax), %rcx
movl $0x7fff80, %edx         # imm = 0x7FFF80
cmpq %rdx, %rcx
cmovbq %rcx, %rdx
addl $0x7f, %edx
shrl $0x7, %edx
cmpq $0x0, -0x10(%rax)
movl $0xffff, %eax           # imm = 0xFFFF
cmoveq %rdx, %rax
movl %eax, %ecx
shrl $0x7, %ecx
movb %cl, 0xc(%r15,%r12)
andb $0x7f, %al
movb %al, 0xf(%r15,%r12)
movzwl 0xb074(%rip), %edi      # 0x13212
addq 0xb053(%rip), %rdi      # 0x131f8
callq 0x7ba1
xorl %ebx, %ebx
jmp 0x81c2
movq 0x10cd2b(%rip), %rdi    # 0x114ee0
callq 0x807b
andq $0x0, 0x10cd1e(%rip)    # 0x114ee0
movl %ebx, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: cpm_findfirst
byte cpm_findfirst( byte *fcbaddr)
{
    WIN32_FIND_DATA aFindData;
    char *p;
    struct FCB *fcb = (struct FCB *)(mem + cpm_dma_addr);
    DWORD l;

    if ( hFindFile != INVALID_HANDLE_VALUE) FindClose( hFindFile);

    if ( !mk_filename( filename, fcbaddr)) return 0xff;

    hFindFile = FindFirstFile( filename, &aFindData);
    if ( hFindFile == INVALID_HANDLE_VALUE) return 0xff;

    p = aFindData.cAlternateFileName;
    if ( !*p) p = aFindData.cFileName;
    if ( aFindData.dwFileAttributes & 
	 (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_HIDDEN)) {
		return cpm_findnext();
    }

    l = aFindData.nFileSizeLow;
    if ( aFindData.nFileSizeHigh || l > 0x7fff80) l = 0x7fff80;
    l = (l + 0x7f) >> 7;
    fcb->ex = (byte)(l >> 7);
    fcb->rc = (byte)(l & 0x7f);
    mkFCB( mem + cpm_dma_addr, p);
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x130, %rsp            # imm = 0x130
movq %rdi, %rbx
movq 0xb00f(%rip), %r14      # 0x131f8
movzwl 0xb021(%rip), %r15d     # 0x13212
movq 0x10cce8(%rip), %rdi    # 0x114ee0
testq %rdi, %rdi
je 0x8202
callq 0x807b
leaq 0x10c8d7(%rip), %rdi    # 0x114ae0
movq %rbx, %rsi
callq 0x7c2a
movb $-0x1, %bl
testq %rax, %rax
je 0x82a8
leaq 0x10c8bd(%rip), %rdi    # 0x114ae0
movq %rsp, %rsi
callq 0x7d9a
movq %rax, 0x10ccae(%rip)    # 0x114ee0
testq %rax, %rax
je 0x82a8
movzwl (%rsp), %eax
testw $0x4002, %ax            # imm = 0x4002
je 0x824a
callq 0x80fe
movl %eax, %ebx
jmp 0x82a8
leaq 0x11c(%rsp), %rsi
cmpb $0x0, (%rsi)
leaq 0x18(%rsp), %rax
cmoveq %rax, %rsi
movq -0x8(%rax), %rcx
movl $0x7fff80, %edx         # imm = 0x7FFF80
cmpq %rdx, %rcx
cmovbq %rcx, %rdx
addl $0x7f, %edx
shrl $0x7, %edx
cmpq $0x0, -0x10(%rax)
movl $0xffff, %eax           # imm = 0xFFFF
cmoveq %rdx, %rax
movl %eax, %ecx
shrl $0x7, %ecx
movb %cl, 0xc(%r14,%r15)
andb $0x7f, %al
movb %al, 0xf(%r14,%r15)
movzwl 0xaf78(%rip), %edi      # 0x13212
addq 0xaf57(%rip), %rdi      # 0x131f8
callq 0x7ba1
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x130, %rsp            # imm = 0x130
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: cpm_file_close
byte cpm_file_close( byte *fcbaddr)
{
    int i;
    struct FCB *fcb = (struct FCB *)fcbaddr;

	if (( i = fcb->d[ 0]) > 0 && --i < MAXFCB) {
DEBUGOUT( stderr, "CLOSE %d - ", i);
	    if ( fcbs[ i].fp) fclose( fcbs[ i].fp);
	    fcbs[ i].fp = 0;
	    fcb->d[ 0] = 0;
	    return 0;
	}
	if ( i == 0) return 0;
	return 0xff;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movb 0x10(%rdi), %al
testb %al, %al
je 0x85a4
movzbl %al, %ebp
decl %ebp
cmpb $0x40, %al
ja 0x859e
movq %rdi, %rbx
cmpl $0x0, 0x10ada1(%rip)    # 0x113314
jne 0x85ab
movl %ebp, %eax
shlq $0x5, %rax
leaq 0x10cb8e(%rip), %rcx    # 0x115110
leaq (%rcx,%rax), %r14
movq (%rax,%rcx), %rdi
testq %rdi, %rdi
je 0x8594
callq 0x20c0
andq $0x0, (%r14)
movb $0x0, 0x10(%rbx)
jmp 0x85a4
movb $-0x1, %al
testl %ebp, %ebp
jne 0x85a6
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq 0xaa46(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x787b(%rip), %rsi      # 0xfe37
movl %ebp, %edx
xorl %eax, %eax
callq 0x2200
jmp 0x8575
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: cpm_change_filesize
void cpm_change_filesize( byte *fcbaddr)
{
    int i, sz;
    struct FCB *fcb = (struct FCB *)fcbaddr;

    sz = (fcb->d[ 3] << 16) + (fcb->d[2] << 8) + fcb->d[1];
    if (( sz >> 7) == fcb->ex && (sz & 0x7f) > fcb->rc &&
	 mk_filename( filename, fcbaddr) &&
	 ( i = open( filename, O_RDWR)) != -1) {
		chsize( i, (( fcb->ex << 7) + fcb->rc) << 7);
		close( i);
DEBUGOUT( stderr, "Change file size : %s\n", filename);
    }
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movzwl 0x12(%rdi), %ecx
shll $0x8, %ecx
movzbl 0x11(%rdi), %eax
orl %eax, %ecx
shrl $0x7, %ecx
movzbl 0xc(%rdi), %edx
cmpl %edx, %ecx
jne 0x8644
movq %rdi, %rbx
andl $0x7f, %eax
movzbl 0xf(%rdi), %ecx
cmpl %ecx, %eax
jbe 0x8644
leaq 0x10c4e9(%rip), %rdi    # 0x114ae0
movq %rbx, %rsi
callq 0x7c2a
testq %rax, %rax
je 0x8644
leaq 0x10c4d5(%rip), %rdi    # 0x114ae0
pushq $0x2
popq %rsi
xorl %eax, %eax
callq 0x2320
cmpl $-0x1, %eax
je 0x8644
movl %eax, %ebp
movzbl 0xc(%rbx), %eax
movzbl 0xf(%rbx), %esi
shll $0xe, %eax
shll $0x7, %esi
addq %rax, %rsi
movl %ebp, %edi
callq 0x2120
movl %ebp, %edi
callq 0x2190
cmpl $0x0, 0x10acd2(%rip)    # 0x113314
jne 0x864b
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq 0xa9a6(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x77e7(%rip), %rsi      # 0xfe43
leaq 0x10c47d(%rip), %rdx    # 0x114ae0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x2200
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: cpm_file_size
byte cpm_file_size( byte *fcbaddr)
{
    struct FCB *fcb = (struct FCB *)fcbaddr;
    DWORD d;

    if ( cpm_file_open( fcbaddr, CF_OPEN)) return 0xff;
    d = fcb->d[1] + (fcb->d[2] << 8) + (fcb->d[3] << 16);
    fcb->r0 = (byte)d;
    fcb->r1 = (byte)(d >> 8); 
    fcb->r2 = (byte)(d >> 16);
    cpm_file_close( fcbaddr);

    return 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
xorl %esi, %esi
callq 0x82b7
movl %eax, %ecx
movb $-0x1, %al
testb %cl, %cl
jne 0x89c1
movzwl 0x11(%rbx), %eax
movb 0x13(%rbx), %cl
movw %ax, 0x21(%rbx)
movb %cl, 0x23(%rbx)
movq %rbx, %rdi
callq 0x8555
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/serge-404[P]CPM32/cpm.c
// Function: cpm_file_delete
byte cpm_file_delete( byte *fcbaddr)
{
    struct FCB *fcb = (struct FCB *)fcbaddr;
    int i;
    HANDLE hFndFile;
    WIN32_FIND_DATA aFindData;
    char *fname;
    byte st = 0xff;

    if ( memcmp( fcbaddr, "\1$$$     SUB", 1+8+3) == 0) abort_submit = TRUE;

    if (( i = fcb->d[ 0]) > 0 && --i < MAXFCB && 
		fcbs[ i].addr == fcbaddr && fcbs[ i].fp) {
DEBUGOUT( stderr, "REUSE %d - ", i);
	fclose( fcbs[ i].fp); fcbs[ i].fp = NULL;
    }

    if (( fname = mk_filename( filename, fcbaddr)) == NULL) return 0xff;
    hFndFile = FindFirstFile( filename, &aFindData);
    if ( hFndFile == INVALID_HANDLE_VALUE) return 0xff;
    do {
	char *p = aFindData.cAlternateFileName;
	if ( !*p) p = aFindData.cFileName;
	if ( *p != '.') {
	    strcpy( fname, p);
	    if ( remove( filename) == 0) st = 0;
	}
    } while( FindNextFile( hFndFile, &aFindData));
    FindClose( hFndFile);

    return st;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdi, %rbx
leaq 0x74ae(%rip), %rsi      # 0xfe8c
pushq $0xc
popq %rdx
callq 0x22b0
testl %eax, %eax
jne 0x89f4
movl $0x1, 0x10cf1c(%rip)    # 0x115910
movzbl 0x10(%rbx), %edx
testl %edx, %edx
je 0x8a38
cmpb $0x40, %dl
ja 0x8a38
decl %edx
movl %edx, %eax
shlq $0x5, %rax
leaq 0x10c700(%rip), %r14    # 0x115110
cmpq %rbx, 0x10(%rax,%r14)
jne 0x8a38
addq %rax, %r14
movq (%r14), %rdi
testq %rdi, %rdi
je 0x8a38
cmpl $0x0, 0x10a8eb(%rip)    # 0x113314
jne 0x8ad9
callq 0x20c0
andq $0x0, (%r14)
leaq 0x10c0a1(%rip), %rdi    # 0x114ae0
movq %rbx, %rsi
callq 0x7c2a
movb $-0x1, %bl
testq %rax, %rax
je 0x8ac5
movq %rax, %r14
leaq 0x10c088(%rip), %rdi    # 0x114ae0
leaq 0x8(%rsp), %rsi
callq 0x7d9a
testq %rax, %rax
je 0x8ac5
movq %rax, %r15
leaq 0x124(%rsp), %rbp
movb $-0x1, %bl
leaq 0x20(%rsp), %r13
leaq 0x8(%rsp), %r12
cmpb $0x0, 0x124(%rsp)
movq %rbp, %rsi
cmoveq %r13, %rsi
cmpb $0x2e, (%rsi)
je 0x8aae
movq %r14, %rdi
callq 0x2090
leaq 0x10c03f(%rip), %rdi    # 0x114ae0
callq 0x2080
testl %eax, %eax
movzbl %bl, %ebx
cmovel %eax, %ebx
movq %r15, %rdi
movq %r12, %rsi
callq 0x7f6e
testl %eax, %eax
jne 0x8a7e
movq %r15, %rdi
callq 0x807b
movl %ebx, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xa518(%rip), %rax      # 0x12ff8
movq (%rax), %rdi
leaq 0x73af(%rip), %rsi      # 0xfe99
xorl %eax, %eax
callq 0x2200
movq (%r14), %rdi
jmp 0x8a2f