// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/src/tekstat.c
// Function: attachvirus
int
attachvirus(short i, int pic)
{
     int       j,ext,nextj;

     if( option[4] != 0 ) {
          return(0);
     }
     if( (sprptr[i]->statnum == VIRUS) || (sprptr[i]->statnum == PINBALL) ) {
          return(0);
     }
     if( isanandroid(i) || isahologram(i) ) {
          return(0);
     }

	j=headspritestat[VIRUS];
	while( j >= 0 ) {
		nextj = nextspritestat[j];
          // already hosting ?
          if( sprptr[j]->owner == i ) {
               return(0);
          }
		j = nextj;
	}

     j=jsinsertsprite(sprptr[i]->sectnum, VIRUS);
     if( j == -1 ) {
          return(0);
     }

     sprptr[j]->extra=-1;
     sprptr[j]->x=sprptr[i]->x;
     sprptr[j]->y=sprptr[i]->y;
     sprptr[j]->z=sprptr[i]->z;
     sprptr[j]->xrepeat=20;
     sprptr[j]->yrepeat=20;
     sprptr[j]->cstat=0x0000;
     sprptr[j]->shade=-28;
     sprptr[j]->picnum=pic;
     sprptr[j]->lotag=(krand_intercept("STAT1216")&512)+128;
     sprptr[j]->hitag=0;
     sprptr[j]->owner=i;  // host

     if( pic == FIREPIC ) {
          sprptr[j]->xrepeat=sprptr[i]->xrepeat;
          sprptr[j]->yrepeat=sprptr[i]->yrepeat+8;
          ext=sprptr[i]->extra;
          playsound(S_FIRELOOP,sprptr[j]->x,sprptr[j]->y,0,ST_UPDATE);
          if( validext(ext) ) {
               newstatus(i, PINBALL);
               if( sprptr[i]->statnum == PINBALL ) {
                    sprptr[i]->xvel+=4;
                    sprptr[i]->yvel+=4;
               }
          }
     }
     else {
          playsound(S_FORCEFIELDHUMLOOP, sprptr[i]->x,sprptr[i]->y,0,ST_UNIQUE);
     }

     return(1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xb08fa(%rip), %rax     # 0xd1978
xorl %r15d, %r15d
cmpb $0x0, 0x4(%rax)
je 0x21099
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %edi, %r14d
movswq %r14w, %r12
leaq 0x110189(%rip), %r13    # 0x131230
movq (%r13,%r12,8), %rax
movzwl 0x1a(%rax), %eax
cmpl $0xfa, %eax
je 0x21087
cmpl $0x193, %eax            # imm = 0x193
je 0x21087
movl %esi, %ebp
movswl %r14w, %ebx
movl %ebx, %edi
callq 0x20e82
testl %eax, %eax
jne 0x21087
movl %ebx, %edi
callq 0x20ece
testl %eax, %eax
jne 0x21087
leaq 0x54e2bf(%rip), %rax    # 0x56f3a0
movzwl 0x1f4(%rax), %ecx
testw %cx, %cx
js 0x2110c
leaq 0x556abc(%rip), %rax    # 0x577bb0
movzwl %cx, %ecx
movq (%r13,%rcx,8), %rdx
cmpw %r14w, 0x1e(%rdx)
je 0x21087
movzwl (%rax,%rcx,2), %ecx
testw %cx, %cx
jns 0x210f4
movq (%r13,%r12,8), %rax
movswl 0x18(%rax), %edi
movl $0xfa, %esi
callq 0x1eac8
cmpw $-0x1, %ax
je 0x21087
movswq %ax, %r15
movq (%r13,%r15,8), %rax
movw $0xffff, 0x2a(%rax)     # imm = 0xFFFF
movq (%r13,%r12,8), %rax
movl (%rax), %eax
movq (%r13,%r15,8), %rcx
movl %eax, (%rcx)
movq (%r13,%r12,8), %rax
movl 0x4(%rax), %eax
movq (%r13,%r15,8), %rcx
movl %eax, 0x4(%rcx)
movq (%r13,%r12,8), %rax
movl 0x8(%rax), %eax
movq (%r13,%r15,8), %rcx
movl %eax, 0x8(%rcx)
movq (%r13,%r15,8), %rax
movb $0x14, %cl
movb %cl, 0x14(%rax)
movq (%r13,%r15,8), %rax
movb %cl, 0x15(%rax)
movq (%r13,%r15,8), %rax
xorl %ecx, %ecx
movw %cx, 0xc(%rax)
movq (%r13,%r15,8), %rax
movb $-0x1c, 0x10(%rax)
movq (%r13,%r15,8), %rax
movw %bp, 0xe(%rax)
leaq 0x6f49a(%rip), %rdi     # 0x90636
callq 0x2d112
andl $0x200, %eax            # imm = 0x200
orl $0x80, %eax
movq (%r13,%r15,8), %rcx
movw %ax, 0x26(%rcx)
movq (%r13,%r15,8), %rax
xorl %ecx, %ecx
movw %cx, 0x28(%rax)
movq (%r13,%r15,8), %rax
movw %r14w, 0x1e(%rax)
movq (%r13,%r12,8), %rax
cmpl $0x1c2, %ebp            # imm = 0x1C2
jne 0x2125e
movb 0x14(%rax), %al
movq (%r13,%r15,8), %rcx
movb %al, 0x14(%rcx)
movq (%r13,%r12,8), %rax
movb 0x15(%rax), %al
addb $0x8, %al
movq (%r13,%r15,8), %rcx
movb %al, 0x15(%rcx)
movq (%r13,%r12,8), %rax
movzwl 0x2a(%rax), %ebp
movq (%r13,%r15,8), %rax
movl (%rax), %esi
movl 0x4(%rax), %edx
movl $0x24, %edi
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x1c370
movl $0x1, %r15d
cmpw $0x3fff, %bp            # imm = 0x3FFF
ja 0x21087
movl %ebx, %edi
movl $0x193, %esi            # imm = 0x193
callq 0x1fe98
movq (%r13,%r12,8), %rax
cmpw $0x193, 0x1a(%rax)      # imm = 0x193
jne 0x21087
addw $0x4, 0x20(%rax)
movq (%r13,%r12,8), %rax
addw $0x4, 0x22(%rax)
jmp 0x21087
movl (%rax), %esi
movl 0x4(%rax), %edx
movl $0x6c, %edi
xorl %ecx, %ecx
movl $0x8, %r8d
callq 0x1c370
movl $0x1, %r15d
jmp 0x21087