// File: /workspace/github_c_makefile_star2_O1/simh[P]simtools/converters/gt7cvt/gt7cvt.c
// Function: main
int main (int argc, char *argv[])
{
int i, ch, bc, rc, fc;
unsigned char buf[FLPSIZ];
char *ppos, oname[256];
FILE *ifile, *ofile;

if ((argc < 2) || (argv[0] == NULL)) {
	printf ("Usage is: verb file [file...]\n");
	exit (0);  }

for (i = 1; i < argc; i++) {
	strcpy (oname, argv[i]);
        if (ppos = strrchr (oname, '.')) strcpy (ppos, ".tap");
            else strcat (oname, ".tap");
	ifile = fopen (argv[i], "rb");
	if (ifile == NULL) {
	    printf ("Error opening file: %s\n", argv[i]);
	    exit (0);  }
	ofile = fopen (oname, "wb");
	if (ofile == NULL) {
	    printf ("Error opening file: %s\n", oname);
	    exit (0);  }

	printf ("Processing file %s\n", argv[i]);
	for (bc = rc = fc = 0;;) {
	    ch = fgetc (ifile);
	    if (ch == EOF) break;
	    if (ch & 0x80) {
		if (bc) {
		    if (dump_rec (ofile, bc, buf))
			printf ("End of file %d\n", ++fc);
		    else printf ("Record %d size %d\n", ++rc, bc);
		    }
		bc = 0;  }
	    buf[bc++] = ch & 0x3F;
	    }
	fclose (ifile);
	if (bc) dump_rec (ofile, bc, buf);
	fwrite (fzero, sizeof (char), 4, ofile);
	printf ("End of file %d\n", ++fc);
	fclose (ofile);	
	}

return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10128, %rsp          # imm = 0x10128
cmpl $0x2, %edi
jl 0x1474
movq %rsi, %r12
cmpq $0x0, (%rsi)
je 0x1474
movl %edi, %eax
movq %rax, 0x10(%rsp)
movl $0x1, %ebx
leaq 0x20(%rsp), %r14
movq %r12, 0x8(%rsp)
movq (%r12,%rbx,8), %rsi
movq %r14, %rdi
callq 0x1030
movq %r14, %rdi
movl $0x2e, %esi
callq 0x1080
testq %rax, %rax
je 0x12cb
movb $0x0, 0x4(%rax)
movl $0x7061742e, (%rax)     # imm = 0x7061742E
jmp 0x12e0
movq %r14, %rdi
callq 0x1060
movl $0x7061742e, 0x20(%rsp,%rax) # imm = 0x7061742E
movb $0x0, 0x24(%rsp,%rax)
movq (%r12,%rbx,8), %rdi
leaq 0xd1e(%rip), %rsi       # 0x2009
callq 0x10a0
testq %rax, %rax
je 0x144d
movq %rax, %r13
movq %r14, %rdi
leaq 0xd1e(%rip), %rsi       # 0x2024
callq 0x10a0
testq %rax, %rax
je 0x145a
movq %rax, %rbp
movq %rbx, 0x18(%rsp)
movq (%r12,%rbx,8), %rsi
xorl %r15d, %r15d
leaq 0xcfd(%rip), %rdi       # 0x2027
xorl %eax, %eax
callq 0x1070
movq %r13, %rdi
callq 0x1090
cmpl $-0x1, %eax
je 0x13c9
movl %eax, %ebx
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %r14d, %r14d
testb %bl, %bl
jns 0x13a0
testl %r15d, %r15d
je 0x139d
movq %rbp, %rdi
movl %r15d, %esi
leaq 0x120(%rsp), %rdx
callq 0x11cc
testl %eax, %eax
je 0x1386
incl %r14d
xorl %r15d, %r15d
leaq 0xcc1(%rip), %rdi       # 0x203b
movl %r14d, %esi
xorl %eax, %eax
callq 0x1070
jmp 0x13a0
incl %r12d
leaq 0xcbb(%rip), %rdi       # 0x204b
movl %r12d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x1070
xorl %r15d, %r15d
andb $0x3f, %bl
movslq %r15d, %rax
incl %r15d
movb %bl, 0x120(%rsp,%rax)
movq %r13, %rdi
callq 0x1090
movl %eax, %ebx
cmpl $-0x1, %eax
jne 0x134d
incl %r14d
movq 0x8(%rsp), %r12
jmp 0x13cf
movl $0x1, %r14d
movq %r13, %rdi
callq 0x1050
testl %r15d, %r15d
movq 0x18(%rsp), %rbx
je 0x13f4
movq %rbp, %rdi
movl %r15d, %esi
leaq 0x120(%rsp), %rdx
callq 0x11cc
movl $0x1, %esi
movl $0x4, %edx
leaq 0x2c74(%rip), %rdi      # 0x4079
movq %rbp, %rcx
callq 0x10c0
leaq 0xc27(%rip), %rdi       # 0x203b
movl %r14d, %esi
xorl %eax, %eax
callq 0x1070
movq %rbp, %rdi
callq 0x1050
incq %rbx
cmpq 0x10(%rsp), %rbx
leaq 0x20(%rsp), %r14
jne 0x12a1
xorl %eax, %eax
addq $0x10128, %rsp          # imm = 0x10128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r12,%rbx,8), %rsi
leaq 0xbb4(%rip), %rdi       # 0x200c
jmp 0x1466
leaq 0xbab(%rip), %rdi       # 0x200c
leaq 0x20(%rsp), %rsi
xorl %eax, %eax
callq 0x1070
xorl %edi, %edi
callq 0x10b0
leaq 0xbe3(%rip), %rdi       # 0x205e
callq 0x1040
jmp 0x146d