// File: /workspace/github_c_makefile_star2_O1/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 0xb534b(%rip), %rbx     # 0xe2934
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
leaq 0x3fd518(%rip), %r14    # 0x42ab10
movzwl 0xe(%r14,%rax), %r15d
leal -0x194(%r15), %ecx
cmpl $0x20, %ecx
ja 0x2d6de
movabsq $0x160000001, %rdx      # imm = 0x160000001
btq %rcx, %rdx
jae 0x2d66b
movl (%r14,%rax), %esi
movl 0x4(%r14,%rax), %edx
movl $0x6d, %edi
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x1c1f1
cmpl $0x1b0, %r15d           # imm = 0x1B0
jle 0x2d694
leal -0x1b1(%r15), %eax
cmpl $0x3, %eax
ja 0x2d6de
leaq 0x6038f(%rip), %rcx     # 0x8d9e8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movw $0x1b2, %ax             # imm = 0x1B2
jmp 0x2d704
cmpq $0x1, %rcx
je 0x2d6b0
cmpq $0x1f, %rcx
jne 0x2d6de
movswq %di, %rdx
leaq 0x10073e(%rip), %rsi    # 0x12ddc0
cmpl $0x0, (%rsi,%rdx,4)
jne 0x2d6c5
leaq 0x604b9(%rip), %rdi     # 0x8db48
jmp 0x2d7e9
cmpl $0x194, %r15d           # imm = 0x194
je 0x2d7be
cmpl $0x195, %r15d           # imm = 0x195
jne 0x2d712
movw $0x194, %ax             # imm = 0x194
jmp 0x2d704
movswq %di, %rdx
leaq 0x1006c5(%rip), %rsi    # 0x12dd80
cmpl $0x0, (%rsi,%rdx,4)
je 0x2d7e2
cmpl $0x20, %ecx
ja 0x2d6de
movabsq $0x1e0000003, %rdx      # imm = 0x1E0000003
btq %rcx, %rdx
jb 0x2d61e
cmpl $0xe7c, %r15d           # imm = 0xE7C
jne 0x2d6f7
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
movw $0xe7d, 0xe(%r14,%rax)  # imm = 0xE7D
cmpl $0xe7d, %r15d           # imm = 0xE7D
jne 0x2d712
movw $0xe7c, %ax             # imm = 0xE7C
movswq (%rbx), %rcx
imulq $0x2c, %rcx, %rcx
movw %ax, 0xe(%r14,%rcx)
leaq 0x5506a7(%rip), %r15    # 0x57ddc0
cmpw $0x0, (%r15)
jle 0x2d765
leaq 0x3c4199(%rip), %r12    # 0x3f18c0
addq $0x24, %r12
xorl %r13d, %r13d
movzwl (%r12), %eax
movswq (%rbx), %rcx
imulq $0x2c, %rcx, %rcx
cmpw 0x28(%r14,%rcx), %ax
jne 0x2d755
cmpw $0x1, -0x2(%r12)
je 0x2d755
movswl %r13w, %edi
callq 0x276ec
incq %r13
movswq (%r15), %rax
addq $0x28, %r12
cmpq %rax, %r13
jl 0x2d72e
leaq 0x53ec14(%rip), %rax    # 0x56c380
movzwl (%rax), %eax
cmpw $-0x1, %ax
je 0x2d7af
leaq 0x547414(%rip), %r15    # 0x574b90
movswq %ax, %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 0x2d7a7
movswl %ax, %edi
callq 0x1e3e2
movl %ebp, %eax
cmpw $-0x1, %bp
jne 0x2d77c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movw $0x195, %ax             # imm = 0x195
jmp 0x2d704
movw $0x1b4, %ax             # imm = 0x1B4
jmp 0x2d704
movw $0x1b3, %ax             # imm = 0x1B3
jmp 0x2d704
movw $0x1b1, %ax             # imm = 0x1B1
jmp 0x2d704
leaq 0x60342(%rip), %rdi     # 0x8db2b
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x14b61
nop