// File: /workspace/github_c_makefile_star2_O3/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 0xb701f(%rip), %rbx     # 0xe5934
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
leaq 0x3ff20c(%rip), %r14    # 0x42db30
movzwl 0xe(%r14,%rax), %r15d
leal -0x194(%r15), %ecx
cmpl $0x20, %ecx
ja 0x2e9ef
movabsq $0x160000001, %rdx      # imm = 0x160000001
btq %rcx, %rdx
jae 0x2e99a
movl (%r14,%rax), %esi
movl 0x4(%r14,%rax), %edx
movl $0x6d, %edi
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x1c370
leal -0x1b1(%r15), %eax
cmpl $0x3, %eax
ja 0x2ea16
leaq 0x6223c(%rip), %rcx     # 0x90bb8
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 0x2eaa5
cmpq $0x1, %rcx
je 0x2ea41
cmpq $0x1f, %rcx
jne 0x2e9ef
movswq %di, %rcx
leaq 0x10241b(%rip), %rdx    # 0x130dd0
cmpl $0x0, (%rdx,%rcx,4)
je 0x2eb63
movl (%r14,%rax), %esi
movl 0x4(%r14,%rax), %edx
movl $0x6d, %edi
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x1c370
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
movw $0x1b4, 0xe(%r14,%rax)  # imm = 0x1B4
jmp 0x2eaa5
addq %r14, %rax
addq $0xe, %rax
cmpl $0xe7c, %r15d           # imm = 0xE7C
je 0x2ea3a
cmpl $0xe7d, %r15d           # imm = 0xE7D
jne 0x2eaa5
movw $0xe7c, (%rax)          # imm = 0xE7C
jmp 0x2eaa5
cmpl $0x195, %r15d           # imm = 0x195
je 0x2ea71
cmpl $0x194, %r15d           # imm = 0x194
jne 0x2eaa5
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
movw $0x195, 0xe(%r14,%rax)  # imm = 0x195
jmp 0x2eaa5
movw $0xe7d, (%rax)          # imm = 0xE7D
jmp 0x2eaa5
movswq %di, %rcx
leaq 0x102344(%rip), %rdx    # 0x130d90
cmpl $0x0, (%rdx,%rcx,4)
je 0x2eb6c
movl (%r14,%rax), %esi
movl 0x4(%r14,%rax), %edx
movl $0x6d, %edi
xorl %ecx, %ecx
movl $0x2, %r8d
callq 0x1c370
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
movw $0x194, 0xe(%r14,%rax)  # imm = 0x194
jmp 0x2eaa5
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
movw $0x1b3, 0xe(%r14,%rax)  # imm = 0x1B3
jmp 0x2eaa5
movswq (%rbx), %rax
imulq $0x2c, %rax, %rax
movw $0x1b1, 0xe(%r14,%rax)  # imm = 0x1B1
leaq 0x552334(%rip), %r15    # 0x580de0
movzwl (%r15), %eax
testw %ax, %ax
jle 0x2eb04
leaq 0x3c5e24(%rip), %r12    # 0x3f48e0
addq $0x24, %r12
movzwl (%rbx), %ecx
xorl %r13d, %r13d
movzwl (%r12), %edx
movswq %cx, %rsi
imulq $0x2c, %rsi, %rsi
cmpw 0x28(%r14,%rsi), %dx
jne 0x2eaf4
cmpw $0x1, -0x2(%r12)
je 0x2eaf4
movswl %r13w, %edi
callq 0x27c8c
movzwl (%rbx), %ecx
movzwl (%r15), %eax
incq %r13
movswq %ax, %rdx
addq $0x28, %r12
cmpq %rdx, %r13
jl 0x2eac6
leaq 0x540895(%rip), %rax    # 0x56f3a0
movzwl (%rax), %eax
cmpw $-0x1, %ax
je 0x2eb54
movzwl (%rbx), %ecx
leaq 0x549092(%rip), %r15    # 0x577bb0
movswq %ax, %rdx
movzwl (%r15,%rdx,2), %ebp
imulq $0x2c, %rdx, %rdx
movzwl 0x28(%r14,%rdx), %edx
movswq %cx, %rsi
imulq $0x2c, %rsi, %rsi
cmpw 0x28(%r14,%rsi), %dx
jne 0x2eb4c
movswl %ax, %edi
callq 0x1e559
movzwl (%rbx), %ecx
movl %ebp, %eax
cmpw $-0x1, %bp
jne 0x2eb1e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x62196(%rip), %rdi     # 0x90d00
jmp 0x2eb73
leaq 0x62170(%rip), %rdi     # 0x90ce3
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x14be7