LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/./Cpu.h
// Function: CPU::ADC(unsigned char)
inline void CPU::ADC(const unsigned char value)
{
	if (ST&0x08) {
		unsigned int bin_adc = AC + value + (ST&0x01);
		unsigned char AL, AH;

		AL=(AC&0x0F) + (value & 0x0F) + (ST&0x01);
		AH=(AC >> 4) + (value >> 4 ) ;
		// fix lower nybble
		if (AL>9) {
			AL+=6;
			AH++;
		}
		// zero bit depends on the normal ADC...
		(bin_adc)&0xFF ? ST&=0xFD : ST|=0x02;
		// negative flag also...
		( AH & 0x08 ) ? ST|=0x80 : ST&=0x7F; 
		// V flag
		((((AH << 4) ^ AC) & 0x80) && !((AC ^ value) & 0x80)) ? SetVFlag() : ClearVFlag();
		// fix upper nybble
		if (AH>9) 
			AH+=6;
		// set the Carry if the decimal add has an overflow
		(AH > 0x0f) ? ST|=0x01 : ST&=0xFE;
		// calculate new AC value
		AC = (AH<<4)|(AL & 0x0F);
	} else {
		unsigned int bin_adc = AC + value + (ST&0x01);
		(bin_adc>=0x100) ? ST|=0x01 : ST&=0xFE;
		(!((AC ^ value) & 0x80) && ((AC ^ bin_adc) & 0x80) ) ? SetVFlag() : ClearVFlag();
		AC=(unsigned char) bin_adc;
		SETFLAGS_ZN(AC);
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x18(%rdi), %eax
movzbl 0x1c(%rdi), %ecx
movl %eax, %edx
andl $0x1, %edx
leal (%rsi,%rcx), %r14d
addl %edx, %r14d
testb $0x8, %al
jne 0x7ecf
movl %eax, %edx
andl $0xf6, %edx
orl $0x1, %eax
cmpl $0x100, %r14d           # imm = 0x100
cmovbl %edx, %eax
movl %eax, 0x18(%rbx)
xorl %ecx, %esi
cmpl $0x7f, %esi
ja 0x7ebe
xorb %r14b, %cl
js 0x7f86
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movl 0x18(%rbx), %eax
jmp 0x7f89
movl %ecx, %edi
andl $0xf, %edi
movl %esi, %r8d
andl $0xf, %r8d
addl %r8d, %edx
leal (%rdx,%rdi), %r8d
movl %ecx, %r9d
shrb $0x4, %r9b
movl %esi, %r10d
shrb $0x4, %r10b
addb %r9b, %r10b
cmpl $0xa, %r8d
sbbb $-0x1, %r10b
cmpl $0xa, %r8d
leal 0x6(%rdi,%rdx), %ebp
cmovbl %r8d, %ebp
movl %eax, %edx
orl $0x2, %edx
andl $0xfd, %eax
testb %r14b, %r14b
cmovel %edx, %eax
movzbl %r10b, %r14d
movl %eax, %edi
andl $0x7f, %edi
movl $0x80, %edx
orl %edx, %eax
testb $0x8, %r14b
cmovel %edi, %eax
movl %eax, 0x18(%rbx)
xorl %ecx, %esi
cmpl $0x7f, %esi
ja 0x7f49
movl %r14d, %esi
shll $0x4, %esi
xorl %ecx, %esi
andl %edx, %esi
je 0x7f49
orl $0x40, %eax
jmp 0x7f55
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movl 0x18(%rbx), %eax
leal 0x6(%r14), %ecx
cmpb $0xa, %r14b
movzbl %cl, %ecx
cmovbl %r14d, %ecx
movl %eax, %edx
andl $0xfe, %edx
orl $0x1, %eax
cmpb $0x10, %cl
cmovbl %edx, %eax
movl %eax, 0x18(%rbx)
shll $0x4, %ecx
andl $0xf, %ebp
orl %ecx, %ebp
movb %bpl, 0x1c(%rbx)
jmp 0x7fa8
orl $0x40, %eax
movb %r14b, 0x1c(%rbx)
andl $0x7d, %eax
xorl %ecx, %ecx
testb %r14b, %r14b
sete %cl
andl $0x80, %r14d
leal (%r14,%rcx,2), %ecx
orl %eax, %ecx
movl %ecx, 0x18(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/./Cpu.h
// Function: CPU::SBC(unsigned char)
inline void CPU::SBC(const unsigned char value)
{
	if (ST&0x08) { // if in decimal mode
		unsigned int bin_sbc = (AC - value - (1-(ST&0x01)));
		unsigned int dec_sbc = (AC & 0x0F) - (value & 0x0F) - (1-(ST&0x01));
		// Calculate the upper nybble.
		// fix upper nybble
		if (dec_sbc&0x10)
			dec_sbc = ((dec_sbc-6)&0x0F) | ((AC&0xF0) - (value&0xF0) - 0x10);
		else
			dec_sbc = (dec_sbc&0x0F) | ((AC&0xF0) - (value&0xF0));
		
		if (dec_sbc&0x100)
			dec_sbc-= 0x60;

		// all flags depend on the normal SBC...
		(bin_sbc<0x100) ? ST|=0x01 : ST&=0xFE ; // carry flag
		SETFLAGS_ZN( bin_sbc & 0xFF );
		((AC^bin_sbc)&0x80 && (AC^value)&0x80 ) ? SetVFlag() : ClearVFlag(); // V flag

		AC=(unsigned char) dec_sbc;

	} else {
		unsigned int bin_sbc = (AC - value - (1-(ST&0x01)));
		(bin_sbc<0x100) ? ST|=0x01 : ST&=0xFE;
		(((AC ^ value) & 0x80) && ((AC ^ bin_sbc) & 0x80) ) ? SetVFlag() : ClearVFlag();
		AC=(unsigned char) bin_sbc;
		SETFLAGS_ZN(AC);
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x18(%rdi), %eax
movzbl 0x1c(%rdi), %ecx
movl %eax, %edx
orl $-0x2, %edx
incl %edx
movl %edx, %r14d
subl %esi, %r14d
addl %ecx, %r14d
testb $0x8, %al
jne 0x803e
movl %eax, %edx
andl $0xf6, %edx
orl $0x1, %eax
cmpl $0x100, %r14d           # imm = 0x100
cmovael %edx, %eax
movl %eax, 0x18(%rbx)
xorl %ecx, %esi
cmpl $0x80, %esi
jb 0x802d
xorb %r14b, %cl
js 0x80e4
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movl 0x18(%rbx), %eax
jmp 0x80e7
movl %ecx, %edi
andl $0xf, %edi
movl %esi, %r8d
andl $0xf, %r8d
subl %r8d, %edx
addl %edi, %edx
testb $0x10, %dl
jne 0x8067
movl %ecx, %edi
andl $-0x10, %edi
movl %esi, %r8d
andl $-0x10, %r8d
subl %r8d, %edi
addl %edi, %edx
jmp 0x8081
addl $0xa, %edx
andl $0xf, %edx
movl %ecx, %edi
andl $-0x10, %edi
movl %esi, %r8d
andl $-0x10, %r8d
subl %r8d, %edi
addl %edi, %edx
addl $-0x10, %edx
leal 0xa0(%rdx), %ebp
btl $0x8, %edx
cmovael %edx, %ebp
movl %eax, %edx
andl $0x7c, %edx
orl $0x1, %eax
cmpl $0x100, %r14d           # imm = 0x100
cmovael %edx, %eax
andl $0x7d, %eax
xorl %edx, %edx
testb %r14b, %r14b
sete %dl
movl $0x80, %edi
movl %r14d, %r8d
andl %edi, %r8d
leal (%r8,%rdx,2), %edx
orl %eax, %edx
movl %edx, 0x18(%rbx)
xorl %ecx, %esi
cmpl %edi, %esi
jb 0x80d5
xorl %ecx, %r14d
andl %edi, %r14d
je 0x80d5
orl $0x40, %edx
movl %edx, 0x18(%rbx)
jmp 0x80de
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movb %bpl, 0x1c(%rbx)
jmp 0x8106
orl $0x40, %eax
movb %r14b, 0x1c(%rbx)
andl $0x7d, %eax
xorl %ecx, %ecx
testb %r14b, %r14b
sete %cl
andl $0x80, %r14d
leal (%r14,%rcx,2), %ecx
orl %eax, %ecx
movl %ecx, 0x18(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Filter.cpp
// Function: Filter::Filter(unsigned int, unsigned int, unsigned int)
Filter::Filter(unsigned int cutoffFrq, unsigned int sampleFrq, unsigned int order) : 
	order_((order >> 1) << 1),
	sampleFrq_(sampleFrq),
	windowTable_(0),
	sampleHistory_(0),
	precision_(12),
	mixingVolume(2.0)
{
#if 1
	setCutoffFrq(double(cutoffFrq)/double(sampleFrq));
#else
	setCutoffFrq(.000001);
#endif
}

// Assembly:
leaq 0xbaed(%rip), %rax      # 0x13c10
movq %rax, (%rdi)
andl $-0x2, %ecx
movl %ecx, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
andq $0x0, 0x20(%rdi)
movl %edx, 0x3c(%rdi)
movl $0xc, 0x40(%rdi)
movl %esi, %eax
cvtsi2sd %rax, %xmm0
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movl %edx, %ecx
cvtsi2sd %rcx, %xmm1
movq %rax, 0x48(%rdi)
divsd %xmm1, %xmm0
movsd %xmm0, 0x30(%rdi)
jmp 0x8174
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Sid.cpp
// Function: SIDsound::SIDsound(unsigned int, unsigned int)
SIDsound::SIDsound(unsigned int model, unsigned int chnlDisableMask) : enableDigiBlaster(false)
{
	unsigned int i;

	// Link voices together
	for (i=0; i<3; i++) {
		voice[i].index = i;
		voice[i].modulatedBy = &voice[(i+2)%3]; // previous voice
		voice[i].modulatesThis = &voice[(i+1)%3]; // next voice
		voice[i].disabled = !!((chnlDisableMask >> i) & 1);
	}

	filterCutoff = 0;
	setModel(model);
	setFrequency(0);
	reset();
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0xb393(%rip), %rax      # 0x13c40
movq %rax, (%rdi)
movb $0x0, 0x41b5(%rdi)
leaq 0x8(%rdi), %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
pushq $0x74
popq %rdi
xorl %r9d, %r9d
pushq $0x2
popq %r8
cmpq $0x1dc, %rdi            # imm = 0x1DC
je 0x8925
testq %r9, %r9
movl %ecx, %r10d
cmoveq %r8, %r10
imulq $0x78, %r10, %r10
addq %rax, %r10
movq %r9, %r11
incq %r11
cmpq $0x3, %r11
movl %r11d, %r14d
movl $0x0, %r15d
cmovneq %r14, %r15
movl %r9d, -0x6c(%rbx,%rdi)
movq %r10, -0x5c(%rbx,%rdi)
imulq $0x78, %r15, %r10
addq %rax, %r10
movq %r10, -0x54(%rbx,%rdi)
btl %r9d, %edx
setb (%rbx,%rdi)
incq %rcx
addq $0x78, %rdi
movq %r11, %r9
jmp 0x88ca
andl $0x0, 0x198(%rbx)
movq %rbx, %rdi
callq 0x856c
movq (%rbx), %rax
movq %rbx, %rdi
xorl %esi, %esi
callq *0x28(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmpq *0x10(%rax)
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Sid.cpp
// Function: SIDsound::reset()
void SIDsound::reset(void)
{
	volume = masterVolume;

	lastByteWritten = 0;

	for (int v=0; v<3; v++) {
		voice[v].wave = WAVE_NONE;
		voice[v].egState = EG_FROZEN;
		voice[v].accu = 0;
		voice[v].freq = voice[v].pw = 0;
		voice[v].envCurrLevel = voice[v].envSustainLevel = 0;
		voice[v].gate = voice[v].ring = voice[v].test = 0;
		voice[v].filter = voice[v].sync = 0;
		voice[v].muted = 0;
		// Initial value of internal shift register
		voice[v].shiftReg = 0x7FFFFC;
		voice[v].envExpCounter = 0;
		voice[v].envAttackAdd = voice[v].envDecaySub = voice[v].envReleaseSub = 0;
		voice[v].envCounterCompare = 0;
		voice[v].envCounter = 0x7fff;
	}

	filterType = FILTER_NONE;
	filterCutoff = filterResonance = 0;

	Vhp = Vbp = Vlp = 0;
	setFilterCutoff();
	setResonance();

	dcDigiBlaster = 0;
	clockDeltaRemainder = 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x1cac8(%rip), %eax     # 0x25420
movl %eax, 0x170(%rdi)
movb $0x0, 0x41b4(%rdi)
pushq $0x78
popq %rax
xorps %xmm0, %xmm0
movaps 0x67ce(%rip), %xmm1     # 0xf140
cmpq $0x1e0, %rax            # imm = 0x1E0
je 0x89b1
andq $0x0, -0x6c(%rbx,%rax)
andl $0x0, -0x50(%rbx,%rax)
andl $0x0, (%rbx,%rax)
movups %xmm0, -0x18(%rbx,%rax)
andl $0x0, -0x8(%rbx,%rax)
movl $0x7ffffc, -0x48(%rbx,%rax) # imm = 0x7FFFFC
andq $0x0, -0x20(%rbx,%rax)
movups %xmm0, -0x40(%rbx,%rax)
movups %xmm1, -0x30(%rbx,%rax)
addq $0x78, %rax
jmp 0x8972
xorl %eax, %eax
movb %al, 0x194(%rbx)
movb %al, 0x19c(%rbx)
andl $0x0, 0x198(%rbx)
andl $0x0, 0x41b0(%rbx)
andq $0x0, 0x41a8(%rbx)
movq %rbx, %rdi
callq 0x8eac
movq %rbx, %rdi
callq 0x8f04
andl $0x0, 0x18c(%rbx)
andl $0x0, 0x178(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Sid.cpp
// Function: SIDsound::setFilterCutoff()
inline void SIDsound::setFilterCutoff()
{
	const double freqDomainDivCoeff = 2 * M_PI * 1.048576;
	w0 = int(cutOffFreq[filterCutoff] * freqDomainDivCoeff);
	// Limit cutoff to Nyquist frq to keep the sample based filter stable
	const double NyquistFrq = double(sampleRate) / 2;
	const double maxCutOff = NyquistFrq > 16000.0 ? 16000.0 : NyquistFrq;
	const int w0MaxDt = int(maxCutOff * freqDomainDivCoeff); // 16000
	if (w0 > w0MaxDt) w0 = w0MaxDt;
}

// Assembly:
movl 0x198(%rdi), %eax
movl 0x41b8(%rdi), %ecx
cvtsi2sd %rcx, %xmm0
mulsd 0x6173(%rip), %xmm0     # 0xf038
movsd 0x622b(%rip), %xmm1     # 0xf0f8
minsd %xmm0, %xmm1
movsd 0x1a0(%rdi,%rax,8), %xmm0
unpcklpd %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
mulpd 0x624a(%rip), %xmm0     # 0xf130
cvttpd2dq %xmm0, %xmm0
movd %xmm0, %eax
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movd %xmm0, %ecx
cmpl %ecx, %eax
cmovgl %ecx, %eax
movl %eax, 0x41a4(%rdi)
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Sid.cpp
// Function: SIDsound::getWaveSample(SIDsound::SIDVoice&)
inline int SIDsound::getWaveSample(SIDVoice &v)
{
	switch (v.wave) {
		case WAVE_TRI:
			return waveTriangle(v);
		case WAVE_SAW:
			return waveSaw(v);
		case WAVE_PULSE:
			return wavePulse(v);
		case WAVE_TRISAW:
			return waveTriSaw(v);
		case WAVE_TRIPULSE:
			return waveTriPulse(v);
		case WAVE_SAWPULSE:
			return waveSawPulse(v);
		case WAVE_TRISAWPULSE:
			return waveTriSawPulse(v);
		case WAVE_NOISE:
			return v.waveNoiseOut;
		case WAVE_NONE:
			if (v.accu) {
				int rv = (v.accu >> 12);
				//v.accu >>= 1;
				//return rv;
			}
		default:
			return 0x000;
	}
}

// Assembly:
movl 0x4(%rdi), %eax
decl %eax
cmpl $0x7, %eax
ja 0x8f98
leaq 0x63e5(%rip), %rcx      # 0xf33c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x9206
jmp 0x9248
jmp 0x922c
movl 0x20(%rdi), %eax
xorl %ecx, %ecx
cmpl 0x34(%rdi), %eax
movl $0xfff, %eax            # imm = 0xFFF
cmovbl %ecx, %eax
orl 0x60(%rdi), %eax
retq
movl 0x2c(%rdi), %eax
retq
movl 0x20(%rdi), %eax
shrl $0xc, %eax
retq
jmp 0x9270
jmp 0x9294
xorl %eax, %eax
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Sid.cpp
// Function: SIDsound::clock()
inline unsigned int SIDsound::clock()
{
	unsigned int count = sidCyclesPerSampleInt;
	unsigned int newCount = clockDeltaFraction + clockDeltaRemainder;

	if (newCount >= sampleRate) {
		clockDeltaRemainder = newCount - sampleRate;
		count++;
	} else
		clockDeltaRemainder = newCount;
	return count;
}

// Assembly:
movl 0x178(%rdi), %ecx
addl 0x17c(%rdi), %ecx
movl 0x174(%rdi), %eax
movl 0x41b8(%rdi), %edx
xorl %esi, %esi
cmpl %edx, %ecx
cmovael %edx, %esi
sbbl $-0x1, %eax
subl %esi, %ecx
movl %ecx, 0x178(%rdi)
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Sid.cpp
// Function: SIDsound::updateShiftReg(SIDsound::SIDVoice&)
inline void SIDsound::updateShiftReg(SIDVoice &v)
{
	unsigned int &shiftReg = v.shiftReg;
	unsigned int bit22 = bit(shiftReg,22);
	unsigned int bit17 = bit(shiftReg,17);

	// Shift 1 bit left
	shiftReg = ((shiftReg) << 1);// & 0x7fffff;

	// Feed bit 0
	shiftReg = shiftReg | (bit22 ^ bit17);
	// Store output
	v.waveNoiseOut = waveNoise(v);
}

// Assembly:
pushq %rbx
movq %rsi, %rbx
movl 0x28(%rsi), %eax
movl %eax, %ecx
shrl $0x16, %ecx
movl %eax, %edx
shrl $0x11, %edx
xorl %ecx, %edx
andl $0x1, %edx
leal (%rdx,%rax,2), %eax
movl %eax, 0x28(%rsi)
movq %rsi, %rdi
callq 0x92c4
movl %eax, 0x2c(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Sid.cpp
// Function: SIDsound::filterOutput(unsigned int, int)
inline int SIDsound::filterOutput(unsigned int cycles, int Vi)
{
	const int w0deltaTime = w0 >> 6;
	Vi >>= 7;
	unsigned int count = cycles;

	do {
		int dVlp = (w0deltaTime * Vbp >> 14);
		Vlp -= dVlp;
		int dVbp = (w0deltaTime * Vhp >> 14);
		Vbp -= dVbp;
		Vhp = (Vbp * resonanceCoeffDiv1024 >> 10) - Vlp - Vi;
	} while (--count);

	int Vf;

	switch (filterType) {
		default:
		case FILTER_NONE:
			Vf = 0;
			break;
		case FILTER_LP:
			Vf = Vlp;
			break;
		case FILTER_BP:
			Vf = Vbp;
			break;
		case FILTER_LPBP:
			Vf = Vlp + Vbp;
			break;
		case FILTER_HP:
			Vf = Vhp;
			break;
		case FILTER_NOTCH:
			Vf = Vlp + Vhp;
			break;
		case FILTER_HPBP:
			Vf = Vbp + Vhp;
			break;
		case FILTER_ALL:
			Vf = Vlp + Vbp + Vhp;
			break;
	}
	return Vf << 7;
}

// Assembly:
movl 0x41a0(%rdi), %r9d
movl 0x41a4(%rdi), %r10d
sarl $0x6, %r10d
sarl $0x7, %edx
movl 0x41ac(%rdi), %ecx
movl 0x41b0(%rdi), %eax
movl 0x41a8(%rdi), %r8d
movl %ecx, %r11d
imull %r10d, %r11d
sarl $0xe, %r11d
subl %r11d, %eax
imull %r10d, %r8d
sarl $0xe, %r8d
subl %r8d, %ecx
movl %ecx, %r8d
imull %r9d, %r8d
sarl $0xa, %r8d
subl %eax, %r8d
subl %edx, %r8d
decl %esi
jne 0x9178
movl %ecx, 0x41ac(%rdi)
movl %eax, 0x41b0(%rdi)
movl %r8d, 0x41a8(%rdi)
movzbl 0x194(%rdi), %edx
decl %edx
cmpl $0x6, %edx
ja 0x91e0
leaq 0x618e(%rip), %rsi      # 0xf35c
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
jmpq *%rdx
addl %eax, %ecx
jmp 0x91f1
addl %eax, %r8d
jmp 0x91e7
xorl %eax, %eax
jmp 0x91f3
addl %ecx, %r8d
movl %r8d, %eax
jmp 0x91f3
addl %eax, %ecx
addl %r8d, %ecx
movl %ecx, %eax
shll $0x7, %eax
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Sid.cpp
// Function: SIDsound::waveNoise(SIDsound::SIDVoice&)
inline int SIDsound::waveNoise(SIDVoice &v)
{
	unsigned int shiftReg = v.shiftReg;
	// Pick out bits to make output value, left shift by 4
	return
		(bit(shiftReg,22) << 11) |
		(bit(shiftReg,20) << 10) |
		(bit(shiftReg,16) << 9) |
		(bit(shiftReg,13) << 8) |
		(bit(shiftReg,11) << 7) |
		(bit(shiftReg, 7) << 6) |
		(bit(shiftReg, 4) << 5) |
		(bit(shiftReg, 2) << 4);
}

// Assembly:
movl 0x28(%rdi), %eax
movl %eax, %ecx
shrl $0xb, %ecx
andl $0x800, %ecx            # imm = 0x800
movl %eax, %edx
shrl $0xa, %edx
andl $0x400, %edx            # imm = 0x400
orl %ecx, %edx
movl %eax, %ecx
shrl $0x7, %ecx
andl $0x200, %ecx            # imm = 0x200
orl %edx, %ecx
movl %eax, %edx
shrl $0x5, %edx
andl $0x100, %edx            # imm = 0x100
orl %ecx, %edx
movl %eax, %ecx
shrl $0x4, %ecx
andl $0x80, %ecx
orl %edx, %ecx
movl %eax, %edx
shrl %edx
andl $0x40, %edx
orl %ecx, %edx
movl %eax, %ecx
andl $0x10, %ecx
leal (%rdx,%rcx,2), %ecx
shll $0x2, %eax
andl $0x10, %eax
orl %ecx, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/SIDSoundLib.cpp
// Function: SIDSoundLib::SIDSoundLib(unsigned int)
SIDSoundLib::SIDSoundLib(unsigned int model) : SIDsound(model, 0)
{
	if (!detected)
		connect();
	if (detected) {
		sidCreate(sidBaseFreq, model, sidBaseFreq);
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
xorl %edx, %edx
callq 0x889e
leaq 0xa789(%rip), %rax      # 0x13cb8
movq %rax, (%rbx)
movb 0x1bef0(%rip), %al      # 0x25428
testb %al, %al
jne 0x9547
callq 0x9320
movb 0x1bee1(%rip), %al      # 0x25428
testb $0x1, %al
je 0x955b
movl 0x41c0(%rbx), %edi
movl %ebp, %esi
movl %edi, %edx
callq *0x1bedd(%rip)          # 0x25438
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %r14
movq %rbx, %rdi
callq 0x8e74
movq %r14, %rdi
callq 0x3340
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/SIDSoundLib.cpp
// Function: SIDSoundLib::~SIDSoundLib()
SIDSoundLib::~SIDSoundLib()
{
	sidDestroy();
	CLOSE_LIBRARY(m_hDll);
	m_hDll = NULL;
	detected = false;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0xa739(%rip), %rax      # 0x13cb8
movq %rax, (%rdi)
callq *0x1beb8(%rip)          # 0x25440
movq 0x1bea1(%rip), %rdi     # 0x25430
callq 0x3190
andq $0x0, 0x1be94(%rip)     # 0x25430
movb $0x0, 0x1be85(%rip)     # 0x25428
movq %rbx, %rdi
popq %rbx
jmp 0x8e74
movq %rax, %rdi
callq 0x3d21
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/SIDSoundLib.cpp
// Function: SIDSoundLib::setModel(unsigned int)
void SIDSoundLib::setModel(unsigned int model)
{
	if (model_ != model) {
		sidSetModel(model);
		sidReset();
		model_ = model;
	}
}

// Assembly:
cmpl %esi, 0x41bc(%rdi)
je 0x9607
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movl %esi, %edi
callq *0x1be5d(%rip)          # 0x25450
callq *0x1be5f(%rip)          # 0x25458
movl %ebx, 0x41bc(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedmem.cpp
// Function: TED::enableSidCard(unsigned int, unsigned int)
unsigned int TED::enableSidCard(unsigned int sidEmuType_, unsigned int disableMask)
{
	if (sidEmuType_) {
		if (sidEmuType != sidEmuType_) {
			delete sidCard;
			sidCard = 0;
		} else
			return sidEmuType;
		if (sidEmuType_ == 2 && SIDSoundLib::connect()) {
			sidCard = new SIDSoundLib(SID8580);
			sidEmuType = 2;
		}
		else {
			sidCard = new SIDsound(SID8580, disableMask);
			sidEmuType = 1;
		}
		sidCard->setSampleRate(TED_SOUND_CLOCK);
	} else {
		if (!sidCard)
			return 0;
		delete sidCard;
		sidCard = 0;
		sidEmuType = 0;
	}
	return sidEmuType;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
testl %esi, %esi
je 0x9880
movl %esi, %r14d
cmpl %esi, 0xb71d8(%rbx)
je 0x98e7
movl %edx, %ebp
movq 0xb71d0(%rbx), %rdi
testq %rdi, %rdi
je 0x984b
movq (%rdi), %rax
callq *0x8(%rax)
andq $0x0, 0xb71d0(%rbx)
cmpl $0x2, %r14d
jne 0x98a6
callq 0x9320
testb %al, %al
je 0x98a6
movl $0x41c8, %edi           # imm = 0x41C8
callq 0x3220
movq %rax, %r14
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x9518
pushq $0x2
popq %r15
jmp 0x98c4
movq 0xb71d0(%rbx), %rdi
xorl %r14d, %r14d
testq %rdi, %rdi
je 0x98e7
movq (%rdi), %rax
callq *0x8(%rax)
andq $0x0, 0xb71d0(%rbx)
andl $0x0, 0xb71d8(%rbx)
jmp 0x98e7
movl $0x41c8, %edi           # imm = 0x41C8
callq 0x3220
movq %rax, %r14
pushq $0x1
popq %r15
movq %rax, %rdi
movl %r15d, %esi
movl %ebp, %edx
callq 0x889e
movq %r14, 0xb71d0(%rbx)
movl %r15d, 0xb71d8(%rbx)
movq (%r14), %rax
movq %r14, %rdi
movl $0x361f0, %esi          # imm = 0x361F0
callq *0x30(%rax)
movl 0xb71d8(%rbx), %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x98f7
movq %rax, %rbx
movl $0x41c8, %esi           # imm = 0x41C8
movq %r14, %rdi
callq 0x3230
movq %rbx, %rdi
callq 0x3340
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedmem.cpp
// Function: TED::Reset()
void TED::Reset()
{
	// clear RAM with powerup pattern
	for (int i = 0; i < RAMSIZE; i++)
		Ram[i] = (i >> 1) << 1 == i ? 0 : 0xFF;
	// reset oscillators
	oscillatorReset();
	if (sidCard) sidCard->reset();
	lastResetCycle = CycleCounter;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
xorl %eax, %eax
cmpq $0x10000, %rax          # imm = 0x10000
je 0x9931
movl %eax, %ecx
andb $0x1, %cl
negb %cl
movb %cl, 0x45fc0(%rbx,%rax)
incq %rax
jmp 0x9916
movq %rbx, %rdi
callq 0xb758
movq 0xb71d0(%rbx), %rdi
testq %rdi, %rdi
je 0x994b
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x1bb36(%rip), %rax     # 0x25488
movq %rax, 0xb61a0(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedmem.cpp
// Function: TED::ChangeMemBankSetup(bool)
void TED::ChangeMemBankSetup(bool romoff)
{
	if (romoff) {
		mem_8000_bfff = actram + (0x8000 & RAMMask);
		mem_fc00_fcff = mem_c000_ffff = actram + (0xC000 & RAMMask);
	} else {
		mem_8000_bfff = actromlo;
		mem_c000_ffff = actromhi;
		mem_fc00_fcff = &(RomHi[0][0]);
	}
}

// Assembly:
testl %esi, %esi
je 0x99b2
movq 0xb6010(%rdi), %rcx
movl 0x76008(%rdi), %eax
movl %eax, %edx
andl $0x8000, %edx           # imm = 0x8000
addq %rcx, %rdx
andl $0xc000, %eax           # imm = 0xC000
addq %rcx, %rax
movq %rax, %xmm1
movq %rdx, %xmm0
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
jmp 0x99c1
movdqu 0x75fe0(%rdi), %xmm0
leaq 0x55fc0(%rdi), %rax
movdqu %xmm0, 0x75ff0(%rdi)
movq %rax, 0x76000(%rdi)
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedmem.cpp
// Function: TED::chrtoscreen(int, int, char)
void TED::chrtoscreen(int x,int y, char scrchr)
{
	int j, k;
	unsigned char *charset = (unsigned char *) kernal+0x1000;

	if (isalpha(scrchr)) {
		scrchr=toupper(scrchr)-64;
		charset+=(scrchr<<3);
		for (j=0;j<8;j++)
			for (k=0;k<8;k++)
				(*(charset+j) & (0x80>>k)) ? screen[(y+j)*456+x+k]=0x00 : screen[(y+j)*456+x+k]=0x71;
		return;
	}
	charset+=(scrchr<<3);
	for (j=0;j<8;j++)
		for (k=0;k<8;k++)
			(*(charset+j) & (0x80>>k)) ? screen[(y+j)*456+x+k]=0x00 : screen[(y+j)*456+x+k]=0x71;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %r15d
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %rbx
movl %ecx, %edi
callq 0x3300
testl %eax, %eax
je 0x9ab1
movl %r15d, %edi
callq 0x3370
shll $0x18, %eax
addl $0xc0000000, %eax       # imm = 0xC0000000
sarl $0x15, %eax
cltq
leaq 0xe7c5(%rip), %rcx      # 0x18210
addq %rcx, %rax
addq $0x1000, %rax           # imm = 0x1000
movslq %r14d, %rcx
movslq %ebp, %rdx
imulq $0x1c8, %rcx, %rcx      # imm = 0x1C8
addq %rdx, %rcx
leaq (%rbx,%rcx), %rdx
addq $0x824, %rdx            # imm = 0x824
xorl %esi, %esi
pushq $0x71
popq %rdi
cmpq $0x8, %rsi
je 0x9b1e
movzbl (%rax,%rsi), %r8d
xorl %ecx, %ecx
cmpq $0x8, %rcx
je 0x9aa5
movl %r8d, %r10d
shll %cl, %r10d
movl %edi, %r9d
testb %r10b, %r10b
jns 0x9a9c
xorl %r9d, %r9d
movb %r9b, (%rdx,%rcx)
incq %rcx
jmp 0x9a85
incq %rsi
addq $0x1c8, %rdx            # imm = 0x1C8
jmp 0x9a74
movslq %r15d, %rax
leaq 0xe755(%rip), %rcx      # 0x18210
leaq (%rcx,%rax,8), %rax
addq $0x1000, %rax           # imm = 0x1000
movslq %r14d, %rcx
movslq %ebp, %rdx
imulq $0x1c8, %rcx, %rcx      # imm = 0x1C8
addq %rdx, %rcx
leaq (%rbx,%rcx), %rdx
addq $0x824, %rdx            # imm = 0x824
xorl %esi, %esi
pushq $0x71
popq %rdi
cmpq $0x8, %rsi
je 0x9b1e
movzbl (%rax,%rsi), %r8d
xorl %ecx, %ecx
cmpq $0x8, %rcx
je 0x9b12
movl %r8d, %r10d
shll %cl, %r10d
movl %edi, %r9d
testb %r10b, %r10b
jns 0x9b09
xorl %r9d, %r9d
movb %r9b, (%rdx,%rcx)
incq %rcx
jmp 0x9af2
incq %rsi
addq $0x1c8, %rdx            # imm = 0x1C8
jmp 0x9ae5
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedmem.cpp
// Function: TED::loadroms()
void TED::loadroms()
{
	for (int i=0;i<4;i++) {
		loadhiromfromfile(i,romhighpath[i]);
		loadloromfromfile(i,romlopath[i]);
	}
	mem_8000_bfff = actromlo = &(RomLo[0][0]);
	mem_fc00_fcff = mem_c000_ffff = actromhi = &(RomHi[0][0]);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x41b(%rdi), %r14
xorl %r15d, %r15d
cmpq $0x4, %r15
je 0x9b6e
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x9ba6
leaq -0x400(%r14), %rdx
movq %rbx, %rdi
movl %r15d, %esi
callq 0x9c8c
incq %r15
addq $0x100, %r14            # imm = 0x100
jmp 0x9b3c
leaq 0x65fe0(%rbx), %rax
movq %rax, 0x75fe0(%rbx)
movq %rax, 0x75ff0(%rbx)
leaq 0x55fc0(%rbx), %rax
movq %rax, 0x75fe8(%rbx)
movq %rax, 0x75ff8(%rbx)
movq %rax, 0x76000(%rbx)
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedmem.cpp
// Function: TED::loadhiromfromfile(int, char*)
void TED::loadhiromfromfile(int nr, char fname[512])
{
	FILE	*img;

	if (fname[0]!='\0') {
		if (img = fopen(fname, "rb")) {
			// load high ROM file
			fread(&(RomHi[nr]),ROMSIZE,1,img);
			fclose(img);
			return;
		}
		switch (nr) {
			case 0:
				memcpy(&(RomHi[0]),kernal,ROMSIZE);
				break;
			case 1: if (!strncmp(fname,"3PLUS1HIGH",10))
						memcpy(&(RomHi[1]),plus4hi,ROMSIZE);
					else
						memset(&(RomHi[1]),0,ROMSIZE);
				break;
			default : memset(&(RomHi[nr]),0,ROMSIZE);
		}
	} else
		memset(&(RomHi[nr]),0,ROMSIZE);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
cmpb $0x0, (%rdx)
je 0x9c1e
movq %rdx, %r14
leaq 0x454b(%rip), %rsi      # 0xe10c
movq %rdx, %rdi
callq 0x3260
testq %rax, %rax
je 0x9c05
movq %rax, %r15
movslq %ebp, %rax
shlq $0xe, %rax
leaq (%rbx,%rax), %rdi
addq $0x55fc0, %rdi          # imm = 0x55FC0
pushq $0x1
popq %rdx
movl $0x4000, %esi           # imm = 0x4000
movq %r15, %rcx
callq 0x32d0
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3210
cmpl $0x1, %ebp
je 0x9c46
testl %ebp, %ebp
jne 0x9c1e
addq $0x55fc0, %rbx          # imm = 0x55FC0
leaq 0xe5f4(%rip), %rsi      # 0x18210
jmp 0x9c74
movslq %ebp, %rax
shlq $0xe, %rax
leaq (%rbx,%rax), %rdi
addq $0x55fc0, %rdi          # imm = 0x55FC0
movl $0x4000, %edx           # imm = 0x4000
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3130
leaq 0x5a87(%rip), %rsi      # 0xf6d4
pushq $0xa
popq %rdx
movq %r14, %rdi
callq 0x3100
addq $0x59fc0, %rbx          # imm = 0x59FC0
testl %eax, %eax
je 0x9c6d
movl $0x4000, %edx           # imm = 0x4000
movq %rbx, %rdi
jmp 0x9c35
leaq 0x1259c(%rip), %rsi     # 0x1c210
movl $0x4000, %edx           # imm = 0x4000
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x31a0
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedmem.cpp
// Function: TED::loadloromfromfile(int, char*)
void TED::loadloromfromfile(int nr, char fname[512])
{
	FILE			*img;

	if (fname[0]!='\0') {
		if (img = fopen(fname, "rb")) {
			// load low ROM file
			fread(&(RomLo[nr]),ROMSIZE,1,img);
			fclose(img);
			return;
		}
		switch (nr) {
			case 0: memcpy(&(RomLo[0]),basic,ROMSIZE);
				break;
			case 1: if (!strncmp(fname,"3PLUS1LOW",9))
						memcpy(&(RomLo[1]),plus4lo,ROMSIZE);
					else
						memset(&(RomLo[1]),0,ROMSIZE);
				break;
			default : memset(&(RomLo[nr]),0,ROMSIZE);
		}
	} else
		memset(&(RomLo[nr]),0,ROMSIZE);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
cmpb $0x0, (%rdx)
je 0x9d04
movq %rdx, %r14
leaq 0x4465(%rip), %rsi      # 0xe10c
movq %rdx, %rdi
callq 0x3260
testq %rax, %rax
je 0x9ceb
movq %rax, %r15
movslq %ebp, %rax
shlq $0xe, %rax
leaq (%rbx,%rax), %rdi
addq $0x65fe0, %rdi          # imm = 0x65FE0
pushq $0x1
popq %rdx
movl $0x4000, %esi           # imm = 0x4000
movq %r15, %rcx
callq 0x32d0
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3210
cmpl $0x1, %ebp
je 0x9d2c
testl %ebp, %ebp
jne 0x9d04
addq $0x65fe0, %rbx          # imm = 0x65FE0
leaq 0xa50e(%rip), %rsi      # 0x14210
jmp 0x9d5a
movslq %ebp, %rax
shlq $0xe, %rax
leaq (%rbx,%rax), %rdi
addq $0x65fe0, %rdi          # imm = 0x65FE0
movl $0x4000, %edx           # imm = 0x4000
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3130
leaq 0x5997(%rip), %rsi      # 0xf6ca
pushq $0x9
popq %rdx
movq %r14, %rdi
callq 0x3100
addq $0x69fe0, %rbx          # imm = 0x69FE0
testl %eax, %eax
je 0x9d53
movl $0x4000, %edx           # imm = 0x4000
movq %rbx, %rdi
jmp 0x9d1b
leaq 0x164b6(%rip), %rsi     # 0x20210
movl $0x4000, %edx           # imm = 0x4000
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x31a0
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedmem.cpp
// Function: TED::copyToKbBuffer(char*, unsigned int)
void TED::copyToKbBuffer(char *bufferString, unsigned int bufferLength)
{
	unsigned int bufferAddress = 0x0527;
	if (bufferLength == -1U) bufferLength = (unsigned int) strlen(bufferString);

	for (unsigned int i=0; i < bufferLength; i++)
		Write( bufferAddress + i, bufferString[i]);

	Write(0xEF, bufferLength);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
cmpl $-0x1, %edx
jne 0x9dc4
movq %r14, %rdi
callq 0x30e0
movq %rax, %rdx
movl %edx, %r15d
xorl %r12d, %r12d
cmpq %r12, %r15
je 0x9de9
leal 0x527(%r12), %esi
movzbl (%r14,%r12), %edx
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
incq %r12
jmp 0x9dca
movq (%rbx), %rax
movq (%rax), %rax
movzbl %r15b, %edx
movq %rbx, %rdi
movl $0xef, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmpq *%rax
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedmem.cpp
// Function: TED::~TED()
TED::~TED()
{
	if (filter)
		delete filter;

	if (sidCard)
		enableSidCard(0, 0);

}

// Assembly:
pushq %rbx
movq %rdi, %rbx
leaq 0x86bf(%rip), %rax      # 0x13d38
movq %rax, (%rdi)
movq 0x65fd8(%rdi), %rdi
testq %rdi, %rdi
je 0xb68e
movq (%rdi), %rax
callq *0x8(%rax)
movq 0xb71d0(%rbx), %rdi
testq %rdi, %rdi
je 0xb6af
movq (%rdi), %rax
callq *0x8(%rax)
andq $0x0, 0xb71d0(%rbx)
andl $0x0, 0xb71d8(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedmem.cpp
// Function: TED::DoDMA(unsigned char*, unsigned int)
inline void TED::DoDMA( unsigned char *Buf, unsigned int Offset )
{
	if ( CharacterCount>=0x03D8 ) {
		memcpy( Buf, VideoBase + CharacterCount + Offset, 0x400 - CharacterCount);
		memcpy( Buf + 0x400 - CharacterCount, VideoBase + Offset, (CharacterCount + 40)&0x03FF);
	} else {
		memcpy( Buf, VideoBase + CharacterCount + Offset, 40);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl 0x19de8(%rip), %r15d    # 0x254c4
movq 0x19dbd(%rip), %r14     # 0x254a0
leaq (%r14,%r15), %rsi
movl %edx, %r12d
addq %r12, %rsi
cmpq $0x3d8, %r15            # imm = 0x3D8
jb 0xb733
movl $0x400, %edx            # imm = 0x400
subl %r15d, %edx
movq %rbx, %rdi
callq 0x31a0
subq %r15, %rbx
addq $0x400, %rbx            # imm = 0x400
addq %r12, %r14
leal 0x28(%r15), %edx
andl $0x3ff, %edx            # imm = 0x3FF
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x31a0
movq 0x20(%rsi), %rax
movq %rax, 0x20(%rbx)
movups (%rsi), %xmm0
movups 0x10(%rsi), %xmm1
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedsound.cpp
// Function: TED::oscillatorReset()
void TED::oscillatorReset()
{
	FlipFlop[0] = dcOutput[0] = 0;
	FlipFlop[1] = dcOutput[1] = 0;
	oscCount[0] = 0;
	oscCount[1] = 0;
	NoiseCounter = 0;
	Freq1 = Freq2 = 0;
	DAStatus = Snd1Status = Snd2Status = SndNoiseStatus = 0;
}

// Assembly:
andl $0x0, 0x19d95(%rip)     # 0x254f4
andl $0x0, 0x19d96(%rip)     # 0x254fc
andl $0x0, 0x19d8b(%rip)     # 0x254f8
andl $0x0, 0x19d8c(%rip)     # 0x25500
andq $0x0, 0x19d8c(%rip)     # 0x25508
andl $0x0, 0x19d8d(%rip)     # 0x25510
andw $0x0, 0x19d89(%rip)     # 0x25514
andw $0x0, 0x19d83(%rip)     # 0x25516
andl $0x0, 0x19d7e(%rip)     # 0x25518
andl $0x0, 0x19d7b(%rip)     # 0x2551c
andl $0x0, 0x19d78(%rip)     # 0x25520
andl $0x0, 0x19d75(%rip)     # 0x25524
retq
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedsound.cpp
// Function: TED::oscillatorInit()
void TED::oscillatorInit()
{
	unsigned int i;

	oscillatorReset();

	int im = 0xff;
    for (i = 0; i < 256; i++) {
		im = (im << 1) | (((im >> 7) ^ (im >> 5) ^ (im >> 4) ^ (im >> 1)) & 1);
		noise[i] = im & 1;
    }
	for (i = 0; i < 64; i++) {
		int chdbl = (i & 0x30) == 0x30;
		int vol = ((i & 0x0F) < 9 ? (i & 0x0F) : 8);
		int nonl = ((chdbl && vol > 1) ? vol * vol * 54 - 173 * vol + 162 : 0);
		volumeTable[i] = (vol && i & 0x30) ?
			(nonl + (586 + (vol - 1) * 1024) << (chdbl ? 1 : 0)) : 0;
	}
	oscStep = (1 << PRECISION) << 0;

	// set player specific parameters
	waveForm[0] = waveForm[1] = 1;
	masterVolume = AMP(8);
	setplaybackSpeed(3);
	enableChannel(0, true);
	enableChannel(1, true);
	enableChannel(2, true);
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0xb758
movl $0xff, %eax
xorl %ecx, %ecx
leaq 0x19d67(%rip), %rdx     # 0x25530
cmpq $0x100, %rcx            # imm = 0x100
je 0xb800
movl %eax, %esi
shrl $0x7, %esi
movl %eax, %edi
shrl $0x5, %edi
xorl %esi, %edi
movl %eax, %esi
shrl $0x4, %esi
movl %eax, %r8d
shrl %r8d
xorl %esi, %r8d
xorl %edi, %r8d
andl $0x1, %r8d
leal (%r8,%rax,2), %eax
movb %r8b, (%rcx,%rdx)
incq %rcx
jmp 0xb7c9
leaq 0x19e29(%rip), %rax     # 0x25630
xorl %edx, %edx
pushq $0x8
popq %rsi
xorl %edi, %edi
cmpq $0x40, %rdi
je 0xb880
movl %edi, %r8d
andl $0xf, %r8d
sete %r10b
movl %edi, %ecx
andl $0x30, %ecx
sete %r11b
xorl %r9d, %r9d
orb %r10b, %r11b
jne 0xb874
cmpl $0x8, %r8d
movl %esi, %r9d
cmovbl %r8d, %r9d
imull $0x36, %r9d, %r10d
addl $0xffffff53, %r10d      # imm = 0xFFFFFF53
imull %r9d, %r10d
addl $0xa2, %r10d
cmpl $0x2, %r8d
cmovbl %edx, %r10d
cmpl $0x30, %ecx
sete %cl
cmovnel %edx, %r10d
shll $0xa, %r9d
addl %r10d, %r9d
addl $0xfffffe4a, %r9d       # imm = 0xFFFFFE4A
shll %cl, %r9d
movl %r9d, (%rax)
incq %rdi
addq $0x4, %rax
jmp 0xb80e
movb $0x1, 0x19ea9(%rip)     # 0x25730
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0xb61b0(%rbx)
movl $0x180, 0x19c4e(%rip)   # imm = 0x180
movl $0x4, 0xb71b8(%rbx)
pushq $0x1
popq %rbp
movq %rbx, %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0xb638
movq %rbx, %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0xb638
pushq $0x2
popq %rsi
movq %rbx, %rdi
movl %ebp, %edx
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0xb638
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedsound.cpp
// Function: TED::writeSoundReg(unsigned int, unsigned char)
void TED::writeSoundReg(unsigned int reg, unsigned char value)
{
#if defined(_DEBUG) && 0
	static FILE *f = std::fopen("freqlog.txt", "a");
	if (f)
		std::fprintf(f, "%04X <- %02X in cycle %llu", 0xff0e + reg, value, CycleCounter);
	fprintf(f, "\n");
#endif

	switch (reg) {
		case 0:
			Freq1 = (Freq1 & 0x300) | value;
			setFreq(0, Freq1);
			break;
		case 1:
			Freq2 = (Freq2 & 0x300) | value;
			setFreq(1, Freq2);
			break;
		case 2:
			Freq2 = (Freq2 & 0xFF) | (value << 8);
			setFreq(1, Freq2);
			break;
		case 3:
			if ((DAStatus = value & 0x80)) {
				FlipFlop[0] = 1;
				FlipFlop[1] = 1;
				oscCount[0] = OscReload[0];
				oscCount[1] = OscReload[1];
				NoiseCounter = 0;
			}
			Volume = value & 0x0F;
			if (Volume > 8) Volume = 8;
			Volume = (Volume << 9);
			Snd1Status = value & 0x10;
			Snd2Status = value & 0x20;
			SndNoiseStatus = value & 0x40;
			break;
		case 4:
			Freq1 = (Freq1 & 0xFF) | (value << 8);
			setFreq(0, Freq1);
			break;
	}
}

// Assembly:
cmpl $0x4, %esi
ja 0xb967
movl %esi, %eax
leaq 0x3dec(%rip), %rcx      # 0xf6f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzwl 0x19c02(%rip), %eax     # 0x25516
andl $0x300, %eax            # imm = 0x300
movzbl %dl, %ecx
leal (%rax,%rcx), %edx
movw %dx, 0x19bf0(%rip)      # 0x25516
xorl %esi, %esi
cmpl $0x3fe, %edx            # imm = 0x3FE
jmp 0xb94e
movzbl 0x19bdf(%rip), %eax     # 0x25516
movzbl %dl, %ecx
shll $0x8, %ecx
leal (%rax,%rcx), %edx
movw %dx, 0x19bcf(%rip)      # 0x25516
xorl %esi, %esi
cmpw $0x3fe, %dx             # imm = 0x3FE
sete %sil
movl %esi, 0x19b9c(%rip)     # 0x254f4
addl %ecx, %eax
incl %eax
andl $0x3ff, %eax            # imm = 0x3FF
movl %eax, 0x19dd1(%rip)     # 0x25738
retq
movzbl 0x19ba5(%rip), %eax     # 0x25514
movzbl %dl, %ecx
shll $0x8, %ecx
leal (%rax,%rcx), %edx
movw %dx, 0x19b95(%rip)      # 0x25514
xorl %esi, %esi
cmpw $0x3fe, %dx             # imm = 0x3FE
jmp 0xba1a
movzbl %dl, %eax
movl %eax, %ecx
andl $0x80, %ecx
movl %ecx, 0x19b88(%rip)     # 0x25524
je 0xb9c2
pushq $0x1
popq %rcx
movl %ecx, 0x19b55(%rip)     # 0x254fc
movl %ecx, 0x19b53(%rip)     # 0x25500
movq 0x19d84(%rip), %rcx     # 0x25738
movq %rcx, 0x19b4d(%rip)     # 0x25508
andl $0x0, 0x19b4e(%rip)     # 0x25510
movl %eax, %ecx
andl $0xf, %ecx
cmpl $0x8, %ecx
pushq $0x8
popq %rdx
cmovbl %ecx, %edx
shll $0x9, %edx
movl %edx, 0x19d67(%rip)     # 0x25740
movl %eax, %ecx
andl $0x10, %ecx
movl %ecx, 0x19b3c(%rip)     # 0x25520
movl %eax, %ecx
andl $0x20, %ecx
movl %ecx, 0x19b2d(%rip)     # 0x2551c
andl $0x40, %eax
movl %eax, 0x19b20(%rip)     # 0x25518
retq
movzwl 0x19b14(%rip), %eax     # 0x25514
andl $0x300, %eax            # imm = 0x300
movzbl %dl, %ecx
leal (%rax,%rcx), %edx
movw %dx, 0x19b02(%rip)      # 0x25514
xorl %esi, %esi
cmpl $0x3fe, %edx            # imm = 0x3FE
sete %sil
movl %esi, 0x19ad4(%rip)     # 0x254f8
addl %ecx, %eax
incl %eax
andl $0x3ff, %eax            # imm = 0x3FF
movl %eax, 0x19d09(%rip)     # 0x2573c
retq
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedsound.cpp
// Function: TED::storeToBuffer(short*, unsigned int)
void TED::storeToBuffer(short *buffer, unsigned int count)
{
	static double			lp_accu = 0;
	static double			hp_accu = 0;

	const double hptc = 20000.0/1000000;		// 6000us (est) maybe 7000 ?
	const double hpc = 1.0/(hptc * sampleRate * 2.0);	// 2*pi*fc=1/tau..
	
	// TODO: a proper windowed lowpass FIR filter
#if 0
	const double lpc = 1.0 - exp( - double(sampleRate) / 2.0 / double(TED_SOUND_CLOCK));
	do {
		double accu = (double) *buffer;
		// apply low pass filter -> lp_accu = lpc*accu + (1-lpc)*lp_accu
		lp_accu += lpc * (accu - lp_accu);
		accu = lp_accu - hp_accu;
		// update hp filter pole
		hp_accu +=  hpc * accu;
		// fill the buffer
		*buffer++ = ((short)accu);
	} while(--count);
#else
	do {
		double accu = (double) filter->lowPass(*buffer);
		accu = accu - hp_accu;
		// update hp filter pole
		hp_accu +=  hpc * accu;
		// fill the buffer
		*buffer++ = (short)accu;
	} while(--count);
#endif
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0xb71c8(%rdi), %eax
cvtsi2sd %rax, %xmm0
movq %rsi, %r14
mulsd 0x3cd3(%rip), %xmm0     # 0xf728
addsd %xmm0, %xmm0
movsd 0x25af(%rip), %xmm1     # 0xe010
divsd %xmm0, %xmm1
movsd %xmm1, (%rsp)
movl %edx, %r15d
xorl %r12d, %r12d
movq 0x65fd8(%rbx), %rdi
movswl (%r14,%r12,2), %esi
callq 0x8518
cwtl
cvtsi2sd %eax, %xmm0
movsd 0x19cba(%rip), %xmm1    # 0x25748
subsd %xmm1, %xmm0
movsd (%rsp), %xmm2
mulsd %xmm0, %xmm2
addsd %xmm1, %xmm2
cvttsd2si %xmm0, %eax
movsd %xmm2, 0x19c9d(%rip)    # 0x25748
movw %ax, (%r14,%r12,2)
incq %r12
cmpl %r12d, %r15d
jne 0xba70
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedsound.cpp
// Function: TED::setMasterVolume(unsigned int)
void TED::setMasterVolume(unsigned int shift)
{
	if (!shift)
		masterVolume = 0;
	else
		masterVolume = AMP(shift);
}

// Assembly:
testl %esi, %esi
je 0xbd82
pushq %rax
movl %esi, %eax
cvtsi2sd %rax, %xmm0
movsd 0x332e(%rip), %xmm1     # 0xf098
callq 0x3330
mulsd 0x39b9(%rip), %xmm0     # 0xf730
cvttsd2si %xmm0, %rax
addq $0x8, %rsp
jmp 0xbd84
xorl %eax, %eax
movl %eax, 0x19766(%rip)     # 0x254f0
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedsound.cpp
// Function: TED::initFilter(unsigned int, unsigned int)
void TED::initFilter(unsigned int sampleRate_, unsigned int filterOrder_)
{
	if (filter)
		delete filter;
	filter = new Filter(sampleRate_ / 2, TED_SOUND_CLOCK, filterOrder_);
	filter->reCalcWindowTable();
	filterOrder = filterOrder_;
	sampleRate = sampleRate_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movl %esi, %ebx
movq %rdi, %r14
movq 0x65fd8(%rdi), %rdi
testq %rdi, %rdi
je 0xbe0a
movq (%rdi), %rax
callq *0x8(%rax)
pushq $0x50
popq %rdi
callq 0x3220
movq %rax, %r15
movl %ebx, %esi
shrl %esi
movq %rax, %rdi
movl $0x361f0, %edx          # imm = 0x361F0
movl %ebp, %ecx
callq 0x811c
movq %r15, 0x65fd8(%r14)
movq %r15, %rdi
callq 0x8174
movl %ebp, 0xb71cc(%r14)
movl %ebx, 0xb71c8(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
pushq $0x50
popq %rsi
movq %r15, %rdi
callq 0x3230
movq %rbx, %rdi
callq 0x3340
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedsound.cpp
// Function: TED::getWaveSample(unsigned int, unsigned int)
inline unsigned int TED::getWaveSample(unsigned int channel, unsigned int wave)
{
	unsigned int sm;

	switch (wave) {
		default:
		case 1: // square
			return waveSquare(channel);
		case 2: // sawtooth
			return waveSawTooth(channel);
		case 4: // triangle
			return waveTriangle(channel);

		// combined waveforms � la SID
		case 3: // square + sawtooth
			sm = waveSawTooth(channel) + waveSquare(channel);
			return sm /= 2;
		case 5: // square + triangle
			sm = waveTriangle(channel) + waveSquare(channel);
			return sm /= 2;
		case 6: // sawtooth + triangle
			sm = waveTriangle(channel) + waveSawTooth(channel);
			return sm /= 2;
		case 7: // square + sawtooth + triangle
			sm = waveTriangle(channel) + waveSawTooth(channel) + waveSquare(channel);
			return sm /= 3;
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
addl $-0x2, %edx
cmpl $0x5, %edx
ja 0xbf16
movl %esi, %ebx
movq %rdi, %r14
leaq 0x38b0(%rip), %rax      # 0xf740
movslq (%rax,%rdx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq %r14, %rdi
movl %ebx, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0xbf22
movq %r14, %rdi
movl %ebx, %esi
callq 0xbf54
movl %eax, %ebp
movq %r14, %rdi
movl %ebx, %esi
callq 0xbf22
addl %ebp, %eax
jmp 0xbeeb
movq %r14, %rdi
movl %ebx, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0xbf54
movq %r14, %rdi
movl %ebx, %esi
callq 0xbf54
jmp 0xbee5
movq %r14, %rdi
movl %ebx, %esi
callq 0xbf22
addl 0x19855(%rip), %eax     # 0x25740
shrl %eax
jmp 0xbf1c
movq %r14, %rdi
movl %ebx, %esi
callq 0xbf54
movl %eax, %ebp
movq %r14, %rdi
movl %ebx, %esi
callq 0xbf22
addl %ebp, %eax
addl 0x19833(%rip), %eax     # 0x25740
pushq $0x3
popq %rcx
xorl %edx, %edx
divl %ecx
jmp 0xbf1c
movl 0x19824(%rip), %eax     # 0x25740
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/Tedsound.cpp
// Function: TED::waveSawTooth(unsigned int)
inline unsigned int TED::waveSawTooth(unsigned int channel)
{
	unsigned int mod;

#if 0
	int msb = OSCRELOADVAL + 1 - OscReload[channel];
	int diff = 2 * msb - int(FlipFlop[channel]) * msb - int(oscCount[channel]) + int(OscReload[channel]);
	//if (diff < 0) diff = 0;
	//if (oscCount[channel] >= 0x3fa) diff = 0;
	mod = (Volume * diff) / (2 * msb);
#else
	int diff = int(oscCount[channel]) - int(OscReload[channel]);
	if (diff < 0) diff = 0;
	mod = (Volume * diff) / (OSCRELOADVAL + 1 - OscReload[channel]);
#endif
	return mod;
}

// Assembly:
movl %esi, %eax
leaq 0x195dd(%rip), %rcx     # 0x25508
movl (%rcx,%rax,4), %ecx
leaq 0x19803(%rip), %rdx     # 0x25738
movl (%rdx,%rax,4), %edx
subl %edx, %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmovgl %ecx, %eax
imull 0x197f8(%rip), %eax     # 0x25740
movl $0x401, %ecx            # imm = 0x401
subl %edx, %ecx
cltd
idivl %ecx
retq
nop
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/tedplay.cpp
// Function: tedShowScreenData(char*)
void tedShowScreenData(char* out)
{
	const bool isCaps = !(ted->Read(0xFF13) & 4);
	const unsigned int pageAddr = (ted->Read(0xFF14) & 0xF8) << 8;
	unsigned char* in = ted->Ram + (pageAddr | 0x400);
	unsigned int i, j;
	for (i = 0; i < 25; i++) {
		for (j = 0; j < 40; j++) {
			*out++ = convertToAscii(*in, isCaps);
			in++;
		}
		*out++ = '\r';
		*out++ = '\n';
	}
	*out++ = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq 0x19ad2(%rip), %rdi     # 0x25e00
movq (%rdi), %rax
movl $0xff13, %esi           # imm = 0xFF13
callq *0x8(%rax)
movl %eax, %ebp
movq 0x19abe(%rip), %rdi     # 0x25e00
movq (%rdi), %rax
movl $0xff14, %esi           # imm = 0xFF14
callq *0x8(%rax)
andb $-0x8, %al
movzbl %al, %eax
shll $0x8, %eax
movq 0x19aa4(%rip), %rcx     # 0x25e00
leaq (%rcx,%rax), %r14
addq $0x463c0, %r14          # imm = 0x463C0
xorl %r15d, %r15d
cmpl $0x19, %r15d
je 0xc3aa
addq $0x2, %rbx
xorl %r12d, %r12d
cmpl $0x28, %r12d
je 0xc39c
xorl %esi, %esi
testb $0x4, %bpl
sete %sil
movzbl (%r14,%r12), %edi
callq 0xc3b6
movb %al, -0x2(%rbx)
incq %rbx
incq %r12
jmp 0xc377
movw $0xa0d, -0x2(%rbx)      # imm = 0xA0D
incl %r15d
addq %r12, %r14
jmp 0xc36a
movb $0x0, (%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/tedplay.cpp
// Function: convertToAscii(unsigned char, bool)
static char convertToAscii(unsigned char c, bool isCaps)
{
	char rv = 0x20;
	
	if (c == 0)
		rv = ' ';
	else if (isCaps) {
		if (c <= 0x1F)
			rv = c ^ 0x40;
		else if (c >= 0x60 && c <= 0x7F)
			rv = c - 0x20;
		else
			rv = c;
	}
	else {
		if (c >= 0x01 && c <= 0x1A)
			rv = c ^ 0x60;
		else if (c >= 0x1B && c <= 0x1F)
			rv = c ^ 0x40;
		else if (c == 0)
			rv = 64;
		else if (c >= 0x41 && c <= 0x5A)
			rv = c ^ 0x20;
		else if (c >= 0xC1 && c <= 0xDA)
			rv = c ^ 0x80;
		else
			rv = c;
	}
	return rv;
}

// Assembly:
testl %edi, %edi
je 0xc3d4
movl %edi, %eax
testb %sil, %sil
je 0xc3d7
cmpb $0x1f, %al
jbe 0xc3e2
leal -0x20(%rax), %ecx
cmpb $0x60, %al
movzbl %al, %edx
movzbl %cl, %eax
cmovll %edx, %eax
retq
movb $0x20, %al
retq
cmpb $0x1a, %al
ja 0xc3de
orb $0x60, %al
retq
cmpb $0x1f, %al
ja 0xc3e5
orb $0x40, %al
retq
leal -0x41(%rax), %ecx
cmpb $0x19, %cl
ja 0xc3f0
orb $0x20, %al
retq
leal 0x3f(%rax), %ecx
movzbl %al, %edx
andb $0x5f, %al
cmpb $0x1a, %cl
movzbl %al, %eax
cmovael %edx, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/calmopyrin[P]tedplay/tedplay.cpp
// Function: trimTrailingSpace(char*, unsigned int)
char *trimTrailingSpace(char* str, unsigned int maxSize)
{
	size_t sln = strlen(str);
	size_t actualLen = maxSize < sln ? maxSize : sln;

	// Trim trailing space
	char *end = str + actualLen - 1;
	while (end > str && isspace(*end)) end--;

	// Write new null terminator character
	end[1] = '\0';

	return str;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %rbx
callq 0x30e0
movl %ebp, %ecx
cmpq %rcx, %rax
cmovbq %rax, %rcx
addq %rbx, %rcx
decq %rcx
movq %rcx, %r14
cmpq %rbx, %rcx
jbe 0xc438
movsbl (%r14), %edi
callq 0x3050
leaq -0x1(%r14), %rcx
testl %eax, %eax
jne 0xc41f
movb $0x0, 0x1(%r14)
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq