LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/phluid61[P]hsf/src/bytesequence.c
// Function: SH_ByteSequence__to_s
sh_char_t*
SH_ByteSequence__to_s(SH_ByteSequence* obj, int* err) {
	size_t size;
	size_t i;

	uint8_t b1;
	uint8_t b2;
	uint8_t b3;
	uint8_t b4;

	sh_char_t* str;
	sh_char_t* ptr;

	__cascade(err, (sh_char_t*)0);

	size = (obj->length * 4 + 2) / 3; /* 3in -> 4out */
	str = (sh_char_t*)malloc(sizeof(sh_char_t) * (size + 3));
	if ((sh_char_t*)0 == str) {
		__raise(err, SH_E_MALLOC_ERROR);
		return (sh_char_t*)0;
	}

	ptr = str;
	*ptr = SH_CHAR_C('*'); ptr ++;

	for (i = 0; i < obj->length; i += 3) {
		b1 = (obj->value[i] & 0xFC) >> 2;        /* xxxxxx__ -> __xxxxxx */
		b2 = (obj->value[i] & 0x03) << 4;        /* ______xx -> __xx____ */
		b3 = 0;
		b4 = 0;

		*ptr = _b64[b1]; ptr++;

		if ((i + 1) < obj->length) {
			b2 |= (obj->value[i+1] & 0xF0) >> 4; /* xxxx____ -> ____xxxx */
			b3  = (obj->value[i+1] & 0x0F) << 2; /* ____xxxx -> __xxxx__ */

			*ptr = _b64[b2]; ptr++;

			if ((i + 2) < obj->length) {
				b3 |= (obj->value[i+2] & 0xC0) >> 6; /* xx______ -> ______xx */
				b4  = (obj->value[i+2] & 0x3F);      /* __xxxxxx */

				*ptr = _b64[b3]; ptr++;
				*ptr = _b64[b4]; ptr++;
			} else {
				*ptr = _b64[b3]; ptr++;
				*ptr = SH_CHAR_C('='); ptr++;
			}
		} else {
			*ptr = _b64[b2]; ptr++;
			*ptr = SH_CHAR_C('='); ptr++;
			*ptr = SH_CHAR_C('='); ptr++;
		}
	}

	*ptr = SH_CHAR_C('*'); ptr ++;
	*ptr = SH_CHAR_C(0);

	__clear(err);
	return str;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
testq %rsi, %rsi
je 0x1243
cmpl $0x0, (%rbx)
je 0x1243
xorl %eax, %eax
jmp 0x1339
movq 0x8(%r14), %r15
leaq 0x2(,%r15,4), %rax
pushq $0x3
popq %rcx
xorl %edx, %edx
divq %rcx
leaq 0x3(%rax), %rdi
callq 0x1050
testq %rax, %rax
je 0x132b
movb $0x2a, (%rax)
movq %rax, %rcx
addq $0x4, %rcx
pushq $0x2
popq %rdx
movq 0x2d5b(%rip), %rsi      # 0x3fd8
leaq -0x2(%rdx), %r9
cmpq %r15, %r9
jae 0x1321
movq (%r14), %rdi
movzbl -0x2(%rdi,%rdx), %r8d
movl %r8d, %r10d
shrl $0x2, %r10d
shll $0x4, %r8d
andl $0x30, %r8d
movb (%rsi,%r10), %r10b
movb %r10b, -0x3(%rcx)
incq %r9
cmpq %r15, %r9
jae 0x12f9
movzbl -0x1(%rdi,%rdx), %r9d
movl %r9d, %r10d
shrl $0x4, %r10d
orq %r8, %r10
shll $0x2, %r9d
andl $0x3c, %r9d
movb (%rsi,%r10), %r8b
movb %r8b, -0x2(%rcx)
cmpq %r15, %rdx
jae 0x1309
movzbl (%rdi,%rdx), %edi
movl %edi, %r8d
shrl $0x6, %r8d
orq %r9, %r8
andl $0x3f, %edi
movb (%rsi,%r8), %r8b
movb %r8b, -0x1(%rcx)
movb (%rsi,%rdi), %dil
movb %dil, (%rcx)
jmp 0x1314
movb (%rsi,%r8), %dil
movb %dil, -0x2(%rcx)
movw $0x3d3d, -0x1(%rcx)     # imm = 0x3D3D
jmp 0x1314
movb (%rsi,%r9), %dil
movb %dil, -0x1(%rcx)
movb $0x3d, (%rcx)
addq $0x3, %rdx
addq $0x4, %rcx
jmp 0x127d
xorl %edx, %edx
movw $0x2a, -0x3(%rcx)
jmp 0x1332
movl $0x80000001, %edx       # imm = 0x80000001
xorl %eax, %eax
testq %rbx, %rbx
je 0x1339
movl %edx, (%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/carlitosmarin[P]Sistema-Ficheros-SOII/mi_chmod.c
// Function: main
int main (int argc, char **argv) {
	if (argc != 4) {
		printf("Número de parametros incorrectos\n");
		return -1;
	}
	//Montamos el disco
	bmount(argv[1]);

	unsigned int permisos = atoi(argv[2]);
	if(permisos < 0 || permisos > 7) {
		puts("Permisos introducidos invalidos\n");
		bumount();
		return -1;
	}

	if(mi_chmod (argv[3],permisos) == 0) printf("Permisos del fichero %s actualizados correctamente\n", argv[3]);
	else printf("Error: No se ha podido llevar a cabo mi_chmod\n");

	bumount();
	return 0;
}

// Assembly:
pushq %rbx
cmpl $0x4, %edi
jne 0x3c01
movq %rsi, %rbx
movq 0x8(%rsi), %rdi
callq 0x128c
movq 0x10(%rbx), %rdi
callq 0x1150
cmpl $0x8, %eax
jb 0x3c12
leaq 0x935(%rip), %rdi       # 0x4528
callq 0x1060
xorl %eax, %eax
callq 0x12c8
jmp 0x3c0d
leaq 0x9a3(%rip), %rdi       # 0x45ab
callq 0x1060
pushq $-0x1
popq %rbx
jmp 0x3c4b
movq 0x18(%rbx), %rdi
movzbl %al, %esi
callq 0x37dc
testl %eax, %eax
je 0x3c30
leaq 0x954(%rip), %rdi       # 0x457d
callq 0x1060
jmp 0x3c42
movq 0x18(%rbx), %rsi
leaq 0x90e(%rip), %rdi       # 0x4549
xorl %eax, %eax
callq 0x1090
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x12c8
movl %ebx, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/aligrudi[P]gpss/datgen.c
// Function: pt_quicksort
static void pt_quicksort(int *a, int n)
{
	int i, j, t;
	int kx, ky;
	if (n < 2)
		return;
	if (n < 100) {
		pt_insertion(a, n);
		return;
	}
	kx = pt_sx[a[n / 2]];
	ky = pt_sy[a[n / 2]];
	for (i = 0, j = n - 1; ; i++, j--) {
		while (DEGCMP(pt_sx[a[i]], pt_sy[a[i]], kx, ky) < 0)
			i++;
		while (DEGCMP(pt_sx[a[j]], pt_sy[a[j]], kx, ky) > 0)
			j--;
		if (i >= j)
			break;
		t = a[i];
		a[i] = a[j];
		a[j] = t;
	}
	if (i > 1)
		pt_quicksort(a, i);
	if (i + 1 < n)
		pt_quicksort(a + i, n - i);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0xb941c1(%rip), %r14    # 0xb95750
leaq 0xb9ddfa(%rip), %r15    # 0xb9f390
cmpl $0x2, %esi
jl 0x16d2
cmpl $0x63, %esi
jbe 0x1680
movl %esi, %eax
shrl %eax
movslq (%rbx,%rax,4), %rcx
movslq (%r14,%rcx,4), %rax
movslq (%r15,%rcx,4), %rcx
movl %esi, 0x4(%rsp)
movl %esi, %edx
xorl %esi, %esi
movq %rsi, 0x10(%rsp)
movslq %esi, %rsi
leaq (%rbx,%rsi,4), %rdi
pushq $0x4
popq %r12
xorl %ebp, %ebp
movslq (%rdi,%rbp,4), %r8
movslq (%r14,%r8,4), %r9
negq %r9
imulq %rcx, %r9
movslq (%r15,%r8,4), %r10
imulq %rax, %r10
incq %rbp
addq $-0x4, %r12
addq %r9, %r10
js 0x15d2
movslq %edx, %rdx
leaq (%rsi,%rbp), %r10
decq %r10
movslq -0x4(%rbx,%rdx,4), %r9
decq %rdx
movslq (%r14,%r9,4), %r11
negq %r11
imulq %rcx, %r11
movslq (%r15,%r9,4), %r13
imulq %rax, %r13
addq %r11, %r13
jg 0x15ff
cmpq %rdx, %r10
jge 0x1632
movl %r9d, -0x4(%rdi,%rbp,4)
movl %r8d, (%rbx,%rdx,4)
addq %rbp, %rsi
jmp 0x15c0
movq 0x10(%rsp), %r13
movslq %r13d, %rcx
leaq (%rcx,%rbp), %rax
decq %rax
cmpq $0x2, %rax
jl 0x1660
leal -0x1(%r13), %esi
addq %rbp, %rsi
movq %rbx, %rdi
movq %rcx, 0x8(%rsp)
callq 0x1577
movq 0x8(%rsp), %rcx
leal (%r13,%rbp), %eax
movl 0x4(%rsp), %esi
cmpl %esi, %eax
jge 0x16d2
leaq (%rbx,%rcx,4), %rbx
subq %r12, %rbx
subl %r13d, %esi
subl %ebp, %esi
incl %esi
jmp 0x1596
movl %esi, %eax
xorl %ecx, %ecx
cmpq %rax, %rcx
je 0x16d2
movl (%rbx,%rcx,4), %edx
movslq %edx, %rdi
movq %rcx, %rsi
testq %rsi, %rsi
jle 0x16c5
movslq (%r14,%rdi,4), %r9
negq %r9
movslq -0x4(%rbx,%rsi,4), %r8
movslq (%r15,%r8,4), %r10
imulq %r9, %r10
movslq (%r14,%r8,4), %r9
movslq (%r15,%rdi,4), %r11
imulq %r9, %r11
addq %r10, %r11
jns 0x16c7
movl %r8d, (%rbx,%rsi,4)
decq %rsi
jmp 0x1692
xorl %esi, %esi
movslq %esi, %rsi
movl %edx, (%rbx,%rsi,4)
incq %rcx
jmp 0x1684
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/Mikejmoffitt[P]romtools/bsplit/bsplit.c
// Function: split
void split(const char *in_fname, const char *out_even_fname, const char *out_odd_fname, int bytes)
{
	int c;
	FILE *fin, *fout_odd, *fout_even;
	fin = fopen(in_fname, "rb");
	if (!fin)
	{
		fprintf(stderr, "Couldn't open %s.\n", in_fname);
		return;
	}
	fout_odd = fopen(out_odd_fname, "wb");
	if (!fout_odd)
	{
		fprintf(stderr, "Couldn't open %s.\n", out_odd_fname);
		fclose(fin);
		return;
	}
	fout_even = fopen(out_even_fname, "wb");
	if (!fout_even)
	{
		fprintf(stderr, "Couldn't open %s.\n", out_even_fname);
		fclose(fin);
		fclose(fout_odd);
		return;
	}

	do
	{
		for (int i = 0; i < bytes; i++)
		{
			c = fgetc(fin);
			if (feof(fin))
			{
				goto done;
			}
			fputc(c, fout_even);
		}
		for (int i = 0; i < bytes; i++)
		{
			c = fgetc(fin);
			if (feof(fin))
			{
				goto done;
			}
			fputc(c, fout_odd);
		}
	}
	while (c != EOF);
done:
	fclose(fin);
	fclose(fout_odd);
	fclose(fout_even);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, 0x4(%rsp)
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r14
leaq 0xe29(%rip), %rsi       # 0x2004
callq 0x10a0
testq %rax, %rax
je 0x12c0
movq %rax, %rbx
leaq 0xe27(%rip), %rsi       # 0x201a
movq %r15, %rdi
callq 0x10a0
testq %rax, %rax
je 0x12e9
movq %rax, %r14
leaq 0xe0c(%rip), %rsi       # 0x201a
movq %r12, %rdi
callq 0x10a0
testq %rax, %rax
je 0x1309
movq %rax, %r15
xorl %ebp, %ebp
movl 0x4(%rsp), %eax
testl %eax, %eax
movl $0x0, %r13d
cmovgl %eax, %r13d
cmpl %r13d, %ebp
jne 0x1266
xorl %ebp, %ebp
cmpl %ebp, %r13d
je 0x128c
movq %rbx, %rdi
callq 0x1060
movl %eax, %r12d
movq %rbx, %rdi
callq 0x1090
testl %eax, %eax
jne 0x128c
movl %r12d, %edi
movq %r14, %rsi
callq 0x1070
incl %ebp
jmp 0x123b
movq %rbx, %rdi
callq 0x1060
movl %eax, %r12d
movq %rbx, %rdi
callq 0x1090
testl %eax, %eax
jne 0x129a
movl %r12d, %edi
movq %r15, %rsi
callq 0x1070
incl %ebp
jmp 0x1234
cmpl 0x4(%rsp), %ebp
jl 0x129a
xorl %ebp, %ebp
cmpl $-0x1, %r12d
jne 0x1234
movq %rbx, %rdi
callq 0x1040
movq %r14, %rdi
callq 0x1040
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1040
movq 0x2d31(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xd36(%rip), %rsi       # 0x2007
movq %r14, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1080
movq 0x2d08(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xd0d(%rip), %rsi       # 0x2007
movq %r15, %rdx
xorl %eax, %eax
callq 0x1080
movq %rbx, %rdi
jmp 0x12ad
movq 0x2ce8(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xced(%rip), %rsi       # 0x2007
movq %r12, %rdx
xorl %eax, %eax
callq 0x1080
movq %rbx, %rdi
callq 0x1040
movq %r14, %rdi
jmp 0x12ad
// File: /workspace/github_c_makefile_star2_O2/Mikejmoffitt[P]romtools/bsplit/bsplit.c
// Function: combine
void combine(const char *in_even_fname, const char *in_odd_fname, const char *out_fname, int bytes)
{
	int c;
	FILE *fin_odd, *fin_even, *fout;
	fout = fopen(out_fname, "wb");
	if (!fout)
	{
		fprintf(stderr, "Couldn't open %s.\n", out_fname);
		return;
	}
	fin_even = fopen(in_even_fname, "rb");
	if (!fin_even)
	{
		fprintf(stderr, "Couldn't open %s.\n", in_even_fname);
		fclose(fout);
		return;
	}
	fin_odd = fopen(in_odd_fname, "rb");
	if (!fin_odd)
	{
		fprintf(stderr, "Couldn't open %s.\n", in_odd_fname);
		fclose(fin_even);
		fclose(fout);
		return;
	}

	do
	{
		for (int i = 0; i < bytes; i++)
		{
			c = fgetc(fin_even);
			if (c != EOF)
			{
				fputc(c, fout);
			}
		}

		for (int i = 0; i < bytes; i++)
		{
			c = fgetc(fin_odd);
			if (c != EOF)
			{
				fputc(c, fout);
			}
		}
	} while (c != EOF);

	fclose(fout);
	fclose(fin_even);
	fclose(fin_odd);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r14d
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %r15
leaq 0xcc8(%rip), %rsi       # 0x201a
movq %rdx, %rdi
callq 0x10a0
testq %rax, %rax
je 0x1425
movq %rax, %rbx
leaq 0xc97(%rip), %rsi       # 0x2004
movq %r15, %rdi
callq 0x10a0
movq %rax, (%rsp)
testq %rax, %rax
je 0x144e
leaq 0xc7b(%rip), %rsi       # 0x2004
movq %r12, %rdi
callq 0x10a0
testq %rax, %rax
je 0x146b
movq %rax, %r15
xorl %r13d, %r13d
testl %r14d, %r14d
cmovlel %r13d, %r14d
movl %r14d, %ebp
cmpl %r14d, %r13d
jne 0x13d1
subl $0x1, %ebp
jb 0x13f2
movq %r15, %rdi
callq 0x1060
movl %eax, %r12d
cmpl $-0x1, %eax
je 0x13af
movl %r12d, %edi
movq %rbx, %rsi
callq 0x1070
jmp 0x13af
movq (%rsp), %rdi
callq 0x1060
movl %eax, %r12d
cmpl $-0x1, %eax
je 0x13ed
movl %r12d, %edi
movq %rbx, %rsi
callq 0x1070
incl %r13d
jmp 0x13a7
movl $0x0, %r13d
cmpl $-0x1, %r12d
jne 0x13a7
movq %rbx, %rdi
callq 0x1040
movq (%rsp), %rdi
callq 0x1040
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1040
movq 0x2bcc(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xbd1(%rip), %rsi       # 0x2007
movq %r13, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1080
movq 0x2ba3(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xba8(%rip), %rsi       # 0x2007
movq %r15, %rdx
xorl %eax, %eax
callq 0x1080
jmp 0x148f
movq 0x2b86(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xb8b(%rip), %rsi       # 0x2007
movq %r12, %rdx
xorl %eax, %eax
callq 0x1080
movq (%rsp), %rdi
callq 0x1040
movq %rbx, %rdi
jmp 0x1412
// File: /workspace/github_c_makefile_star2_O2/Mikejmoffitt[P]romtools/bsplit/bsplit.c
// Function: exchange
void exchange(const char *in_fname, const char *out_fname)
{
	int c;
	uint8_t byte[2];
	FILE *fin, *fout;
	fout = fopen(out_fname, "wb");
	if (!fout)
	{
		fprintf(stderr, "Couldn't open %s.\n", out_fname);
		return;
	}
	fin = fopen(in_fname, "rb");
	if (!fin)
	{
		fprintf(stderr, "Couldn't open %s.\n", in_fname);
		fclose(fout);
		return;
	}

	do
	{
		c = fgetc(fin);
		if (c == EOF)
		{
			break;
		}
		byte[0] = c;
		c = fgetc(fin);
		if (c == EOF)
		{
			break;
		}
		byte[1] = c;

		fputc(byte[1], fout);
		fputc(byte[0], fout);
	} while (c != EOF);

	fclose(fout);
	fclose(fin);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
leaq 0xb6f(%rip), %rsi       # 0x201a
movq %r14, %rdi
callq 0x10a0
testq %rax, %rax
je 0x152e
movq %rax, %rbx
leaq 0xb42(%rip), %rsi       # 0x2004
movq %r15, %rdi
callq 0x10a0
testq %rax, %rax
je 0x1553
movq %rax, %r14
movl $0xff, %r15d
movq %r14, %rdi
callq 0x1060
cmpl $-0x1, %eax
je 0x1514
movl %eax, %ebp
movq %r14, %rdi
callq 0x1060
cmpl $-0x1, %eax
je 0x1514
andl %r15d, %eax
movl %eax, %edi
movq %rbx, %rsi
callq 0x1070
andl %r15d, %ebp
movl %ebp, %edi
movq %rbx, %rsi
callq 0x1070
jmp 0x14dc
movq %rbx, %rdi
callq 0x1040
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1040
movq 0x2ac3(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xac8(%rip), %rsi       # 0x2007
movq %r14, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1080
movq 0x2a9e(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xaa3(%rip), %rsi       # 0x2007
movq %r15, %rdx
xorl %eax, %eax
callq 0x1080
movq %rbx, %rdi
jmp 0x151f
// File: /workspace/github_c_makefile_star2_O2/Mikejmoffitt[P]romtools/bsplit/bsplit.c
// Function: exchange_nybbles
void exchange_nybbles(const char *in_fname, const char *out_fname)
{
	int c;
	FILE *fin, *fout;
	fout = fopen(out_fname, "wb");
	if (!fout)
	{
		fprintf(stderr, "Couldn't open %s.\n", out_fname);
		return;
	}
	fin = fopen(in_fname, "rb");
	if (!fin)
	{
		fprintf(stderr, "Couldn't open %s.\n", in_fname);
		fclose(fout);
		return;
	}

	do
	{
		c = fgetc(fin);
		if (c == EOF)
		{
			break;
		}
		fputc(((c & 0xF) << 4) | ((c & 0xF0) >> 4), fout);
	} while (c != EOF);

	fclose(fout);
	fclose(fin);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0xa95(%rip), %rsi       # 0x201a
movq %r14, %rdi
callq 0x10a0
testq %rax, %rax
je 0x15ea
movq %rax, %rbx
leaq 0xa68(%rip), %rsi       # 0x2004
movq %r15, %rdi
callq 0x10a0
testq %rax, %rax
je 0x160a
movq %rax, %r14
movq %r14, %rdi
callq 0x1060
cmpl $-0x1, %eax
je 0x15d5
movl %eax, %ecx
shll $0x4, %ecx
movzbl %cl, %ecx
shrl $0x4, %eax
andl $0xf, %eax
orl %ecx, %eax
movl %eax, %edi
movq %rbx, %rsi
callq 0x1070
jmp 0x15ac
movq %rbx, %rdi
callq 0x1040
movq %r14, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x1040
movq 0x2a07(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0xa0c(%rip), %rsi       # 0x2007
movq %r14, %rdx
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x1080
movq 0x29e7(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x9ec(%rip), %rsi       # 0x2007
movq %r15, %rdx
xorl %eax, %eax
callq 0x1080
movq %rbx, %rdi
jmp 0x15e0
// File: /workspace/github_c_makefile_star2_O2/Mikejmoffitt[P]romtools/bsplit/bsplit.c
// Function: exchange_halfnybbles
void exchange_halfnybbles(const char *in_fname, const char *out_fname)
{
	int c;
	uint8_t byte;
	FILE *fin, *fout;
	fout = fopen(out_fname, "wb");
	if (!fout)
	{
		fprintf(stderr, "Couldn't open %s.\n", out_fname);
		return;
	}
	fin = fopen(in_fname, "rb");
	if (!fin)
	{
		fprintf(stderr, "Couldn't open %s.\n", in_fname);
		fclose(fout);
		return;
	}

	do
	{
		c = fgetc(fin);
		if (c == EOF)
		{
			break;
		}
		byte = c;
		c = ((byte & 0x03) << 2) | ((byte & 0x0C) >> 2) | (((byte & 0x30) << 2) | ((byte & 0xC0) >> 2));

		fputc(c, fout);
	} while (c != EOF);

	fclose(fout);
	fclose(fin);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x9de(%rip), %rsi       # 0x201a
movq %r14, %rdi
callq 0x10a0
testq %rax, %rax
je 0x169d
movq %rax, %rbx
leaq 0x9b1(%rip), %rsi       # 0x2004
movq %r15, %rdi
callq 0x10a0
testq %rax, %rax
je 0x16bd
movq %rax, %r14
movq %r14, %rdi
callq 0x1060
cmpl $-0x1, %eax
je 0x1688
movl %eax, %ecx
shrl $0x2, %ecx
andl $0x33, %ecx
andl $0x33, %eax
leal (%rcx,%rax,4), %edi
movq %rbx, %rsi
callq 0x1070
jmp 0x1663
movq %rbx, %rdi
callq 0x1040
movq %r14, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x1040
movq 0x2954(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x959(%rip), %rsi       # 0x2007
movq %r14, %rdx
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x1080
movq 0x2934(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
leaq 0x939(%rip), %rsi       # 0x2007
movq %r15, %rdx
xorl %eax, %eax
callq 0x1080
movq %rbx, %rdi
jmp 0x1693
// File: /workspace/github_c_makefile_star2_O2/Mikejmoffitt[P]romtools/bsplit/bsplit.c
// Function: usage
void usage(const char *name)
{
	printf("Usage: %s [op]\n", name);
	printf("    split: s in out.even out.odd <bytes per>\n");
	printf("  combine: c in.even in.odd out <bytes per>\n");
	printf(" exchange: x in out\n");
	printf(" ex. 4bit: n in out\n");
	printf(" ex. 2bit: z in out\n");
}

// Assembly:
pushq %rax
movq %rdi, %rsi
leaq 0x935(%rip), %rdi       # 0x201d
xorl %eax, %eax
callq 0x1050
leaq 0x95a(%rip), %rdi       # 0x2050
callq 0x1030
leaq 0x97b(%rip), %rdi       # 0x207d
callq 0x1030
leaq 0x99b(%rip), %rdi       # 0x20a9
callq 0x1030
leaq 0x9a3(%rip), %rdi       # 0x20bd
callq 0x1030
leaq 0x9ab(%rip), %rdi       # 0x20d1
popq %rax
jmp 0x1030
// File: /workspace/github_c_makefile_star2_O2/Mikejmoffitt[P]romtools/bsplit/bsplit.c
// Function: main
int main(int argc, char **argv)
{
	if (argc < 2)
	{
		usage(argv[0]);
		return 0;
	}

	int bytes = 1;

	if (argc > 5)
	{
		bytes = atoi(argv[5]);
		printf("Using %d bytes interleave cadence\n", bytes);
	}

	if (argv[1][0] == 's')
	{
		if (argc < 5)
		{
			usage(argv[0]);
			return 0;
		}
		printf("Splitting\n");
		split(argv[2], argv[3], argv[4], bytes);
	}
	else if (argv[1][0] == 'c')
	{
		if (argc < 5)
		{
			usage(argv[0]);
			return 0;
		}
		printf("Combining\n");
		combine(argv[2], argv[3], argv[4], bytes);
	}
	else if (argv[1][0] == 'x')
	{
		if (argc < 4)
		{
			usage(argv[0]);
			return 0;
		}
		printf("Exchanging bytes\n");
		exchange(argv[2], argv[3]);
	}
	else if (argv[1][0] == 'n')
	{
		if (argc < 4)
		{
			usage(argv[0]);
			return 0;
		}
		printf("Exchanging nybbles\n");
		exchange_nybbles(argv[2], argv[3]);
	}
	else if (argv[1][0] == 'z')
	{
		if (argc < 4)
		{
			usage(argv[0]);
			return 0;
		}
		printf("Exchanging half-nybbles\n");
		exchange_halfnybbles(argv[2], argv[3]);
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
cmpl $0x1, %edi
jg 0x1747
movq (%rbx), %rdi
callq 0x16dd
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
movl %edi, %r14d
cmpl $0x6, %edi
jb 0x176c
movq 0x28(%rbx), %rdi
callq 0x10b0
movl %eax, %ebp
leaq 0x8cc(%rip), %rdi       # 0x202d
movl %eax, %esi
xorl %eax, %eax
callq 0x1050
jmp 0x176f
pushq $0x1
popq %rbp
movq 0x8(%rbx), %rax
movzbl (%rax), %eax
cmpl $0x63, %eax
je 0x1836
cmpl $0x6e, %eax
je 0x17be
cmpl $0x7a, %eax
je 0x180e
cmpl $0x78, %eax
je 0x17e6
cmpl $0x73, %eax
jne 0x1740
cmpl $0x4, %r14d
jbe 0x1738
leaq 0x987(%rip), %rdi       # 0x212b
callq 0x1030
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
movl %ebp, %ecx
callq 0x11bc
jmp 0x1740
cmpl $0x3, %r14d
jbe 0x1738
leaq 0x92e(%rip), %rdi       # 0x20fd
callq 0x1030
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
callq 0x1573
jmp 0x1740
cmpl $0x3, %r14d
jbe 0x1738
leaq 0x919(%rip), %rdi       # 0x2110
callq 0x1030
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
callq 0x1497
jmp 0x1740
cmpl $0x3, %r14d
jbe 0x1738
leaq 0x8c6(%rip), %rdi       # 0x20e5
callq 0x1030
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
callq 0x162a
jmp 0x1740
cmpl $0x4, %r14d
jbe 0x1738
leaq 0x8da(%rip), %rdi       # 0x2121
callq 0x1030
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
movq 0x20(%rbx), %rdx
movl %ebp, %ecx
callq 0x1334
jmp 0x1740
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/sonic.c
// Function: sonicIntCreateStream
sonicStream sonicCreateStream(int sampleRate, int numChannels) {
  sonicStream stream =
      (sonicStream)sonicCalloc(1, sizeof(struct sonicStreamStruct));

  sampleRate = CLAMP(sampleRate, SONIC_MIN_SAMPLE_RATE, SONIC_MAX_SAMPLE_RATE);
  numChannels = CLAMP(numChannels, SONIC_MIN_CHANNELS, SONIC_MAX_CHANNELS);
  if (stream == NULL) {
    return NULL;
  }
  if (!allocateStreamBuffers(stream, sampleRate, numChannels)) {
    return NULL;
  }
  stream->speed = 1.0f;
  stream->pitch = 1.0f;
  stream->volume = 1.0f;
  stream->rate = 1.0f;
  stream->oldRatePosition = 0;
  stream->newRatePosition = 0;
  stream->quality = 0;
  return stream;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %r14d
movl %edi, %ebp
pushq $0x1
popq %rdi
movl $0x88, %esi
callq 0x10a0
testq %rax, %rax
je 0x13e7
movq %rax, %rbx
cmpl $0x20, %r14d
pushq $0x20
popq %rax
cmovll %r14d, %eax
cmpl $0x2, %eax
pushq $0x1
popq %rdx
cmovgel %eax, %edx
movl $0x7a120, %eax          # imm = 0x7A120
cmpl %eax, %ebp
cmovll %ebp, %eax
cmpl $0x3e9, %eax            # imm = 0x3E9
movl $0x3e8, %esi            # imm = 0x3E8
cmovgel %eax, %esi
movq %rbx, %rdi
callq 0x13fc
testl %eax, %eax
je 0x13e7
movaps 0x1c58(%rip), %xmm0     # 0x3030
movups %xmm0, 0x28(%rbx)
andq $0x0, 0x44(%rbx)
andl $0x0, 0x4c(%rbx)
jmp 0x13e9
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/sonic.c
// Function: sonicIntReadFloatFromStream
int sonicReadFloatFromStream(sonicStream stream, float* samples,
                             int maxSamples) {
  int numSamples = stream->numOutputSamples;
  int remainingSamples = 0;
  short* buffer;
  int count;

  if (numSamples == 0) {
    return 0;
  }
  if (numSamples > maxSamples) {
    remainingSamples = numSamples - maxSamples;
    numSamples = maxSamples;
  }
  buffer = stream->outputBuffer;
  count = numSamples * stream->numChannels;
  while (count--) {
    *samples++ = (*buffer++) / 32767.0f;
  }
  if (remainingSamples > 0) {
    memmove(stream->outputBuffer,
            stream->outputBuffer + numSamples * stream->numChannels,
            remainingSamples * sizeof(short) * stream->numChannels);
  }
  stream->numOutputSamples = remainingSamples;
  return numSamples;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl 0x64(%rdi), %r15d
testl %r15d, %r15d
je 0x1615
movl %edx, %eax
movq %rdi, %r14
cmpl %edx, %r15d
movl %edx, %ebx
cmovll %r15d, %ebx
movq 0x8(%rdi), %rdi
movslq 0x50(%r14), %rdx
movl %edx, %ecx
imull %ebx, %ecx
xorl %r8d, %r8d
movss 0x1a41(%rip), %xmm0     # 0x3010
cmpl %r8d, %ecx
je 0x15ed
movswl (%rdi,%r8,2), %r9d
cvtsi2ss %r9d, %xmm1
divss %xmm0, %xmm1
movss %xmm1, (%rsi,%r8,4)
incq %r8
jmp 0x15cf
xorl %esi, %esi
subl %eax, %r15d
cmovlel %esi, %r15d
testl %r15d, %r15d
jle 0x160f
movslq %ecx, %rax
leaq (%rdi,%rax,2), %rsi
leal (%r15,%r15), %eax
imulq %rax, %rdx
callq 0x1150
movl %r15d, 0x64(%r14)
jmp 0x1617
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/sonic.c
// Function: sonicIntReadShortFromStream
int sonicReadShortFromStream(sonicStream stream, short* samples,
                             int maxSamples) {
  int numSamples = stream->numOutputSamples;
  int remainingSamples = 0;

  if (numSamples == 0) {
    return 0;
  }
  if (numSamples > maxSamples) {
    remainingSamples = numSamples - maxSamples;
    numSamples = maxSamples;
  }
  memcpy(samples, stream->outputBuffer,
         numSamples * sizeof(short) * stream->numChannels);
  if (remainingSamples > 0) {
    memmove(stream->outputBuffer,
            stream->outputBuffer + numSamples * stream->numChannels,
            remainingSamples * sizeof(short) * stream->numChannels);
  }
  stream->numOutputSamples = remainingSamples;
  return numSamples;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movl 0x64(%rdi), %eax
testl %eax, %eax
je 0x1687
movl %edx, %ebx
movq %rdi, %r14
xorl %ecx, %ecx
movl %eax, %r15d
subl %edx, %r15d
cmovll %eax, %ebx
cmovlel %ecx, %r15d
movq 0x8(%rdi), %rax
movslq %ebx, %r12
movslq 0x50(%rdi), %rdx
imulq %r12, %rdx
addq %rdx, %rdx
movq %rsi, %rdi
movq %rax, %rsi
callq 0x10f0
testl %r15d, %r15d
jle 0x1681
movq 0x8(%r14), %rdi
movslq 0x50(%r14), %rax
imulq %rax, %r12
leaq (%rdi,%r12,2), %rsi
leal (%r15,%r15), %edx
imulq %rax, %rdx
callq 0x1150
movl %r15d, 0x64(%r14)
jmp 0x1689
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/sonic.c
// Function: sonicIntReadUnsignedCharFromStream
int sonicReadUnsignedCharFromStream(sonicStream stream, unsigned char* samples,
                                    int maxSamples) {
  int numSamples = stream->numOutputSamples;
  int remainingSamples = 0;
  short* buffer;
  int count;

  if (numSamples == 0) {
    return 0;
  }
  if (numSamples > maxSamples) {
    remainingSamples = numSamples - maxSamples;
    numSamples = maxSamples;
  }
  buffer = stream->outputBuffer;
  count = numSamples * stream->numChannels;
  while (count--) {
    *samples++ = (char)((*buffer++) >> 8) + 128;
  }
  if (remainingSamples > 0) {
    memmove(stream->outputBuffer,
            stream->outputBuffer + numSamples * stream->numChannels,
            remainingSamples * sizeof(short) * stream->numChannels);
  }
  stream->numOutputSamples = remainingSamples;
  return numSamples;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl 0x64(%rdi), %r15d
testl %r15d, %r15d
je 0x1707
movq %rdi, %r14
cmpl %edx, %r15d
movl %edx, %ebx
cmovll %r15d, %ebx
movq 0x8(%rdi), %rax
movl 0x50(%rdi), %ecx
imull %ebx, %ecx
xorl %edi, %edi
cmpl %edi, %ecx
je 0x16d3
movb 0x1(%rax,%rdi,2), %r8b
addb $-0x80, %r8b
movb %r8b, (%rsi,%rdi)
incq %rdi
jmp 0x16bd
xorl %eax, %eax
subl %edx, %r15d
cmovlel %eax, %r15d
testl %r15d, %r15d
jle 0x1701
movq 0x8(%r14), %rdi
movslq 0x50(%r14), %rax
movslq %ebx, %rcx
imulq %rax, %rcx
leaq (%rdi,%rcx,2), %rsi
leal (%r15,%r15), %edx
imulq %rax, %rdx
callq 0x1150
movl %r15d, 0x64(%r14)
jmp 0x1709
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/sonic.c
// Function: sonicIntFlushStream
int sonicFlushStream(sonicStream stream) {
  int maxRequired = stream->maxRequired;
  int remainingSamples = stream->numInputSamples;
  float speed = stream->speed / stream->pitch;
  float rate = stream->rate * stream->pitch;
  int expectedOutputSamples =
      stream->numOutputSamples +
      (int)((remainingSamples / speed + stream->numPitchSamples) / rate + 0.5f);

  /* Add enough silence to flush both input and pitch buffers. */
  if (!enlargeInputBufferIfNeeded(stream, remainingSamples + 2 * maxRequired)) {
    return 0;
  }
  memset(stream->inputBuffer + remainingSamples * stream->numChannels, 0,
         2 * maxRequired * sizeof(short) * stream->numChannels);
  stream->numInputSamples += 2 * maxRequired;
  if (!sonicWriteShortToStream(stream, NULL, 0)) {
    return 0;
  }
  /* Throw away any extra samples we generated due to the silence we added */
  if (stream->numOutputSamples > expectedOutputSamples) {
    stream->numOutputSamples = expectedOutputSamples;
  }
  /* Empty input and pitch buffers */
  stream->numInputSamples = 0;
  stream->inputPlayTime = 0.0f;
  stream->timeError = 0.0f;
  stream->numPitchSamples = 0;
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movslq 0x74(%rdi), %r15
movslq 0x60(%rdi), %r14
movss 0x28(%rdi), %xmm0
movss 0x30(%rdi), %xmm1
divss %xmm1, %xmm0
cvtsi2ss %r14d, %xmm2
divss %xmm0, %xmm2
cvtsi2ssl 0x68(%rdi), %xmm0
mulss 0x34(%rdi), %xmm1
addss %xmm2, %xmm0
divss %xmm1, %xmm0
addss 0x18bf(%rip), %xmm0     # 0x3014
cvttss2si %xmm0, %r12d
addl 0x64(%rdi), %r12d
addq %r15, %r15
leal (%r14,%r15), %esi
callq 0x17cb
testl %eax, %eax
je 0x17be
movslq 0x50(%rbx), %rax
imulq %rax, %r14
addq %r14, %r14
addq (%rbx), %r14
movq %r15, %rdx
imulq %rax, %rdx
addq %rdx, %rdx
xorl %ebp, %ebp
movq %r14, %rdi
xorl %esi, %esi
callq 0x1090
addl %r15d, 0x60(%rbx)
movq %rbx, %rdi
callq 0x18f0
testl %eax, %eax
je 0x17c0
cmpl %r12d, 0x64(%rbx)
jle 0x17ac
movl %r12d, 0x64(%rbx)
andl $0x0, 0x60(%rbx)
andq $0x0, 0x3c(%rbx)
andl $0x0, 0x68(%rbx)
pushq $0x1
popq %rbp
jmp 0x17c0
xorl %ebp, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/sonic.c
// Function: enlargeInputBufferIfNeeded
static int enlargeInputBufferIfNeeded(sonicStream stream, int numSamples) {
  int inputBufferSize = stream->inputBufferSize;

  if (stream->numInputSamples + numSamples > inputBufferSize) {
    stream->inputBufferSize += (inputBufferSize >> 1) + numSamples;
    stream->inputBuffer = (short*)sonicRealloc(
        stream->inputBuffer, inputBufferSize, stream->inputBufferSize,
        sizeof(short) * stream->numChannels);
    if (stream->inputBuffer == NULL) {
      return 0;
    }
  }
  return 1;
}

// Assembly:
movl 0x54(%rdi), %eax
movl 0x60(%rdi), %ecx
addl %esi, %ecx
cmpl %eax, %ecx
jle 0x1800
pushq %rbx
movq %rdi, %rbx
movl %eax, %ecx
sarl %ecx
addl %eax, %esi
addl %ecx, %esi
movl %esi, 0x54(%rdi)
movq (%rdi), %rdi
imull 0x50(%rbx), %esi
addl %esi, %esi
movslq %esi, %rsi
callq 0x1140
movq %rax, (%rbx)
testq %rax, %rax
popq %rbx
je 0x1804
pushq $0x1
popq %rax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/sonic.c
// Function: sonicIntChangeFloatSpeed
int sonicChangeFloatSpeed(float* samples, int numSamples, float speed,
                          float pitch, float rate, float volume,
                          int useChordPitch, int sampleRate, int numChannels) {
  sonicStream stream = sonicCreateStream(sampleRate, numChannels);

  sonicSetSpeed(stream, speed);
  sonicSetPitch(stream, pitch);
  sonicSetRate(stream, rate);
  sonicSetVolume(stream, volume);
  sonicWriteFloatToStream(stream, samples, numSamples);
  sonicFlushStream(stream);
  numSamples = sonicSamplesAvailable(stream);
  sonicReadFloatFromStream(stream, samples, numSamples);
  sonicDestroyStream(stream);
  return numSamples;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x40, %rsp
movaps %xmm3, 0x30(%rsp)
movaps %xmm2, 0x20(%rsp)
movaps %xmm1, (%rsp)
movaps %xmm0, 0x10(%rsp)
movl %esi, %ebp
movq %rdi, %rbx
movl %ecx, %edi
movl %r8d, %esi
callq 0x1110
movq %rax, %r14
movaps (%rsp), %xmm0
unpcklps 0x20(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
movaps 0x10(%rsp), %xmm2
unpcklps 0x30(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
movlhps %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
andq $0x0, 0x44(%rax)
movaps 0xe08(%rip), %xmm0      # 0x3040
movaps 0xe11(%rip), %xmm1      # 0x3050
minps %xmm2, %xmm1
cmpltps %xmm0, %xmm2
andps %xmm2, %xmm0
andnps %xmm1, %xmm2
orps %xmm0, %xmm2
movups %xmm2, 0x28(%rax)
movq %rax, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x1040
movq %r14, %rdi
callq 0x1060
movl 0x64(%r14), %ebp
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x1100
movq %r14, %rdi
callq 0x10d0
movl %ebp, %eax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/sonic.c
// Function: sonicIntChangeShortSpeed
int sonicChangeShortSpeed(short* samples, int numSamples, float speed,
                          float pitch, float rate, float volume,
                          int useChordPitch, int sampleRate, int numChannels) {
  sonicStream stream = sonicCreateStream(sampleRate, numChannels);

  sonicSetSpeed(stream, speed);
  sonicSetPitch(stream, pitch);
  sonicSetRate(stream, rate);
  sonicSetVolume(stream, volume);
  sonicWriteShortToStream(stream, samples, numSamples);
  sonicFlushStream(stream);
  numSamples = sonicSamplesAvailable(stream);
  sonicReadShortFromStream(stream, samples, numSamples);
  sonicDestroyStream(stream);
  return numSamples;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x40, %rsp
movaps %xmm3, 0x30(%rsp)
movaps %xmm2, 0x20(%rsp)
movaps %xmm1, (%rsp)
movaps %xmm0, 0x10(%rsp)
movl %esi, %ebp
movq %rdi, %rbx
movl %ecx, %edi
movl %r8d, %esi
callq 0x1110
movq %rax, %r14
movaps (%rsp), %xmm0
unpcklps 0x20(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
movaps 0x10(%rsp), %xmm2
unpcklps 0x30(%rsp), %xmm2       # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
movlhps %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
andq $0x0, 0x44(%rax)
movaps 0xd65(%rip), %xmm0      # 0x3040
movaps 0xd6e(%rip), %xmm1      # 0x3050
minps %xmm2, %xmm1
cmpltps %xmm0, %xmm2
andps %xmm2, %xmm0
andnps %xmm1, %xmm2
orps %xmm0, %xmm2
movups %xmm2, 0x28(%rax)
movq %rax, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x10e0
movq %r14, %rdi
callq 0x1060
movl 0x64(%r14), %ebp
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x1180
movq %r14, %rdi
callq 0x10d0
movl %ebp, %eax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/sonic.c
// Function: removeInputSamples
static void removeInputSamples(sonicStream stream, int position) {
  int remainingSamples = stream->numInputSamples - position;

  if (remainingSamples > 0) {
    memmove(stream->inputBuffer,
            stream->inputBuffer + position * stream->numChannels,
            remainingSamples * sizeof(short) * stream->numChannels);
  }
  /* If we play 3/4ths of the samples, then the expected play time of the
     remaining samples is 1/4th of the original expected play time. */
  stream->inputPlayTime =
      (stream->inputPlayTime * remainingSamples) / stream->numInputSamples;
  stream->numInputSamples = remainingSamples;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x60(%rdi), %eax
movl %eax, %r14d
subl %esi, %r14d
jle 0x2388
movq (%rbx), %rdi
movslq 0x50(%rbx), %rax
movslq %esi, %rcx
imulq %rax, %rcx
leaq (%rdi,%rcx,2), %rsi
leal (%r14,%r14), %edx
imulq %rax, %rdx
callq 0x1150
movl 0x60(%rbx), %eax
cvtsi2ss %r14d, %xmm0
mulss 0x3c(%rbx), %xmm0
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
movss %xmm0, 0x3c(%rbx)
movl %r14d, 0x60(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/sonic.c
// Function: enlargeOutputBufferIfNeeded
static int enlargeOutputBufferIfNeeded(sonicStream stream, int numSamples) {
  int outputBufferSize = stream->outputBufferSize;

  if (stream->numOutputSamples + numSamples > outputBufferSize) {
    stream->outputBufferSize += (outputBufferSize >> 1) + numSamples;
    stream->outputBuffer = (short*)sonicRealloc(
        stream->outputBuffer, outputBufferSize, stream->outputBufferSize,
        sizeof(short) * stream->numChannels);
    if (stream->outputBuffer == NULL) {
      return 0;
    }
  }
  return 1;
}

// Assembly:
movl 0x5c(%rdi), %eax
movl 0x64(%rdi), %ecx
addl %esi, %ecx
cmpl %eax, %ecx
jle 0x23e2
pushq %rbx
movq %rdi, %rbx
movl %eax, %ecx
sarl %ecx
addl %eax, %esi
addl %ecx, %esi
movl %esi, 0x5c(%rdi)
movq 0x8(%rdi), %rdi
imull 0x50(%rbx), %esi
addl %esi, %esi
movslq %esi, %rsi
callq 0x1140
movq %rax, 0x8(%rbx)
testq %rax, %rax
popq %rbx
je 0x23e6
pushq $0x1
popq %rax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/sonic.c
// Function: findPitchPeriodInRange
static int findPitchPeriodInRange(short* samples, int minPeriod, int maxPeriod,
                                  int* retMinDiff, int* retMaxDiff) {
  int period, bestPeriod = 0, worstPeriod = 255;
  short* s;
  short* p;
  short sVal, pVal;
  unsigned long diff, minDiff = 1, maxDiff = 0;
  int i;

  for (period = minPeriod; period <= maxPeriod; period++) {
    diff = 0;
    s = samples;
    p = samples + period;
    for (i = 0; i < period; i++) {
      sVal = *s++;
      pVal = *p++;
      diff += sVal >= pVal ? (unsigned short)(sVal - pVal)
                           : (unsigned short)(pVal - sVal);
    }
    /* Note that the highest number of samples we add into diff will be less
       than 256, since we skip samples.  Thus, diff is a 24 bit number, and
       we can safely multiply by numSamples without overflow */
    if (bestPeriod == 0 || diff * bestPeriod < minDiff * period) {
      minDiff = diff;
      bestPeriod = period;
    }
    if (diff * worstPeriod > maxDiff * period) {
      maxDiff = diff;
      worstPeriod = period;
    }
  }
  *retMinDiff = minDiff / bestPeriod;
  *retMaxDiff = maxDiff / worstPeriod;
  return bestPeriod;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, -0x10(%rsp)
movq %rcx, -0x18(%rsp)
movq %rdi, -0x8(%rsp)
movslq %esi, %r11
movslq %edx, %rdi
leaq (%r11,%r11), %rbx
movabsq $0x1, %rax
xorl %esi, %esi
movl $0xff, %r10d
xorl %r9d, %r9d
testl %r11d, %r11d
movl $0x0, %ebp
cmovgl %r11d, %ebp
movslq %esi, %r15
movslq %r10d, %r10
cmpq %rdi, %r11
jg 0x24af
movq -0x8(%rsp), %r12
xorl %r14d, %r14d
subl $0x1, %ebp
jb 0x2470
movzwl (%r12), %r13d
movzwl (%r12,%rbx), %edx
movl %r13d, %ecx
subw %dx, %cx
movl %ecx, %r8d
negl %r8d
cmpw %dx, %r13w
cmovgel %ecx, %r8d
addq $0x2, %r12
movzwl %r8w, %ecx
addq %rcx, %r14
jmp 0x2440
testl %esi, %esi
je 0x2484
imulq %r14, %r15
movq %rax, %rcx
imulq %r11, %rcx
cmpq %rcx, %r15
jae 0x248a
movl %r11d, %esi
movq %r14, %rax
movq %r14, %rcx
imulq %r10, %rcx
movq %r9, %rdx
imulq %r11, %rdx
cmpq %rdx, %rcx
cmoval %r11d, %r10d
cmovaq %r14, %r9
incq %r11
addq $0x2, %rbx
jmp 0x2421
xorl %edx, %edx
divq %r15
movq -0x18(%rsp), %rcx
movl %eax, (%rcx)
movq %r9, %rax
xorl %edx, %edx
divq %r10
movq -0x10(%rsp), %rcx
movl %eax, (%rcx)
movl %esi, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/sonic.c
// Function: downSampleInput
static void downSampleInput(sonicStream stream, short* samples, int skip) {
  int numSamples = stream->maxRequired / skip;
  int samplesPerValue = stream->numChannels * skip;
  int i, j;
  int value;
  short* downSamples = stream->downSampleBuffer;

  for (i = 0; i < numSamples; i++) {
    value = 0;
    for (j = 0; j < samplesPerValue; j++) {
      value += *samples++;
    }
    value /= samplesPerValue;
    *downSamples++ = value;
  }
}

// Assembly:
movl %edx, %ecx
movl 0x74(%rdi), %eax
cltd
idivl %ecx
movl %eax, %r8d
imull 0x50(%rdi), %ecx
movq 0x18(%rdi), %rdi
xorl %r9d, %r9d
testl %ecx, %ecx
movl $0x0, %r10d
cmovgl %ecx, %r10d
testl %eax, %eax
cmovlel %r9d, %r8d
cmpl %r8d, %r9d
je 0x252a
xorl %eax, %eax
movl %r10d, %edx
subl $0x1, %edx
jb 0x251b
movswl (%rsi), %r11d
addq $0x2, %rsi
addl %r11d, %eax
jmp 0x2509
cltd
idivl %ecx
movw %ax, (%rdi)
addq $0x2, %rdi
incl %r9d
jmp 0x24ff
retq
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/sonic.c
// Function: overlapAdd
static void overlapAdd(int numSamples, int numChannels, short* out,
                       short* rampDown, short* rampUp) {
  short* o;
  short* u;
  short* d;
  int i, t;

  for (i = 0; i < numChannels; i++) {
    o = out + i;
    u = rampUp + i;
    d = rampDown + i;
    for (t = 0; t < numSamples; t++) {
#ifdef SONIC_USE_SIN
      float ratio = sin(t * M_PI / (2 * numSamples));
      *o = *d * (1.0f - ratio) + *u * ratio;
#else
      *o = (*d * (numSamples - t) + *u * t) / numSamples;
#endif
      o += numChannels;
      d += numChannels;
      u += numChannels;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r9
movslq %esi, %rsi
xorl %r10d, %r10d
testl %edi, %edi
movl $0x0, %r11d
cmovgl %edi, %r11d
testl %esi, %esi
movl $0x0, %ebx
cmovgl %esi, %ebx
addq %rsi, %rsi
cmpq %rbx, %r10
je 0x259b
xorl %r14d, %r14d
movl %edi, %ebp
xorl %r15d, %r15d
cmpl %r15d, %r11d
je 0x258a
movswl (%rcx,%r14), %edx
imull %ebp, %edx
movswl (%r8,%r14), %eax
imull %r15d, %eax
addl %edx, %eax
cltd
idivl %edi
movw %ax, (%r9,%r14)
incl %r15d
addq %rsi, %r14
decl %ebp
jmp 0x2560
incq %r10
addq $0x2, %r9
addq $0x2, %r8
addq $0x2, %rcx
jmp 0x2553
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/wave.c
// Function: openInputWaveFile
waveFile openInputWaveFile(const char* fileName, int* sampleRate, int* numChannels) {
  waveFile file;
  FILE* soundFile = fopen(fileName, "rb");

  if (soundFile == NULL) {
    fprintf(stderr, "Unable to open wave file %s for reading\n", fileName);
    return NULL;
  }
  file = (waveFile)calloc(1, sizeof(struct waveFileStruct));
  file->soundFile = soundFile;
  file->isInput = 1;
  if (!readHeader(file)) {
    closeFile(file);
    return NULL;
  }
  *sampleRate = file->sampleRate;
  *numChannels = file->numChannels;
  return file;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %r14
leaq 0xf70(%rip), %rsi       # 0x3532
callq 0x1160
testq %rax, %rax
je 0x2714
movq %rax, %r15
pushq $0x1
popq %rdi
pushq $0x20
popq %rsi
callq 0x10a0
movq %rax, %rbx
movq %r15, 0x8(%rax)
movl $0x1, 0x18(%rax)
leaq 0xfd7(%rip), %rsi       # 0x35ca
movq %rax, %rdi
callq 0x2b52
movq %rbx, %rdi
callq 0x2bf1
leaq 0xfc5(%rip), %rsi       # 0x35cf
movq %rbx, %rdi
callq 0x2b52
leaq 0xfbb(%rip), %rsi       # 0x35d4
movq %rbx, %rdi
callq 0x2b52
movq %rbx, %rdi
callq 0x2bf1
movl %eax, %ebp
andl $-0x3, %eax
cmpl $0x10, %eax
jne 0x2733
movq %rbx, %rdi
callq 0x2c1a
cmpl $0x1, %eax
jne 0x2748
movq %rbx, %rdi
callq 0x2c1a
movl %eax, (%rbx)
movq %rbx, %rdi
callq 0x2bf1
movl %eax, 0x4(%rbx)
movq %rbx, %rdi
callq 0x2bf1
movq %rbx, %rdi
callq 0x2c1a
movq %rbx, %rdi
callq 0x2c1a
cmpl $0x10, %eax
jne 0x2764
movq %r13, (%rsp)
movq %r12, 0x8(%rsp)
cmpl $0x12, %ebp
jne 0x2694
movq %rbx, %rdi
callq 0x2c1a
leaq 0x13(%rsp), %r12
movb $0x0, 0x4(%r12)
leaq 0xfae(%rip), %r13       # 0x3654
pushq $0x5
popq %r14
pushq $0x1
popq %r15
movq %rbx, %rdi
movq %r12, %rsi
pushq $0x4
popq %rdx
callq 0x2c38
movq %rbx, %rdi
callq 0x2bf1
movl %eax, %ebp
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1120
testl %eax, %eax
je 0x2700
movq 0x8(%rbx), %rdi
movslq %ebp, %rsi
movl %r15d, %edx
callq 0x1130
testl %eax, %eax
je 0x26ae
movq 0x3906(%rip), %rax      # 0x5ff8
movq (%rax), %rcx
leaq 0xe8e(%rip), %rdi       # 0x358a
pushq $0x1e
jmp 0x2777
movl 0x4(%rbx), %eax
movq (%rsp), %rcx
movl %eax, (%rcx)
movl (%rbx), %eax
movq 0x8(%rsp), %rcx
movl %eax, (%rcx)
jmp 0x278a
movq 0x38dd(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0xe10(%rip), %rsi       # 0x3535
xorl %ebx, %ebx
movq %r14, %rdx
xorl %eax, %eax
callq 0x10c0
jmp 0x278a
movq 0x38be(%rip), %rax      # 0x5ff8
movq (%rax), %rcx
leaq 0xe95(%rip), %rdi       # 0x35d9
pushq $0x24
jmp 0x2777
movq 0x38a9(%rip), %rcx      # 0x5ff8
movq (%rcx), %rdi
leaq 0xea5(%rip), %rsi       # 0x35fe
movl %eax, %edx
xorl %eax, %eax
callq 0x10c0
jmp 0x2780
movq 0x388d(%rip), %rax      # 0x5ff8
movq (%rax), %rcx
leaq 0xeb5(%rip), %rdi       # 0x362a
pushq $0x29
popq %rsi
pushq $0x1
popq %rdx
callq 0x1170
movq %rbx, %rdi
callq 0x279c
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/wave.c
// Function: closeFile
static void closeFile(waveFile file) {
  FILE* soundFile = file->soundFile;

  if (soundFile != NULL) {
    fclose(soundFile);
    file->soundFile = NULL;
  }
  free(file);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
je 0x27ae
callq 0x1070
movq %rbx, %rdi
popq %rbx
jmp 0x1030
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/wave.c
// Function: openOutputWaveFile
waveFile openOutputWaveFile(const char* fileName, int sampleRate, int numChannels) {
  waveFile file;
  FILE* soundFile = fopen(fileName, "wb");

  if (soundFile == NULL) {
    fprintf(stderr, "Unable to open wave file %s for writing\n", fileName);
    return NULL;
  }
  file = (waveFile)calloc(1, sizeof(struct waveFileStruct));
  file->soundFile = soundFile;
  file->sampleRate = sampleRate;
  file->numChannels = numChannels;
  writeHeader(file, sampleRate, numChannels);
  if (file->failed) {
    closeFile(file);
    return NULL;
  }
  return file;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %r15
leaq 0xd90(%rip), %rsi       # 0x355e
callq 0x1160
testq %rax, %rax
je 0x28b6
movq %rax, %r12
pushq $0x1
popq %rdi
pushq $0x20
popq %rsi
callq 0x10a0
movq %rax, %rbx
movq %r12, 0x8(%rax)
movl %ebp, 0x4(%rax)
movl %r14d, (%rax)
leaq 0xdcc(%rip), %rsi       # 0x35ca
movq %rax, %rdi
callq 0x2c90
pushq $0x24
popq %rsi
movq %rbx, %rdi
callq 0x29bf
leaq 0xdb7(%rip), %rsi       # 0x35cf
movq %rbx, %rdi
callq 0x2c90
leaq 0xdad(%rip), %rsi       # 0x35d4
movq %rbx, %rdi
callq 0x2c90
pushq $0x10
popq %r15
movq %rbx, %rdi
movl %r15d, %esi
callq 0x29bf
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x2cb6
movswl %r14w, %esi
movq %rbx, %rdi
callq 0x2cb6
movq %rbx, %rdi
movl %ebp, %esi
callq 0x29bf
addl %ebp, %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x29bf
pushq $0x2
popq %rsi
movq %rbx, %rdi
callq 0x2cb6
movq %rbx, %rdi
movl %r15d, %esi
callq 0x2cb6
leaq 0xdcc(%rip), %rsi       # 0x3654
movq %rbx, %rdi
callq 0x2c90
movq %rbx, %rdi
xorl %esi, %esi
callq 0x29bf
cmpl $0x0, 0x14(%rbx)
je 0x28aa
movq %rbx, %rdi
callq 0x279c
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x373b(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0xc9a(%rip), %rsi       # 0x3561
xorl %ebx, %ebx
movq %r15, %rdx
xorl %eax, %eax
callq 0x10c0
jmp 0x28aa
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/wave.c
// Function: closeWaveFile
int closeWaveFile(waveFile file) {
  FILE* soundFile = file->soundFile;
  int passed = 1;

  if (!file->isInput) {
    if (fseek(soundFile, 4, SEEK_SET) != 0) {
      fprintf(stderr, "Failed to seek on input file.\n");
      passed = 0;
    } else {
      /* Now update the file to have the correct size. */
      writeInt(file, file->bytesWritten - 8);
      if (file->failed) {
        fprintf(stderr, "Failed to write wave file size.\n");
        passed = 0;
      }
      if (fseek(soundFile, 40, SEEK_SET) != 0) {
        fprintf(stderr, "Failed to seek on input file.\n");
        passed = 0;
      } else {
        /* Now update the file to have the correct size. */
        writeInt(file, file->bytesWritten - 48);
        if (file->failed) {
          fprintf(stderr, "Failed to write wave file size.\n");
          passed = 0;
        }
      }
    }
  }
  closeFile(file);
  return passed;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, 0x18(%rdi)
je 0x28e7
pushq $0x1
popq %rbp
jmp 0x293a
movq 0x8(%rbx), %r14
pushq $0x4
popq %rsi
xorl %ebp, %ebp
movq %r14, %rdi
xorl %edx, %edx
callq 0x1130
testl %eax, %eax
jne 0x2949
movl 0x10(%rbx), %esi
addl $-0x8, %esi
movq %rbx, %rdi
callq 0x29bf
cmpl $0x0, 0x14(%rbx)
jne 0x2967
pushq $0x1
popq %rbp
pushq $0x28
popq %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x1130
testl %eax, %eax
jne 0x2987
movl 0x10(%rbx), %esi
addl $-0x30, %esi
movq %rbx, %rdi
callq 0x29bf
cmpl $0x0, 0x14(%rbx)
jne 0x299c
movq %rbx, %rdi
callq 0x279c
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq 0x36a8(%rip), %rax      # 0x5ff8
movq (%rax), %rcx
leaq 0xc30(%rip), %rdi       # 0x358a
pushq $0x1e
popq %rsi
pushq $0x1
popq %rdx
callq 0x1170
jmp 0x293a
movq 0x368a(%rip), %rax      # 0x5ff8
movq (%rax), %rcx
leaq 0xc31(%rip), %rdi       # 0x35a9
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
callq 0x1170
xorl %ebp, %ebp
jmp 0x2915
movq 0x366a(%rip), %rax      # 0x5ff8
movq (%rax), %rcx
leaq 0xbf2(%rip), %rdi       # 0x358a
pushq $0x1e
jmp 0x29af
movq 0x3655(%rip), %rax      # 0x5ff8
movq (%rax), %rcx
leaq 0xbfc(%rip), %rdi       # 0x35a9
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
callq 0x1170
xorl %ebp, %ebp
jmp 0x293a
// File: /workspace/github_c_makefile_star2_O2/waywardgeek[P]sonic/wave.c
// Function: writeInt
static void writeInt(waveFile file, int value) {
  char bytes[4];
  int i;

  for (i = 0; i < 4; i++) {
    bytes[i] = value;
    value >>= 8;
  }
  writeBytes(file, bytes, 4);
}

// Assembly:
pushq %rax
xorl %eax, %eax
cmpq $0x4, %rax
je 0x29d5
movb %sil, 0x4(%rsp,%rax)
sarl $0x8, %esi
incq %rax
jmp 0x29c2
leaq 0x4(%rsp), %rsi
pushq $0x4
popq %rdx
callq 0x2af4
popq %rax
retq