// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: nextpage
void nextpage(void)
{
	int i;
	permfifotype *per;

	//char snotbuf[32];
	//j = 0; k = 0;
	//for(i=0;i<4096;i++)
	//   if (waloff[i] != 0)
	//   {
	//      sprintf(snotbuf,"%ld-%ld",i,tilesizx[i]*tilesizy[i]);
	//      printext256((j>>5)*40+32,(j&31)*6,walock[i]>>3,-1,snotbuf,1);
	//      k += tilesizx[i]*tilesizy[i];
	//      j++;
	//   }
	//sprintf(snotbuf,"Total: %ld",k);
	//printext256((j>>5)*40+32,(j&31)*6,31,-1,snotbuf,1);

	switch(qsetmode)
	{
		case 200:
			for(i=permtail;i!=permhead;i=((i+1)&(MAXPERMS-1)))
			{
				per = &permfifo[i];
				if ((per->pagesleft > 0) && (per->pagesleft <= numpages))
					dorotatesprite(per->sx,per->sy,per->z,per->a,per->picnum,
							per->dashade,per->dapalnum,per->dastat,
							per->cx1,per->cy1,per->cx2,per->cy2,per->uniqid);
			}

			OSD_Draw();
#if USE_POLYMOST
			polymost_nextpage();
#endif

			if (captureatnextpage) {
				screencapture(NULL, captureatnextpage);
				captureatnextpage = 0;
			}

			showframe();
#if USE_POLYMOST && USE_OPENGL
			polymost_aftershowframe();
#endif
			if (usegammabrightness!=ousegammabrightness) setbrightness(0,NULL,4);

			/*
			if (ratelimit > 0) {
				int delaytime;
				unsigned int thisticks, thist;

				ratelimitlast[ ratelimitn++ & 31 ] = thist = getusecticks();
				delaytime = 0;
				if (ratelimitn >= 32) {
					for (i=1;i<32;i++) delaytime += ratelimitlast[i] - ratelimitlast[i-1];
					delaytime = (1000000/ratelimit) - (delaytime/31);
				}
#ifdef _WIN32
				while (delaytime > 0) {
					Sleep(1);
					thisticks = getusecticks();
					delaytime -= (thisticks - thist);
					thist = thisticks;
				}
#endif
			}
			*/

			for(i=permtail;i!=permhead;i=((i+1)&(MAXPERMS-1)))
			{
				per = &permfifo[i];
				if (per->pagesleft >= 130)
					dorotatesprite(per->sx,per->sy,per->z,per->a,per->picnum,
										per->dashade,per->dapalnum,per->dastat,
										per->cx1,per->cy1,per->cx2,per->cy2,per->uniqid);

				if ((per->pagesleft&127) && (numpages < 127)) per->pagesleft--;
				if (((per->pagesleft&127) == 0) && (i == permtail))
					permtail = ((permtail+1)&(MAXPERMS-1));
			}
			break;

		case 480:
			break;
	}
	faketimerhandler();

	if ((totalclock >= lastageclock+8) || (totalclock < lastageclock))
		{ lastageclock = totalclock; agecache(); }

#if USE_POLYMOST && USE_OPENGL
	omdtims = mdtims; mdtims = getticks();
	if (((unsigned int)(mdtims-omdtims)) > 10000) omdtims = mdtims;
#endif

	beforedrawrooms = 1;
	numframes++;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x50, %rsp
movl 0x1a8703(%rip), %eax    # 0x1f5588
movl %eax, -0x34(%rbp)
subl $0xc8, %eax
je 0x4cea4
jmp 0x4ce91
movl -0x34(%rbp), %eax
subl $0x1e0, %eax            # imm = 0x1E0
je 0x4d141
jmp 0x4d143
movl 0x406802(%rip), %eax    # 0x4536ac
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl 0x4067fa(%rip), %eax    # 0x4536b0
je 0x4cfa7
movslq -0x24(%rbp), %rcx
leaq 0x4067f9(%rip), %rax    # 0x4536c0
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzbl 0x13(%rax), %eax
cmpl $0x0, %eax
jle 0x4cf92
movq -0x30(%rbp), %rax
movzbl 0x13(%rax), %eax
cmpl 0x4107cf(%rip), %eax    # 0x45d6c0
jg 0x4cf92
movq -0x30(%rbp), %rax
movl (%rax), %edi
movq -0x30(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x30(%rbp), %rax
movw 0xc(%rax), %cx
movq -0x30(%rbp), %rax
movw 0xe(%rax), %r8w
movq -0x30(%rbp), %rax
movb 0x10(%rax), %r9b
movq -0x30(%rbp), %rax
movb 0x11(%rax), %r12b
movq -0x30(%rbp), %rax
movb 0x12(%rax), %r15b
movq -0x30(%rbp), %rax
movl 0x14(%rax), %r14d
movq -0x30(%rbp), %rax
movl 0x18(%rax), %ebx
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %r11d
movq -0x30(%rbp), %rax
movl 0x20(%rax), %r10d
movq -0x30(%rbp), %rax
movl 0x24(%rax), %eax
movswl %cx, %ecx
movswl %r8w, %r8d
movsbl %r9b, %r9d
movzbl %r12b, %r12d
movl %r12d, (%rsp)
movzbl %r15b, %r15d
movl %r15d, 0x8(%rsp)
movl %r14d, 0x10(%rsp)
movl %ebx, 0x18(%rsp)
movl %r11d, 0x20(%rsp)
movl %r10d, 0x28(%rsp)
movl %eax, 0x30(%rsp)
callq 0x4d1f0
jmp 0x4cf94
movl -0x24(%rbp), %eax
addl $0x1, %eax
andl $0x3ff, %eax            # imm = 0x3FF
movl %eax, -0x24(%rbp)
jmp 0x4cead
callq 0x6e140
callq 0x739d0
cmpb $0x0, 0x41070c(%rip)    # 0x45d6c4
je 0x4cfd1
xorl %eax, %eax
movl %eax, %edi
movsbl 0x4106ff(%rip), %esi    # 0x45d6c4
callq 0x4dfc0
movb $0x0, 0x4106f3(%rip)    # 0x45d6c4
callq 0xa67c0
callq 0x73390
movl 0x93c9b(%rip), %eax     # 0xe0c7c
cmpl 0x93c99(%rip), %eax     # 0xe0c80
je 0x4cff9
xorl %edi, %edi
xorl %eax, %eax
movl %eax, %esi
movl $0x4, %edx
callq 0x4c9c0
movl 0x4066ad(%rip), %eax    # 0x4536ac
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl 0x4066a5(%rip), %eax    # 0x4536b0
je 0x4d13f
movslq -0x24(%rbp), %rcx
leaq 0x4066a4(%rip), %rax    # 0x4536c0
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movzbl 0x13(%rax), %eax
cmpl $0x82, %eax
jl 0x4d0d5
movq -0x30(%rbp), %rax
movl (%rax), %edi
movq -0x30(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x30(%rbp), %rax
movw 0xc(%rax), %cx
movq -0x30(%rbp), %rax
movw 0xe(%rax), %r8w
movq -0x30(%rbp), %rax
movb 0x10(%rax), %r9b
movq -0x30(%rbp), %rax
movb 0x11(%rax), %r12b
movq -0x30(%rbp), %rax
movb 0x12(%rax), %r15b
movq -0x30(%rbp), %rax
movl 0x14(%rax), %r14d
movq -0x30(%rbp), %rax
movl 0x18(%rax), %ebx
movq -0x30(%rbp), %rax
movl 0x1c(%rax), %r11d
movq -0x30(%rbp), %rax
movl 0x20(%rax), %r10d
movq -0x30(%rbp), %rax
movl 0x24(%rax), %eax
movswl %cx, %ecx
movswl %r8w, %r8d
movsbl %r9b, %r9d
movzbl %r12b, %r12d
movl %r12d, (%rsp)
movzbl %r15b, %r15d
movl %r15d, 0x8(%rsp)
movl %r14d, 0x10(%rsp)
movl %ebx, 0x18(%rsp)
movl %r11d, 0x20(%rsp)
movl %r10d, 0x28(%rsp)
movl %eax, 0x30(%rsp)
callq 0x4d1f0
movq -0x30(%rbp), %rax
movzbl 0x13(%rax), %eax
andl $0x7f, %eax
cmpl $0x0, %eax
je 0x4d0fb
cmpl $0x7f, 0x4105d4(%rip)   # 0x45d6c0
jge 0x4d0fb
movq -0x30(%rbp), %rax
movb 0x13(%rax), %cl
addb $-0x1, %cl
movb %cl, 0x13(%rax)
movq -0x30(%rbp), %rax
movzbl 0x13(%rax), %eax
andl $0x7f, %eax
cmpl $0x0, %eax
jne 0x4d12a
movl -0x24(%rbp), %eax
cmpl 0x406598(%rip), %eax    # 0x4536ac
jne 0x4d12a
movl 0x406590(%rip), %eax    # 0x4536ac
addl $0x1, %eax
andl $0x3ff, %eax            # imm = 0x3FF
movl %eax, 0x406582(%rip)    # 0x4536ac
jmp 0x4d12c
movl -0x24(%rbp), %eax
addl $0x1, %eax
andl $0x3ff, %eax            # imm = 0x3FF
movl %eax, -0x24(%rbp)
jmp 0x4d002
jmp 0x4d143
jmp 0x4d143
callq 0xc220
movl 0x39befa(%rip), %eax    # 0x3e9048
movl 0x410574(%rip), %ecx    # 0x45d6c8
addl $0x8, %ecx
cmpl %ecx, %eax
jge 0x4d169
movl 0x39bee7(%rip), %eax    # 0x3e9048
cmpl 0x410561(%rip), %eax    # 0x45d6c8
jge 0x4d17a
movl 0x39bed9(%rip), %eax    # 0x3e9048
movl %eax, 0x410553(%rip)    # 0x45d6c8
callq 0x2efd0
leaq 0x659eff(%rip), %rax    # 0x6a7080
movl (%rax), %ecx
leaq 0x659efa(%rip), %rax    # 0x6a7084
movl %ecx, (%rax)
callq 0xa56e0
movl %eax, %ecx
leaq 0x659ee6(%rip), %rax    # 0x6a7080
movl %ecx, (%rax)
leaq 0x659edd(%rip), %rax    # 0x6a7080
movl (%rax), %eax
leaq 0x659ed8(%rip), %rcx    # 0x6a7084
subl (%rcx), %eax
cmpl $0x2710, %eax           # imm = 0x2710
jbe 0x4d1c7
leaq 0x659ec4(%rip), %rax    # 0x6a7080
movl (%rax), %ecx
leaq 0x659ebf(%rip), %rax    # 0x6a7084
movl %ecx, (%rax)
movl $0x1, 0x93aa7(%rip)     # 0xe0c78
movl 0x4104f5(%rip), %eax    # 0x45d6cc
addl $0x1, %eax
movl %eax, 0x4104ec(%rip)    # 0x45d6cc
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)