LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/qpfiffer[P]lair/src/unit_test.c
// Function: run_program
int _run_program(const char *filename) {
	printf("%c[%dm%s%c[%dm\n", 0x1B, 32, filename, 0x1B, 0);
	char *buf = NULL;
	size_t buf_siz = 0;

	buf = lair_load_file(filename, &buf_siz);
	int rc = lair_execute(buf, buf_siz);
	if (rc != 0) {
		lair_unload_file(buf, buf_siz);
		return 1;
	}

	lair_unload_file(buf, buf_siz);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x2d26(%rip), %rdi      # 0x4004
movl $0x1b, %esi
movl $0x20, %edx
movq %rbx, %rcx
movl $0x1b, %r8d
xorl %r9d, %r9d
xorl %eax, %eax
callq 0x10a0
leaq 0x8(%rsp), %r14
movq $0x0, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3c50
movq %rax, %rbx
movq (%r14), %rsi
movq %rax, %rdi
callq 0x3ce7
xorl %ebp, %ebp
testl %eax, %eax
setne %bpl
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x3d8a
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/upload-reset/upload-reset.c
// Function: openserial
int openserial(char *devicename) 
{
     struct termios attr;

     if ((fd = open(devicename, O_RDWR)) == -1) return 0; /* Error */ 
     atexit(closeserial);

     if (tcgetattr(fd, &oldterminfo) == -1) return 0; /* Error */
     attr = oldterminfo;
     attr.c_cflag |= CRTSCTS | CLOCAL;
     attr.c_oflag = 0;
     if (tcflush(fd, TCIOFLUSH) == -1) return 0; /* Error */
     if (tcsetattr(fd, TCSANOW, &attr) == -1) return 0; /* Error */ 

     /* Set the lines to a known state, and */
     /* finally return non-zero is successful. */
     return setRTS(0) && setDTR(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x48, %rsp
xorl %ebx, %ebx
movl $0x2, %esi
xorl %eax, %eax
callq 0x10b0
movl %eax, 0x2e5f(%rip)      # 0x408c
cmpl $-0x1, %eax
je 0x12d6
leaq -0x51(%rip), %rdi       # 0x11ec
callq 0x14c0
movl 0x2e44(%rip), %edi      # 0x408c
leaq 0x2e41(%rip), %rsi      # 0x4090
callq 0x1080
cmpl $-0x1, %eax
je 0x12d6
movups 0x2e30(%rip), %xmm0     # 0x4090
movaps %xmm0, -0x50(%rbp)
movups 0x2e51(%rip), %xmm0     # 0x40bc
movups %xmm0, -0x24(%rbp)
movups 0x2e3a(%rip), %xmm0     # 0x40b0
movaps %xmm0, -0x30(%rbp)
movups 0x2e1f(%rip), %xmm0     # 0x40a0
movaps %xmm0, -0x40(%rbp)
orl $0x80000800, -0x48(%rbp) # imm = 0x80000800
movl $0x0, -0x4c(%rbp)
movl 0x2df3(%rip), %edi      # 0x408c
movl $0x2, %esi
callq 0x1040
cmpl $-0x1, %eax
je 0x12d6
movl 0x2dde(%rip), %edi      # 0x408c
xorl %ebx, %ebx
leaq -0x50(%rbp), %rdx
xorl %esi, %esi
callq 0x1090
cmpl $-0x1, %eax
je 0x12d6
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x12df
testl %eax, %eax
je 0x12d6
xorl %edi, %edi
callq 0x1356
movl %eax, %ebx
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/koendv[P]stm32duino-raspberrypi/Arduino_Tools/src/upload-reset/upload-reset.c
// Function: main
int main(int argc, char *argv[])
{
 	
	if (argc<2 || argc >3)
	{
		printf("Usage upload-reset <serial_device> <Optional_delay_in_milliseconds>\n\r");
		return 0;
	}

 	if (openserial(argv[1]))
	{
		// Send magic sequence of DTR and RTS followed by the magic word "1EAF"
		setRTS(false);
 		setDTR(false);
 		setDTR(true);

		usleep(50000L);

		setDTR(false);
		setRTS(true);
		setDTR(true);

		usleep(50000L);

		setDTR(false);

		usleep(50000L);

		write(fd,"1EAF",4);
 		
		closeserial();
		if (argc==3)
		{
			usleep(atol(argv[2])*1000L);
		}
	}
	else
	{
		printf("Failed to open serial device.\n\r");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %edi, %r14d
leal -0x4(%r14), %eax
cmpl $-0x3, %eax
ja 0x13ec
leaq 0xc67(%rip), %rdi       # 0x204e
jmp 0x14b1
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x1210
testl %eax, %eax
je 0x14aa
xorl %edi, %edi
callq 0x12df
xorl %edi, %edi
callq 0x1356
movl $0x1, %edi
callq 0x1356
movl $0xc350, %edi           # imm = 0xC350
callq 0x10e0
xorl %edi, %edi
callq 0x1356
movl $0x1, %edi
callq 0x12df
movl $0x1, %edi
callq 0x1356
movl $0xc350, %edi           # imm = 0xC350
callq 0x10e0
xorl %edi, %edi
callq 0x1356
movl $0xc350, %edi           # imm = 0xC350
callq 0x10e0
movl 0x2c2e(%rip), %edi      # 0x408c
leaq 0xc2f(%rip), %rsi       # 0x2094
movl $0x4, %edx
callq 0x1030
movl 0x2c17(%rip), %edi      # 0x408c
leaq 0x2c14(%rip), %rdx      # 0x4090
xorl %esi, %esi
callq 0x1090
movl 0x2c03(%rip), %edi      # 0x408c
callq 0x1070
cmpl $0x3, %r14d
jne 0x14b8
movq 0x10(%rbx), %rdi
callq 0x10a0
imull $0x3e8, %eax, %edi      # imm = 0x3E8
callq 0x10e0
jmp 0x14b8
leaq 0xbe8(%rip), %rdi       # 0x2099
xorl %eax, %eax
callq 0x1050
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/giometti[P]mastering_UNIX_programming/chapter_06/ungetc.c
// Function: main
int main(void)
{
	FILE *fp;
	int i;
	char c;

	/* Open a file for writing */
	fp = fopen("file.txt", "r");
	if (!fp) {
		perror("fopen");
		return -1;
	}

	/* Start reading first three bytes */
	for (i = 0; i < 3; i++) {
		c = fgetc(fp);
		if (ferror(fp) || feof(fp)) {
			fprintf(stderr, "cannot read\n");
			return -1;
		}
		printf("\ngot '%c'", c);
	}

	/* Do the unread */
	if (ungetc('x', fp) == EOF) {
		fprintf(stderr, "cannot unread\n");
		return -1;
	}
	printf(" but unread 'x'\n");

	/* Now continue reading the whole file */
	while (1) {
		c = fgetc(fp);
		if (ferror(fp)) {
			fprintf(stderr, "cannot read\n");
			return -1;
		}
		if (feof(fp))
			break;
		printf("got '%c'\n", c);
	}

	fclose(fp);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0xdca(%rip), %rdi       # 0x2004
leaq 0xdcc(%rip), %rsi       # 0x200d
callq 0x10a0
testq %rax, %rax
je 0x1325
movq %rax, %rbx
movl $0x3, %r15d
leaq 0xdc3(%rip), %r14       # 0x2022
movq %rbx, %rdi
callq 0x1070
movl %eax, %ebp
movq %rbx, %rdi
callq 0x1040
testl %eax, %eax
jne 0x131e
movq %rbx, %rdi
callq 0x1080
testl %eax, %eax
jne 0x131e
movsbl %bpl, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x1060
decl %r15d
jne 0x125f
movl $0x78, %edi
movq %rbx, %rsi
callq 0x1090
cmpl $-0x1, %eax
je 0x1333
leaq 0xd8c(%rip), %rdi       # 0x2045
callq 0x1030
movq %rbx, %rdi
callq 0x1070
movl %eax, %ebp
movq %rbx, %rdi
callq 0x1040
testl %eax, %eax
jne 0x130b
leaq 0xd60(%rip), %r14       # 0x203b
movq %rbx, %rdi
callq 0x1080
testl %eax, %eax
jne 0x1312
movsbl %bpl, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x1060
movq %rbx, %rdi
callq 0x1070
movl %eax, %ebp
movq %rbx, %rdi
callq 0x1040
testl %eax, %eax
je 0x12db
callq 0x10fc
jmp 0x1338
movq %rbx, %rdi
callq 0x1050
xorl %eax, %eax
jmp 0x133d
callq 0x10e0
jmp 0x1338
leaq 0xce3(%rip), %rdi       # 0x200f
callq 0x10b0
jmp 0x1338
callq 0x1118
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/AtifChy[P]st/x.c
// Function: reload
void
reload(int sig)
{
	config_init();

	/* colors, fonts */
	xloadcols();
	xunloadfonts();
	usedfont = (opt_font == NULL)? font : opt_font;
	xloadfonts(usedfont, 0);

	/* pretend the window just got resized */
	cresize(win.w, win.h);

	redraw();

	/* triggers re-render if we're visible. */
	ttywrite("\033[O", 3, 1);

	signal(SIGUSR1, reload);
}

// Assembly:
pushq %rax
callq 0xd0a0
callq 0xb99b
callq 0xd101
movq 0x12981(%rip), %rdi     # 0x1f9c8
testq %rdi, %rdi
jne 0xd053
movq 0xb5b5(%rip), %rdi      # 0x18608
movq %rdi, 0x12976(%rip)     # 0x1f9d0
xorps %xmm0, %xmm0
callq 0xd169
movl 0x12920(%rip), %edi     # 0x1f988
movl 0x1291e(%rip), %esi     # 0x1f98c
callq 0xd415
callq 0x904f
leaq 0x4cb8(%rip), %rdi      # 0x11d37
movl $0x3, %esi
movl $0x1, %edx
callq 0x7f01
leaq -0x65(%rip), %rsi       # 0xd030
movl $0xa, %edi
popq %rax
jmp 0x6070
// File: /workspace/github_c_makefile_star2_O1/AtifChy[P]st/x.c
// Function: config_init
void
config_init(void)
{
	char *resm;
	XrmDatabase db;
	ResourcePref *p;

	XrmInitialize();
	resm = XResourceManagerString(XOpenDisplay(NULL));
	if (!resm)
		return;

	db = XrmGetStringDatabase(resm);
	for (p = resources; p < resources + LEN(resources); p++)
		resource_load(db, p->name, p->type, p->dst);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
callq 0x65e0
xorl %edi, %edi
callq 0x6310
movq %rax, %rdi
callq 0x6190
testq %rax, %rax
je 0xd0fb
movq %rax, %rdi
callq 0x6760
movq %rax, %rbx
movq $-0x18, %r14
leaq 0xbd89(%rip), %r15      # 0x18e60
movq 0x18(%r14,%r15), %rsi
movl 0x20(%r14,%r15), %edx
movq 0x28(%r14,%r15), %rcx
movq %rbx, %rdi
callq 0xcef2
addq $0x18, %r14
cmpq $0x2d0, %r14            # imm = 0x2D0
jb 0xd0d7
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/AtifChy[P]st/x.c
// Function: xunloadfonts
void
xunloadfonts(void)
{
	/* Clear Harfbuzz font cache. */
	hbunloadfonts();

	/* Free the loaded fonts in the font cache.  */
	while (frclen > 0)
		XftFontClose(xw.dpy, frc[--frclen].font);

	xunloadfont(&dc.font);
	xunloadfont(&dc.bfont);
	xunloadfont(&dc.ifont);
	xunloadfont(&dc.ibfont);
}

// Assembly:
pushq %rax
xorl %eax, %eax
callq 0x10470
movl 0x12931(%rip), %eax     # 0x1fa40
testl %eax, %eax
jle 0xd138
movq 0x12766(%rip), %rdi     # 0x1f880
movq 0x12927(%rip), %rcx     # 0x1fa48
decl %eax
movl %eax, 0x12917(%rip)     # 0x1fa40
shlq $0x4, %rax
movq (%rcx,%rax), %rsi
callq 0x60e0
jmp 0xd109
leaq 0x12659(%rip), %rdi     # 0x1f798
callq 0xe55b
leaq 0x12685(%rip), %rdi     # 0x1f7d0
callq 0xe55b
leaq 0x126b1(%rip), %rdi     # 0x1f808
callq 0xe55b
leaq 0x126dd(%rip), %rdi     # 0x1f840
popq %rax
jmp 0xe55b
// File: /workspace/github_c_makefile_star2_O1/AtifChy[P]st/x.c
// Function: opencopied
void
opencopied(const Arg *arg)
{
	const size_t max_cmd = 2048;
	const char *clip = xsel.clipboard;
	if(!clip) {
		fprintf(stderr, "Warning: nothing copied to clipboard\n");
		return;
	}

	/* account for space/quote (3) and \0 (1) and & (1) */
	char cmd[max_cmd + strlen(clip) + 5];
	strncpy(cmd, (char *)arg->v, max_cmd);
	cmd[max_cmd] = '\0';

	strcat(cmd, " \"");
	strcat(cmd, clip);
	strcat(cmd, "\"");
	strcat(cmd, "&");

	system(cmd);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x1156c(%rip), %rbx     # 0x1fa18
testq %rbx, %rbx
je 0xe554
movq %rdi, %r15
movq %rbx, %rdi
callq 0x63b0
movq %rax, %r12
movq %rsp, -0x30(%rbp)
movq %rsp, %r13
addq $0x814, %r12            # imm = 0x814
andq $-0x10, %r12
movq %r13, %r14
subq %r12, %r14
movq %r14, %rsp
movq (%r15), %rsi
movl $0x800, %edx            # imm = 0x800
movq %r14, %rdi
callq 0x6860
negq %r12
xorl %r15d, %r15d
movb %r15b, 0x800(%r13,%r12)
movq %r14, %rdi
callq 0x63b0
movb %r15b, 0x2(%rax,%r14)
movw $0x2220, (%rax,%r14)    # imm = 0x2220
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6500
movq %r14, %rdi
callq 0x63b0
movw $0x22, (%rax,%r14)
movq %r14, %rdi
callq 0x63b0
movw $0x26, (%rax,%r14)
movq %r14, %rdi
callq 0x6240
movq -0x30(%rbp), %rsp
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x6df6
jmp 0xe545
// File: /workspace/github_c_makefile_star2_O1/AtifChy[P]st/x.c
// Function: cmessage
void
cmessage(XEvent *e)
{
	/*
	 * See xembed specs
	 *  http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html
	 */
	if (e->xclient.message_type == xw.xembed && e->xclient.format == 32) {
		if (e->xclient.data.l[1] == XEMBED_FOCUS_IN) {
			win.mode |= MODE_FOCUSED;
			xseturgency(0);
		} else if (e->xclient.data.l[1] == XEMBED_FOCUS_OUT) {
			win.mode &= ~MODE_FOCUSED;
		}
	} else if (e->xclient.data.l[0] == xw.wmdeletewin) {
		ttyhangup();
		exit(0);
	} else if (strcmp(XGetAtomName(xw.dpy, e->xclient.message_type), "ReloadColors") == 0) {
		config_init();
		xloadcols();
		cresize(win.w, win.h);
	}
}

// Assembly:
pushq %rax
movq 0x28(%rdi), %rsi
cmpq 0x1034f(%rip), %rsi     # 0x1f8a8
jne 0xf580
cmpl $0x20, 0x30(%rdi)
jne 0xf580
movq 0x40(%rdi), %rax
cmpq $0x5, %rax
je 0xf5ca
cmpq $0x4, %rax
jne 0xf5ac
orb $0x2, 0x10428(%rip)     # 0x1f9a0
xorl %edi, %edi
popq %rax
jmp 0xce96
movq 0x38(%rdi), %rax
cmpq 0x10325(%rip), %rax     # 0x1f8b0
je 0xf5d3
movq 0x102ec(%rip), %rdi     # 0x1f880
callq 0x66e0
leaq 0x2fce(%rip), %rsi      # 0x1256e
movq %rax, %rdi
callq 0x6700
testl %eax, %eax
je 0xf5ae
popq %rax
retq
callq 0xd0a0
callq 0xb99b
movl 0x103ca(%rip), %edi     # 0x1f988
movl 0x103c8(%rip), %esi     # 0x1f98c
popq %rax
jmp 0xd415
andb $-0x3, 0x103cf(%rip)    # 0x1f9a0
jmp 0xf5ac
callq 0x8234
xorl %edi, %edi
callq 0x61a0
// File: /workspace/github_c_makefile_star2_O1/antonblanchard[P]will-it-scale/tests/open1.c
// Function: testcase
void testcase(unsigned long long *iterations, unsigned long nr)
{
	char *tmpfile = tmpfiles[nr];

	while (1) {
		int fd = open(tmpfile, O_RDWR);
		assert(fd >= 0);
		close(fd);

		(*iterations)++;
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq (%rsi,%rsi,2), %r14
shlq $0x3, %r14
addq 0xa45f(%rip), %r14      # 0xc1a8
movq %r14, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x1220
testl %eax, %eax
js 0x1d68
movl %eax, %edi
callq 0x1160
incq (%rbx)
jmp 0x1d49
leaq 0x556(%rip), %rdi       # 0x22c5
leaq 0x504(%rip), %rsi       # 0x227a
leaq 0x550(%rip), %rcx       # 0x22cd
movl $0x27, %edx
callq 0x1130
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tools/gftool.c
// Function: gf_dump
static void gf_dump(const gf_elem_t *tab)
{
	const int tab_size = 1 << gf_degree;
	const int digits = (gf_degree + 3) >> 2;
	const int per_line = 72 / (digits + 5);
	char fmt[16];
	int i;

	snprintf(fmt, sizeof(fmt), "0x%%0%dx,", digits);

	for (i = 0; i < tab_size; i++) {
		if (i % per_line)
			printf(" ");

		printf(fmt, tab[i]);

		if (!((i + 1) % per_line))
			printf("\n");
	}

	if (i % per_line)
		printf("\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movzwl 0x2839(%rip), %r15d     # 0x40a2
leal 0x3(%r15), %ecx
shrl $0x2, %ecx
leal 0x5(%rcx), %esi
xorl %r14d, %r14d
movl $0x48, %eax
xorl %edx, %edx
divl %esi
movl %eax, %ebp
leaq 0x93b(%rip), %rdx       # 0x21c3
movq %rsp, %rdi
movl $0x10, %esi
xorl %eax, %eax
callq 0x1080
cmpl $0x1f, %r15d
je 0x18fd
movl $0x1, %eax
movl $0x1, %r12d
movl %r15d, %ecx
shll %cl, %r12d
cmpl $0x2, %r12d
cmovll %eax, %r12d
movq %rsp, %r15
xorl %r14d, %r14d
movl %r14d, %eax
xorl %edx, %edx
divl %ebp
testl %edx, %edx
je 0x18d1
movl $0x20, %edi
callq 0x1040
movzwl (%rbx,%r14,2), %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x1070
incq %r14
movl %r14d, %eax
xorl %edx, %edx
divl %ebp
testl %edx, %edx
jne 0x18f8
movl $0xa, %edi
callq 0x1040
cmpq %r14, %r12
jne 0x18bc
movl %r14d, %eax
xorl %edx, %edx
divl %ebp
testl %edx, %edx
je 0x191e
movl $0xa, %edi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1040
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/dlbeer[P]dhara/tools/gftool.c
// Function: print_poly
static void print_poly(char var, poly_t p)
{
	int have_term = 0;
	int i;

	printf("0x%lx [0x%lx] -> ", p, reciprocal(p));

	for (i = MAX_DEGREE; i >= 0; i--) {
		if (!((p >> i) & 1))
			continue;

		if (have_term)
			printf(" + ");

		if (!i)
			printf("1");
		else if (i == 1)
			printf("%c", var);
		else
			printf("%c^%d", var, i);

		have_term = 1;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %edx, %edx
testq %rdi, %rdi
je 0x1958
movq %rbx, %rcx
movq %rbx, %rax
movl %ecx, %esi
andl $0x1, %esi
leaq (%rsi,%rdx,2), %rdx
shrq %rax
cmpq $0x1, %rcx
movq %rax, %rcx
ja 0x1943
leaq 0x7ec(%rip), %rdi       # 0x214b
movq %rbx, %rsi
xorl %eax, %eax
callq 0x1070
movl $0x3f, %r14d
leaq 0x7eb(%rip), %r15       # 0x2161
leaq 0x7e0(%rip), %r12       # 0x215d
xorl %eax, %eax
btq %r14, %rbx
jae 0x19c8
testl %eax, %eax
je 0x1993
movq %r12, %rdi
xorl %eax, %eax
callq 0x1070
cmpl $0x1, %r14d
je 0x19a5
testl %r14d, %r14d
jne 0x19b1
movl $0x31, %edi
jmp 0x19aa
movl $0x78, %edi
callq 0x1040
jmp 0x19c3
movq %r15, %rdi
movl $0x78, %esi
movl %r14d, %edx
xorl %eax, %eax
callq 0x1070
movl $0x1, %eax
addq $-0x1, %r14
jb 0x197f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/baines[P]MiniGBS/minigbs.c
// Function: cpu_frame
void cpu_frame(void){

	while(regs.sp != h.sp || regs.pc){
		cpu_step();
	}

	debug_separator();

	regs.pc = h.play_addr;
	mem[regs.sp-1] = mem[regs.sp-2] = 0;
	regs.sp -= 2;

	ui_redraw(&h);
}

// Assembly:
pushq %rax
movzwl 0xbc14(%rip), %eax      # 0x113c8
cmpw 0xbc1d(%rip), %ax       # 0x113d8
jne 0x57c7
cmpw $0x0, 0xbc05(%rip)      # 0x113ca
je 0x57ce
callq 0x581c
jmp 0x57ad
callq 0x83c2
leaq 0xbbf2(%rip), %rdi      # 0x113cc
movzwl 0xbbf5(%rip), %eax      # 0x113d6
movw %ax, 0xbbe2(%rip)       # 0x113ca
movq 0xbc51(%rip), %rax      # 0x11440
movzwl 0xbbd2(%rip), %ecx      # 0x113c8
xorl %edx, %edx
movb %dl, -0x2(%rax,%rcx)
movq 0xbc3d(%rip), %rax      # 0x11440
movzwl 0xbbbe(%rip), %ecx      # 0x113c8
movb %dl, -0x1(%rax,%rcx)
addw $-0x2, 0xbbb2(%rip)     # 0x113c8
popq %rax
jmp 0xa3a7
// File: /workspace/github_c_makefile_star2_O1/baines[P]MiniGBS/minigbs.c
// Function: mem_write
static inline void mem_write(uint16_t addr, uint8_t val){
	if(addr >= 0x2000 && addr < 0x4000){
		bank_switch(val);
	} else if(addr >= 0xFF10 && addr <= 0xFF40){
		audio_write(addr, val);
	} else if(addr < 0x8000){
		debug_msg("rom write?: [%4x] <- [%2x]", addr, val);
	} else if(addr == 0xFF06 || addr == 0xFF07){
		if(mem[addr] != val){
			mem[addr] = val;
			audio_update_rate();
		}
	} else {
		switch(addr){
			case 0xFF04: debug_msg("DIV write: %2x", val); break;
			case 0xFF05: debug_msg("TIMA write: %2x", val); break;
			case 0xFF0F: debug_msg("IF write: %2x", val); break;
			case 0xFF41: debug_msg("STAT: %2x", val); break;
			case 0xFF46: debug_msg("DMA: %2x", val); break;
			case 0xFFFF: debug_msg("IE: %2x", val); break;
		}
		mem[addr] = val;
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movl %edi, %eax
andl $0xe000, %eax           # imm = 0xE000
cmpl $0x2000, %eax           # imm = 0x2000
jne 0x795c
movzbl %bl, %ebp
leaq 0x4e32(%rip), %rdi      # 0xc72f
movl %ebp, %esi
xorl %eax, %eax
callq 0x83f1
cmpb $0x1f, %bl
ja 0x7a4c
cmpb $0x2, %bl
movl $0x1, %eax
cmovael %ebp, %eax
movzbl %al, %eax
leaq 0x9b5c(%rip), %rcx      # 0x11480
movq (%rcx,%rax,8), %rsi
testq %rsi, %rsi
je 0x7a4c
movl $0x4000, %eax           # imm = 0x4000
movq 0x9b03(%rip), %rdi      # 0x11440
addq %rax, %rdi
movl $0x4000, %edx           # imm = 0x4000
callq 0x55a0
leaq 0x4df4(%rip), %rdi      # 0xc745
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x83f1
movl %edi, %esi
leal 0xf0(%rsi), %eax
cmpw $0x30, %ax
ja 0x7979
movzwl %si, %edi
movzbl %bl, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x98d6
testw %si, %si
js 0x7993
movzbl %bl, %edx
leaq 0x4d44(%rip), %rdi      # 0xc6cc
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x83f1
movl %esi, %eax
andl $0xfffe, %eax           # imm = 0xFFFE
cmpl $0xff06, %eax           # imm = 0xFF06
jne 0x79c0
movq 0x9a98(%rip), %rax      # 0x11440
movzwl %si, %ecx
cmpb %bl, (%rax,%rcx)
je 0x7a4c
movb %bl, (%rax,%rcx)
popq %rbx
popq %r14
popq %rbp
jmp 0x94b5
movzwl %si, %r14d
cmpl $0xff40, %r14d          # imm = 0xFF40
jg 0x79f1
cmpl $0xff04, %r14d          # imm = 0xFF04
je 0x7a15
cmpl $0xff05, %r14d          # imm = 0xFF05
je 0x7a27
cmpl $0xff0f, %r14d          # imm = 0xFF0F
jne 0x7a41
leaq 0x4d17(%rip), %rdi      # 0xc706
jmp 0x7a37
cmpl $0xff41, %r14d          # imm = 0xFF41
je 0x7a1e
cmpl $0xff46, %r14d          # imm = 0xFF46
je 0x7a30
cmpl $0xffff, %r14d          # imm = 0xFFFF
jne 0x7a41
leaq 0x4d14(%rip), %rdi      # 0xc727
jmp 0x7a37
leaq 0x4ccb(%rip), %rdi      # 0xc6e7
jmp 0x7a37
leaq 0x4cef(%rip), %rdi      # 0xc714
jmp 0x7a37
leaq 0x4cc8(%rip), %rdi      # 0xc6f6
jmp 0x7a37
leaq 0x4ce7(%rip), %rdi      # 0xc71e
movzbl %bl, %esi
xorl %eax, %eax
callq 0x83f1
movq 0x99f8(%rip), %rax      # 0x11440
movb %bl, (%rax,%r14)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x99e5(%rip), %rax      # 0x11440
movl %edi, %ecx
movb (%rax,%rcx), %bl
leal 0xf0(%rsi), %eax
cmpw $0x16, %ax
ja 0x7a7c
leal -0xff10(%rsi), %eax
leaq 0x4717(%rip), %rcx      # 0xc190
orb (%rax,%rcx), %bl
cmpl $0x0, 0x99c5(%rip)      # 0x11448
je 0x7b6d
movzwl %si, %ecx
leal -0xff04(%rcx), %eax
cmpl $0x42, %eax
ja 0x7b00
leaq 0x45c6(%rip), %rcx      # 0xc064
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl %bl, %edx
leaq 0x49bd(%rip), %rdi      # 0xc46e
xorl %eax, %eax
callq 0x83f1
jmp 0x7b6d
movl %esi, %eax
addl $0xffff00f0, %eax       # imm = 0xFFFF00F0
cltq
imulq $0x66666667, %rax, %rax # imm = 0x66666667
movq %rax, %rdx
shrq $0x3f, %rdx
sarq $0x21, %rax
leal (%rax,%rdx), %ecx
leal (%rcx,%rcx,4), %ecx
negl %ecx
addl %esi, %ecx
addl $0xffff00f0, %ecx       # imm = 0xFFFF00F0
leal 0x1(%rax,%rdx), %edx
movzbl %bl, %r8d
leaq 0x4954(%rip), %rdi      # 0xc44b
xorl %eax, %eax
callq 0x83f1
jmp 0x7b6d
cmpl $0xffff, %ecx           # imm = 0xFFFF
jne 0x7b6d
movzbl %bl, %esi
leaq 0x49d7(%rip), %rdi      # 0xc4e9
jmp 0x7b66
movzbl %bl, %esi
leaq 0x49ae(%rip), %rdi      # 0xc4cc
jmp 0x7b66
movzbl %bl, %esi
leaq 0x49b1(%rip), %rdi      # 0xc4db
jmp 0x7b66
movzbl %bl, %esi
leaq 0x4950(%rip), %rdi      # 0xc486
jmp 0x7b66
movzbl %bl, %esi
leaq 0x4952(%rip), %rdi      # 0xc494
jmp 0x7b66
movzbl %bl, %esi
leaq 0x4971(%rip), %rdi      # 0xc4bf
jmp 0x7b66
movzbl %bl, %esi
leaq 0x4949(%rip), %rdi      # 0xc4a3
jmp 0x7b66
movzbl %bl, %esi
leaq 0x494b(%rip), %rdi      # 0xc4b1
xorl %eax, %eax
callq 0x83f1
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/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 %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
movq %rsp, %r14
movaps %xmm0, (%r14)
movq $0x0, 0x10(%r14)
leaq 0x4b0a(%rip), %rdi      # 0xc69e
movq %r14, %rsi
movl $0x26, %edx
callq 0x5300
leaq 0x4b10(%rip), %rdi      # 0xc6b8
movq %r14, %rsi
movl $0x26, %edx
callq 0x5300
cmpq $0x0, (%r14)
je 0x7bd0
movq 0x8(%rsp), %rax
movq (%rax), %rdi
movq %rbx, %rsi
callq 0x51d0
movq %rax, %rbx
jmp 0x7bd2
xorl %ebx, %ebx
movq %rsp, %rdi
callq 0x5510
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %rbx
pushq %rax
movl %edi, %eax
leaq 0x8250(%rip), %rcx      # 0x104d0
movq (%rcx,%rax,8), %rbx
leaq 0x46ae(%rip), %rsi      # 0xc939
movl $0x4, %edx
movq %rbx, %rdi
callq 0x51b0
movb $0x1, %bpl
testl %eax, %eax
je 0x8301
leaq 0x4698(%rip), %rsi      # 0xc93e
movl $0x2, %edx
movq %rbx, %rdi
callq 0x51b0
testl %eax, %eax
je 0x8301
leaq 0x4683(%rip), %rsi      # 0xc941
movl $0x2, %edx
movq %rbx, %rdi
callq 0x51b0
testl %eax, %eax
je 0x8301
leaq 0x466e(%rip), %rsi      # 0xc944
movl $0x3, %edx
movq %rbx, %rdi
callq 0x51b0
testl %eax, %eax
je 0x8301
leaq 0x465a(%rip), %rsi      # 0xc948
movl $0x3, %edx
movq %rbx, %rdi
callq 0x51b0
testl %eax, %eax
sete %bpl
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x89ae(%rip), %r9       # 0x10cd0
leaq (%r8,%r9), %rax
addq $0x8, %rax
xorl %ecx, %ecx
leaq 0x924f(%rip), %r10      # 0x11582
movl $0x21, %r11d
movl $0x24, %ebx
movq %rdx, %r14
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
cmpq $0x4, %rcx
je 0x8341
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 0x45d0(%rip), %rdi      # 0xc976
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_O1/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 0x907f(%rip), %rax      # 0x11448
cmpl $0x0, (%rax)
je 0x83f0
pushq %rax
leaq 0x44a2(%rip), %rdi      # 0xc878
callq 0x5120
movb $0x0, 0x919e(%rip)      # 0x11580
movl $0x0, 0x91a4(%rip)      # 0x11590
addq $0x8, %rsp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x8436
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 0x8ff2(%rip), %r14      # 0x11448
cmpl $0x0, (%r14)
je 0x84bc
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
movl $0x27, %esi
movq %rbx, %rdi
movq %r10, %rdx
callq 0x53f0
cmpl $0x2, (%r14)
leaq 0x4422(%rip), %rax      # 0xc8c9
leaq 0x445c(%rip), %rdi      # 0xc90a
cmoveq %rax, %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x5050
addq $0xf8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O1/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 0x9027(%rip), %rcx      # 0x115b0
movb %sil, (%rax,%rcx)
leaq 0x8eac(%rip), %rax      # 0x11440
movq (%rax), %rax
movb 0xff26(%rax), %cl
andb $-0x80, %cl
movb 0x915a(%rip), %dl       # 0x11700
shlb $0x3, %dl
orb %cl, %dl
movb 0x90df(%rip), %cl       # 0x11690
shlb $0x2, %cl
orb %dl, %cl
movb 0x9064(%rip), %dl       # 0x11620
addb %dl, %dl
orb %cl, %dl
orb 0x8fea(%rip), %dl       # 0x115b0
movb %dl, 0xff26(%rax)
retq
// File: /workspace/github_c_makefile_star2_O1/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
ucomiss 0x3a2e(%rip), %xmm0     # 0xc00c
jbe 0x8634
movl 0x30(%rdi), %eax
movss 0x4c79(%rip), %xmm1     # 0xd264
movss 0x3a19(%rip), %xmm2     # 0xc00c
movl $0xf, %ecx
xorl %edx, %edx
testl %eax, %eax
je 0x862b
movzbl 0x34(%rdi), %esi
decl %esi
orl $0x1, %esi
addl 0x4(%rdi), %esi
movl %esi, 0x4(%rdi)
cmpl $0xf, %esi
je 0x8616
testl %esi, %esi
jne 0x861d
movl $0x0, 0x3c(%rdi)
cmpl $0xf, %esi
cmovgel %ecx, %esi
testl %esi, %esi
cmovlel %edx, %esi
movl %esi, 0x4(%rdi)
addss %xmm1, %xmm0
ucomiss %xmm2, %xmm0
ja 0x85fa
movss %xmm0, 0x38(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x86c4
movss 0x2c(%rdi), %xmm0
addss 0x28(%rdi), %xmm0
movss %xmm0, 0x28(%rdi)
ucomiss 0x39b2(%rip), %xmm0     # 0xc00c
jbe 0x86c4
leaq 0x8f4d(%rip), %rax      # 0x115b0
movq %rdi, %rcx
subq %rax, %rcx
shrq $0x4, %rcx
imull $0xb6db6db7, %ecx, %ecx # imm = 0xB6DB6DB7
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
movb $0x0, (%rcx,%rax)
leaq 0x8dbb(%rip), %rax      # 0x11440
movq (%rax), %rax
movb 0xff26(%rax), %cl
andb $-0x80, %cl
movb 0x9069(%rip), %dl       # 0x11700
shlb $0x3, %dl
orb %cl, %dl
movb 0x8fee(%rip), %cl       # 0x11690
shlb $0x2, %cl
orb %dl, %cl
movb 0x8f73(%rip), %dl       # 0x11620
addb %dl, %dl
orb %cl, %dl
orb 0x8ef9(%rip), %dl       # 0x115b0
movb %dl, 0xff26(%rax)
movl $0x0, 0x28(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x392a(%rip), %xmm0     # 0xc00c
jbe 0x8701
movss 0x4b78(%rip), %xmm2     # 0xd264
addss %xmm0, %xmm2
subss %xmm2, %xmm1
movss %xmm1, (%rsi)
movl $0x0, 0x10(%rdi)
jmp 0x8705
movss %xmm1, (%rsi)
ucomiss 0x3900(%rip), %xmm0     # 0xc00c
seta %al
retq
// File: /workspace/github_c_makefile_star2_O1/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 %rbp
pushq %rbx
pushq %rax
movss 0x54(%rdi), %xmm0
addss 0x50(%rdi), %xmm0
movss %xmm0, 0x50(%rdi)
ucomiss 0x38e3(%rip), %xmm0     # 0xc00c
jbe 0x8820
movq %rdi, %rbx
movss 0x4b2a(%rip), %xmm1     # 0xd264
movss 0x38ca(%rip), %xmm2     # 0xc00c
movl $0xffffffd0, %ebp       # imm = 0xFFFFFFD0
movl 0x4c(%rbx), %ecx
testl %ecx, %ecx
je 0x8800
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)
movzwl %ax, %ecx
cmpl $0x800, %ecx            # imm = 0x800
jae 0x8806
movl $0x800, %ecx            # imm = 0x800
subl %eax, %ecx
movzwl %cx, %eax
shll $0x5, %eax
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
movss 0x4ad2(%rip), %xmm0     # 0xd268
divss %xmm1, %xmm0
movaps %xmm0, %xmm1
divss 0x4ab7(%rip), %xmm1     # 0xd25c
movss %xmm1, 0x14(%rbx)
divss 0x4aae(%rip), %xmm0     # 0xd260
callq 0x51f0
divss 0x8de5(%rip), %xmm0     # 0x115a4
callq 0x50d0
movss 0x3840(%rip), %xmm2     # 0xc00c
movss 0x4a90(%rip), %xmm1     # 0xd264
cvttss2si %xmm0, %eax
cmpl $-0x2f, %eax
cmovll %ebp, %eax
addl $0x30, %eax
movl %eax, 0x1c(%rbx)
movzwl 0xc(%rbx), %eax
movw %ax, 0x40(%rbx)
movss 0x14(%rbx), %xmm0
mulss 0x4a73(%rip), %xmm0     # 0xd26c
movss %xmm0, 0x14(%rbx)
jmp 0x8809
cmpl $0x0, 0x44(%rbx)
je 0x8809
movb $0x0, (%rbx)
movss 0x50(%rbx), %xmm0
addss %xmm1, %xmm0
movss %xmm0, 0x50(%rbx)
ucomiss %xmm2, %xmm0
ja 0x8747
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x84b7(%rip), %rdi      # 0x115b0
movl $0x1c0, %edx            # imm = 0x1C0
xorl %esi, %esi
callq 0x5080
movq 0x8674(%rip), %rbx      # 0x11780
movq 0x865d(%rip), %r14      # 0x11770
leaq (,%r14,4), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x5080
movq %rbx, 0x8664(%rip)      # 0x11790
leaq (%rbx,%r14,4), %rax
movq %rax, 0x8661(%rip)      # 0x11798
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x84f6(%rip)      # 0x11638
movl %eax, 0x8480(%rip)      # 0x115c8
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x3dd7(%rip), %xmm0     # 0xd25c
movq %rbx, %rsi
callq 0x9cc4
movw %ax, 0x831c(%rip)       # 0x117b0
movl $0x3d6c982c, 0x8106(%rip) # imm = 0x3D6C982C
movl $0x3f7f0feb, 0x80f8(%rip) # imm = 0x3F7F0FEB
callq 0x94b5
movl (%rbx), %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/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:
movl $0x426ecccd, 0x8301(%rip) # imm = 0x426ECCCD
leaq 0x7f7a(%rip), %rax      # 0x11440
movq (%rax), %rcx
movzbl 0xff07(%rcx), %eax
testb $0x4, %al
je 0x950b
movzbl 0xff06(%rcx), %ecx
movl %eax, %edx
andl $0x3, %edx
leaq 0x3e69(%rip), %rsi      # 0xd350
cvtsi2ssl (%rsi,%rdx,4), %xmm0
movl $0x100, %edx            # imm = 0x100
subl %ecx, %edx
cvtsi2ss %edx, %xmm1
divss %xmm1, %xmm0
testb %al, %al
jns 0x9503
addss %xmm0, %xmm0
movss %xmm0, 0x82b5(%rip)     # 0x117c0
pushq %r15
pushq %r14
pushq %rbx
leaq 0x7f31(%rip), %rax      # 0x11448
movss 0x20(%rax), %xmm0
mulss 0x829c(%rip), %xmm0     # 0x117c0
movss %xmm0, 0x8294(%rip)     # 0x117c0
cvtss2sd %xmm0, %xmm0
leaq 0x3e39(%rip), %rdi      # 0xd370
movb $0x1, %al
callq 0x83f1
movss 0x3d16(%rip), %xmm0     # 0xd25c
divss 0x8272(%rip), %xmm0     # 0x117c0
cvttss2si %xmm0, %eax
addl %eax, %eax
movslq %eax, %rbx
movl $0x4, %esi
movq %rbx, %rdi
callq 0x5490
movq %rax, %r14
movq 0x8212(%rip), %r15      # 0x11780
testq %r15, %r15
je 0x958c
movq 0x81f6(%rip), %rdx      # 0x11770
cmpq %rbx, %rdx
cmovaeq %rbx, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x55a0
movq %r15, %rdi
callq 0x5250
movq %r14, 0x81e5(%rip)      # 0x11780
movq %rbx, 0x81ce(%rip)      # 0x11770
movq 0x820f(%rip), %rdi      # 0x117b8
callq 0x5250
movl $0x4, %esi
movq %rbx, %rdi
callq 0x5490
movq %rax, 0x81f6(%rip)      # 0x117b8
movq %r14, 0x81c7(%rip)      # 0x11790
leaq (%r14,%rbx,4), %rax
movq %rax, 0x81c4(%rip)      # 0x11798
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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:
leaq 0x7fca(%rip), %rax      # 0x115b0
xorl %ecx, %ecx
leaq 0x7fb9(%rip), %rdx      # 0x115a8
movw $0xffff, %si            # imm = 0xFFFF
cmpb $0x0, (%rcx,%rdx)
jne 0x961a
cmpb $0x1, (%rax)
jne 0x961a
cmpb $0x1, 0x1(%rax)
jne 0x961a
cmpb $0x0, 0x2(%rax)
jne 0x9610
cmpb $0x1, 0x3(%rax)
jne 0x961a
cmpl $0x0, 0x4(%rax)
je 0x961a
movzwl 0x1c(%rax), %esi
movw %si, (%rdi,%rcx,2)
incq %rcx
addq $0x70, %rax
cmpq $0x4, %rcx
jne 0x95ef
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x7f81(%rip), %rcx      # 0x115b4
xorl %edx, %edx
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
cmpq $0x4, %rdx
jne 0x9635
leaq 0x7de6(%rip), %rax      # 0x11440
movq (%rax), %rax
movl $0xf, %esi
xorl %ecx, %ecx
xorl %edx, %edx
movl %esi, %r8d
movl %edx, %r9d
movzbl 0xff30(%rax,%rcx), %edx
movl %edx, %r10d
shrl $0x4, %r10d
andl $0xf, %edx
cmpl %edx, %r10d
movl %edx, %esi
cmovbl %r10d, %esi
cmoval %r10d, %edx
cmpl %esi, %r8d
cmovll %r8d, %esi
cmpl %edx, %r9d
cmovgl %r9d, %edx
incq %rcx
cmpq $0x10, %rcx
jne 0x9666
subl %esi, %edx
cvtsi2ss %edx, %xmm0
divss 0x3bc0(%rip), %xmm0     # 0xd270
movzbl 0x4(%rdi), %eax
testl %eax, %eax
je 0x96d1
movl $0x4, %ecx
subl %eax, %ecx
leal (%rcx,%rcx,4), %eax
cvtsi2ss %eax, %xmm1
mulss %xmm0, %xmm1
cvttss2si %xmm1, %eax
movb %al, 0x4(%rdi)
movzbl 0x5(%rdi), %eax
testl %eax, %eax
je 0x96f5
movl $0x4, %ecx
subl %eax, %ecx
leal (%rcx,%rcx,4), %eax
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
mulss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movb %al, 0x5(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/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 %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %edi, %ebx
movslq %edi, %r15
imulq $0x70, %r15, %r12
leaq 0x7e9d(%rip), %r13      # 0x115b0
leaq (%r12,%r13), %r14
leaq 0x7d2a(%rip), %rax      # 0x11448
cmpl $0x0, (%rax)
je 0x973f
leaq 0x3c0e(%rip), %rax      # 0xd338
movslq (%rax,%r15,4), %rsi
addq %rax, %rsi
leaq 0x3c64(%rip), %rdi      # 0xd39c
xorl %eax, %eax
callq 0x83f1
movb $0x1, (%r12,%r13)
leaq 0x7cf5(%rip), %rax      # 0x11440
movq (%rax), %rax
movb 0xff26(%rax), %cl
andb $-0x80, %cl
movb 0x7fa3(%rip), %dl       # 0x11700
shlb $0x3, %dl
orb %cl, %dl
movb 0x7f28(%rip), %cl       # 0x11690
shlb $0x2, %cl
orb %dl, %cl
movb 0x7ead(%rip), %dl       # 0x11620
addb %dl, %dl
orb %cl, %dl
orb 0x7e33(%rip), %dl       # 0x115b0
movb %dl, 0xff26(%rax)
movl 0x8(%r14), %ecx
movl %ecx, 0x4(%r14)
leaq (%r15,%r15,4), %rcx
movzbl 0xff12(%rax,%rcx), %edx
movl %edx, %ecx
andl $0x7, %ecx
movl %ecx, 0x30(%r14)
shrb $0x3, %dl
andb $0x1, %dl
movb %dl, 0x34(%r14)
testl %ecx, %ecx
je 0x97c8
cvtsi2ss %ecx, %xmm1
movss 0x3ac6(%rip), %xmm0     # 0xd280
divss %xmm1, %xmm0
divss 0x3a96(%rip), %xmm0     # 0xd25c
jmp 0x97d0
movss 0x3ab4(%rip), %xmm0     # 0xd284
movss %xmm0, 0x3c(%r14)
movl $0x0, 0x38(%r14)
cmpl $0x3, %ebx
je 0x9870
cmpl $0x2, %ebx
je 0x9866
testl %ebx, %ebx
jne 0x987f
movzbl 0xff10(%rax), %ecx
movzwl 0xc(%r14), %eax
movw %ax, 0x40(%r14)
movl %ecx, %eax
shrl $0x4, %eax
andl $0x7, %eax
movl %eax, 0x44(%r14)
testb $0x8, %cl
sete 0x48(%r14)
andl $0x7, %ecx
movl %ecx, 0x4c(%r14)
xorps %xmm0, %xmm0
testl %eax, %eax
je 0x9842
xorps %xmm1, %xmm1
cvtsi2ss %eax, %xmm1
movss 0x3a52(%rip), %xmm0     # 0xd288
divss %xmm1, %xmm0
divss 0x3a1a(%rip), %xmm0     # 0xd25c
movss %xmm0, 0x54(%r14)
flds 0x3a3e(%rip)            # 0xd28c
fstpt (%rsp)
movss 0x27b3(%rip), %xmm0     # 0xc00c
callq 0x5360
movss %xmm0, 0x50(%r14)
jmp 0x987f
movl $0x0, 0x18(%r14)
jmp 0x987f
movw $0xffff, 0x64(%r14)     # imm = 0xFFFF
movl $0xffffffff, 0x18(%r14) # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/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
movl $0x40, %edx
cmovel %ecx, %edx
imulq $0x70, %rax, %rax
leaq 0x7d05(%rip), %rcx      # 0x115b0
subl 0x20(%rax,%rcx), %edx
cvtsi2ss %edx, %xmm0
movss 0x39d5(%rip), %xmm1     # 0xd290
divss %xmm0, %xmm1
divss 0x3995(%rip), %xmm1     # 0xd25c
movss %xmm1, 0x2c(%rax,%rcx)
movl $0x0, 0x28(%rax,%rcx)
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x36ea(%rip), %rsi      # 0xd414
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x5230
movq 0x30(%r14), %rdi
cvttss2si 0x14(%rsp), %r8
movl $0x411b, (%rsp)         # imm = 0x411B
movl $0xe, %esi
movl $0x3, %edx
movl $0x2, %ecx
movl $0x1, %r9d
callq 0x5380
movq 0x30(%r14), %rdi
leaq 0x38(%r14), %rsi
leaq 0x40(%r14), %rdx
callq 0x5240
movq 0x30(%r14), %rdi
callq 0x5540
movq (%r15), %rdi
movslq (%rbx), %rsi
movslq %eax, %r12
addq %r12, %rsi
shlq $0x3, %rsi
callq 0x5520
movq %rax, (%r15)
movq 0x30(%r14), %rdi
movslq (%rbx), %rcx
leaq (%rax,%rcx,8), %rsi
movl %r12d, %edx
callq 0x5460
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_O1/baines[P]MiniGBS/audio_output.c
// Function: alsa_ready
static bool alsa_ready(struct audio_output* out, struct pollfd* fds, int nfds) {
	struct audio_alsa* alsa = (struct audio_alsa*)out;

	uint16_t ev;
	snd_pcm_poll_descriptors_revents(alsa->pcm, fds, nfds, &ev);

	return (ev & POLLOUT);
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq 0x30(%rdi), %rdi
leaq 0xe(%rsp), %rbx
movq %rbx, %rcx
callq 0x5450
movzwl (%rbx), %eax
andl $0x4, %eax
shrl $0x2, %eax
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/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 0x9dfb
popq %rbx
retq
movq 0x30(%rbx), %rdi
movl %eax, %esi
movl $0x1, %edx
popq %rbx
jmp 0x5290
// File: /workspace/github_c_makefile_star2_O1/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 0x9eb0
movq %rax, 0x30(%r14)
testq %rax, %rax
je 0x9e94
movl $0x1, %edi
xorl %esi, %esi
callq 0x5200
movl %eax, 0x38(%r14)
movq (%r15), %rdi
movslq (%rbx), %rax
leaq 0x8(,%rax,8), %rsi
callq 0x5520
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 0x358c(%rip), %xmm0     # 0xd410
movl %eax, (%rbx)
cvttss2si %xmm0, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
callq 0x568d