// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movw %di, %ax
movw %ax, -0x6(%rbp)
movl %esi, -0xc(%rbp)
leaq 0xeaf3f(%rip), %rax     # 0x119f18
movzbl 0x4(%rax), %eax
cmpl $0x0, %eax
je 0x2efee
movl $0x0, -0x4(%rbp)
jmp 0x2f37c
movswq -0x6(%rbp), %rcx
leaq 0x14b1e6(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movswl 0x1a(%rax), %eax
cmpl $0xfa, %eax
je 0x2f024
movswq -0x6(%rbp), %rcx
leaq 0x14b1cb(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movswl 0x1a(%rax), %eax
cmpl $0x193, %eax            # imm = 0x193
jne 0x2f030
movl $0x0, -0x4(%rbp)
jmp 0x2f37c
movswl -0x6(%rbp), %edi
callq 0x2ec80
cmpl $0x0, %eax
jne 0x2f04c
movswl -0x6(%rbp), %edi
callq 0x2ed00
cmpl $0x0, %eax
je 0x2f058
movl $0x0, -0x4(%rbp)
jmp 0x2f37c
leaq 0x5892f1(%rip), %rax    # 0x5b8350
movswl 0x1f4(%rax), %eax
movl %eax, -0x10(%rbp)
cmpl $0x0, -0x10(%rbp)
jl 0x2f0b0
movslq -0x10(%rbp), %rcx
leaq 0x591ae6(%rip), %rax    # 0x5c0b60
movswl (%rax,%rcx,2), %eax
movl %eax, -0x18(%rbp)
movslq -0x10(%rbp), %rcx
leaq 0x14b154(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movswl 0x1e(%rax), %eax
movswl -0x6(%rbp), %ecx
cmpl %ecx, %eax
jne 0x2f0a8
movl $0x0, -0x4(%rbp)
jmp 0x2f37c
movl -0x18(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x2f069
movswq -0x6(%rbp), %rcx
leaq 0x14b124(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movl $0xfa, %esi
movswl 0x18(%rax), %edi
callq 0x2abd0
cwtl
movl %eax, -0x10(%rbp)
cmpl $-0x1, -0x10(%rbp)
jne 0x2f0e4
movl $0x0, -0x4(%rbp)
jmp 0x2f37c
movslq -0x10(%rbp), %rcx
leaq 0x14b0f1(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movw $0xffff, 0x2a(%rax)     # imm = 0xFFFF
movswq -0x6(%rbp), %rcx
leaq 0x14b0db(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movl (%rax), %ecx
movslq -0x10(%rbp), %rdx
leaq 0x14b0ca(%rip), %rax    # 0x17a1e0
movq (%rax,%rdx,8), %rax
movl %ecx, (%rax)
movswq -0x6(%rbp), %rcx
leaq 0x14b0b8(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %ecx
movslq -0x10(%rbp), %rdx
leaq 0x14b0a6(%rip), %rax    # 0x17a1e0
movq (%rax,%rdx,8), %rax
movl %ecx, 0x4(%rax)
movswq -0x6(%rbp), %rcx
leaq 0x14b093(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movl 0x8(%rax), %ecx
movslq -0x10(%rbp), %rdx
leaq 0x14b081(%rip), %rax    # 0x17a1e0
movq (%rax,%rdx,8), %rax
movl %ecx, 0x8(%rax)
movslq -0x10(%rbp), %rcx
leaq 0x14b06f(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movb $0x14, 0x14(%rax)
movslq -0x10(%rbp), %rcx
leaq 0x14b05c(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movb $0x14, 0x15(%rax)
movslq -0x10(%rbp), %rcx
leaq 0x14b049(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movw $0x0, 0xc(%rax)
movslq -0x10(%rbp), %rcx
leaq 0x14b034(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movb $-0x1c, 0x10(%rax)
movl -0xc(%rbp), %eax
movw %ax, %cx
movslq -0x10(%rbp), %rdx
leaq 0x14b01b(%rip), %rax    # 0x17a1e0
movq (%rax,%rdx,8), %rax
movw %cx, 0xe(%rax)
leaq 0xab1e2(%rip), %rdi     # 0xda3b6
callq 0x41510
andl $0x200, %eax            # imm = 0x200
addl $0x80, %eax
movw %ax, %cx
movslq -0x10(%rbp), %rdx
leaq 0x14afef(%rip), %rax    # 0x17a1e0
movq (%rax,%rdx,8), %rax
movw %cx, 0x26(%rax)
movslq -0x10(%rbp), %rcx
leaq 0x14afdc(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movw $0x0, 0x28(%rax)
movw -0x6(%rbp), %cx
movslq -0x10(%rbp), %rdx
leaq 0x14afc3(%rip), %rax    # 0x17a1e0
movq (%rax,%rdx,8), %rax
movw %cx, 0x1e(%rax)
cmpl $0x1c2, -0xc(%rbp)      # imm = 0x1C2
jne 0x2f33e
movswq -0x6(%rbp), %rcx
leaq 0x14afa2(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movb 0x14(%rax), %cl
movslq -0x10(%rbp), %rdx
leaq 0x14af90(%rip), %rax    # 0x17a1e0
movq (%rax,%rdx,8), %rax
movb %cl, 0x14(%rax)
movswq -0x6(%rbp), %rcx
leaq 0x14af7d(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movzbl 0x15(%rax), %eax
addl $0x8, %eax
movb %al, %cl
movslq -0x10(%rbp), %rdx
leaq 0x14af65(%rip), %rax    # 0x17a1e0
movq (%rax,%rdx,8), %rax
movb %cl, 0x15(%rax)
movswq -0x6(%rbp), %rcx
leaq 0x14af52(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movswl 0x2a(%rax), %eax
movl %eax, -0x14(%rbp)
movslq -0x10(%rbp), %rcx
leaq 0x14af3c(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movl (%rax), %esi
movslq -0x10(%rbp), %rcx
leaq 0x14af2b(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %edx
movl $0x24, %edi
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x26af0
movl -0x14(%rbp), %edi
callq 0x2ae90
cmpl $0x0, %eax
je 0x2f33c
movl $0x193, %esi            # imm = 0x193
movswl -0x6(%rbp), %edi
callq 0x2d0c0
movswq -0x6(%rbp), %rcx
leaq 0x14aeeb(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movswl 0x1a(%rax), %eax
cmpl $0x193, %eax            # imm = 0x193
jne 0x2f33a
movswq -0x6(%rbp), %rcx
leaq 0x14aed0(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movswl 0x20(%rax), %ecx
addl $0x4, %ecx
movw %cx, 0x20(%rax)
movswq -0x6(%rbp), %rcx
leaq 0x14aeb5(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movswl 0x22(%rax), %ecx
addl $0x4, %ecx
movw %cx, 0x22(%rax)
jmp 0x2f33c
jmp 0x2f375
movswq -0x6(%rbp), %rcx
leaq 0x14ae96(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movl (%rax), %esi
movswq -0x6(%rbp), %rcx
leaq 0x14ae84(%rip), %rax    # 0x17a1e0
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %edx
movl $0x6c, %edi
xorl %ecx, %ecx
movl $0x8, %r8d
callq 0x26af0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)