// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/src/tektag.c
// Function: tekswitchtrigger
void
tekswitchtrigger(short snum)
{
     int       i,j;
     int      nexti;
     int      dax,day;

     j=sprite[neartagsprite].picnum;

     switch( j ) {
     case SWITCH2OFF:
          if( invredcards[snum] == 0 ) {
               showmessage("PASSAGE REQUIRES RED KEYCARD");
               return;
          }
          break;
     case SWITCH4OFF:
          if( invbluecards[snum] == 0 ) {
               showmessage("PASSAGE REQUIRES BLUE KEYCARD");
               return;
          }
          break;
     }

     switch( j ) {
     case SWITCH2ON:
     case SWITCH2OFF:
     case SWITCH3ON:
     case SWITCH3OFF:
     case SWITCH4ON:
     case SWITCH4OFF:
          dax = sprite[neartagsprite].x;
          day = sprite[neartagsprite].y;
          playsound(S_KEYCARDBLIP, dax,day,0, ST_UPDATE);
          break;
     default:
          break;
     }

     if (j == SWITCH2ON) sprite[neartagsprite].picnum = SWITCH2OFF;
     if (j == SWITCH2OFF) sprite[neartagsprite].picnum = SWITCH2ON;
     if (j == SWITCH3ON) sprite[neartagsprite].picnum = SWITCH3OFF;
     if (j == SWITCH3OFF) sprite[neartagsprite].picnum = SWITCH3ON;
     if (j == SWITCH4ON) sprite[neartagsprite].picnum = SWITCH4OFF;
     if (j == SWITCH4OFF) sprite[neartagsprite].picnum = SWITCH4ON;

     if (j == 3708) sprite[neartagsprite].picnum = 3709;
     if (j == 3709) sprite[neartagsprite].picnum = 3708;

     for(i=0;i<numsectors;i++)
          if (sector[i].hitag == sprite[neartagsprite].hitag)
               if (sector[i].lotag != 1)
                    operatesector(i);

     i = headspritestat[0];
     while (i != -1)
     {
          nexti = nextspritestat[i];
          if (sprite[i].hitag == sprite[neartagsprite].hitag)
               operatesprite(i);
          i = nexti;
     }


}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xb0ed1(%rip), %rbx     # 0xdb934
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
leaq 0x3f90be(%rip), %r14    # 0x423b30
movzwl 0xe(%r14,%rax), %r15d
leal -0x194(%r15), %ecx
cmpl $0x20, %ecx
ja 0x2ab35
movabsq $0x160000001, %rdx      # imm = 0x160000001
btq %rcx, %rdx
jae 0x2aae4
movl (%r14,%rax), %esi
movl 0x4(%r14,%rax), %edx
pushq $0x6d
popq %rdi
pushq $0x2
popq %r8
xorl %ecx, %ecx
callq 0x1ab2a
leal -0x1b1(%r15), %eax
cmpl $0x3, %eax
ja 0x2ab5c
leaq 0x57fba(%rip), %rcx     # 0x82a80
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
movw $0x1b2, 0xe(%r14,%rax)  # imm = 0x1B2
jmp 0x2abe7
cmpq $0x1, %rcx
je 0x2ab87
cmpq $0x1f, %rcx
jne 0x2ab35
movswq %di, %rcx
leaq 0xfc2d1(%rip), %rdx     # 0x126dd0
cmpl $0x0, (%rdx,%rcx,4)
je 0x2ac92
movl (%r14,%rax), %esi
movl 0x4(%r14,%rax), %edx
pushq $0x6d
popq %rdi
pushq $0x2
popq %r8
xorl %ecx, %ecx
callq 0x1ab2a
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
movw $0x1b4, 0xe(%r14,%rax)  # imm = 0x1B4
jmp 0x2abe7
addq %r14, %rax
addq $0xe, %rax
cmpl $0xe7c, %r15d           # imm = 0xE7C
je 0x2ab80
cmpl $0xe7d, %r15d           # imm = 0xE7D
jne 0x2abe7
movw $0xe7c, (%rax)          # imm = 0xE7C
jmp 0x2abe7
cmpl $0x195, %r15d           # imm = 0x195
je 0x2abb3
cmpl $0x194, %r15d           # imm = 0x194
jne 0x2abe7
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
movw $0x195, 0xe(%r14,%rax)  # imm = 0x195
jmp 0x2abe7
movw $0xe7d, (%rax)          # imm = 0xE7D
jmp 0x2abe7
movswq %di, %rcx
leaq 0xfc1fe(%rip), %rdx     # 0x126d90
cmpl $0x0, (%rdx,%rcx,4)
je 0x2ac9b
movl (%r14,%rax), %esi
movl 0x4(%r14,%rax), %edx
pushq $0x6d
popq %rdi
pushq $0x2
popq %r8
xorl %ecx, %ecx
callq 0x1ab2a
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
movw $0x194, 0xe(%r14,%rax)  # imm = 0x194
jmp 0x2abe7
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
movw $0x1b3, 0xe(%r14,%rax)  # imm = 0x1B3
jmp 0x2abe7
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
movw $0x1b1, 0xe(%r14,%rax)  # imm = 0x1B1
leaq 0x3bfcf2(%rip), %r15    # 0x3ea8e0
addq $0x24, %r15
leaq 0x54c1e7(%rip), %r12    # 0x576de0
movzwl (%r12), %eax
xorl %r13d, %r13d
movswq %ax, %rcx
cmpq %rcx, %r13
jge 0x2ac3d
movzwl (%r15), %ecx
movswq (%rbx), %rdx
imulq $0x2c, %rdx, %rdx
cmpw 0x28(%r14,%rdx), %cx
jne 0x2ac34
cmpw $0x1, -0x2(%r15)
je 0x2ac34
movswl %r13w, %edi
callq 0x253e8
movzwl (%r12), %eax
incq %r13
addq $0x28, %r15
jmp 0x2ac01
leaq 0x53a75c(%rip), %rax    # 0x5653a0
movzwl (%rax), %ebp
leaq 0x542f62(%rip), %r15    # 0x56dbb0
cmpw $-0x1, %bp
je 0x2ac83
movl %ebp, %eax
movswq %bp, %rcx
movzwl (%r15,%rcx,2), %ebp
imulq $0x2c, %rcx, %rcx
movzwl 0x28(%r14,%rcx), %ecx
movswq (%rbx), %rdx
imulq $0x2c, %rdx, %rdx
cmpw 0x28(%r14,%rdx), %cx
jne 0x2ac4e
movswl %ax, %edi
callq 0x1c9b0
jmp 0x2ac4e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x57f2f(%rip), %rdi     # 0x82bc8
jmp 0x2aca2
leaq 0x57f09(%rip), %rdi     # 0x82bab
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1373a
nop