// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/src/bstub.c
// Function: checkextras
void checkextras(void)
{
     int       i,j,ext;
     FILE      *fp;

     fp=fopen("exts", "wt");
     if( fp == NULL ) {
          return;
     }

     fprintf(fp,"\n\t SPR\t\t EXT\n\n");
     for( i=0; i<MAXSPRITES; i++ ) {
          if( sprite[i].extra != -1 ) {
               fprintf(fp,"\t%4d\t\t%4d\n", i,sprite[i].extra);
          }
     }

     fprintf(fp, "\n");
     // check for maps to unlocked XT
     for( i=0; i<MAXSPRITES; i++ ) {
          ext=sprite[i].extra;
          if( ext != -1 ) {
               if( spriteXT[ext].lock == 0x00 ) {
                    sprite[i].extra=-1;
                    buildprintf("bad extra for %d\n", i);
                    fprintf(fp, "Sprite %d at %d,%d mapped to unlocked XT %4d\n", i,sprite[i].x,sprite[i].y,ext);
               }
          }
     }

     fprintf(fp, "\n");
     // check for locked XT with no mapping
     for( i=0; i<MAXSPRITES; i++ ) {
          if( spriteXT[i].lock == 0xFF ) {
               for( j=0; j<MAXSPRITES; j++ ) {
                    if( sprite[j].extra == i ) {
                         break;
                    }
               }
               if( j == MAXSPRITES ) {
                    spriteXT[i].lock=0x00;
                    buildprintf("extension %d had no map\n", i);
                    fprintf(fp, "No mapping for locked XT %4d\n", i);
               }
          }
     }

     fprintf(fp, "\n");
     // check for non-unique mapping
     for( i=0; i<MAXSPRITES; i++ ) {
          ext=sprite[i].extra;
          if( ext != -1 ) {
               for( j=0; j<MAXSPRITES; j++ ) {
                    if( (j != i) && (sprite[j].extra == ext) ) {
                         buildprintf("non unique map for %d\n",i);
                         fprintf(fp, "Non unique mapping for %4d at %d,%d\n", i,sprite[i].x,sprite[i].y);
                         break;
                    }
               }
          }
     }

     fclose(fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x6c431(%rip), %rdi     # 0x73537
leaq 0x6c42f(%rip), %rsi     # 0x7353c
callq 0x6ce0
testq %rax, %rax
je 0x7311
movq %rax, %rbx
leaq 0x6c41a(%rip), %rdi     # 0x7353f
movl $0xe, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x6b90
leaq 0x275b72(%rip), %r13    # 0x27ccb0
leaq 0x2a(%r13), %r12
leaq 0x6c405(%rip), %r14     # 0x7354e
xorl %r15d, %r15d
movswl (%r12), %ecx
cmpl $-0x1, %ecx
je 0x7166
movq %rbx, %rdi
movq %r14, %rsi
movl %r15d, %edx
xorl %eax, %eax
callq 0x61e0
incq %r15
addq $0x2c, %r12
cmpq $0x4000, %r15           # imm = 0x4000
jne 0x714c
movl $0xa, %edi
movq %rbx, %rsi
callq 0x6920
leaq 0x2a(%r13), %r15
leaq 0x9e682(%rip), %r14     # 0xa5810
xorl %r12d, %r12d
movswl (%r15), %ebp
cmpl $-0x1, %ebp
je 0x71e6
movslq %ebp, %rax
movq %rax, %rcx
shlq $0x5, %rcx
leaq (%rcx,%rax,2), %rax
cmpb $0x0, 0x1e(%r14,%rax)
jne 0x71e6
movw $0xffff, (%r15)         # imm = 0xFFFF
leaq 0x6c39c(%rip), %rdi     # 0x73559
movl %r12d, %esi
xorl %eax, %eax
callq 0x25221
movl -0x2a(%r15), %ecx
movl -0x26(%r15), %r8d
movq %rbx, %rdi
leaq 0x6c392(%rip), %rsi     # 0x7356b
movl %r12d, %edx
movl %ebp, %r9d
xorl %eax, %eax
callq 0x61e0
incq %r12
addq $0x2c, %r15
cmpq $0x4000, %r12           # imm = 0x4000
jne 0x7191
movl $0xa, %edi
movq %rbx, %rsi
callq 0x6920
leaq 0x6c38f(%rip), %rbp     # 0x73599
leaq 0x6c3a1(%rip), %r15     # 0x735b2
xorl %r12d, %r12d
movq %r12, %rax
shlq $0x5, %rax
leaq (%rax,%r12,2), %rax
cmpb $-0x1, 0x1e(%r14,%rax)
jne 0x726d
addq %r14, %rax
addq $0x1e, %rax
movl $0x2a, %ecx
movswq (%r13,%rcx), %rdx
movl %edx, %edx
cmpq %rdx, %r12
je 0x726d
addq $0x2c, %rcx
cmpq $0xb002a, %rcx          # imm = 0xB002A
jne 0x7233
movb $0x0, (%rax)
movq %rbp, %rdi
movl %r12d, %esi
xorl %eax, %eax
callq 0x25221
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x61e0
incq %r12
cmpq $0x4000, %r12           # imm = 0x4000
jne 0x7214
movl $0xa, %edi
movq %rbx, %rsi
callq 0x6920
leaq 0x6c35a(%rip), %r15     # 0x735e7
xorl %ebp, %ebp
xorl %r12d, %r12d
imulq $0x2c, %r12, %r14
movzwl 0x2a(%r13,%r14), %eax
cmpw $-0x1, %ax
je 0x72eb
addq %r13, %r14
xorl %ecx, %ecx
cmpq %rcx, %rbp
je 0x72b4
cmpw %ax, 0x2a(%r13,%rcx)
je 0x72c3
addq $0x2c, %rcx
cmpq $0xb0000, %rcx          # imm = 0xB0000
jne 0x72a7
jmp 0x72eb
leaq 0x6c306(%rip), %rdi     # 0x735d0
movl %r12d, %esi
xorl %eax, %eax
callq 0x25221
movl (%r14), %ecx
movl 0x4(%r14), %r8d
movq %rbx, %rdi
movq %r15, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x61e0
incq %r12
addq $0x2c, %rbp
cmpq $0x4000, %r12           # imm = 0x4000
jne 0x7292
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6480
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq