// File: /workspace/github_c_makefile_star2_O0/calmopyrin[P]tedplay/Tedmem.cpp
// Function: TED::ted_process(short*, unsigned int)
void TED::ted_process(short *buffer, unsigned int count)
{
    do {
        switch(++beamx) {

            default:
                break;

            case 2:
                if (VertSubActive)
                	VertSubCount = (VertSubCount+1)&7;
                break;

            case 3:
				if (AttribFetch && beamy==0) {
					VertSubCount = 7;
				}
				break;

             case 4:
                 if (AttribFetch) {
					BadLine |= ((vshift)&7) == (beamy&7);
					if ( BadLine ) {
						ClockingState = THALT1;
					} else
                 		ClockingState = TSS;
                 	if (beamy==203) {
						AttribFetch = false;
						if (!(BadLine & 2)) ClockingState = TSS;
					}
				}
                break;

            case 8:
				HBlanking = false;
				break;

            case 10:
				if (VertSubActive)
					CharacterPosition = CharacterPositionReload;
                break;

            case 16:
				if (ScreenOn) {
					SideBorderFlipFlop = true;
					memset( scrptr, mcol[0], hshift);
					if (nrwscr)
						CharacterWindow = true;
					x = 0;
				}
				if (BadLine & 1)
					DoDMA(tmpClrbuf, 0);
				if (BadLine & 2)
					DoDMA(chrbuf, (BadLine & 1) ? 0 : 0x400);
                break;

			case 18:
				if (ScreenOn && !nrwscr) {
					CharacterWindow = true;
				}
				break;

			case 89:
				if (/*VertSubActive &&*/ VertSubCount == 6)
					CharacterCount = (CharacterCount + 40)&0x3FF;
				break;

            case 90:
    			if ( VertSubActive && VertSubCount == 7 )
					CharacterPositionReload = (CharacterPosition + 40)&0x3FF;
				break;

            case 91:
		    	ClockingState = TRFSH;
		    	break;

			case 94:
				if (ScreenOn && !nrwscr)
  					SideBorderFlipFlop = CharacterWindow = false;
				break;

  			case 96:
				if (ScreenOn && nrwscr)
  					SideBorderFlipFlop = CharacterWindow = false;
				// FIXME this breaks on FF1E writes
				if (BadLine & 1) {
					// swap DMA fetch pointers for colour DMA...
					unsigned char *tmpbuf = clrbuf;
					clrbuf = tmpClrbuf;
					tmpClrbuf = tmpbuf;
				}
  			    break;

			case 111:
				if ((BadLine&1)) {
    			    BadLine = 2;
					VertSubActive = true;
				} else if (BadLine&2) {// in the second bad line, we're finished...
   					BadLine &= ~2;
				}
				break;

            case 102:
		    	ClockingState = fastmode ? TDS : TSS;
		    	break;

		    case 104:
				HBlanking = true;
				break;

		    case 107: // HSYNC start
				break;

			case 256:
			case 128:
				beamx = 15;
				break;
			case 114: // HSYNC end
    			beamx=0;
    			// the beam reached a new line
    			TVScanLineCounter += 1;
    			if ( TVScanLineCounter >= 340 ) {
					TVScanLineCounter = 0;
					scrptr=screen;
//					render_ok=true;
				}
    			switch (++beamy) {

    			    case 4:
    			        if (!fltscr) ScreenOn = AttribFetch;
    			        break;

    			    case 8:
						if (fltscr) ScreenOn = AttribFetch;
    			        break;

					case 200:
						if (fltscr) ScreenOn = false;
						break;

    			    case 204:
						if (!fltscr) ScreenOn = false;
						break;

    			    case 205:
						CharacterCount = 0;
					    // cursor phase counter in TED register $1F
						VertSubActive = false;
						if ((++crsrphase&0x0F) == 0x0F)
    			        	crsrblinkon ^= 1;
    			        break;

					case 251:
						VBlanking = true;
						break;

    			    case 261: // Vertical retrace
						// frame ready...
						//render_ok=true;
						// reset screen pointer ("TV" electron beam)
						scrptr=screen;
						TVScanLineCounter = 0;
						break;

					case 271:
						VBlanking = false;
						break;

					case 512:
					case 312:
					    beamy = 0;
					    CharacterPosition = CharacterPositionReload = 0;
					    AttribFetch = (Ram[0xFF06]&0x10) != 0;
				}
				// is there raster interrupt?
				if (beamy == irqline)
					Ram[0xFF09] |= Ram[0xFF0A]&0x02 ? 0x82 : 0x02;
		}

		if (beamx&1) {	// perform these only in every second cycle
			if (t2on && !((timer2--)&0xFFFF)) {// Timer2 permitted
				timer2=0xFFFF;
				Ram[0xFF09] |= Ram[0xFF0A]&0x10 ? 0x90 : 0x10; // interrupt
			}
			if (t3on && !((timer3--)&0xFFFF)) {// Timer3 permitted
				timer3=0xFFFF;
				Ram[0xFF09] |= Ram[0xFF0A]&0x40 ? 0xC0 : 0x40; // interrupt
			}
			if (!CharacterWindow && !HBlanking && !VBlanking) {
				// we are on the border area, so use the frame color
				*((int*)(scrptr+4)) = framecol;
			}
			if (scrptr != endptr)
				scrptr+=8;
		} else {
			if (t1on && !timer1--) { // Timer1 permitted decreased and zero
				timer1=(t1start-1)&0xFFFF;
				Ram[0xFF09] |= Ram[0xFF0A]&0x08 ? 0x88 : 0x08; // interrupt
			}

			if (!(HBlanking |VBlanking)) {
				if (SideBorderFlipFlop) { // drawing the visible part of the screen
					// call the relevant rendering function
					//switch (scrattr) {
					//	case 0:
					//		hi_text();
					//		break;
					//	case REVERSE :
					//		rv_text();
					//		break;
					//	case MULTICOLOR|REVERSE :
					//	    mc_text_rvs();
					//	    break;
					//	case MULTICOLOR :
					//		mc_text();
					//		break;
					//	case EXTCOLOR|REVERSE :
					//	case EXTCOLOR :
					//		ec_text();
					//		break;
					//	case GRAPHMODE|REVERSE :
					//	case GRAPHMODE :
					//		hi_bitmap();
					//		break;
					//	case EXTCOLOR|MULTICOLOR :
					//	case GRAPHMODE|EXTCOLOR :
					//	case GRAPHMODE|MULTICOLOR|EXTCOLOR :
					//	case REVERSE|MULTICOLOR|EXTCOLOR :
					//	case GRAPHMODE|MULTICOLOR|EXTCOLOR|REVERSE :
					//		mcec();
					//		break;
					//	case GRAPHMODE|MULTICOLOR :
					//	case GRAPHMODE|MULTICOLOR|REVERSE :
					//		mc_bitmap();
					//		break;
					//	default:
				 //   		illegalbank();
				 //   		break;
					//}
					x = (x + 1) & 0x3F;
				}
				if (!CharacterWindow) {
					// we are on the border area, so use the frame color
					*((int*)scrptr) = framecol;
				}
			}

			CycleCounter++;
			if (!(CycleCounter & 0x03) && buffer && int(count) > 0) {
				static unsigned int remainder = 0;
				unsigned int samples = (playbackSpeed + remainder) / 4;
				if (samples) {
					renderSound(samples, buffer);
					if (sidCard) {
						short imBuf[128];
						sidCard->calcSamples(imBuf, samples);
						unsigned int i = samples - 1;
						do {
							buffer[i] += (short)(int(imBuf[i]) * int(masterVolume) / 1000);
						}while (i--);
					}
					storeToBuffer(buffer, samples);
				}
				remainder = (playbackSpeed + remainder) % 4;
				count -= samples;
				buffer += samples;
			}
		}
		if (aligned_write) {
			*aw_addr_ptr = aw_value;
			aligned_write = false;
		}
		switch (ClockingState|(beamx&1)) {
        	case TRFSH|1:
 	    	case TSS|1:
 	    	case TDS|1:
       		case TDS:
     	    	cpuptr->process();
     	    	break;
      		case THALT1|1:
  	    	case THALT2|1:
        	case THALT3|1:
            	cpuptr->stopcycle();
            	ClockingState<<=1;
            	break;
		}

	} while (int(count) > 0 && buffer);

	render_ok = false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x150, %rsp            # imm = 0x150
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rcx
movl 0x81c(%rcx), %eax
incl %eax
movl %eax, -0x144(%rbp)
movl %eax, 0x81c(%rcx)
subl $0x2, %eax
je 0x18c82
jmp 0x18b47
movl -0x144(%rbp), %eax
subl $0x3, %eax
je 0x18ca2
jmp 0x18b58
movl -0x144(%rbp), %eax
subl $0x4, %eax
je 0x18cca
jmp 0x18b69
movl -0x144(%rbp), %eax
subl $0x8, %eax
je 0x18d60
jmp 0x18b7a
movl -0x144(%rbp), %eax
subl $0xa, %eax
je 0x18d6c
jmp 0x18b8b
movl -0x144(%rbp), %eax
subl $0x10, %eax
je 0x18d86
jmp 0x18b9c
movl -0x144(%rbp), %eax
subl $0x12, %eax
je 0x18e3b
jmp 0x18bad
movl -0x144(%rbp), %eax
subl $0x59, %eax
je 0x18e60
jmp 0x18bbe
movl -0x144(%rbp), %eax
subl $0x5a, %eax
je 0x18e82
jmp 0x18bcf
movl -0x144(%rbp), %eax
subl $0x5b, %eax
je 0x18ead
jmp 0x18be0
movl -0x144(%rbp), %eax
subl $0x5e, %eax
je 0x18ebc
jmp 0x18bf1
movl -0x144(%rbp), %eax
subl $0x60, %eax
je 0x18ee8
jmp 0x18c02
movl -0x144(%rbp), %eax
subl $0x66, %eax
je 0x18f92
jmp 0x18c13
movl -0x144(%rbp), %eax
subl $0x68, %eax
je 0x18fba
jmp 0x18c24
movl -0x144(%rbp), %eax
subl $0x6b, %eax
je 0x18fc6
jmp 0x18c35
movl -0x144(%rbp), %eax
subl $0x6f, %eax
je 0x18f4d
jmp 0x18c46
movl -0x144(%rbp), %eax
subl $0x72, %eax
je 0x18fe1
jmp 0x18c57
movl -0x144(%rbp), %eax
subl $0x80, %eax
je 0x18fcb
jmp 0x18c6a
movl -0x144(%rbp), %eax
subl $0x100, %eax            # imm = 0x100
je 0x18fcb
jmp 0x18c7d
jmp 0x1928f
testb $0x1, 0x1cca7(%rip)     # 0x35930
je 0x18c9d
movl 0x1cc8f(%rip), %eax     # 0x35920
addl $0x1, %eax
andl $0x7, %eax
movl %eax, 0x1cc83(%rip)     # 0x35920
jmp 0x1928f
testb $0x1, 0x1cc9b(%rip)     # 0x35944
je 0x18cc5
movq -0x140(%rbp), %rax
cmpl $0x0, 0x820(%rax)
jne 0x18cc5
movl $0x7, 0x1cc5b(%rip)     # 0x35920
jmp 0x1928f
testb $0x1, 0x1cc73(%rip)     # 0x35944
je 0x18d5b
movq -0x140(%rbp), %rcx
movl 0xb6020(%rcx), %eax
andl $0x7, %eax
movl 0x820(%rcx), %ecx
andl $0x7, %ecx
cmpl %ecx, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
orl 0x1cc40(%rip), %eax     # 0x35940
movl %eax, 0x1cc3a(%rip)     # 0x35940
cmpl $0x0, 0x1cc33(%rip)     # 0x35940
je 0x18d1b
movl $0x10, 0x1cc2f(%rip)    # 0x35948
jmp 0x18d25
movl $0x2, 0x1cc23(%rip)     # 0x35948
movq -0x140(%rbp), %rax
cmpl $0xcb, 0x820(%rax)
jne 0x18d59
movb $0x0, 0x1cc05(%rip)     # 0x35944
movl 0x1cbfb(%rip), %eax     # 0x35940
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x18d57
movl $0x2, 0x1cbf1(%rip)     # 0x35948
jmp 0x18d59
jmp 0x18d5b
jmp 0x1928f
movb $0x0, 0x1cbfa(%rip)     # 0x35961
jmp 0x1928f
testb $0x1, 0x1cbbd(%rip)     # 0x35930
je 0x18d81
movl 0x1cbbd(%rip), %eax     # 0x35938
movl %eax, 0x1cbb3(%rip)     # 0x35934
jmp 0x1928f
testb $0x1, 0x1cbd5(%rip)     # 0x35962
je 0x18ddc
movq -0x140(%rbp), %rcx
movb $0x1, 0x1cb9f(%rip)     # 0x3593c
movq 0xb6160(%rcx), %rdi
movzbl 0xb618a(%rcx), %eax
movl 0xb601c(%rcx), %ecx
movl %ecx, %edx
movzbl %al, %esi
callq 0x3130
movq -0x140(%rbp), %rax
cmpl $0x0, 0xb6024(%rax)
je 0x18dd2
movb $0x1, 0x1cb91(%rip)     # 0x35963
movl $0x0, 0x1cb88(%rip)     # 0x35964
movl 0x1cb5e(%rip), %eax     # 0x35940
andl $0x1, %eax
cmpl $0x0, %eax
je 0x18dff
movq -0x140(%rbp), %rdi
movq 0xb6100(%rdi), %rsi
xorl %edx, %edx
callq 0x19870
movl 0x1cb3b(%rip), %eax     # 0x35940
andl $0x2, %eax
cmpl $0x0, %eax
je 0x18e36
movq -0x140(%rbp), %rdi
movq 0xb60f0(%rdi), %rsi
movl 0x1cb1f(%rip), %ecx     # 0x35940
andl $0x1, %ecx
movl $0x400, %edx            # imm = 0x400
xorl %eax, %eax
cmpl $0x0, %ecx
cmovnel %eax, %edx
callq 0x19870
jmp 0x1928f
testb $0x1, 0x1cb20(%rip)     # 0x35962
je 0x18e5b
movq -0x140(%rbp), %rax
cmpl $0x0, 0xb6024(%rax)
jne 0x18e5b
movb $0x1, 0x1cb08(%rip)     # 0x35963
jmp 0x1928f
cmpl $0x6, 0x1cab9(%rip)     # 0x35920
jne 0x18e7d
movl 0x1cadd(%rip), %eax     # 0x3594c
addl $0x28, %eax
andl $0x3ff, %eax            # imm = 0x3FF
movl %eax, 0x1cacf(%rip)     # 0x3594c
jmp 0x1928f
testb $0x1, 0x1caa7(%rip)     # 0x35930
je 0x18ea8
cmpl $0x7, 0x1ca8e(%rip)     # 0x35920
jne 0x18ea8
movl 0x1ca9a(%rip), %eax     # 0x35934
addl $0x28, %eax
andl $0x3ff, %eax            # imm = 0x3FF
movl %eax, 0x1ca90(%rip)     # 0x35938
jmp 0x1928f
movl $0x8, 0x1ca91(%rip)     # 0x35948
jmp 0x1928f
testb $0x1, 0x1ca9f(%rip)     # 0x35962
je 0x18ee3
movq -0x140(%rbp), %rax
cmpl $0x0, 0xb6024(%rax)
jne 0x18ee3
movb $0x0, 0x1ca87(%rip)     # 0x35963
movb $0x0, 0x1ca59(%rip)     # 0x3593c
jmp 0x1928f
testb $0x1, 0x1ca73(%rip)     # 0x35962
je 0x18f0f
movq -0x140(%rbp), %rax
cmpl $0x0, 0xb6024(%rax)
je 0x18f0f
movb $0x0, 0x1ca5b(%rip)     # 0x35963
movb $0x0, 0x1ca2d(%rip)     # 0x3593c
movl 0x1ca2b(%rip), %eax     # 0x35940
andl $0x1, %eax
cmpl $0x0, %eax
je 0x18f48
movq -0x140(%rbp), %rax
movq 0xb60f8(%rax), %rcx
movq %rcx, -0x20(%rbp)
movq 0xb6100(%rax), %rcx
movq %rcx, 0xb60f8(%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0xb6100(%rax)
jmp 0x1928f
movl 0x1c9ed(%rip), %eax     # 0x35940
andl $0x1, %eax
cmpl $0x0, %eax
je 0x18f6e
movl $0x2, 0x1c9db(%rip)     # 0x35940
movb $0x1, 0x1c9c4(%rip)     # 0x35930
jmp 0x18f8d
movl 0x1c9cc(%rip), %eax     # 0x35940
andl $0x2, %eax
cmpl $0x0, %eax
je 0x18f8b
movl 0x1c9be(%rip), %eax     # 0x35940
andl $-0x3, %eax
movl %eax, 0x1c9b5(%rip)     # 0x35940
jmp 0x18f8d
jmp 0x1928f
movq -0x140(%rbp), %rax
movl 0xb6180(%rax), %edx
movl $0x2, %eax
movl $0x4, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, 0x1c993(%rip)     # 0x35948
jmp 0x1928f
movb $0x1, 0x1c9a0(%rip)     # 0x35961
jmp 0x1928f
jmp 0x1928f
movq -0x140(%rbp), %rax
movl $0xf, 0x81c(%rax)
jmp 0x1928f
movq -0x140(%rbp), %rax
movl $0x0, 0x81c(%rax)
movl 0x1c970(%rip), %eax     # 0x35968
addl $0x1, %eax
movl %eax, 0x1c967(%rip)     # 0x35968
cmpl $0x154, 0x1c95d(%rip)   # imm = 0x154
jb 0x1902f
movq -0x140(%rbp), %rax
movl $0x0, 0x1c94a(%rip)     # 0x35968
movq %rax, %rcx
addq $0x824, %rcx            # imm = 0x824
movq %rcx, 0xb6160(%rax)
movq -0x140(%rbp), %rcx
movl 0x820(%rcx), %eax
incl %eax
movl %eax, -0x148(%rbp)
movl %eax, 0x820(%rcx)
subl $0x4, %eax
je 0x19101
jmp 0x19055
movl -0x148(%rbp), %eax
subl $0x8, %eax
je 0x19124
jmp 0x19066
movl -0x148(%rbp), %eax
subl $0xc8, %eax
je 0x19147
jmp 0x19079
movl -0x148(%rbp), %eax
subl $0xcc, %eax
je 0x19163
jmp 0x1908c
movl -0x148(%rbp), %eax
subl $0xcd, %eax
je 0x1917f
jmp 0x1909f
movl -0x148(%rbp), %eax
subl $0xfb, %eax
je 0x191d5
jmp 0x190b2
movl -0x148(%rbp), %eax
subl $0x105, %eax            # imm = 0x105
je 0x191de
jmp 0x190c5
movl -0x148(%rbp), %eax
subl $0x10f, %eax            # imm = 0x10F
je 0x19202
jmp 0x190d8
movl -0x148(%rbp), %eax
subl $0x138, %eax            # imm = 0x138
je 0x1920b
jmp 0x190eb
movl -0x148(%rbp), %eax
subl $0x200, %eax            # imm = 0x200
je 0x1920b
jmp 0x19248
movq -0x140(%rbp), %rax
cmpl $0x0, 0xb6028(%rax)
jne 0x1911f
movb 0x1c82d(%rip), %al      # 0x35944
andb $0x1, %al
movb %al, 0x1c843(%rip)      # 0x35962
jmp 0x19248
movq -0x140(%rbp), %rax
cmpl $0x0, 0xb6028(%rax)
je 0x19142
movb 0x1c80a(%rip), %al      # 0x35944
andb $0x1, %al
movb %al, 0x1c820(%rip)      # 0x35962
jmp 0x19248
movq -0x140(%rbp), %rax
cmpl $0x0, 0xb6028(%rax)
je 0x1915e
movb $0x0, 0x1c804(%rip)     # 0x35962
jmp 0x19248
movq -0x140(%rbp), %rax
cmpl $0x0, 0xb6028(%rax)
jne 0x1917a
movb $0x0, 0x1c7e8(%rip)     # 0x35962
jmp 0x19248
movq -0x140(%rbp), %rcx
movl $0x0, 0x1c7bc(%rip)     # 0x3594c
movb $0x0, 0x1c799(%rip)     # 0x35930
movl 0x45fac(%rcx), %eax
addl $0x1, %eax
movl %eax, 0x45fac(%rcx)
andl $0xf, %eax
cmpl $0xf, %eax
jne 0x191d3
movq -0x140(%rbp), %rax
movb 0x45fb0(%rax), %cl
andb $0x1, %cl
movzbl %cl, %ecx
xorl $0x1, %ecx
cmpl $0x0, %ecx
setne %cl
andb $0x1, %cl
movb %cl, 0x45fb0(%rax)
jmp 0x19248
movb $0x1, 0x1c790(%rip)     # 0x3596c
jmp 0x19248
movq -0x140(%rbp), %rax
movq %rax, %rcx
addq $0x824, %rcx            # imm = 0x824
movq %rcx, 0xb6160(%rax)
movl $0x0, 0x1c768(%rip)     # 0x35968
jmp 0x19248
movb $0x0, 0x1c763(%rip)     # 0x3596c
jmp 0x19248
movq -0x140(%rbp), %rax
movl $0x0, 0x820(%rax)
movl $0x0, 0x1c712(%rip)     # 0x35938
movl $0x0, 0x1c704(%rip)     # 0x35934
movzbl 0x55ec6(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, 0x1c6fc(%rip)      # 0x35944
movq -0x140(%rbp), %rcx
movl 0x820(%rcx), %eax
cmpl 0xb6184(%rcx), %eax
jne 0x1928d
movq -0x140(%rbp), %rax
movzbl 0x55eca(%rax), %esi
andl $0x2, %esi
movl $0x2, %edx
movl $0x82, %ecx
cmpl $0x0, %esi
cmovnel %ecx, %edx
movzbl 0x55ec9(%rax), %ecx
orl %edx, %ecx
movb %cl, 0x55ec9(%rax)
jmp 0x1928f
movq -0x140(%rbp), %rax
movl 0x81c(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x193e7
movq -0x140(%rbp), %rax
testb $0x1, 0x65fc1(%rax)
je 0x19314
movq -0x140(%rbp), %rcx
movl 0x65fc8(%rcx), %eax
movl %eax, %edx
addl $-0x1, %edx
movl %edx, 0x65fc8(%rcx)
andl $0xffff, %eax           # imm = 0xFFFF
cmpl $0x0, %eax
jne 0x19314
movq -0x140(%rbp), %rax
movl $0xffff, 0x65fc8(%rax)  # imm = 0xFFFF
movzbl 0x55eca(%rax), %esi
andl $0x10, %esi
movl $0x10, %edx
movl $0x90, %ecx
cmpl $0x0, %esi
cmovnel %ecx, %edx
movzbl 0x55ec9(%rax), %ecx
orl %edx, %ecx
movb %cl, 0x55ec9(%rax)
movq -0x140(%rbp), %rax
testb $0x1, 0x65fc2(%rax)
je 0x19380
movq -0x140(%rbp), %rcx
movl 0x65fcc(%rcx), %eax
movl %eax, %edx
addl $-0x1, %edx
movl %edx, 0x65fcc(%rcx)
andl $0xffff, %eax           # imm = 0xFFFF
cmpl $0x0, %eax
jne 0x19380
movq -0x140(%rbp), %rax
movl $0xffff, 0x65fcc(%rax)  # imm = 0xFFFF
movzbl 0x55eca(%rax), %esi
andl $0x40, %esi
movl $0x40, %edx
movl $0xc0, %ecx
cmpl $0x0, %esi
cmovnel %ecx, %edx
movzbl 0x55ec9(%rax), %ecx
orl %edx, %ecx
movb %cl, 0x55ec9(%rax)
testb $0x1, 0x1c5dc(%rip)     # 0x35963
jne 0x193b2
testb $0x1, 0x1c5d1(%rip)     # 0x35961
jne 0x193b2
testb $0x1, 0x1c5d3(%rip)     # 0x3596c
jne 0x193b2
movq -0x140(%rbp), %rax
movl 0xb6138(%rax), %ecx
movq 0xb6160(%rax), %rax
movl %ecx, 0x4(%rax)
movq -0x140(%rbp), %rcx
movq 0xb6160(%rcx), %rax
cmpq 0xb6168(%rcx), %rax
je 0x193e2
movq -0x140(%rbp), %rax
movq 0xb6160(%rax), %rcx
addq $0x8, %rcx
movq %rcx, 0xb6160(%rax)
jmp 0x19600
movq -0x140(%rbp), %rax
testb $0x1, 0x65fc0(%rax)
je 0x19459
movq -0x140(%rbp), %rcx
movl 0x65fc4(%rcx), %eax
movl %eax, %edx
addl $-0x1, %edx
movl %edx, 0x65fc4(%rcx)
cmpl $0x0, %eax
jne 0x19459
movq -0x140(%rbp), %rax
movl 0x65fd0(%rax), %ecx
subl $0x1, %ecx
andl $0xffff, %ecx           # imm = 0xFFFF
movl %ecx, 0x65fc4(%rax)
movzbl 0x55eca(%rax), %esi
andl $0x8, %esi
movl $0x8, %edx
movl $0x88, %ecx
cmpl $0x0, %esi
cmovnel %ecx, %edx
movzbl 0x55ec9(%rax), %ecx
orl %edx, %ecx
movb %cl, 0x55ec9(%rax)
movb 0x1c502(%rip), %al      # 0x35961
andb $0x1, %al
movzbl %al, %eax
movb 0x1c502(%rip), %cl      # 0x3596c
andb $0x1, %cl
movzbl %cl, %ecx
orl %ecx, %eax
cmpl $0x0, %eax
jne 0x194b3
testb $0x1, 0x1c4be(%rip)     # 0x3593c
je 0x19492
movl 0x1c4de(%rip), %eax     # 0x35964
addl $0x1, %eax
andl $0x3f, %eax
movl %eax, 0x1c4d2(%rip)     # 0x35964
testb $0x1, 0x1c4ca(%rip)     # 0x35963
jne 0x194b1
movq -0x140(%rbp), %rax
movl 0xb6138(%rax), %ecx
movq 0xb6160(%rax), %rax
movl %ecx, (%rax)
jmp 0x194b3
movq 0x1c456(%rip), %rax     # 0x35910
addq $0x1, %rax
movq %rax, 0x1c44b(%rip)     # 0x35910
movq 0x1c444(%rip), %rax     # 0x35910
andq $0x3, %rax
cmpq $0x0, %rax
jne 0x195fe
cmpq $0x0, -0x10(%rbp)
je 0x195fe
cmpl $0x0, -0x14(%rbp)
jle 0x195fe
movq -0x140(%rbp), %rax
movl 0xb71b8(%rax), %eax
addl 0x1c46e(%rip), %eax     # 0x35970
shrl $0x2, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x195c4
movq -0x140(%rbp), %rdi
movl -0x24(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x19f00
movq -0x140(%rbp), %rax
cmpq $0x0, 0xb71d0(%rax)
je 0x195b1
movq -0x140(%rbp), %rax
movq 0xb71d0(%rax), %rdi
leaq -0x130(%rbp), %rsi
movl -0x24(%rbp), %eax
movl %eax, %edx
movq (%rdi), %rax
callq *0x48(%rax)
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x134(%rbp)
movl -0x134(%rbp), %eax
movswl -0x130(%rbp,%rax,2), %eax
leaq 0x1c409(%rip), %rcx     # 0x35980
imull (%rcx), %eax
movl $0x3e8, %ecx            # imm = 0x3E8
cltd
idivl %ecx
movswl %ax, %esi
movq -0x10(%rbp), %rax
movl -0x134(%rbp), %ecx
movswl (%rax,%rcx,2), %edx
addl %esi, %edx
movw %dx, (%rax,%rcx,2)
movl -0x134(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x134(%rbp)
cmpl $0x0, %eax
jne 0x19562
jmp 0x195b1
movq -0x140(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x24(%rbp), %edx
callq 0x19e10
movq -0x140(%rbp), %rax
movl 0xb71b8(%rax), %eax
addl 0x1c399(%rip), %eax     # 0x35970
andl $0x3, %eax
movl %eax, 0x1c390(%rip)     # 0x35970
movl -0x24(%rbp), %ecx
movl -0x14(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x14(%rbp)
movl -0x24(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, %ecx
shlq %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
jmp 0x19600
testb $0x1, 0x1c34d(%rip)     # 0x35954
je 0x1961f
movb 0x1c351(%rip), %cl      # 0x35960
movq 0x1c342(%rip), %rax     # 0x35958
movb %cl, (%rax)
movb $0x0, 0x1c335(%rip)     # 0x35954
movq -0x140(%rbp), %rcx
movl 0x1c31c(%rip), %eax     # 0x35948
movl 0x81c(%rcx), %ecx
andl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x14c(%rbp)
addl $-0x3, %eax
subl $0x3, %eax
jb 0x1967b
jmp 0x19647
movl -0x14c(%rbp), %eax
subl $0x9, %eax
je 0x1967b
jmp 0x19654
movl -0x14c(%rbp), %eax
subl $0x11, %eax
je 0x19690
jmp 0x19661
movl -0x14c(%rbp), %eax
subl $0x21, %eax
je 0x19690
jmp 0x1966e
movl -0x14c(%rbp), %eax
subl $0x41, %eax
je 0x19690
jmp 0x196b1
movq -0x140(%rbp), %rax
movq 0x45fb8(%rax), %rdi
callq 0x5010
jmp 0x196b1
movq -0x140(%rbp), %rax
movq 0x45fb8(%rax), %rdi
callq 0x10c10
movl 0x1c29f(%rip), %eax     # 0x35948
shll %eax
movl %eax, 0x1c297(%rip)     # 0x35948
jmp 0x196b3
xorl %eax, %eax
cmpl $0x0, -0x14(%rbp)
movb %al, -0x14d(%rbp)
jle 0x196cf
cmpq $0x0, -0x10(%rbp)
setne %al
movb %al, -0x14d(%rbp)
movb -0x14d(%rbp), %al
testb $0x1, %al
jne 0x18b21
movq -0x140(%rbp), %rax
movb $0x0, 0x45fa4(%rax)
addq $0x150, %rsp            # imm = 0x150
popq %rbp
retq
nopw %cs:(%rax,%rax)