// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/converters/m8376/m8376.c
// Function: main
int main (int argc, char *argv[])
{
FILE *fi[8], *outf;
char fname[256];
int c, i, j;
unsigned int wd[1024];

for (i = 0; i < 8; i++) {
	sprintf (fname, "C:\\temp\\m8376\\m8376e%03d.bin", fnum[i]);
	fi[i] = fopen (fname, "rb");
	if (fi[i] == NULL) {
	    printf ("Can't open file %s\n", fname);
	    return 0;
	    }
	}

for (i = 0; i < 1024; i++) {
	wd[i] = 0;
	for (j = 7; j >=0; j--) {
	    c = fgetc (fi[j]);
	    if (c == EOF) {
		printf ("Premature end of file on file %d\n", i);
		return 0;
		}
	    wd[i] = (wd[i] << 4) | (c & 0xF);
	    }
	}

for (i = 0; i < 8; i++) fclose (fi[i]);
outf = fopen ("c:\\prom.bin", "wb");
if (outf == NULL) {
	printf ("Can't open output file\n");
	return 0;
	}
fwrite (wd, 1024, sizeof (int), outf);
fclose (outf);
return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1170, %rsp           # imm = 0x1170
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, -0x168(%rbp)
cmpl $0x8, -0x168(%rbp)
jge 0x124e
leaq -0x160(%rbp), %rdi
movslq -0x168(%rbp), %rcx
leaq 0xebb(%rip), %rax       # 0x2090
movl (%rax,%rcx,4), %edx
leaq 0xe25(%rip), %rsi       # 0x2004
movb $0x0, %al
callq 0x1070
leaq -0x160(%rbp), %rdi
leaq 0xe2d(%rip), %rsi       # 0x2021
callq 0x1060
movq %rax, %rcx
movslq -0x168(%rbp), %rax
movq %rcx, -0x50(%rbp,%rax,8)
movslq -0x168(%rbp), %rax
cmpq $0x0, -0x50(%rbp,%rax,8)
jne 0x1238
leaq -0x160(%rbp), %rsi
leaq 0xdff(%rip), %rdi       # 0x2024
movb $0x0, %al
callq 0x1040
movl $0x0, -0x4(%rbp)
jmp 0x13b5
jmp 0x123a
movl -0x168(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x168(%rbp)
jmp 0x11b3
movl $0x0, -0x168(%rbp)
cmpl $0x400, -0x168(%rbp)    # imm = 0x400
jge 0x1321
movslq -0x168(%rbp), %rax
movl $0x0, -0x1170(%rbp,%rax,4)
movl $0x7, -0x16c(%rbp)
cmpl $0x0, -0x16c(%rbp)
jl 0x130b
movslq -0x16c(%rbp), %rax
movq -0x50(%rbp,%rax,8), %rdi
callq 0x1050
movl %eax, -0x164(%rbp)
cmpl $-0x1, -0x164(%rbp)
jne 0x12cd
movl -0x168(%rbp), %esi
leaq 0xd7e(%rip), %rdi       # 0x2038
movb $0x0, %al
callq 0x1040
movl $0x0, -0x4(%rbp)
jmp 0x13b5
movslq -0x168(%rbp), %rax
movl -0x1170(%rbp,%rax,4), %ecx
shll $0x4, %ecx
movl -0x164(%rbp), %eax
andl $0xf, %eax
orl %eax, %ecx
movslq -0x168(%rbp), %rax
movl %ecx, -0x1170(%rbp,%rax,4)
movl -0x16c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x16c(%rbp)
jmp 0x1284
jmp 0x130d
movl -0x168(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x168(%rbp)
jmp 0x1258
movl $0x0, -0x168(%rbp)
cmpl $0x8, -0x168(%rbp)
jge 0x1356
movslq -0x168(%rbp), %rax
movq -0x50(%rbp,%rax,8), %rdi
callq 0x1030
movl -0x168(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x168(%rbp)
jmp 0x132b
leaq 0xcfd(%rip), %rdi       # 0x205a
leaq 0xd02(%rip), %rsi       # 0x2066
callq 0x1060
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x138b
leaq 0xcee(%rip), %rdi       # 0x2069
movb $0x0, %al
callq 0x1040
movl $0x0, -0x4(%rbp)
jmp 0x13b5
leaq -0x1170(%rbp), %rdi
movq -0x58(%rbp), %rcx
movl $0x400, %esi            # imm = 0x400
movl $0x4, %edx
callq 0x1080
movq -0x58(%rbp), %rdi
callq 0x1030
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1170, %rsp           # imm = 0x1170
popq %rbp
retq