LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/minigbs.c
// Function: mem_read
static inline uint8_t mem_read(uint16_t addr){
	uint8_t val = mem[addr];

	static uint8_t ortab[] = {
		0x80, 0x3f, 0x00, 0xff, 0xbf,
		0xff, 0x3f, 0x00, 0xff, 0xbf,
		0x7f, 0xff, 0x9f, 0xff, 0xbf,
		0xff, 0xff, 0x00, 0x00, 0xbf,
		0x00, 0x00, 0x70
	};

	if(addr >= 0xFF10 && addr <= 0xFF26){
		val |= ortab[addr - 0xFF10];
	}

	if(cfg.debug_mode){
		switch(addr){
			case 0xFF10 ... 0xFF26: {
				int i = (addr - 0xFF10)/5;
				int j = (addr - 0xFF10)%5;
				debug_msg("Audio read : %4x / NR%1d%1d -> %2x", addr, i+1, j, val);
				break;
			}
			case 0xFF27 ... 0xFF40:
				debug_msg("Audio read : %4x -> %2x", addr, val);
				break;
			case 0xFF04: debug_msg("DIV read: %2x", val); break;
			case 0xFF05: debug_msg("TIMA read: %2x", val); break;
			case 0xFF06: debug_msg("TMA read: %2x", val); break;
			case 0xFF07: debug_msg("TAC read: %2x", val); break;
			case 0xFF0F: debug_msg("IF read: %2x", val); break;
			case 0xFF41: debug_msg("STAT read: %2x", val); break;
			case 0xFF46: debug_msg("DMA read: %2x", val); break;
			case 0xFFFF: debug_msg("IE read: %2x", val); break;
		}
	}

	return val;
}

// Assembly:
pushq %rbx
movl %edi, %esi
movq 0xabca(%rip), %rax      # 0x12440
movl %edi, %ecx
movb (%rax,%rcx), %bl
leal 0xf0(%rsi), %eax
cmpw $0x16, %ax
ja 0x7897
leal -0xff10(%rsi), %eax
leaq 0x494c(%rip), %rcx      # 0xc1e0
orb (%rax,%rcx), %bl
cmpl $0x0, 0xabaa(%rip)      # 0x12448
je 0x796b
movzwl %si, %ecx
leal -0xff04(%rcx), %eax
cmpl $0x42, %eax
ja 0x78fe
leaq 0x47fb(%rip), %rcx      # 0xc0b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %bl, %edx
leaq 0x4bf2(%rip), %rdi      # 0xc4be
xorl %eax, %eax
callq 0x817d
jmp 0x796b
leal -0x10(%rsi), %eax
movzbl %al, %eax
movb $0x5, %cl
divb %cl
movzbl %ah, %ecx
incb %al
movzbl %al, %edx
movzbl %bl, %r8d
leaq 0x4ba6(%rip), %rdi      # 0xc49b
xorl %eax, %eax
callq 0x817d
jmp 0x796b
cmpl $0xffff, %ecx           # imm = 0xFFFF
jne 0x796b
movzbl %bl, %esi
leaq 0x4c29(%rip), %rdi      # 0xc539
jmp 0x7964
movzbl %bl, %esi
leaq 0x4c00(%rip), %rdi      # 0xc51c
jmp 0x7964
movzbl %bl, %esi
leaq 0x4c03(%rip), %rdi      # 0xc52b
jmp 0x7964
movzbl %bl, %esi
leaq 0x4ba2(%rip), %rdi      # 0xc4d6
jmp 0x7964
movzbl %bl, %esi
leaq 0x4ba4(%rip), %rdi      # 0xc4e4
jmp 0x7964
movzbl %bl, %esi
leaq 0x4bc3(%rip), %rdi      # 0xc50f
jmp 0x7964
movzbl %bl, %esi
leaq 0x4b9b(%rip), %rdi      # 0xc4f3
jmp 0x7964
movzbl %bl, %esi
leaq 0x4b9d(%rip), %rdi      # 0xc501
xorl %eax, %eax
callq 0x817d
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/minigbs.c
// Function: config_open
static FILE* config_open(const char* mode){
	const int flags = WRDE_NOCMD | WRDE_UNDEF | WRDE_APPEND;
	wordexp_t w = {};

	wordexp("$XDG_CONFIG_DIR/minigbsrc", &w, flags);
	wordexp("~/.config/minigbsrc"      , &w, flags);

	FILE* config = w.we_wordc > 0 ? fopen(w.we_wordv[0], mode) : NULL;
	wordfree(&w);
	return config;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
movq %rsp, %r14
movaps %xmm0, (%r14)
andq $0x0, 0x10(%r14)
leaq 0x4d5e(%rip), %rdi      # 0xc6ee
pushq $0x26
popq %rbp
movq %r14, %rsi
movl %ebp, %edx
callq 0x5300
leaq 0x4d64(%rip), %rdi      # 0xc708
movq %r14, %rsi
movl %ebp, %edx
callq 0x5300
cmpq $0x0, (%r14)
je 0x79c9
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %rbx, %rsi
callq 0x51d0
movq %rax, %rbx
jmp 0x79cb
xorl %ebx, %ebx
movq %rsp, %rdi
callq 0x5520
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/debug.c
// Function: debug_is_jump
static bool debug_is_jump(uint8_t op){
	const char* str = opcodes[op];
	return strncmp(str, "call", 4) == 0
		|| strncmp(str, "jr", 2) == 0
		|| strncmp(str, "jp", 2) == 0
		|| strncmp(str, "rst", 3) == 0
		|| strncmp(str, "ret", 3) == 0;
}

// Assembly:
pushq %rbx
movl %edi, %eax
leaq 0x948f(%rip), %rcx      # 0x114d0
movq (%rcx,%rax,8), %rbx
leaq 0x4925(%rip), %rsi      # 0xc971
pushq $0x4
popq %rdx
movq %rbx, %rdi
callq 0x51b0
movl %eax, %ecx
movb $0x1, %al
testl %ecx, %ecx
je 0x8099
movzbl (%rbx), %ecx
cmpl $0x72, %ecx
je 0x8078
cmpl $0x6a, %ecx
jne 0x8097
cmpb $0x72, 0x1(%rbx)
je 0x8099
movb $0x70, %al
pushq $0x1
jmp 0x808e
cmpb $0x73, 0x1(%rbx)
jne 0x8084
cmpb $0x74, 0x2(%rbx)
je 0x8099
cmpb $0x65, 0x1(%rbx)
jne 0x8097
movb $0x74, %al
pushq $0x2
popq %rcx
cmpb %al, (%rbx,%rcx)
sete %al
jmp 0x8099
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/debug.c
// Function: debug_print_colour_reg
static void debug_print_colour_reg(uint32_t mask, void* regs, off_t offset){
	int val_colours[2];
	int name_colours[2];

	for(int i = 0; i < 2; ++i){
		uint8_t a = ((uint8_t*)regs)[offset+i];
		uint8_t b = ((uint8_t*)&prev_regs)[offset+i];

		name_colours[i]
			= (mask & reg_by_offset[offset+i].mask)
			? colours[DBG_COLOUR_ACTIVE]
			: colours[DBG_COLOUR_PLAIN]
			;

		val_colours[i]
			= a == b
			? name_colours[i]
			: colours[DBG_COLOUR_CHANGED]
			;
	}

	printf(
		"\e[%dm%s\e[%dm%s\e[0m:\e[%dm%02x\e[%dm%02x\e[0m ",
		name_colours[1],
		reg_by_offset[offset+1].name,
		name_colours[0],
		reg_by_offset[offset].name,
		val_colours[1],
		((uint8_t*)regs)[offset+1],
		val_colours[0],
		((uint8_t*)regs)[offset]
	);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r8
shlq $0x4, %r8
leaq 0x9c1d(%rip), %r9       # 0x11cd0
leaq (%r8,%r9), %rax
addq $0x8, %rax
xorl %ecx, %ecx
leaq 0xa4be(%rip), %r10      # 0x12582
pushq $0x21
popq %r11
pushq $0x24
popq %rbx
movq %rdx, %r14
cmpq $0x8, %rcx
je 0x80fe
movb (%rsi,%r14), %bpl
movl (%rax,%rcx,4), %r15d
andl %edi, %r15d
cmovnel %r11d, %r15d
movl %r15d, 0x8(%rsp,%rcx)
cmpb (%r14,%r10), %bpl
cmovnel %ebx, %r15d
movl %r15d, 0x10(%rsp,%rcx)
addq $0x4, %rcx
incq %r14
jmp 0x80ce
movl 0x8(%rsp), %ecx
movl 0xc(%rsp), %eax
leaq 0x1(%rdx), %rdi
shlq $0x4, %rdi
movq (%rdi,%r9), %r10
movq (%r8,%r9), %r8
movl 0x10(%rsp), %r11d
movl 0x14(%rsp), %r9d
movzbl 0x1(%rsi,%rdx), %ebx
movzbl (%rsi,%rdx), %r14d
subq $0x8, %rsp
leaq 0x486f(%rip), %rdi      # 0xc9a4
movl %eax, %esi
movq %r10, %rdx
xorl %eax, %eax
pushq %r14
pushq %r11
pushq %rbx
callq 0x5050
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/debug.c
// Function: debug_separator
void debug_separator(void){
	if(!cfg.debug_mode)
		return;

	puts("---------------+-----------------------------------------+----------------+-----");

	// XXX: not obvious that the function will do this...
	prev_op = 0;
	prev_len = 0;
}

// Assembly:
leaq 0xa2f0(%rip), %rax      # 0x12448
cmpl $0x0, (%rax)
je 0x817c
pushq %rax
leaq 0x474b(%rip), %rdi      # 0xc8b0
callq 0x5120
movb $0x0, 0xa40f(%rip)      # 0x12580
andl $0x0, 0xa418(%rip)      # 0x12590
addq $0x8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/debug.c
// Function: debug_msg
void debug_msg(const char* fmt, ...){
	if(!cfg.debug_mode)
		return;

	va_list va;
	va_start(va, fmt);

	char msg[39];
	vsnprintf(msg, sizeof(msg), fmt, va);

	if(cfg.debug_mode == 2){
		printf("     \e[0;35m* * *     \e[0m+ \e[0;35m%-39s\e[0m +                +\n", msg);
	} else {
		printf("     * * *     + %-39s +                +\n", msg);
	}

	va_end(va);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xf8, %rsp
testb %al, %al
je 0x81c2
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsi, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
leaq 0xa266(%rip), %r14      # 0x12448
cmpl $0x0, (%r14)
je 0x8246
movq %rdi, %r10
leaq 0x20(%rsp), %rax
movq %rsp, %rcx
movq %rax, 0x10(%rcx)
leaq 0x110(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rcx)
leaq 0xd0(%rsp), %rbx
pushq $0x27
popq %rsi
movq %rbx, %rdi
movq %r10, %rdx
callq 0x5400
cmpl $0x2, (%r14)
leaq 0x46d0(%rip), %rax      # 0xc901
leaq 0x470a(%rip), %rdi      # 0xc942
cmoveq %rax, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x5050
addq $0xf8, %rsp
popq %rbx
popq %r14
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio.c
// Function: chan_enable
void chan_enable(int i, bool enable){
	chans[i].enabled = enable;

	uint8_t val = (mem[0xFF26] & 0x80)
		| (chans[3].enabled << 3)
		| (chans[2].enabled << 2)
		| (chans[1].enabled << 1)
		| (chans[0].enabled << 0);

	mem[0xFF26] = val;
}

// Assembly:
movslq %edi, %rax
imulq $0x70, %rax, %rax
leaq 0xa2a4(%rip), %rcx      # 0x125b0
movb %sil, (%rax,%rcx)
leaq 0xa129(%rip), %rax      # 0x12440
movq (%rax), %rax
movb 0xff26(%rax), %cl
andb $-0x80, %cl
movb 0xa3d7(%rip), %dl       # 0x12700
shlb $0x3, %dl
orb %cl, %dl
movb 0xa35c(%rip), %cl       # 0x12690
shlb $0x2, %cl
orb %dl, %cl
movb 0xa2e1(%rip), %dl       # 0x12620
addb %dl, %dl
orb %cl, %dl
orb 0xa267(%rip), %dl       # 0x125b0
movb %dl, 0xff26(%rax)
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio.c
// Function: update_env
void update_env(struct chan* c){
	c->env.counter += c->env.inc;

	while(c->env.counter > 1.0f){
		if(c->env.step){
			c->volume += c->env.up ? 1 : -1;
			if(c->volume == 0 || c->volume == 15){
				c->env.inc = 0;
			}
			c->volume = MAX(0, MIN(15, c->volume));
		}
		c->env.counter -= 1.0f;
	}
}

// Assembly:
movss 0x3c(%rdi), %xmm0
addss 0x38(%rdi), %xmm0
movss 0x3cfa(%rip), %xmm1     # 0xc05c
movss 0x4f2a(%rip), %xmm2     # 0xd294
pushq $0xf
popq %rax
xorl %ecx, %ecx
ucomiss %xmm1, %xmm0
jbe 0x83a7
cmpl $0x0, 0x30(%rdi)
je 0x83a1
movzbl 0x34(%rdi), %edx
decl %edx
orl $0x1, %edx
addl 0x4(%rdi), %edx
cmpl $0xf, %edx
je 0x838f
testl %edx, %edx
jne 0x8393
andl $0x0, 0x3c(%rdi)
cmpl $0xf, %edx
cmovgel %eax, %edx
testl %edx, %edx
cmovlel %ecx, %edx
movl %edx, 0x4(%rdi)
addss %xmm2, %xmm0
jmp 0x836f
movss %xmm0, 0x38(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio.c
// Function: update_len
void update_len(struct chan* c){
	if(c->len.enabled){
		c->len.counter += c->len.inc;
		if(c->len.counter > 1.0f){
			chan_enable(c - chans, 0);
			c->len.counter = 0.0f;
		}
	}
}

// Assembly:
cmpb $0x1, 0x24(%rdi)
jne 0x83f2
pushq %rbx
movq %rdi, %rbx
movss 0x2c(%rdi), %xmm0
addss 0x28(%rdi), %xmm0
movss %xmm0, 0x28(%rdi)
ucomiss 0x3c8f(%rip), %xmm0     # 0xc05c
jbe 0x83f1
leaq 0xa1da(%rip), %rcx      # 0x125b0
movq %rbx, %rax
subq %rcx, %rax
pushq $0x70
popq %rcx
cqto
idivq %rcx
movl %eax, %edi
xorl %esi, %esi
callq 0x82fe
andl $0x0, 0x28(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio.c
// Function: update_freq
bool update_freq(struct chan* c, float* pos){
	float inc = c->freq_inc - *pos;
	c->freq_counter += inc;

	if(c->freq_counter > 1.0f){
		*pos = c->freq_inc - (c->freq_counter - 1.0f);
		c->freq_counter = 0.0f;
		return true;
	} else {
		*pos = c->freq_inc;
		return false;
	}
}

// Assembly:
movss 0x14(%rdi), %xmm1
movaps %xmm1, %xmm0
subss (%rsi), %xmm0
addss 0x10(%rdi), %xmm0
movss %xmm0, 0x10(%rdi)
ucomiss 0x3c4c(%rip), %xmm0     # 0xc05c
jbe 0x842c
movss 0x4e7a(%rip), %xmm2     # 0xd294
addss %xmm0, %xmm2
subss %xmm2, %xmm1
movss %xmm1, (%rsi)
andl $0x0, 0x10(%rdi)
jmp 0x8430
movss %xmm1, (%rsi)
ucomiss 0x3c25(%rip), %xmm0     # 0xc05c
seta %al
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio.c
// Function: update_sweep
void update_sweep(struct chan* c){
	c->sweep.counter += c->sweep.inc;

	while(c->sweep.counter > 1.0f){
		if(c->sweep.shift){
			uint16_t inc = (c->sweep.freq >> c->sweep.shift);
			if(!c->sweep.up) inc *= -1;

			c->freq = c->sweep.freq + inc;
			if(c->freq > 2047){
				c->enabled = 0;
			} else {
				set_note_freq(c, 4194304.0f / (float)((2048 - c->freq) << 5));
				c->sweep.freq = c->freq;
				c->freq_inc *= 8.0f;
			}
		} else if(c->sweep.rate){
			c->enabled = 0;
		}
		c->sweep.counter -= 1.0f;
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movss 0x54(%rdi), %xmm0
addss 0x50(%rdi), %xmm0
movss 0x3c0b(%rip), %xmm1     # 0xc05c
movss 0x4e3b(%rip), %xmm2     # 0xd294
movss %xmm0, 0x50(%rbx)
ucomiss %xmm1, %xmm0
jbe 0x84f5
movl 0x4c(%rbx), %ecx
testl %ecx, %ecx
je 0x84e3
movzwl 0x40(%rbx), %edx
movl %edx, %esi
shrl %cl, %esi
movl %esi, %eax
negl %eax
cmpb $0x0, 0x48(%rbx)
cmovnel %esi, %eax
addl %edx, %eax
movw %ax, 0xc(%rbx)
cmpw $0x800, %ax             # imm = 0x800
jae 0x84e9
movl $0x800, %ecx            # imm = 0x800
subl %eax, %ecx
movzwl %cx, %eax
shll $0x5, %eax
cvtsi2ss %eax, %xmm1
movss 0x4df2(%rip), %xmm0     # 0xd298
divss %xmm1, %xmm0
movq %rbx, %rdi
callq 0x8275
movss 0x4dda(%rip), %xmm2     # 0xd294
movss 0x3b9a(%rip), %xmm1     # 0xc05c
movzwl 0xc(%rbx), %eax
movw %ax, 0x40(%rbx)
movss 0x14(%rbx), %xmm0
mulss 0x4dc5(%rip), %xmm0     # 0xd29c
movss %xmm0, 0x14(%rbx)
movss 0x50(%rbx), %xmm0
jmp 0x84ec
cmpl $0x0, 0x44(%rbx)
je 0x84ec
movb $0x0, (%rbx)
addss %xmm2, %xmm0
jmp 0x8459
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio.c
// Function: wave_sample
static uint8_t wave_sample(int pos, int volume){
	uint8_t sample = mem[0xFF30 + pos / 2];
	if(pos & 1){
		sample &= 0xF;
	} else {
		sample >>= 4;
	}
	return volume ? (sample >> (volume-1)) : 0;
}

// Assembly:
leaq 0x9b31(%rip), %rax      # 0x12440
movq (%rax), %rcx
pushq $0x2
popq %r8
movl %edi, %eax
cltd
idivl %r8d
cltq
movb 0xff30(%rcx,%rax), %al
movl %eax, %ecx
andb $0xf, %cl
shrb $0x4, %al
testb $0x1, %dil
movzbl %al, %eax
movzbl %cl, %edx
cmovel %eax, %edx
leal -0x1(%rsi), %ecx
movzbl %dl, %edx
shrl %cl, %edx
xorl %eax, %eax
cmpl $0x1, %esi
cmovael %edx, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio.c
// Function: audio_reset
void audio_reset(void){
	memset(chans, 0, sizeof(chans));
	memset(samples, 0, nsamples * sizeof(float));
	sample_ptr = samples;
	sample_end = samples + nsamples;
	chans[0].val = chans[1].val = -1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
leaq 0x99f8(%rip), %rdi      # 0x125b0
movl $0x1c0, %edx            # imm = 0x1C0
xorl %esi, %esi
callq 0x5080
movq 0x9bb5(%rip), %rbx      # 0x12780
movq 0x9b9e(%rip), %r14      # 0x12770
leaq (,%r14,4), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5080
movq %rbx, 0x9ba5(%rip)      # 0x12790
leaq (%rbx,%r14,4), %rax
orl $-0x1, 0x9a42(%rip)     # 0x12638
movq %rax, 0x9b9b(%rip)      # 0x12798
orl $-0x1, 0x99c4(%rip)     # 0x125c8
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio.c
// Function: audio_init
int audio_init(struct pollfd** fds, int nfds){
	pcm_period_size = audio_output_init(fds, &nfds, FREQ);

	logbase = log(1.059463094f);
	charge_factor = pow(0.999958, 4194304.0 / FREQ);

	audio_update_rate();

	return nfds;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
leaq 0xc(%rsp), %rbx
movl %esi, (%rbx)
movss 0x4379(%rip), %xmm0     # 0xd28c
movq %rbx, %rsi
callq 0x9610
movw %ax, 0x988e(%rip)       # 0x127b0
movl $0x3d6c982c, 0x9678(%rip) # imm = 0x3D6C982C
movl $0x3f7f0feb, 0x966a(%rip) # imm = 0x3F7F0FEB
callq 0x8f43
movl (%rbx), %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio.c
// Function: audio_update_rate
void audio_update_rate(void){
	audio_rate = 59.7f;

	uint8_t tma = mem[0xff06];
	uint8_t tac = mem[0xff07];

	if(tac & 0x04){
		int rates[] = { 4096, 262144, 65536, 16384 };
		audio_rate = rates[tac & 0x03] / (float)(256 - tma);
		if(tac & 0x80) audio_rate *= 2.0f;
	}

	audio_rate *= cfg.speed;

	debug_msg("Audio rate changed: %.4f", audio_rate);

	size_t new_nsamples = (int)(FREQ / audio_rate) * 2;
	float* new_samples = calloc(new_nsamples, sizeof(float));

	if(samples){
		memcpy(new_samples, samples, MIN(nsamples, new_nsamples));
	}

	free(samples);
	samples    = new_samples;
	nsamples   = new_nsamples;

	free(samples_tmp);
	samples_tmp = calloc(nsamples, sizeof(float));

	// TODO: these should really be adjusted more accurately to not lose samples on speed change
	sample_ptr = samples;
	sample_end = samples + nsamples;
}

// Assembly:
leaq 0x94f6(%rip), %rax      # 0x12440
movq (%rax), %rcx
movzbl 0xff07(%rcx), %eax
testb $0x4, %al
jne 0x8f62
movss 0x4350(%rip), %xmm0     # 0xd2b0
jmp 0x8f91
movzbl 0xff06(%rcx), %ecx
movl %eax, %edx
andl $0x3, %edx
leaq 0x436b(%rip), %rsi      # 0xd2e0
cvtsi2ssl (%rsi,%rdx,4), %xmm0
movl $0x100, %edx            # imm = 0x100
subl %ecx, %edx
cvtsi2ss %edx, %xmm1
divss %xmm1, %xmm0
testb %al, %al
jns 0x8f91
addss %xmm0, %xmm0
pushq %r15
pushq %r14
pushq %rbx
leaq 0x94ab(%rip), %rax      # 0x12448
mulss 0x20(%rax), %xmm0
movss %xmm0, 0x9816(%rip)     # 0x127c0
cvtss2sd %xmm0, %xmm0
leaq 0x43f3(%rip), %rdi      # 0xd3a8
movb $0x1, %al
callq 0x817d
movss 0x42c8(%rip), %xmm0     # 0xd28c
divss 0x97f4(%rip), %xmm0     # 0x127c0
cvttss2si %xmm0, %eax
addl %eax, %eax
movslq %eax, %rbx
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x54a0
movq %rax, %r14
movq 0x9796(%rip), %r15      # 0x12780
testq %r15, %r15
je 0x9008
movq 0x977a(%rip), %rdx      # 0x12770
cmpq %rbx, %rdx
cmovaeq %rbx, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x55b0
movq %r15, %rdi
callq 0x5250
movq %r14, 0x9769(%rip)      # 0x12780
movq %rbx, 0x9752(%rip)      # 0x12770
movq 0x9793(%rip), %rdi      # 0x127b8
callq 0x5250
pushq $0x4
popq %rsi
movq %rbx, %rdi
callq 0x54a0
movq %rax, 0x977c(%rip)      # 0x127b8
movq %r14, 0x974d(%rip)      # 0x12790
leaq (%r14,%rbx,4), %rax
movq %rax, 0x974a(%rip)      # 0x12798
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio.c
// Function: audio_get_notes
void audio_get_notes(uint16_t notes[static 4]){
	for(int i = 0; i < 4; ++i){
		if(chan_muted(chans + i)){
			notes[i] = 0xffff;
		} else {
			notes[i] = chans[i].note;
		}
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x9548(%rip), %r14      # 0x125b0
xorl %r15d, %r15d
cmpq $0x4, %r15
je 0x9094
movq %r14, %rdi
callq 0x82b8
movw $0xffff, %cx            # imm = 0xFFFF
testb %al, %al
jne 0x9086
movzwl 0x1c(%r14), %ecx
movw %cx, (%rbx,%r15,2)
incq %r15
addq $0x70, %r14
jmp 0x906b
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio.c
// Function: audio_get_vol
void audio_get_vol(uint8_t vol[static 8]){
	for(int i = 0; i < 4; ++i){
		vol[i*2+0] = chans[i].volume * chans[i].on_left;
		vol[i*2+1] = chans[i].volume * chans[i].on_right;
	}

	int ch3_hi = 0, ch3_lo = 0xf;
	for(uint8_t* p = mem + 0xFF30; p < mem + 0xFF40; ++p){
		uint8_t a = *p >> 4, b = *p & 0xF;
		ch3_lo = MIN(ch3_lo, MIN(a, b));
		ch3_hi = MAX(ch3_hi, MAX(a, b));
	}

	float ch3_v = (ch3_hi - ch3_lo) / 15.0f;

	if(vol[4]) vol[4] = 5*(4-vol[4]) * ch3_v;
	if(vol[5]) vol[5] = 5*(4-vol[5]) * ch3_v;
}

// Assembly:
leaq 0x9513(%rip), %rcx      # 0x125b4
xorl %edx, %edx
cmpq $0x4, %rdx
je 0x90c3
movb -0x2(%rcx), %al
mulb (%rcx)
movb %al, (%rdi,%rdx,2)
movb -0x1(%rcx), %al
mulb (%rcx)
movb %al, 0x1(%rdi,%rdx,2)
incq %rdx
addq $0x70, %rcx
jmp 0x90a3
leaq 0x9376(%rip), %rax      # 0x12440
movq (%rax), %rcx
xorl %edx, %edx
pushq $0xf
popq %rax
xorl %esi, %esi
cmpq $0x10, %rdx
je 0x910f
movzbl 0xff30(%rcx,%rdx), %r8d
movl %r8d, %r9d
shrl $0x4, %r9d
andl $0xf, %r8d
cmpl %r8d, %r9d
movl %r8d, %r10d
cmovbl %r9d, %r10d
cmoval %r9d, %r8d
cmpl %r10d, %eax
cmovgel %r10d, %eax
cmpl %r8d, %esi
cmovlel %r8d, %esi
incq %rdx
jmp 0x90d4
subl %eax, %esi
cvtsi2ss %esi, %xmm0
divss 0x4183(%rip), %xmm0     # 0xd2a0
movzbl 0x4(%rdi), %ecx
pushq $0x4
popq %rax
testl %ecx, %ecx
je 0x913e
movl %eax, %edx
subl %ecx, %edx
leal (%rdx,%rdx,4), %ecx
cvtsi2ss %ecx, %xmm1
mulss %xmm0, %xmm1
cvttss2si %xmm1, %ecx
movb %cl, 0x4(%rdi)
movzbl 0x5(%rdi), %ecx
testl %ecx, %ecx
je 0x915a
subl %ecx, %eax
leal (%rax,%rax,4), %eax
cvtsi2ss %eax, %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movb %al, 0x5(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio.c
// Function: chan_trigger
void chan_trigger(int i){
	struct chan* c = chans + i;

	if(cfg.debug_mode){
		static const char* cname[] = { "sq1", "sq2", "wave", "noise" };
		debug_msg("Trigger %s", cname[i]);
	}

	chan_enable(i, 1);
	c->volume = c->volume_init;

	// volume envelope
	{
		uint8_t val = mem[0xFF12 + (i*5)];

		c->env.step    = val & 0x07;
		c->env.up      = val & 0x08;
		c->env.inc     = c->env.step ? (64.0f / (float)c->env.step) / FREQ : 8.0f / FREQ;
		c->env.counter = 0.0f;
	}

	// freq sweep
	if(i == 0){
		uint8_t val = mem[0xFF10];

		c->sweep.freq    = c->freq;
		c->sweep.rate    = (val >> 4) & 0x07;
		c->sweep.up      = !(val & 0x08);
		c->sweep.shift   = (val & 0x07);
		c->sweep.inc     = c->sweep.rate ? (128.0f / (float)(c->sweep.rate)) / FREQ : 0;
		c->sweep.counter = nexttowardf(1.0f, 1.1f);
	}

	if(i == 2){ // wave
		c->val = 0;
	} else if(i == 3){ // noise
		c->lfsr_reg = 0xFFFF;
		c->val = -1;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edi, %ebx
movslq %edi, %r14
imulq $0x70, %r14, %rax
leaq 0x943c(%rip), %r15      # 0x125b0
addq %rax, %r15
leaq 0x92ca(%rip), %rax      # 0x12448
cmpl $0x0, (%rax)
je 0x919f
leaq 0x420e(%rip), %rax      # 0xd398
movslq (%rax,%r14,4), %rsi
addq %rax, %rsi
leaq 0x423c(%rip), %rdi      # 0xd3d4
xorl %eax, %eax
callq 0x817d
pushq $0x1
popq %rsi
movl %r14d, %edi
callq 0x82fe
movl 0x8(%r15), %eax
movl %eax, 0x4(%r15)
leaq 0x9287(%rip), %rax      # 0x12440
movq (%rax), %rax
leaq (%r14,%r14,4), %rcx
movzbl 0xff12(%rax,%rcx), %edx
movl %edx, %ecx
andl $0x7, %ecx
movl %ecx, 0x30(%r15)
shrb $0x3, %dl
andb $0x1, %dl
movb %dl, 0x34(%r15)
testl %ecx, %ecx
je 0x91f9
cvtsi2ss %ecx, %xmm1
movss 0x40c9(%rip), %xmm0     # 0xd2b4
divss %xmm1, %xmm0
divss 0x4095(%rip), %xmm0     # 0xd28c
jmp 0x9201
movss 0x40b7(%rip), %xmm0     # 0xd2b8
movss %xmm0, 0x3c(%r15)
andl $0x0, 0x38(%r15)
cmpl $0x3, %ebx
je 0x9298
cmpl $0x2, %ebx
je 0x9291
testl %ebx, %ebx
jne 0x92a3
movzbl 0xff10(%rax), %ecx
movzwl 0xc(%r15), %eax
movw %ax, 0x40(%r15)
movl %ecx, %eax
shrl $0x4, %eax
andl $0x7, %eax
movl %eax, 0x44(%r15)
testb $0x8, %cl
sete 0x48(%r15)
andl $0x7, %ecx
movl %ecx, 0x4c(%r15)
xorps %xmm0, %xmm0
testl %eax, %eax
je 0x926d
cvtsi2ss %eax, %xmm1
movss 0x405b(%rip), %xmm0     # 0xd2bc
divss %xmm1, %xmm0
divss 0x401f(%rip), %xmm0     # 0xd28c
movss %xmm0, 0x54(%r15)
flds 0x4047(%rip)            # 0xd2c0
fstpt (%rsp)
movss 0x2dd8(%rip), %xmm0     # 0xc05c
callq 0x5370
movss %xmm0, 0x50(%r15)
jmp 0x92a3
andl $0x0, 0x18(%r15)
jmp 0x92a3
orw $-0x1, 0x64(%r15)
orl $-0x1, 0x18(%r15)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio.c
// Function: chan_update_len
void chan_update_len(int i) {
	struct chan* c = chans + i;
	int len_max = i == 2 ? 256 : 64;
	c->len.inc = (256.0f / (float)(len_max - c->len.load)) / FREQ;
	c->len.counter = 0.0f;
}

// Assembly:
movslq %edi, %rax
cmpl $0x2, %eax
movl $0x100, %ecx            # imm = 0x100
pushq $0x40
popq %rdx
cmovel %ecx, %edx
imulq $0x70, %rax, %rax
leaq 0x92e7(%rip), %rcx      # 0x125b0
subl 0x20(%rax,%rcx), %edx
cvtsi2ss %edx, %xmm0
movss 0x3feb(%rip), %xmm1     # 0xd2c4
divss %xmm0, %xmm1
divss 0x3fa7(%rip), %xmm1     # 0xd28c
movss %xmm1, 0x2c(%rax,%rcx)
andl $0x0, 0x28(%rax,%rcx)
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio_output.c
// Function: alsa_init
static uint16_t alsa_init(struct audio_output* out, struct pollfd** fds, int* nfds, float freq) {
	struct audio_alsa* alsa = (struct audio_alsa*)out;

	snd_pcm_open(&alsa->pcm, "default", SND_PCM_STREAM_PLAYBACK, 0);
	snd_pcm_set_params(alsa->pcm, SND_PCM_FORMAT_FLOAT, SND_PCM_ACCESS_RW_INTERLEAVED, 2, freq, 1, 16667);
	snd_pcm_get_params(alsa->pcm, &alsa->pcm_buffer_size, &alsa->pcm_period_size);

	int count = snd_pcm_poll_descriptors_count(alsa->pcm);
	*fds = realloc(*fds, (*nfds + count) * sizeof(struct pollfd));
	snd_pcm_poll_descriptors(alsa->pcm, (*fds) + *nfds, count);

	*nfds += count;

	return alsa->pcm_period_size;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movss %xmm0, 0x14(%rsp)
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
addq $0x30, %rdi
leaq 0x3dd6(%rip), %rsi      # 0xd44c
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x5230
movq 0x30(%r14), %rdi
cvttss2si 0x14(%rsp), %r8
movl $0x411b, (%rsp)         # imm = 0x411B
pushq $0xe
popq %rsi
pushq $0x3
popq %rdx
pushq $0x2
popq %rcx
pushq $0x1
popq %r9
callq 0x5390
movq 0x30(%r14), %rdi
leaq 0x38(%r14), %rsi
leaq 0x40(%r14), %rdx
callq 0x5240
movq 0x30(%r14), %rdi
callq 0x5550
movq (%r15), %rdi
movslq (%rbx), %rsi
movslq %eax, %r12
addq %r12, %rsi
shlq $0x3, %rsi
callq 0x5530
movq %rax, (%r15)
movq 0x30(%r14), %rdi
movslq (%rbx), %rcx
leaq (%rax,%rcx,8), %rsi
movl %r12d, %edx
callq 0x5470
addl %r12d, (%rbx)
movzwl 0x40(%r14), %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio_output.c
// Function: alsa_write
static void alsa_write(struct audio_output* out, const float* samples, uint16_t period_size) {
	struct audio_alsa* alsa = (struct audio_alsa*)out;

	int err = snd_pcm_writei(alsa->pcm, samples, period_size);
	if(err < 0){
		snd_pcm_recover(alsa->pcm, err, 1);
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x30(%rdi), %rdi
movl %edx, %edx
callq 0x52f0
testl %eax, %eax
js 0x973f
popq %rbx
retq
movq 0x30(%rbx), %rdi
pushq $0x1
popq %rdx
movl %eax, %esi
popq %rbx
jmp 0x5290
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/audio_output.c
// Function: wav_init
static uint16_t wav_init(struct audio_output* out, struct pollfd** fds, int* nfds, float freq) {
	struct audio_wav* wav = (struct audio_wav*)out;
	wav->writer = wav_write_begin(wav->output.filename, freq);
	if(!wav->writer) {
		fprintf(stderr, "Error opening .wav file\n");
		exit(1);
	}

	wav->eventfd = eventfd(1, 0);

	*fds = realloc(*fds, (*nfds + 1) * sizeof(struct pollfd));
	(*fds)[*nfds] = (struct pollfd){
		.fd = wav->eventfd,
		.events = POLLIN,
	};
	*nfds += 1;

	return freq / 60;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq 0x28(%rdi), %rdi
movss %xmm0, 0xc(%rsp)
cvttss2si %xmm0, %rsi
callq 0x9810
movq %rax, 0x30(%r14)
testq %rax, %rax
je 0x97d4
pushq $0x1
popq %rdi
xorl %esi, %esi
callq 0x5200
movl %eax, 0x38(%r14)
movq (%r15), %rdi
movslq (%rbx), %rax
leaq 0x8(,%rax,8), %rsi
callq 0x5530
movq %rax, (%r15)
movslq (%rbx), %rcx
movl 0x38(%r14), %edx
movl %edx, (%rax,%rcx,8)
movl $0x1, 0x4(%rax,%rcx,8)
leal 0x1(%rcx), %eax
movss 0xc(%rsp), %xmm0
divss 0x3c84(%rip), %xmm0     # 0xd448
movl %eax, (%rbx)
cvttss2si %xmm0, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0x880d(%rip), %rax      # 0x11fe8
movq (%rax), %rcx
leaq 0x3c6f(%rip), %rdi      # 0xd454
pushq $0x18
popq %rsi
pushq $0x1
popq %rdx
callq 0x5510
pushq $0x1
popq %rdi
callq 0x5150
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/wav_write.c
// Function: wav_write_begin
struct wav_writer* wav_write_begin(const char* filename, uint32_t freq) {
	struct wav_writer* wav = calloc(1, sizeof(struct wav_writer));

	*wav = (struct wav_writer){
		.header = {
			.riff_magic = "RIFF",
			.wave_magic = "WAVE",
			.fmt_magic  = "fmt ",
			.fmt_size   = 16,
			.format     = 3,
			.nchannels  = 2,
			.sample_rate = freq,
			.byte_rate = freq * 2 * sizeof(float),
			.block_align = 2 * sizeof(float),
			.bits_per_sample = sizeof(float) * 8,
			.data_magic = "data",
		},
	};

	wav->file = fopen(filename, "w");
	if(!wav->file) {
		fprintf(stderr, "fopen(%s): %m\n", filename);
		return NULL;
	}

	fwrite(&wav->header, sizeof(wav->header), 1, wav->file);

	return wav;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movq %rdi, %r14
pushq $0x1
popq %rdi
pushq $0x40
popq %rsi
callq 0x54a0
movq %rax, %rbx
movl $0x46464952, (%rax)     # imm = 0x46464952
movabsq $0x20746d6645564157, %rax # imm = 0x20746D6645564157
movq %rax, 0x8(%rbx)
movabsq $0x2000300000010, %rax  # imm = 0x2000300000010
movq %rax, 0x10(%rbx)
movl %ebp, 0x18(%rbx)
shll $0x3, %ebp
movl %ebp, 0x1c(%rbx)
movabsq $0x6174616400200008, %rax # imm = 0x6174616400200008
movq %rax, 0x20(%rbx)
leaq 0x3f88(%rip), %rsi      # 0xd7ef
movq %r14, %rdi
callq 0x51d0
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0x9891
pushq $0x2c
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %rax, %rcx
callq 0x5510
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
movq 0x8750(%rip), %rax      # 0x11fe8
movq (%rax), %rdi
leaq 0x3bcb(%rip), %rsi      # 0xd46d
xorl %ebx, %ebx
movq %r14, %rdx
xorl %eax, %eax
callq 0x5580
jmp 0x9889
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/wav_write.c
// Function: wav_write_end
void wav_write_end(struct wav_writer* wav) {

	uint32_t size = 36 + wav->data_size;
	fseek(wav->file, 4, SEEK_SET);
	fwrite(&size, 4, 1, wav->file);

	fseek(wav->file, 40, SEEK_SET);
	fwrite(&wav->data_size, 4, 1, wav->file);

	fflush(wav->file);
	fclose(wav->file);

	free(wav);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x38(%rdi), %r14
movl 0x38(%rdi), %eax
addl $0x24, %eax
leaq 0xc(%rsp), %r15
movl %eax, (%r15)
movq 0x30(%rdi), %rdi
pushq $0x4
popq %r12
movq %r12, %rsi
xorl %edx, %edx
callq 0x5130
movq 0x30(%rbx), %rcx
pushq $0x1
popq %r13
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x5510
movq 0x30(%rbx), %rdi
pushq $0x28
popq %rsi
xorl %edx, %edx
callq 0x5130
movq 0x30(%rbx), %rcx
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x5510
movq 0x30(%rbx), %rdi
callq 0x55d0
movq 0x30(%rbx), %rdi
callq 0x54c0
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x5250
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/ui.c
// Function: ui_chart_set
void ui_chart_set(uint16_t notes[static 3]){
	if(++col >= &grid[0] + GRID_W){
		col = &grid[0];
	}

	memset(col, 0, sizeof(*col));

	for(int i = 0; i < 3; ++i){
		int n = notes[i] - 5;
		if(n < 0 || n >= GRID_H) continue;
		
		(*col)[n] |= (1 << i);
	}
}

// Assembly:
movq 0x8a39(%rip), %rcx      # 0x123a0
addq $0x3c, %rcx
leaq 0x8e5e(%rip), %rax      # 0x127d0
leaq 0x9c67(%rip), %rdx      # 0x135e0
cmpq %rdx, %rcx
cmovbq %rcx, %rax
movq %rax, 0x8a19(%rip)      # 0x123a0
xorps %xmm0, %xmm0
movups %xmm0, 0x2c(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
xorl %ecx, %ecx
pushq $0x1
popq %rdx
cmpq $0x3, %rcx
je 0x99c5
movzwl (%rdi,%rcx,2), %esi
leal -0x41(%rsi), %r8d
cmpw $-0x3c, %r8w
jb 0x99c0
movl %edx, %r8d
shll %cl, %r8d
addl $-0x5, %esi
orb %r8b, (%rax,%rsi)
incq %rcx
jmp 0x999e
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/ui.c
// Function: ui_msg_set
void ui_msg_set(const char* fmt, ...){
	va_list va;
	va_start(va, fmt);

	vsnprintf(msg, sizeof(msg), fmt, va);

	msg_timer = 20;
	va_end(va);
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, %r10
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x9a24
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %rcx
movq %rdi, 0x10(%rcx)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rcx)
leaq 0x9b95(%rip), %rdi      # 0x135e0
movl $0x80, %esi
movq %r10, %rdx
callq 0x5400
movl $0x14, 0x9bfe(%rip)     # 0x13660
addq $0xd8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/ui.c
// Function: ui_osc_draw
void ui_osc_draw(int chan, float* samples, size_t count){
	struct osc_chan* c = osc_chans + chan;

	count /= 2;

	if(count > OSC_SAMPLES){
		samples += 2 * (count - OSC_SAMPLES);
		count = OSC_SAMPLES;
	}

	size_t copy_count = OSC_SAMPLES - count;
	memmove(c->samples, c->samples + count, copy_count * sizeof(float));

	for(size_t i = 0; i < count; ++i){
		float s = ((samples[i*2] + samples[i*2+1]) / 2.0f);// * 1.2f * height;
		c->samples[copy_count + i] = s;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movslq %edi, %rax
imulq $0x1900, %rax, %rbx     # imm = 0x1900
leaq 0x9aed(%rip), %r14      # 0x13730
leaq (%r14,%rbx), %rdi
movq %rdx, %rax
shrq %rax
movabsq $0x3ffffffffffffffe, %rcx # imm = 0x3FFFFFFFFFFFFFFE
andq %rdx, %rcx
cmpq $0xc82, %rdx            # imm = 0xC82
leaq -0x3200(%rsi,%rcx,4), %r15
movl $0x640, %r12d           # imm = 0x640
cmovbq %rax, %r12
cmovbq %rsi, %r15
movl $0x640, %edx            # imm = 0x640
subl %r12d, %edx
leaq (%rdi,%r12,4), %rsi
shll $0x2, %edx
callq 0x53e0
leaq (,%r12,4), %rax
subq %rax, %rbx
addq $0x1900, %rbx           # imm = 0x1900
xorl %eax, %eax
movss 0x37d5(%rip), %xmm0     # 0xd47c
cmpq %rax, %r12
je 0x9ccc
movss (%r15,%rax,8), %xmm1
addss 0x4(%r15,%rax,8), %xmm1
mulss %xmm0, %xmm1
leaq (%rbx,%rax,4), %rcx
movss %xmm1, (%r14,%rcx)
incq %rax
jmp 0x9ca7
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/ui.c
// Function: ui_cmd
int ui_cmd(int key){
	int result = -1;

	if(cfg.hide_ui)
		return result;

	switch(key){
		case '\n': {
			if(ui_in_cmd_mode && *input){
				result = atoi(input);
			}
			input_ptr = input;
			*input = 0;
			ui_in_cmd_mode = !ui_in_cmd_mode;
			move(cfg.win_h-1, 0);
			clrtoeol();
		} break;

		case KEY_BACKSPACE: {
			if(input_ptr != input){
				*--input_ptr = 0;
			}
		} break;

		default: {
			if(input_ptr - input < sizeof(input)){
				*input_ptr++ = key;
				*input_ptr = 0;
			}
		} break;
	}

	return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0x7c23(%rip), %r14      # 0x12448
pushq $-0x1
popq %rbx
cmpb $0x0, 0x5(%r14)
jne 0xa8f9
cmpl $0x107, %edi            # imm = 0x107
je 0xa8a9
cmpl $0xa, %edi
jne 0xa8cd
movb 0xf2e5(%rip), %bpl      # 0x19b30
cmpb $0x1, %bpl
jne 0xa868
cmpb $0x0, 0xf2e8(%rip)      # 0x19b40
je 0xa868
leaq 0xf2df(%rip), %rdi      # 0x19b40
callq 0x53b0
movl %eax, %ebx
leaq 0xf2d1(%rip), %rax      # 0x19b40
movq %rax, 0x7b32(%rip)      # 0x123a8
movb $0x0, 0xf2c3(%rip)      # 0x19b40
xorb $0x1, %bpl
movb %bpl, 0xf2a8(%rip)      # 0x19b30
movq 0x7741(%rip), %r15      # 0x11fd0
movq (%r15), %rdi
movl 0x2c(%r14), %esi
decl %esi
xorl %edx, %edx
callq 0x5210
movq (%r15), %rdi
callq 0x5220
jmp 0xa8f9
movq 0x7af8(%rip), %rax      # 0x123a8
leaq 0xf289(%rip), %rcx      # 0x19b40
cmpq %rcx, %rax
je 0xa8f9
leaq -0x1(%rax), %rcx
movq %rcx, 0x7ae1(%rip)      # 0x123a8
movb $0x0, -0x1(%rax)
jmp 0xa8f9
movq 0x7ad4(%rip), %rax      # 0x123a8
leaq 0xf265(%rip), %rcx      # 0x19b40
movq %rax, %rdx
subq %rcx, %rdx
cmpq $0x1f, %rdx
ja 0xa8f9
leaq 0x1(%rax), %rcx
movq %rcx, 0x7ab6(%rip)      # 0x123a8
movb %dil, (%rax)
movb $0x0, 0x1(%rax)
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/x11.c
// Function: x11_action
int x11_action(bool* have_more_events){
	if(!x11_win || !x11.pending(x11_dpy)){
		*have_more_events = false;
		return -1;
	}

	XEvent ev;
	x11.next_event(x11_dpy, &ev);

	if(ev.type == KeyPress){
		KeySym sym = x11.lookup_key(&ev.xkey, 0);

		switch(sym){
			case XK_Escape:
			case XK_q:
				return 'o';
			case XK_BackSpace:
				return KEY_BACKSPACE;
			case XK_Up:
				return KEY_UP;
			case XK_Down:
				return KEY_DOWN;
			case XK_Left:
				return KEY_LEFT;
			case XK_Right:
				return KEY_RIGHT;
			case XK_Return:
				return '\n';
			case XK_c:
				if(ev.xkey.state & ControlMask){
					return 'q';
				}
			default:
				return sym;
		}
	}

	if(ev.type == ClientMessage && ev.xclient.data.l[0] == x11_atom_wm_delete){
		x11.unmap_window(x11_dpy, x11_win);
		x11_visible = false;
	}

	return -1;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xc8, %rsp
movq %rdi, %rbx
cmpq $0x0, 0xed7b(%rip)      # 0x19c10
je 0xaf1d
movq 0xed66(%rip), %rdi      # 0x19c08
callq *0xed30(%rip)           # 0x19bd8
testl %eax, %eax
je 0xaf1d
movq 0xed55(%rip), %rdi      # 0x19c08
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq *0xed1f(%rip)           # 0x19be0
pushq $-0x1
popq %rbx
movl (%r14), %eax
cmpl $0x21, %eax
je 0xaf30
cmpl $0x2, %eax
jne 0xaf23
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
callq *0xed0a(%rip)           # 0x19be8
leaq -0xff51(%rax), %rcx
cmpq $0x3, %rcx
jbe 0xaf5b
cmpq $0x63, %rax
je 0xaf7d
pushq $0x6f
popq %rbx
cmpq $0x71, %rax
je 0xaf23
cmpq $0xff1b, %rax           # imm = 0xFF1B
je 0xaf23
cmpq $0xff0d, %rax           # imm = 0xFF0D
je 0xaf72
cmpq $0xff08, %rax           # imm = 0xFF08
jne 0xaf84
movl $0x107, %ebx            # imm = 0x107
jmp 0xaf23
movb $0x0, (%rbx)
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0xc8, %rsp
popq %rbx
popq %r14
retq
movq 0x40(%rsp), %rax
cmpq 0xecfc(%rip), %rax      # 0x19c38
jne 0xaf23
movq 0xecc3(%rip), %rdi      # 0x19c08
movq 0xecc4(%rip), %rsi      # 0x19c10
callq *0xec36(%rip)           # 0x19b88
movb $0x0, 0xece7(%rip)      # 0x19c40
jmp 0xaf23
leaq 0x27da(%rip), %rax      # 0xd73c
movslq (%rax,%rcx,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movl $0x104, %ebx            # imm = 0x104
jmp 0xaf23
pushq $0xa
jmp 0xaf22
movl $0x105, %ebx            # imm = 0x105
jmp 0xaf23
testb $0x4, 0x58(%rsp)
jne 0xaf96
movl %eax, %ebx
jmp 0xaf23
movl $0x102, %ebx            # imm = 0x102
jmp 0xaf23
movl $0x103, %ebx            # imm = 0x103
jmp 0xaf23
pushq $0x71
jmp 0xaf22
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/x11.c
// Function: x11_draw_end
void x11_draw_end(void){
	if(!x11_win || !x11_visible) return;

	struct present_pixmap_req* req = x11.get_request(x11_dpy, x11_present_op, sizeof(*req));
	memset(req->crap, 0, sizeof(req->crap));
	req->subtype = 1;
	req->window = x11_win;
	req->pixmap = x11_pix;

	if(x11_dpy->synchandler)
		x11_dpy->synchandler(x11_dpy);

	x11.flush(x11_dpy);
}

// Assembly:
pushq %rax
cmpq $0x0, 0xebec(%rip)      # 0x19c10
je 0xb092
cmpb $0x1, 0xec13(%rip)      # 0x19c40
jne 0xb092
movq 0xebd2(%rip), %rdi      # 0x19c08
movzbl 0xebdb(%rip), %esi      # 0x19c18
pushq $0x48
popq %rdx
callq *0xebba(%rip)           # 0x19c00
xorps %xmm0, %xmm0
movups %xmm0, 0xc(%rax)
movups %xmm0, 0x1c(%rax)
movups %xmm0, 0x2c(%rax)
movups %xmm0, 0x38(%rax)
movb $0x1, 0x1(%rax)
movl 0xebad(%rip), %ecx      # 0x19c10
movl %ecx, 0x4(%rax)
movl 0xebb4(%rip), %ecx      # 0x19c20
movl %ecx, 0x8(%rax)
movq 0xeb92(%rip), %rdi      # 0x19c08
movq 0xd0(%rdi), %rax
testq %rax, %rax
je 0xb08b
callq *%rax
movq 0xeb7d(%rip), %rdi      # 0x19c08
popq %rax
jmpq *0xeb36(%rip)           # 0x19bc8
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/baines[P]MiniGBS/x11.c
// Function: x11_toggle
void x11_toggle(void){
	if(!x11_win) return;

	if(x11_visible){
		x11.unmap_window(x11_dpy, x11_win);
	} else {
		x11.map_window(x11_dpy, x11_win);
	}

	x11_visible = !x11_visible;
	x11.flush(x11_dpy);
}

// Assembly:
pushq %rax
movq 0xeb74(%rip), %rsi      # 0x19c10
testq %rsi, %rsi
je 0xb0cf
movzbl 0xeb98(%rip), %eax      # 0x19c40
movq 0xeb59(%rip), %rdi      # 0x19c08
leaq 0xeaba(%rip), %rcx      # 0x19b70
callq *0x10(%rcx,%rax,8)
xorb $0x1, 0xeb7f(%rip)      # 0x19c40
movq 0xeb40(%rip), %rdi      # 0x19c08
popq %rax
jmpq *0xeaf9(%rip)           # 0x19bc8
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/s3lase[P]v6shell/if.c
// Function: main
int
main(int argc, char **argv)
{
	bool re;		/* return value of expr() */

	setmyerrexit(&ut_errexit);
	setmyname(argv[0]);
	setmypid(getpid());

	ifeuid = geteuid();

	/*
	 * Set-ID execution is not supported.
	 */
	if (ifeuid != getuid() || getegid() != getgid())
		err(FC_ERR, FMT2S, getmyname(), ERR_SETID);

	(void)sasignal(SIGCHLD, SIG_DFL);

	if (argc > 1) {
		ac = argc;
		av = argv;
		ap = 1;
		re = expr();
		if (re && ap < ac)
			doex(!FORKED);
	} else
		re = false;

	return re ? SH_TRUE : SH_FALSE;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movl %edi, %ebp
leaq 0xc76(%rip), %rdi       # 0x1fb2
callq 0x1f42
movq (%rbx), %rdi
callq 0x1f4f
callq 0x10d0
movl %eax, %edi
callq 0x1fa1
callq 0x1140
movl %eax, %r14d
movl %eax, 0x3dd5(%rip)      # 0x5138
callq 0x10f0
cmpl %eax, %r14d
jne 0x137f
callq 0x11d0
movl %eax, %r14d
callq 0x11b0
cmpl %eax, %r14d
je 0x139f
callq 0x1f1d
leaq 0x1d9e(%rip), %rsi      # 0x3129
leaq 0x1d75(%rip), %rcx      # 0x3107
pushq $0x7c
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1ce0
pushq $0x11
popq %rdi
xorl %esi, %esi
callq 0x24b0
pushq $0x1
popq %r14
cmpl $0x2, %ebp
jl 0x13ed
movl %ebp, 0x3d84(%rip)      # 0x513c
movq %rbx, 0x3d81(%rip)      # 0x5140
movl $0x1, 0x3d7f(%rip)      # 0x5148
callq 0x13f5
testb %al, %al
je 0x13ed
movl 0x3d70(%rip), %eax      # 0x5148
xorl %r14d, %r14d
cmpl 0x3d5b(%rip), %eax      # 0x513c
jge 0x13ed
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x1499
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/s3lase[P]v6shell/if.c
// Function: expr
static bool
expr(void)
{
	bool re;

	re = e1();
	if (equal(nxtarg(RETERR), "-o"))
		return re | expr();
	ap--;
	return re;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %ebx, %ebx
pushq $0x1
popq %rbp
leaq 0x1e9a(%rip), %r14      # 0x32a6
leaq 0x1d0f(%rip), %r15      # 0x3122
leaq 0x1d05(%rip), %r12      # 0x311f
movb $0x1, %r13b
movl %ebp, %edi
callq 0x1657
movq %rax, %rdi
movq %r14, %rsi
callq 0x162e
testb %al, %al
je 0x143c
callq 0x1705
xorb $0x1, %al
jmp 0x1447
decl 0x3d06(%rip)            # 0x5148
callq 0x1705
andb %al, %r13b
movl %ebp, %edi
callq 0x1657
movq %rax, %rdi
movq %r15, %rsi
callq 0x162e
testb %al, %al
jne 0x141d
decl 0x3ce2(%rip)            # 0x5148
movl %ebp, %edi
callq 0x1657
movq %rax, %rdi
movq %r12, %rsi
callq 0x162e
orb %r13b, %bl
testb %al, %al
jne 0x141a
decl 0x3cc3(%rip)            # 0x5148
andb $0x1, %bl
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/s3lase[P]v6shell/if.c
// Function: doex
static void
doex(bool forked)
{
	char **xap, **xav;

	if (ap < 2 || ap > ac)	/* should never (but can) be true */
		err(FC_ERR, FMT2S, getmyname(), ERR_AVIINVAL);

	xav = xap = &av[ap];
	while (*xap != NULL) {
		if (forked && equal(*xap, "}"))
			break;
		xap++;
	}
	if (forked && xap - xav > 0 && !equal(*xap, "}"))
		err(FC_ERR, FMT3S, getmyname(), av[ap - 1], ERR_BRACE);
	*xap = NULL;
	if (xav[0] == NULL) {
		if (forked)
			err(FC_ERR, FMT3S, getmyname(),av[ap - 1],ERR_COMMAND);
		else
			/* Currently unreachable; do not remove. */
			err(FC_ERR, FMT2S, getmyname(), ERR_COMMAND);
	}

	/* Invoke the ":" or "exit" special command. */
	if (equal(xav[0], ":"))
		EXIT(SH_TRUE);
	if (equal(xav[0], "exit")) {
		(void)lseek(FD0, (off_t)0, SEEK_END);
		EXIT(SH_TRUE);
	}

	(void)err_pexec(xav[0], xav);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edi, %ebp
movl 0x3c9f(%rip), %eax      # 0x5148
cmpl $0x2, %eax
jl 0x14b6
cmpl 0x3c88(%rip), %eax      # 0x513c
jle 0x14dc
callq 0x1f1d
leaq 0x1c67(%rip), %rsi      # 0x3129
leaq 0x1d18(%rip), %rcx      # 0x31e1
pushq $0x7c
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1ce0
movl 0x3c6c(%rip), %eax      # 0x5148
movslq %eax, %rbx
shlq $0x3, %rbx
addq 0x3c56(%rip), %rbx      # 0x5140
xorl %r12d, %r12d
leaq 0x1c78(%rip), %r15      # 0x316c
movq (%rbx,%r12), %r14
testq %r14, %r14
je 0x1517
testb %bpl, %bpl
je 0x1511
movq %r14, %rdi
movq %r15, %rsi
callq 0x162e
testb %al, %al
jne 0x1517
addq $0x8, %r12
jmp 0x14f4
testq %r12, %r12
setg %al
andb %bpl, %al
cmpb $0x1, %al
jne 0x156a
leaq 0x1c41(%rip), %rsi      # 0x316c
movq %r14, %rdi
callq 0x162e
testb %al, %al
jne 0x156a
callq 0x1f1d
movq 0x3bfd(%rip), %rcx      # 0x5140
movslq 0x3bfe(%rip), %rdx      # 0x5148
movq -0x8(%rcx,%rdx,8), %rcx
leaq 0x1bcf(%rip), %rsi      # 0x3125
leaq 0x1ca9(%rip), %r8       # 0x3206
pushq $0x7c
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1ce0
andq $0x0, (%rbx,%r12)
cmpq $0x0, (%rbx)
jne 0x15ca
callq 0x1f1d
testb %bpl, %bpl
je 0x15af
movq 0x3bba(%rip), %rcx      # 0x5140
movslq 0x3bbb(%rip), %rdx      # 0x5148
movq -0x8(%rcx,%rdx,8), %rcx
leaq 0x1b8c(%rip), %rsi      # 0x3125
leaq 0x1c71(%rip), %r8       # 0x3211
pushq $0x7c
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1ce0
jmp 0x15ca
leaq 0x1b73(%rip), %rsi      # 0x3129
leaq 0x1c54(%rip), %rcx      # 0x3211
pushq $0x7c
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1ce0
movq (%rbx), %r14
leaq 0x1c4e(%rip), %rsi      # 0x3222
movq %r14, %rdi
callq 0x162e
testb %al, %al
jne 0x1612
leaq 0x1c3d(%rip), %rsi      # 0x3224
movq %r14, %rdi
callq 0x162e
testb %al, %al
jne 0x1606
movq %r14, %rdi
movq %rbx, %rsi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x22bc
pushq $0x2
popq %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x1120
callq 0x10d0
movl %eax, %ebx
callq 0x1f33
xorl %edi, %edi
cmpl %eax, %ebx
jne 0x1629
callq 0x11f0
callq 0x1070
// File: /workspace/github_c_makefile_star2_O2/s3lase[P]v6shell/if.c
// Function: nxtarg
static char *
nxtarg(bool reterr)
{
	char *nap;

	if (ap < 1 || ap > ac)	/* should never (but can) be true */
		err(FC_ERR, FMT2S, getmyname(), ERR_AVIINVAL);

	if (ap == ac) {
		if (reterr) {
			ap++;
			return NULL;
		}
		err(FC_ERR, FMT3S, getmyname(), av[ap - 1], ERR_ARGUMENT);
	}
	nap = av[ap];
	ap++;
	return nap;
}

// Assembly:
pushq %rbx
movl %edi, %ebx
movl 0x3ae8(%rip), %edx      # 0x5148
testl %edx, %edx
setle %al
movl 0x3ad1(%rip), %ecx      # 0x513c
cmpl %ecx, %edx
setg %sil
orb %al, %sil
cmpb $0x1, %sil
jne 0x16a6
callq 0x1f1d
leaq 0x1aa3(%rip), %rsi      # 0x3129
leaq 0x1b54(%rip), %rcx      # 0x31e1
pushq $0x7c
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1ce0
movl 0x3aa8(%rip), %edx      # 0x5148
movl 0x3a96(%rip), %ecx      # 0x513c
cmpl %ecx, %edx
jne 0x16eb
testb %bl, %bl
je 0x16b2
xorl %eax, %eax
jmp 0x16fb
callq 0x1f1d
movq 0x3a82(%rip), %rcx      # 0x5140
movslq 0x3a83(%rip), %rdx      # 0x5148
movq -0x8(%rcx,%rdx,8), %rcx
leaq 0x1a54(%rip), %rsi      # 0x3125
leaq 0x1b1c(%rip), %r8       # 0x31f4
pushq $0x7c
popq %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1ce0
movl 0x3a5d(%rip), %edx      # 0x5148
movq 0x3a4e(%rip), %rax      # 0x5140
movslq %edx, %rcx
movq (%rax,%rcx,8), %rax
movl %edx, %ecx
incl %ecx
movl %ecx, 0x3a45(%rip)      # 0x5148
popq %rbx
retq