// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/src/tektag.c
// Function: warp
void
warp(int *x, int *y, int *z, short *daang, short *dasector)
{
     short          startwall, endwall, s;
     int           i, j, dax, day;

     (void)daang;

     for( i=0; i<warpsectorcnt; i++ ) {
          if( warpsectorlist[i] == *dasector ) {
               j = sector[*dasector].hitag;
               do {
                    i++;
                    if (i >= warpsectorcnt) i = 0;
               } while( sector[warpsectorlist[i]].hitag != j );
               *dasector = warpsectorlist[i];
               break;
          }
     }

     // find center of sector
     startwall = sector[*dasector].wallptr;
     endwall = startwall+sector[*dasector].wallnum-1;
     dax = 0L, day = 0L;
     for( s=startwall; s<=endwall; s++ ) {
          dax += wall[s].x, day += wall[s].y;
          if( wall[s].nextsector >= 0 ) {
               i = s;
          }
     }
     *x = dax / (endwall-startwall+1);
     *y = day / (endwall-startwall+1);
     *z = sector[*dasector].floorz-(42<<8);

     updatesector(*x,*y,dasector);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
leaq 0x137b23(%rip), %rcx    # 0x176c60
movswl (%rcx), %ecx
cmpl %ecx, %eax
jge 0x3f1f1
movslq -0x34(%rbp), %rcx
leaq 0x137a8d(%rip), %rax    # 0x176be0
movswl (%rax,%rcx,2), %eax
movq -0x28(%rbp), %rcx
movswl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x3f1e1
movq -0x28(%rbp), %rax
movswq (%rax), %rcx
leaq 0x3fe71f(%rip), %rax    # 0x43d890
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movswl 0x24(%rax), %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
leaq 0x137ace(%rip), %rcx    # 0x176c60
movswl (%rcx), %ecx
cmpl %ecx, %eax
jl 0x3f1a0
movl $0x0, -0x34(%rbp)
jmp 0x3f1a2
movslq -0x34(%rbp), %rcx
leaq 0x137a33(%rip), %rax    # 0x176be0
movswq (%rax,%rcx,2), %rcx
leaq 0x3fe6d7(%rip), %rax    # 0x43d890
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movswl 0x24(%rax), %eax
cmpl -0x38(%rbp), %eax
jne 0x3f17f
movslq -0x34(%rbp), %rcx
leaq 0x137a0c(%rip), %rax    # 0x176be0
movw (%rax,%rcx,2), %cx
movq -0x28(%rbp), %rax
movw %cx, (%rax)
jmp 0x3f1f1
jmp 0x3f1e3
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x3f133
movq -0x28(%rbp), %rax
movswq (%rax), %rcx
leaq 0x3fe690(%rip), %rax    # 0x43d890
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movw (%rax), %ax
movw %ax, -0x2a(%rbp)
movswl -0x2a(%rbp), %eax
movq -0x28(%rbp), %rcx
movswq (%rcx), %rdx
leaq 0x3fe66f(%rip), %rcx    # 0x43d890
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movswl 0x2(%rcx), %ecx
addl %ecx, %eax
subl $0x1, %eax
movw %ax, -0x2c(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movw -0x2a(%rbp), %ax
movw %ax, -0x2e(%rbp)
movswl -0x2e(%rbp), %eax
movswl -0x2c(%rbp), %ecx
cmpl %ecx, %eax
jg 0x3f2c1
movswq -0x2e(%rbp), %rcx
leaq 0x37361d(%rip), %rax    # 0x3b2880
shlq $0x5, %rcx
addq %rcx, %rax
movl (%rax), %eax
addl -0x3c(%rbp), %eax
movl %eax, -0x3c(%rbp)
movswq -0x2e(%rbp), %rcx
leaq 0x373602(%rip), %rax    # 0x3b2880
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
addl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
movswq -0x2e(%rbp), %rcx
leaq 0x3735e6(%rip), %rax    # 0x3b2880
shlq $0x5, %rcx
addq %rcx, %rax
movswl 0xc(%rax), %eax
cmpl $0x0, %eax
jl 0x3f2b1
movswl -0x2e(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x3f2b3
movw -0x2e(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x2e(%rbp)
jmp 0x3f24b
movl -0x3c(%rbp), %eax
movswl -0x2c(%rbp), %ecx
movswl -0x2a(%rbp), %edx
subl %edx, %ecx
addl $0x1, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movl -0x40(%rbp), %eax
movswl -0x2c(%rbp), %ecx
movswl -0x2a(%rbp), %edx
subl %edx, %ecx
addl $0x1, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x28(%rbp), %rax
movswq (%rax), %rcx
leaq 0x3fe58a(%rip), %rax    # 0x43d890
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %ecx
subl $0x2a00, %ecx           # imm = 0x2A00
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x10(%rbp), %rax
movl (%rax), %esi
movq -0x28(%rbp), %rdx
callq 0x53c40
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)