// File: mdpkh[P]retro6k/src/main.cpp
// Function: GenerateStereoAudio(void*, unsigned char*, int)
void GenerateStereoAudio(void* userdata, Uint8* stream, int len) //callback to fill audio buffer
{
	if (!menuhassound)
	{
		static signed char tickcounter{ 49 }; // 900 ticks per 1s at 44.1k sample rate
		static unsigned short phase[4]{ 0, 0, 0, 0 };
		static short lev[16];
		// clipped normal-ish distribution with RMS 8; when multiplied by volume and divided by 4, RMS maxes out at 30 (equal to max vol square wave RMS) while value is clipped at +/-37
		static std::discrete_distribution<short> dis{ 240127971, 49520773, 52161640, 54569628, 56671960, 58394828, 59666729, 60422379, 60606996, 60180662, 53532056, 60180662, 60606996, 60422379, 59666729, 58394828, 56671960, 54569628, 52161640, 49520773, 240127971 };
		for (int v = 0; v < 4; ++v)
		{
			switch ((voicetype)((soundvoicetyperegister >> (v << 1)) & 0x3))
			{
			case voicetype::VT_SQUARE:
				lev[(v << 2)    ] = -(soundvolregister[v] & (short)0xf0) >> 3;
				lev[(v << 2) | 1] = (soundvolregister[v] & (short)0xf0) >> 3;
				lev[(v << 2) | 2] = -(soundvolregister[v] & (short)0xf) << 1;
				lev[(v << 2) | 3] = (soundvolregister[v] & (short)0xf) << 1;
				break;
			case voicetype::VT_NOISE:
				// retain existing levels
				break;
			default:
				// undefined
				lev[(v << 2)    ] = 0;
				lev[(v << 2) | 1] = 0;
				lev[(v << 2) | 2] = 0;
				lev[(v << 2) | 3] = 0;
			}
			if (!soundfreqregister[v])
			{
				lev[v << 2    ] = 0;
				lev[v << 2 | 1] = 0;
				lev[v << 2 | 2] = 0;
				lev[v << 2 | 3] = 0;
			}
		}
		int t = soundspec.freq >> 1;
		for (; len > 0; len -= 2)
		{
			--tickcounter;
			if (tickcounter < 0)
			{
				tickcounter = 49;
				StepSoundSchedules();
			}
			phase[0] += soundfreqregister[0];
			phase[1] += soundfreqregister[1];
			phase[2] += soundfreqregister[2];
			phase[3] += soundfreqregister[3];
			if (phase[0] > soundspec.freq)
			{
				phase[0] -= soundspec.freq;
				if ((voicetype)(soundvoicetyperegister & 0x3) == voicetype::VT_NOISE)
				{ // on falling edge of square wave, sample and hold new random value
					short r = dis(noisegen) - 10;
					lev[0] = (r * ((soundvolregister[0] & (short)0xf0) >> 4) + 1) >> 2;
					lev[1] = lev[0];
					lev[2] = (r * (soundvolregister[0] & (short)0xf) + 1) >> 2;
					lev[3] = lev[2];
				}
			}
			if (phase[1] > soundspec.freq)
			{
				phase[1] -= soundspec.freq;
				if ((voicetype)((soundvoicetyperegister >> 2) & 0x3) == voicetype::VT_NOISE)
				{ // on falling edge of square wave, sample and hold new random value
					short r = dis(noisegen) - 10;
					lev[4] = (r * ((soundvolregister[1] & (short)0xf0) >> 4) + 1) >> 2;
					lev[5] = lev[0];
					lev[6] = (r * (soundvolregister[1] & (short)0xf) + 1) >> 2;
					lev[7] = lev[2];
				}
			}
			if (phase[2] > soundspec.freq)
			{
				phase[2] -= soundspec.freq;
				if ((voicetype)((soundvoicetyperegister >> 4) & 0x3) == voicetype::VT_NOISE)
				{ // on falling edge of square wave, sample and hold new random value
					short r = dis(noisegen) - 10;
					lev[8] = (r * ((soundvolregister[2] & (short)0xf0) >> 4) + 1) >> 2;
					lev[9] = lev[0];
					lev[10] = (r * (soundvolregister[2] & (short)0xf) + 1) >> 2;
					lev[11] = lev[2];
				}
			}
			if (phase[3] > soundspec.freq)
			{
				phase[3] -= soundspec.freq;
				if ((voicetype)((soundvoicetyperegister >> 6) & 0x3) == voicetype::VT_NOISE)
				{ // on falling edge of square wave, sample and hold new random value
					short r = dis(noisegen) - 10;
					lev[12] = (r * ((soundvolregister[3] & (short)0xf0) >> 4) + 1) >> 2;
					lev[13] = lev[0];
					lev[14] = (r * (soundvolregister[3] & (short)0xf) + 1) >> 2;
					lev[15] = lev[2];
				}
			}
			*stream = soundspec.silence
				+ lev[     (int)(phase[0] >= t)]
				- lev[4  | (int)(phase[1] >= t)]
				+ lev[8  | (int)(phase[2] >= t)]
				- lev[12 | (int)(phase[3] >= t)];
			++stream;
			*stream = soundspec.silence
				+ lev[2  | (int)(phase[0] >= t)]
				- lev[6  | (int)(phase[1] >= t)]
				+ lev[10 | (int)(phase[2] >= t)]
				- lev[14 | (int)(phase[3] >= t)];
			++stream;
		}
	}
	else
	{
		static unsigned short phase{ 0 };
		short lev[2]{ -13, 13 };
		int t = soundspec.freq >> 1;
		if (!menubeepfreq || !menubeepdur)
		{
			lev[0] = 0;
			lev[1] = 0;
		}
		for (; len > 0; len -= 2)
		{
			if (menubeepdur)
			{
				phase += menubeepfreq;
				--menubeepdur;
			}
			if (phase > soundspec.freq)
				phase -= soundspec.freq;
			*stream = soundspec.silence + lev[(int)(phase >= t)];
			++stream;
			*stream = soundspec.silence + lev[(int)(phase >= t)];
			++stream;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
testb $0x1, 0x2048d(%rip)     # 0x2d92a
jne 0xdcad
cmpb $0x0, 0x823fd6(%rip)    # 0x831480
jne 0xd52b
leaq 0x823fcd(%rip), %rdi    # 0x831480
callq 0x7740
cmpl $0x0, %eax
je 0xd52b
leaq 0x1318c(%rip), %rsi     # 0x20650
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x100(%rbp)
movl $0xa8, %edx
callq 0x73c0
movq -0x100(%rbp), %rax
movq %rax, -0x28(%rbp)
movq $0x15, -0x20(%rbp)
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq 0x823f52(%rip), %rdi    # 0x831450
callq 0x13fb0
jmp 0xd505
leaq 0x6ae4(%rip), %rdi      # 0x13ff0
leaq 0x823f3d(%rip), %rsi    # 0x831450
leaq 0x1eede(%rip), %rdx     # 0x2c3f8
callq 0x73e0
leaq 0x823f5a(%rip), %rdi    # 0x831480
callq 0x72f0
movl $0x0, -0xe0(%rbp)
cmpl $0x4, -0xe0(%rbp)
jge 0xd77c
movzbl 0x20289(%rip), %eax     # 0x2d7d2
movb -0xe0(%rbp), %cl
addb %cl, %cl
shrl %cl, %eax
andl $0x3, %eax
movl %eax, -0x104(%rbp)
je 0xd597
jmp 0xd560
movl -0x104(%rbp), %eax
subl $0x1, %eax
je 0xd675
jmp 0xd677
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xd8(%rbp)
movl %eax, -0xdc(%rbp)
leaq 0x823ef3(%rip), %rdi    # 0x831480
callq 0x72d0
jmp 0xdde6
movslq -0xe0(%rbp), %rcx
leaq 0x20229(%rip), %rax     # 0x2d7ce
movzbl (%rax,%rcx), %ecx
andl $0xf0, %ecx
xorl %eax, %eax
subl %ecx, %eax
sarl $0x3, %eax
movw %ax, %dx
movl -0xe0(%rbp), %eax
shll $0x2, %eax
movslq %eax, %rcx
leaq 0x823e64(%rip), %rax    # 0x831430
movw %dx, (%rax,%rcx,2)
movslq -0xe0(%rbp), %rcx
leaq 0x201f0(%rip), %rax     # 0x2d7ce
movzbl (%rax,%rcx), %eax
andl $0xf0, %eax
sarl $0x3, %eax
movw %ax, %dx
movl -0xe0(%rbp), %eax
shll $0x2, %eax
orl $0x1, %eax
movslq %eax, %rcx
leaq 0x823e2d(%rip), %rax    # 0x831430
movw %dx, (%rax,%rcx,2)
movslq -0xe0(%rbp), %rcx
leaq 0x201b9(%rip), %rax     # 0x2d7ce
movzbl (%rax,%rcx), %ecx
andl $0xf, %ecx
xorl %eax, %eax
subl %ecx, %eax
shll %eax
movw %ax, %dx
movl -0xe0(%rbp), %eax
shll $0x2, %eax
orl $0x2, %eax
movslq %eax, %rcx
leaq 0x823df5(%rip), %rax    # 0x831430
movw %dx, (%rax,%rcx,2)
movslq -0xe0(%rbp), %rcx
leaq 0x20181(%rip), %rax     # 0x2d7ce
movzbl (%rax,%rcx), %eax
andl $0xf, %eax
shll %eax
movw %ax, %dx
movl -0xe0(%rbp), %eax
shll $0x2, %eax
orl $0x3, %eax
movslq %eax, %rcx
leaq 0x823dc1(%rip), %rax    # 0x831430
movw %dx, (%rax,%rcx,2)
jmp 0xd6e4
jmp 0xd6e4
movl -0xe0(%rbp), %eax
shll $0x2, %eax
movslq %eax, %rcx
leaq 0x823da6(%rip), %rax    # 0x831430
movw $0x0, (%rax,%rcx,2)
movl -0xe0(%rbp), %eax
shll $0x2, %eax
orl $0x1, %eax
movslq %eax, %rcx
leaq 0x823d8a(%rip), %rax    # 0x831430
movw $0x0, (%rax,%rcx,2)
movl -0xe0(%rbp), %eax
shll $0x2, %eax
orl $0x2, %eax
movslq %eax, %rcx
leaq 0x823d6e(%rip), %rax    # 0x831430
movw $0x0, (%rax,%rcx,2)
movl -0xe0(%rbp), %eax
shll $0x2, %eax
orl $0x3, %eax
movslq %eax, %rcx
leaq 0x823d52(%rip), %rax    # 0x831430
movw $0x0, (%rax,%rcx,2)
movslq -0xe0(%rbp), %rcx
leaq 0x200d4(%rip), %rax     # 0x2d7c6
cmpw $0x0, (%rax,%rcx,2)
jne 0xd766
movl -0xe0(%rbp), %eax
shll $0x2, %eax
movslq %eax, %rcx
leaq 0x823d24(%rip), %rax    # 0x831430
movw $0x0, (%rax,%rcx,2)
movl -0xe0(%rbp), %eax
shll $0x2, %eax
orl $0x1, %eax
movslq %eax, %rcx
leaq 0x823d08(%rip), %rax    # 0x831430
movw $0x0, (%rax,%rcx,2)
movl -0xe0(%rbp), %eax
shll $0x2, %eax
orl $0x2, %eax
movslq %eax, %rcx
leaq 0x823cec(%rip), %rax    # 0x831430
movw $0x0, (%rax,%rcx,2)
movl -0xe0(%rbp), %eax
shll $0x2, %eax
orl $0x3, %eax
movslq %eax, %rcx
leaq 0x823cd0(%rip), %rax    # 0x831430
movw $0x0, (%rax,%rcx,2)
jmp 0xd768
movl -0xe0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe0(%rbp)
jmp 0xd535
movl 0x823c7e(%rip), %eax    # 0x831400
sarl %eax
movl %eax, -0xe4(%rbp)
cmpl $0x0, -0x14(%rbp)
jle 0xdca8
movb 0x1ec6b(%rip), %al      # 0x2c405
addb $-0x1, %al
movb %al, 0x1ec63(%rip)      # 0x2c405
movsbl 0x1ec5c(%rip), %eax     # 0x2c405
cmpl $0x0, %eax
jge 0xd7ba
movb $0x31, 0x1ec50(%rip)    # 0x2c405
callq 0xde00
movzwl 0x20005(%rip), %ecx     # 0x2d7c6
movzwl 0x823c60(%rip), %eax    # 0x831428
addl %ecx, %eax
movw %ax, 0x823c57(%rip)     # 0x831428
movzwl 0x1fff0(%rip), %ecx     # 0x2d7c8
movzwl 0x823c4b(%rip), %eax    # 0x83142a
addl %ecx, %eax
movw %ax, 0x823c42(%rip)     # 0x83142a
movzwl 0x1ffdb(%rip), %ecx     # 0x2d7ca
movzwl 0x823c36(%rip), %eax    # 0x83142c
addl %ecx, %eax
movw %ax, 0x823c2d(%rip)     # 0x83142c
movzwl 0x1ffc6(%rip), %ecx     # 0x2d7cc
movzwl 0x823c21(%rip), %eax    # 0x83142e
addl %ecx, %eax
movw %ax, 0x823c18(%rip)     # 0x83142e
movzwl 0x823c0b(%rip), %eax    # 0x831428
cmpl 0x823bdd(%rip), %eax    # 0x831400
jle 0xd8d6
movl 0x823bd1(%rip), %ecx    # 0x831400
movzwl 0x823bf2(%rip), %eax    # 0x831428
subl %ecx, %eax
movw %ax, 0x823be9(%rip)     # 0x831428
movzbl 0x1ff8c(%rip), %eax     # 0x2d7d2
andl $0x3, %eax
cmpl $0x1, %eax
jne 0xd8d4
leaq 0x823bf7(%rip), %rdi    # 0x831450
leaq 0x822800(%rip), %rsi    # 0x830060
callq 0x14010
cwtl
subl $0xa, %eax
movw %ax, -0xe6(%rbp)
movswl -0xe6(%rbp), %eax
movzbl 0x1ff50(%rip), %ecx     # 0x2d7ce
andl $0xf0, %ecx
sarl $0x4, %ecx
imull %ecx, %eax
addl $0x1, %eax
sarl $0x2, %eax
movw %ax, 0x823b99(%rip)     # 0x831430
movw 0x823b92(%rip), %ax     # 0x831430
movw %ax, 0x823b8d(%rip)     # 0x831432
movswl -0xe6(%rbp), %eax
movzbl 0x1ff1b(%rip), %ecx     # 0x2d7ce
andl $0xf, %ecx
imull %ecx, %eax
addl $0x1, %eax
sarl $0x2, %eax
movw %ax, 0x823b6e(%rip)     # 0x831434
movw 0x823b67(%rip), %ax     # 0x831434
movw %ax, 0x823b62(%rip)     # 0x831436
jmp 0xd8d6
movzwl 0x823b4d(%rip), %eax    # 0x83142a
cmpl 0x823b1d(%rip), %eax    # 0x831400
jle 0xd999
movl 0x823b11(%rip), %ecx    # 0x831400
movzwl 0x823b34(%rip), %eax    # 0x83142a
subl %ecx, %eax
movw %ax, 0x823b2b(%rip)     # 0x83142a
movzbl 0x1fecc(%rip), %eax     # 0x2d7d2
sarl $0x2, %eax
andl $0x3, %eax
cmpl $0x1, %eax
jne 0xd997
leaq 0x823b34(%rip), %rdi    # 0x831450
leaq 0x82273d(%rip), %rsi    # 0x830060
callq 0x14010
cwtl
subl $0xa, %eax
movw %ax, -0xe8(%rbp)
movswl -0xe8(%rbp), %eax
movzbl 0x1fe8e(%rip), %ecx     # 0x2d7cf
andl $0xf0, %ecx
sarl $0x4, %ecx
imull %ecx, %eax
addl $0x1, %eax
sarl $0x2, %eax
movw %ax, 0x823ade(%rip)     # 0x831438
movw 0x823acf(%rip), %ax     # 0x831430
movw %ax, 0x823ad2(%rip)     # 0x83143a
movswl -0xe8(%rbp), %eax
movzbl 0x1fe59(%rip), %ecx     # 0x2d7cf
andl $0xf, %ecx
imull %ecx, %eax
addl $0x1, %eax
sarl $0x2, %eax
movw %ax, 0x823ab3(%rip)     # 0x83143c
movw 0x823aa4(%rip), %ax     # 0x831434
movw %ax, 0x823aa7(%rip)     # 0x83143e
jmp 0xd999
movzwl 0x823a8c(%rip), %eax    # 0x83142c
cmpl 0x823a5a(%rip), %eax    # 0x831400
jle 0xda5c
movl 0x823a4e(%rip), %ecx    # 0x831400
movzwl 0x823a73(%rip), %eax    # 0x83142c
subl %ecx, %eax
movw %ax, 0x823a6a(%rip)     # 0x83142c
movzbl 0x1fe09(%rip), %eax     # 0x2d7d2
sarl $0x4, %eax
andl $0x3, %eax
cmpl $0x1, %eax
jne 0xda5a
leaq 0x823a71(%rip), %rdi    # 0x831450
leaq 0x82267a(%rip), %rsi    # 0x830060
callq 0x14010
cwtl
subl $0xa, %eax
movw %ax, -0xea(%rbp)
movswl -0xea(%rbp), %eax
movzbl 0x1fdcc(%rip), %ecx     # 0x2d7d0
andl $0xf0, %ecx
sarl $0x4, %ecx
imull %ecx, %eax
addl $0x1, %eax
sarl $0x2, %eax
movw %ax, 0x823a23(%rip)     # 0x831440
movw 0x823a0c(%rip), %ax     # 0x831430
movw %ax, 0x823a17(%rip)     # 0x831442
movswl -0xea(%rbp), %eax
movzbl 0x1fd97(%rip), %ecx     # 0x2d7d0
andl $0xf, %ecx
imull %ecx, %eax
addl $0x1, %eax
sarl $0x2, %eax
movw %ax, 0x8239f8(%rip)     # 0x831444
movw 0x8239e1(%rip), %ax     # 0x831434
movw %ax, 0x8239ec(%rip)     # 0x831446
jmp 0xda5c
movzwl 0x8239cb(%rip), %eax    # 0x83142e
cmpl 0x823997(%rip), %eax    # 0x831400
jle 0xdb1f
movl 0x82398b(%rip), %ecx    # 0x831400
movzwl 0x8239b2(%rip), %eax    # 0x83142e
subl %ecx, %eax
movw %ax, 0x8239a9(%rip)     # 0x83142e
movzbl 0x1fd46(%rip), %eax     # 0x2d7d2
sarl $0x6, %eax
andl $0x3, %eax
cmpl $0x1, %eax
jne 0xdb1d
leaq 0x8239ae(%rip), %rdi    # 0x831450
leaq 0x8225b7(%rip), %rsi    # 0x830060
callq 0x14010
cwtl
subl $0xa, %eax
movw %ax, -0xec(%rbp)
movswl -0xec(%rbp), %eax
movzbl 0x1fd0a(%rip), %ecx     # 0x2d7d1
andl $0xf0, %ecx
sarl $0x4, %ecx
imull %ecx, %eax
addl $0x1, %eax
sarl $0x2, %eax
movw %ax, 0x823968(%rip)     # 0x831448
movw 0x823949(%rip), %ax     # 0x831430
movw %ax, 0x82395c(%rip)     # 0x83144a
movswl -0xec(%rbp), %eax
movzbl 0x1fcd5(%rip), %ecx     # 0x2d7d1
andl $0xf, %ecx
imull %ecx, %eax
addl $0x1, %eax
sarl $0x2, %eax
movw %ax, 0x82393d(%rip)     # 0x83144c
movw 0x82391e(%rip), %ax     # 0x831434
movw %ax, 0x823931(%rip)     # 0x83144e
jmp 0xdb1f
movzbl 0x8238e1(%rip), %eax    # 0x831407
movzwl 0x8238fb(%rip), %ecx    # 0x831428
cmpl -0xe4(%rbp), %ecx
setge %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rdx
leaq 0x8238ea(%rip), %rcx    # 0x831430
movswl (%rcx,%rdx,2), %ecx
addl %ecx, %eax
movzwl 0x8238d7(%rip), %ecx    # 0x83142a
cmpl -0xe4(%rbp), %ecx
setge %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl $0x4, %ecx
movslq %ecx, %rdx
leaq 0x8238c1(%rip), %rcx    # 0x831430
movswl (%rcx,%rdx,2), %ecx
subl %ecx, %eax
movzwl 0x8238b0(%rip), %ecx    # 0x83142c
cmpl -0xe4(%rbp), %ecx
setge %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl $0x8, %ecx
movslq %ecx, %rdx
leaq 0x823898(%rip), %rcx    # 0x831430
movswl (%rcx,%rdx,2), %ecx
addl %ecx, %eax
movzwl 0x823889(%rip), %ecx    # 0x83142e
cmpl -0xe4(%rbp), %ecx
setge %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl $0xc, %ecx
movslq %ecx, %rdx
leaq 0x82386f(%rip), %rcx    # 0x831430
movswl (%rcx,%rdx,2), %ecx
subl %ecx, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movzbl 0x823825(%rip), %eax    # 0x831407
movzwl 0x82383f(%rip), %ecx    # 0x831428
cmpl -0xe4(%rbp), %ecx
setge %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl $0x2, %ecx
movslq %ecx, %rdx
leaq 0x82382b(%rip), %rcx    # 0x831430
movswl (%rcx,%rdx,2), %ecx
addl %ecx, %eax
movzwl 0x823818(%rip), %ecx    # 0x83142a
cmpl -0xe4(%rbp), %ecx
setge %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl $0x6, %ecx
movslq %ecx, %rdx
leaq 0x823802(%rip), %rcx    # 0x831430
movswl (%rcx,%rdx,2), %ecx
subl %ecx, %eax
movzwl 0x8237f1(%rip), %ecx    # 0x83142c
cmpl -0xe4(%rbp), %ecx
setge %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl $0xa, %ecx
movslq %ecx, %rdx
leaq 0x8237d9(%rip), %rcx    # 0x831430
movswl (%rcx,%rdx,2), %ecx
addl %ecx, %eax
movzwl 0x8237ca(%rip), %ecx    # 0x83142e
cmpl -0xe4(%rbp), %ecx
setge %cl
andb $0x1, %cl
movzbl %cl, %ecx
orl $0xe, %ecx
movslq %ecx, %rdx
leaq 0x8237b0(%rip), %rcx    # 0x831430
movswl (%rcx,%rdx,2), %ecx
subl %ecx, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movl -0x14(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x14(%rbp)
jmp 0xd78a
jmp 0xdddd
movl 0x1574d(%rip), %eax     # 0x23400
movl %eax, -0xf0(%rbp)
movl 0x823741(%rip), %eax    # 0x831400
sarl %eax
movl %eax, -0xf4(%rbp)
cmpw $0x0, 0x1fc59(%rip)     # 0x2d928
je 0xdcdb
cmpw $0x0, 0x1fc4d(%rip)     # 0x2d926
jne 0xdced
movw $0x0, -0xf0(%rbp)
movw $0x0, -0xee(%rbp)
jmp 0xdcef
cmpl $0x0, -0x14(%rbp)
jle 0xdddb
cmpw $0x0, 0x1fc25(%rip)     # 0x2d926
je 0xdd2c
movzwl 0x1fc1e(%rip), %ecx     # 0x2d928
movzwl 0x823777(%rip), %eax    # 0x831488
addl %ecx, %eax
movw %ax, 0x82376e(%rip)     # 0x831488
movw 0x1fc05(%rip), %ax      # 0x2d926
addw $-0x1, %ax
movw %ax, 0x1fbfa(%rip)      # 0x2d926
movzwl 0x823755(%rip), %eax    # 0x831488
cmpl 0x8236c7(%rip), %eax    # 0x831400
jle 0xdd51
movl 0x8236bf(%rip), %ecx    # 0x831400
movzwl 0x823740(%rip), %eax    # 0x831488
subl %ecx, %eax
movw %ax, 0x823737(%rip)     # 0x831488
movzbl 0x8236af(%rip), %eax    # 0x831407
movzwl 0x823729(%rip), %ecx    # 0x831488
cmpl -0xf4(%rbp), %ecx
setge %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movswl -0xf0(%rbp,%rcx,2), %ecx
addl %ecx, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movzbl 0x823671(%rip), %eax    # 0x831407
movzwl 0x8236eb(%rip), %ecx    # 0x831488
cmpl -0xf4(%rbp), %ecx
setge %cl
andb $0x1, %cl
movzbl %cl, %ecx
movslq %ecx, %rcx
movswl -0xf0(%rbp,%rcx,2), %ecx
addl %ecx, %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, (%rax)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movl -0x14(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x14(%rbp)
jmp 0xdcef
jmp 0xdddd
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0xd8(%rbp), %rdi
callq 0x7710
nopw %cs:(%rax,%rax)