LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRCompression.cpp
// Function: DKRCompression::writeBinaryFile(std::vector<unsigned char, std::allocator<unsigned char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool DKRCompression::writeBinaryFile(std::vector<uint8_t>& output, std::string filename)
{
    try 
    {
        std::ofstream wf(filename.c_str(), std::ios::out | std::ios::binary);
        for(int i = 0; i < output.size(); i++)
            wf.write((char *)&output[i], 1);
        wf.close();
    } 
    catch (int e)
    {
        return false;
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x200, %rsp            # imm = 0x200
movq %rsi, %rbx
movq (%rdx), %rsi
leaq -0x220(%rbp), %rdi
pushq $0x14
popq %rdx
callq 0x2190
xorl %r12d, %r12d
leaq -0x220(%rbp), %r14
pushq $0x1
popq %r15
movq (%rbx), %rsi
movq 0x8(%rbx), %rax
subq %rsi, %rax
cmpq %r12, %rax
jbe 0x2f43
addq %r12, %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0x21d0
incq %r12
jmp 0x2f21
leaq -0x220(%rbp), %rdi
callq 0x2200
leaq -0x220(%rbp), %rdi
callq 0x2220
movb $0x1, %al
addq $0x200, %rsp            # imm = 0x200
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2f77
movq %rdx, %r14
movq %rax, %rbx
jmp 0x2f89
movq %rdx, %r14
movq %rax, %rbx
leaq -0x220(%rbp), %rdi
callq 0x2220
movq %rbx, %rdi
cmpl $0x1, %r14d
jne 0x2fa0
callq 0x20a0
callq 0x2260
xorl %eax, %eax
jmp 0x2f5d
callq 0x2280
nop
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRCompression.cpp
// Function: DKRCompression::readBinaryFile(std::vector<unsigned char, std::allocator<unsigned char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool DKRCompression::readBinaryFile(std::vector<uint8_t>& input, std::string filename)
{
    try 
    {
        std::ifstream is;
        is.open(filename.c_str(), std::ios::binary);
        is.seekg(0, std::ios::end);
        size_t filesize = is.tellg();
        is.seekg(0, std::ios::beg);
        input.resize(filesize);
        is.read((char *)input.data(), filesize);
    } 
    catch (int e)
    {
        return false;
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x210, %rsp            # imm = 0x210
movq %rdx, %r14
movq %rsi, %rbx
leaq -0x218(%rbp), %rdi
callq 0x21a0
movq (%r14), %rsi
leaq -0x218(%rbp), %rdi
pushq $0x4
popq %rdx
callq 0x2110
leaq -0x218(%rbp), %rdi
pushq $0x2
popq %rdx
xorl %esi, %esi
callq 0x21e0
leaq -0x218(%rbp), %rdi
callq 0x2270
movq %rax, %r14
leaq -0x218(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21e0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x30d4
movq (%rbx), %rsi
leaq -0x218(%rbp), %rdi
movq %r14, %rdx
callq 0x21b0
leaq -0x218(%rbp), %rdi
callq 0x2060
movb $0x1, %al
addq $0x210, %rsp            # imm = 0x210
popq %rbx
popq %r14
popq %rbp
retq
jmp 0x304b
movq %rdx, %r14
movq %rax, %rbx
jmp 0x305d
jmp 0x304b
movq %rdx, %r14
movq %rax, %rbx
leaq -0x218(%rbp), %rdi
callq 0x2060
movq %rbx, %rdi
cmpl $0x1, %r14d
jne 0x3074
callq 0x20a0
callq 0x2260
xorl %eax, %eax
jmp 0x3033
callq 0x2280
nop
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/GECompression.cpp
// Function: GECompression::GECompression()
GECompression::GECompression()
{
//	inputBuffer = NULL;
	compressedBuffer = NULL;
//	inputBufferSize = 0;
	compressedBufferSize = 0;
	wordTable = NULL;
	unpackTable = NULL;
	game = GOLDENEYE;

	unpackTable = new tableEntry[0xFFFF];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x18(%rdi), %rax
movq %rax, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
movb $0x0, 0x18(%rdi)
andq $0x0, 0x50(%rdi)
andl $0x0, 0x58(%rdi)
andq $0x0, 0x78(%rdi)
andq $0x0, 0x28(%rdi)
leaq 0x8(%rdi), %r14
andl $0x0, (%rdi)
movl $0x17ffe8, %edi         # imm = 0x17FFE8
callq 0x2030
movq %rax, 0x28(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
movq %r14, %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2280
nop
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/GECompression.cpp
// Function: GECompression::~GECompression()
GECompression::~GECompression(void)
{
	if (unpackTable != NULL)
	{
		delete [] unpackTable;
		unpackTable = NULL;
	}
	if (wordTable != NULL)
	{
		delete [] wordTable;
		wordTable = NULL;
	}
	if (compressedBuffer != NULL)
	{
		delete [] compressedBuffer;
		compressedBuffer = NULL;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x28(%rdi), %rdi
testq %rdi, %rdi
je 0x3490
callq 0x21c0
andq $0x0, 0x28(%rbx)
movq 0x78(%rbx), %rdi
testq %rdi, %rdi
je 0x34a3
callq 0x21c0
andq $0x0, 0x78(%rbx)
movq 0x50(%rbx), %rdi
testq %rdi, %rdi
je 0x34b6
callq 0x21c0
andq $0x0, 0x50(%rbx)
addq $0x8, %rbx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x20c0
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/GECompression.cpp
// Function: GECompression::SetCompressedBuffer(unsigned char*, int)
void GECompression::SetCompressedBuffer(unsigned char* Buffer, int bufferSize)
{
	if (compressedBuffer == NULL)
	{
		compressedBuffer = new unsigned char[bufferSize];
	}
	else
	{
		delete [] compressedBuffer;
		compressedBuffer = new unsigned char[bufferSize];
	}

	for (int x = 0; x < bufferSize; x++)
	{
		compressedBuffer[x] = Buffer[x];
	}

	compressedBufferSize = bufferSize;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
movq 0x50(%rdi), %rdi
testq %rdi, %rdi
je 0x34f1
callq 0x21c0
movslq %ebx, %r12
movq %r12, %rdi
callq 0x2030
movq %rax, 0x50(%r14)
xorl %eax, %eax
testl %r12d, %r12d
movl $0x0, %ecx
cmovgl %ebx, %ecx
cmpq %rax, %rcx
je 0x3522
movb (%r15,%rax), %dl
movq 0x50(%r14), %rsi
movb %dl, (%rsi,%rax)
incq %rax
jmp 0x350d
movl %ebx, 0x58(%r14)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/GECompression.cpp
// Function: GECompression::GetNBits(int)
unsigned long GECompression::GetNBits(int nBits)
{
	while (bitsRemain < nBits)
	{
		if (bytesIndex >= maxByteSize)
			return 0; // bad decompression
		if (bytesIndex >= compressedBufferSize)
			return 0; // bad decompression
		bitsCache = ((bitsCache) | (compressedBuffer[bytesIndex] << bitsRemain));
		bitsRemain = bitsRemain + 8;
		bytesIndex++;
	}

	unsigned long result = (bitsCache & ((1 << nBits)-1));
	bitsCache = bitsCache >> nBits;
	bitsRemain = bitsRemain - nBits;
	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl 0x40(%rdi), %ecx
movl 0x58(%rdi), %eax
movl $0x800000, %r8d         # imm = 0x800000
cmpl %r8d, %eax
cmovbl %eax, %r8d
movq 0x50(%rdi), %r9
movq 0x48(%rdi), %r10
movq 0x38(%rdi), %rdx
xorl %eax, %eax
movl %ecx, %r11d
subl %esi, %r11d
jge 0x3583
cmpq %r8, %r10
jae 0x359b
movzbl (%r9,%r10), %r11d
shll %cl, %r11d
movslq %r11d, %r11
orq %r11, %rdx
movq %rdx, 0x38(%rdi)
addl $0x8, %ecx
movl %ecx, 0x40(%rdi)
incq %r10
movq %r10, 0x48(%rdi)
jmp 0x3555
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %esi, %ecx
shll %cl, %eax
notl %eax
andl %edx, %eax
shrq %cl, %rdx
movq %rdx, 0x38(%rdi)
movl %r11d, 0x40(%rdi)
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/GECompression.cpp
// Function: GECompression::GetNBitsAndPreserve(int)
unsigned long GECompression::GetNBitsAndPreserve(int nBits)
{
	while (bitsRemain < nBits)
	{
		if (bytesIndex >= maxByteSize)
			return 0; // bad decompression
		if (bytesIndex >= compressedBufferSize)
			return 0; // bad decompression
		bitsCache = ((bitsCache) | (compressedBuffer[bytesIndex] << bitsRemain));
		bitsRemain = bitsRemain + 8;
		bytesIndex++;
	}

	unsigned long result = (bitsCache & ((1 << nBits)-1));
	return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl 0x40(%rdi), %ecx
movl 0x58(%rdi), %eax
movl $0x800000, %r8d         # imm = 0x800000
cmpl %r8d, %eax
cmovbl %eax, %r8d
movq 0x50(%rdi), %r9
movq 0x48(%rdi), %r10
movq 0x38(%rdi), %rdx
xorl %eax, %eax
cmpl %esi, %ecx
jge 0x35ed
cmpq %r8, %r10
jae 0x35fd
movzbl (%r9,%r10), %r11d
shll %cl, %r11d
movslq %r11d, %r11
orq %r11, %rdx
movq %rdx, 0x38(%rdi)
addl $0x8, %ecx
movl %ecx, 0x40(%rdi)
incq %r10
movq %r10, 0x48(%rdi)
jmp 0x35c3
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %esi, %ecx
shll %cl, %eax
notl %eax
andl %eax, %edx
movq %rdx, %rax
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/GECompression.cpp
// Function: GECompression::UncompressType0(unsigned char*, int&)
bool GECompression::UncompressType0(unsigned char* returnBuffer, int& fileSize)
{
	// discard bits

	unsigned long discardBits = bitsRemain & 0x7;
	GetNBits(discardBits); // discard begins

	unsigned short copyLen = GetNBits(16);
	GetNBits(16); // discarded

	for (int x = 0; x < copyLen; x++)
	{
		if (fileSize >= maxByteSize)
		{
			fileSize = 0;
			return false;
		}
		returnBuffer[fileSize] = GetNBits(8);
		fileSize++;

		if (iterationCounter > 268435455)
		{
			fileSize = 0;
			return false;
		}
		iterationCounter++;
	}

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl 0x40(%rdi), %esi
andl $0x7, %esi
callq 0x3530
pushq $0x10
popq %r12
movq %r15, %rdi
movl %r12d, %esi
callq 0x3530
movq %rax, %r13
movq %r15, %rdi
movl %r12d, %esi
callq 0x3530
movzwl %r13w, %r13d
xorl %r12d, %r12d
cmpl %r12d, %r13d
je 0x3912
cmpl $0x7fffff, (%rbx)       # imm = 0x7FFFFF
jg 0x390f
movq %r15, %rdi
pushq $0x8
popq %rsi
callq 0x3530
movslq (%rbx), %rcx
movb %al, (%r14,%rcx)
incl (%rbx)
movq 0x80(%r15), %rax
cmpq $0xfffffff, %rax        # imm = 0xFFFFFFF
ja 0x390f
incq %rax
movq %rax, 0x80(%r15)
incl %r12d
jmp 0x38d0
andl $0x0, (%rbx)
cmpl %r13d, %r12d
setae %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: put_int(int)
void put_int(int i) {
    outbuf[outcnt++] = i & 0xFF;
    outbuf[outcnt++] = (i >> 8) & 0xFF;
    outbuf[outcnt++] = (i >> 16) & 0xFF;
    outbuf[outcnt++] = (i >> 24) & 0xFF;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edi, %eax
movslq 0x100941c(%rip), %rcx   # 0x100db00
leaq 0x9415(%rip), %rdx      # 0xdb00
movb %al, (%rcx,%rdx)
movb %ah, 0x1(%rcx,%rdx)
movl %edi, %esi
shrl $0x10, %esi
movb %sil, 0x2(%rcx,%rdx)
shrl $0x18, %eax
leal 0x4(%rcx), %esi
movl %esi, 0x10093f8(%rip)   # 0x100db00
movb %al, 0x3(%rcx,%rdx)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: updcrc(char*, unsigned int)
u32 updcrc(char* bytes, u32 numBytes) {
    u32 c;

    static u32 crc = 0xffffffff;

    if (bytes == NULL) {
        c = 0xffffffff;
    } else {
        c = crc;
        if (numBytes) do {
            c = crc_32_tab[((int)c ^ (*bytes++)) & 0xff] ^ (c >> 8);
        } while (--numBytes);
    }
    crc = c;
    return c ^ 0xffffffff;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
testq %rdi, %rdi
je 0x4747
movl 0x6457(%rip), %eax      # 0xab74
testl %esi, %esi
je 0x474c
movl %esi, %ecx
xorl %edx, %edx
leaq 0x6044(%rip), %rsi      # 0xa770
movb (%rdi,%rdx), %r8b
xorb %al, %r8b
movzbl %r8b, %r8d
shrl $0x8, %eax
xorl (%rsi,%r8,4), %eax
incq %rdx
cmpl %edx, %ecx
jne 0x472c
jmp 0x474c
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x6422(%rip)      # 0xab74
notl %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: read_buf(char*, unsigned int)
int read_buf(char* buf, u32 size){
    u32 len;
    
    if(incnt + size >= inbufSize) {
        len = inbufSize - incnt;
    } else {
        len = size;
    }
    
    memcpy(buf, inbuf + incnt, len);

    crc = updcrc((char*)buf, len);
    incnt += (u32)len;
    return (int)len;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movslq 0x10093ad(%rip), %rax   # 0x100db14
movl 0x10093a3(%rip), %ecx   # 0x100db10
movl %ecx, %r14d
subl %eax, %r14d
leal (%rax,%rsi), %edx
cmpl %ecx, %edx
cmovbl %esi, %r14d
addq 0x1009385(%rip), %rax   # 0x100db08
movq %rax, %rsi
movq %r14, %rdx
callq 0x2130
movq %rbx, %rdi
movl %r14d, %esi
callq 0x470e
movl %eax, 0x1009381(%rip)   # 0x100db20
addl %r14d, 0x100936e(%rip)  # 0x100db14
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: send_bits(int, int)
void send_bits(int value, int length){
    // printf("send_bits(%d, %d);\n", value, length);
    /* If not enough room in bi_buf, use (valid) bits from bi_buf and
     * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
     * unused bits in value.
     */
    if (bi_valid > (int)Buf_size - length) {
        bi_buf |= (value << bi_valid);
        put_short(bi_buf);
        bi_buf = (u16)value >> (Buf_size - bi_valid);
        bi_valid += length - Buf_size;
    } else {
        bi_buf |= value << bi_valid;
        bi_valid += length;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movl 0x623e(%rip), %ecx      # 0xabc8
pushq $0x10
popq %rdx
movl %edi, %eax
shll %cl, %eax
subl %esi, %edx
orw 0x622a(%rip), %ax       # 0xabc4
cmpl %edx, %ecx
jle 0x49c8
movl %edi, %r14d
movw %ax, 0x621c(%rip)       # 0xabc4
movswl %ax, %edi
callq 0x46b1
movzwl %r14w, %eax
movl 0x620e(%rip), %edx      # 0xabc8
movb $0x10, %cl
subb %dl, %cl
shrl %cl, %eax
leal (%rbx,%rdx), %ecx
addl $-0x10, %ecx
jmp 0x49ca
addl %ebx, %ecx
movw %ax, 0x61f3(%rip)       # 0xabc4
movl %ecx, 0x61f1(%rip)      # 0xabc8
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: gen_codes(ct_data*, int)
void gen_codes (ct_data* tree, int max_code) {
    u16 next_code[MAX_BITS+1]; /* next code value for each bit length */
    u16 code = 0;              /* running code value */
    int bits;                  /* bit index */
    int n;                     /* code index */

    /* The distribution counts are first used to generate the code values
     * without bit reversal.
     */
    for (bits = 1; bits <= MAX_BITS; bits++) {
        next_code[bits] = code = (code + bl_count[bits-1]) << 1;
    }
    /* Check that the bit counts in bl_count are consistent. The last code
     * must be all ones.
     */
    // Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1, "inconsistent bit counts");
    // Tracev((stderr,"\ngen_codes: max_code %d ", max_code));

    for (n = 0;  n <= max_code; n++) {
        int len = tree[n].Len;
        if (len == 0) continue;
        /* Now reverse the bits */
        tree[n].Code = bi_reverse(next_code[len]++, len);
        //Tracec(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
xorl %eax, %eax
leaq 0x7159(%rip), %rcx      # 0xbb70
xorl %edx, %edx
cmpq $0x1e, %rax
je 0x4a30
addw (%rax,%rcx), %dx
addl %edx, %edx
movw %dx, -0x3e(%rbp,%rax)
addq $0x2, %rax
jmp 0x4a19
movslq %esi, %r14
xorl %r15d, %r15d
cmpq %r14, %r15
jg 0x4a63
movzwl 0x2(%rbx,%r15,4), %esi
testl %esi, %esi
je 0x4a5e
movl %esi, %eax
movzwl -0x40(%rbp,%rax,2), %edi
leal 0x1(%rdi), %ecx
movw %cx, -0x40(%rbp,%rax,2)
callq 0x49dc
movw %ax, (%rbx,%r15,4)
incq %r15
jmp 0x4a36
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: init_block()
void init_block() {
    int n; /* iterates over tree elements */

    /* Initialize the trees. */
    for (n = 0; n < L_CODES;  n++) dyn_ltree[n].Freq = 0;
    for (n = 0; n < D_CODES;  n++) dyn_dtree[n].Freq = 0;
    for (n = 0; n < B_CODES; n++) bl_tree[n].Freq = 0;

    dyn_ltree[END_BLOCK].Freq = 1;
    opt_len = static_len = 0;
    last_lit = last_dist = last_flags = 0;
    flags = 0; 
    flag_bit = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
leaq 0x6155(%rip), %rcx      # 0xabd0
cmpq $0x478, %rax            # imm = 0x478
je 0x4a8e
andw $0x0, (%rax,%rcx)
addq $0x4, %rax
jmp 0x4a7b
xorl %eax, %eax
leaq 0x6a39(%rip), %rcx      # 0xb4d0
cmpq $0x78, %rax
je 0x4aa8
andw $0x0, (%rax,%rcx)
addq $0x4, %rax
jmp 0x4a97
xorl %eax, %eax
leaq 0x701f(%rip), %rcx      # 0xbad0
cmpq $0x4c, %rax
je 0x4ac2
andw $0x0, (%rax,%rcx)
addq $0x4, %rax
jmp 0x4ab1
andl $0x0, 0x901b(%rip)      # 0xdae4
andl $0x0, 0x9010(%rip)      # 0xdae0
andl $0x0, 0x9001(%rip)      # 0xdad8
andl $0x0, 0x8ff6(%rip)      # 0xdad4
andl $0x0, 0x8feb(%rip)      # 0xdad0
movw $0x1, 0x64e2(%rip)      # 0xafd0
movb $0x0, 0x8fe7(%rip)      # 0xdadc
movb $0x1, 0x8fe1(%rip)      # 0xdadd
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: pqdownheap(ct_data*, int)
void pqdownheap(ct_data* tree, int k){
    int v = heap[k];
    int j = k << 1;  /* left son of k */
    while (j <= heap_len) {
        /* Set j to the smallest of the two sons: */
        if (j < heap_len && smaller(tree, heap[j+1], heap[j])) j++;

        /* Exit if v is smaller than both sons */
        if (smaller(tree, v, heap[j])) break;

        /* Exchange v with the smallest son */
        heap[k] = heap[j];  k = j;

        /* And continue down the tree, setting j to the left son of k */
        j <<= 1;
    }
    heap[k] = v;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movslq %esi, %rcx
leaq 0x707b(%rip), %rax      # 0xbb90
movl (%rax,%rcx,4), %ecx
movslq %ecx, %rdx
movl 0x7962(%rip), %r8d      # 0xc484
leaq 0x7967(%rip), %r9       # 0xc490
movslq %esi, %r10
addl %esi, %esi
cmpl %r8d, %esi
jg 0x4b91
jge 0x4b5b
movl %esi, %ebx
orl $0x1, %ebx
movslq %ebx, %r14
movslq (%rax,%r14,4), %r15
movslq %esi, %r11
movslq (%rax,%r11,4), %r12
movzwl (%rdi,%r12,4), %r13d
cmpw %r13w, (%rdi,%r15,4)
jae 0x4b83
movq %r14, %r11
movl %ebx, %esi
jmp 0x4b5e
movslq %esi, %r11
movl (%rax,%r11,4), %r11d
movslq %r11d, %rbx
movzwl (%rdi,%rbx,4), %r14d
cmpw %r14w, (%rdi,%rdx,4)
jb 0x4b91
jne 0x4b7d
movb (%rdx,%r9), %r14b
cmpb (%rbx,%r9), %r14b
jbe 0x4b91
movl %r11d, (%rax,%r10,4)
jmp 0x4b29
jne 0x4b5e
movb (%r15,%r9), %r15b
cmpb (%r12,%r9), %r15b
jbe 0x4b54
jmp 0x4b5e
movl %ecx, (%rax,%r10,4)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: scan_tree(ct_data*, int)
void scan_tree (ct_data* tree, int max_code){
    int n;                     /* iterates over all tree elements */
    int prevlen = -1;          /* last emitted length */
    int curlen;                /* length of current code */
    int nextlen = tree[0].Len; /* length of next code */
    int count = 0;             /* repeat count of the current code */
    int max_count = 7;         /* max repeat count */
    int min_count = 4;         /* min repeat count */

    if (nextlen == 0) max_count = 138, min_count = 3;
    tree[max_code+1].Len = (u16)0xffff; /* guard */

    for (n = 0; n <= max_code; n++) {
        curlen = nextlen; nextlen = tree[n+1].Len;
        if (++count < max_count && curlen == nextlen) {
            continue;
        } else if (count < min_count) {
            bl_tree[curlen].Freq += count;
        } else if (curlen != 0) {
            if (curlen != prevlen) bl_tree[curlen].Freq++;
            bl_tree[REP_3_6].Freq++;
        } else if (count <= 10) {
            bl_tree[REPZ_3_10].Freq++;
        } else {
            bl_tree[REPZ_11_138].Freq++;
        }
        count = 0; prevlen = curlen;
        if (nextlen == 0) {
            max_count = 138, min_count = 3;
        } else if (curlen == nextlen) {
            max_count = 6, min_count = 3;
        } else {
            max_count = 7, min_count = 4;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movzwl 0x2(%rdi), %ecx
xorl %ebx, %ebx
testl %ecx, %ecx
movl $0x8a, %eax
movl $0x7, %r14d
cmovel %eax, %r14d
setne %bl
addl $0x3, %ebx
movslq %esi, %rdx
orw $-0x1, 0x6(%rdi,%rdx,4)
movl $0xffffffff, %r11d      # imm = 0xFFFFFFFF
xorl %esi, %esi
leaq 0x6b1e(%rip), %r8       # 0xbad0
movl $0x4, %r9d
movl $0x3, %r10d
movl %r11d, %r12d
xorl %r15d, %r15d
cmpq %rdx, %rsi
jg 0x5048
movl %ecx, %r11d
movzwl 0x6(%rdi,%rsi,4), %ecx
incq %rsi
incl %r15d
cmpl %r14d, %r15d
jge 0x4fe1
cmpl %ecx, %r11d
je 0x4fc4
movl %r11d, %r14d
cmpl %ebx, %r15d
jge 0x4ff4
addl (%r8,%r14,4), %r15d
movw %r15w, (%r8,%r14,4)
jmp 0x5025
testl %r11d, %r11d
je 0x500c
cmpl %r12d, %r11d
je 0x5003
incw (%r8,%r14,4)
incw 0x6b06(%rip)            # 0xbb10
jmp 0x5025
decl %r15d
cmpl $0x9, %r15d
ja 0x501e
incw 0x6af8(%rip)            # 0xbb14
jmp 0x5025
incw 0x6af3(%rip)            # 0xbb18
xorl %r14d, %r14d
cmpl %ecx, %r11d
sete %r14b
movl %r9d, %ebx
subl %r14d, %ebx
xorl $0x7, %r14d
testl %ecx, %ecx
cmovel %eax, %r14d
cmovel %r10d, %ebx
jmp 0x4fbe
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: build_bl_tree()
int build_bl_tree(){
    int max_blindex;  /* index of last bit length code of non zero freq */

    /* Determine the bit length frequencies for literal and distance trees */
    scan_tree((ct_data *)dyn_ltree, l_desc.max_code);
    scan_tree((ct_data *)dyn_dtree, d_desc.max_code);

    /* Build the bit length tree: */
    build_tree_1((tree_desc *)(&bl_desc));
    /* opt_len now includes the length of the tree representations, except
     * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
     */

    /* Determine the number of bit length codes to send. The pkzip format
     * requires that at least 4 bit length codes be sent. (appnote.txt says
     * 3 but the actual value used is 4.)
     */
    for (max_blindex = B_CODES-1; max_blindex >= 3; max_blindex--) {
        if (bl_tree[bl_order[max_blindex]].Len != 0) break;
    }
    /* Update opt_len to include the bit length tree and counts */
    opt_len += 3*(max_blindex+1) + 5+5+4;
    //Tracev((stderr, "\ndyn trees: dyn %lu, stat %lu", opt_len, static_len));

    return max_blindex;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl 0x53db(%rip), %esi      # 0xa5a4
leaq 0x5a00(%rip), %rdi      # 0xabd0
callq 0x4f72
movl 0x53f1(%rip), %esi      # 0xa5cc
leaq 0x62ee(%rip), %rdi      # 0xb4d0
callq 0x4f72
leaq 0x53e2(%rip), %rdi      # 0xa5d0
callq 0x4d7a
pushq $0x12
popq %rcx
pushq $0x2
popq %rax
leaq 0x5400(%rip), %rdx      # 0xa600
leaq 0x68c9(%rip), %rsi      # 0xbad0
cmpl $0x3, %ecx
jb 0x5220
movl %ecx, %edi
movzbl (%rdi,%rdx), %edi
cmpw $0x0, 0x2(%rsi,%rdi,4)
jne 0x521e
decl %ecx
jmp 0x5207
movl %ecx, %eax
leal (%rax,%rax,2), %ecx
movl 0x88b7(%rip), %edx      # 0xdae0
addl %edx, %ecx
addl $0x11, %ecx
movl %ecx, 0x88ac(%rip)      # 0xdae0
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: send_all_trees(int, int, int)
void send_all_trees(int lcodes, int dcodes, int blcodes){
    int rank;                    /* index in bl_order */

    //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
    //Assert (lcodes <= _CODES && dcodes <= D_CODES && blcodes <= B_CODES, "too many codes");
    //Tracev((stderr, "\nbl counts: "));
    send_bits(lcodes-257, 5); /* not +255 as stated in appnote.txt */
    send_bits(dcodes-1,   5);
    send_bits(blcodes-4,  4); /* not -3 as stated in appnote.txt */
    for (rank = 0; rank < blcodes; rank++) {
        //Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
        send_bits(bl_tree[bl_order[rank]].Len, 3);
    }

    send_tree((ct_data *)dyn_ltree, lcodes-1); /* send the literal tree */

    send_tree((ct_data *)dyn_dtree, dcodes-1); /* send the distance tree */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r15d
movl %esi, %ebx
movq %rdi, -0x38(%rbp)
addl $0xfffffeff, %edi       # imm = 0xFFFFFEFF
pushq $0x5
popq %r12
movl %r12d, %esi
callq 0x497b
decl %ebx
movl %ebx, -0x2c(%rbp)
movl %ebx, %edi
movl %r12d, %esi
callq 0x497b
leal -0x4(%r15), %edi
pushq $0x4
popq %rsi
callq 0x497b
xorl %r13d, %r13d
testl %r15d, %r15d
cmovlel %r13d, %r15d
leaq 0x5372(%rip), %rbx      # 0xa600
leaq 0x683b(%rip), %r14      # 0xbad0
pushq $0x3
popq %r12
cmpq %r13, %r15
je 0x52b7
movzbl (%r13,%rbx), %eax
movzwl 0x2(%r14,%rax,4), %edi
movl %r12d, %esi
callq 0x497b
incq %r13
jmp 0x5299
movq -0x38(%rbp), %rsi
decl %esi
leaq 0x590c(%rip), %rdi      # 0xabd0
callq 0x5051
leaq 0x6200(%rip), %rdi      # 0xb4d0
movl -0x2c(%rbp), %esi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5051
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: bi_windup()
void bi_windup()
{
    if (bi_valid > 8) {
        put_short(bi_buf);
    } else if (bi_valid > 0) {
        put_byte(bi_buf);
    }
    bi_buf = 0;
    bi_valid = 0;
}

// Assembly:
movl 0x58dc(%rip), %eax      # 0xabc8
cmpl $0x9, %eax
jl 0x5304
pushq %rbp
movq %rsp, %rbp
movswl 0x58c8(%rip), %edi      # 0xabc4
callq 0x46b1
popq %rbp
jmp 0x5328
testl %eax, %eax
jle 0x5328
movb 0x58b6(%rip), %al       # 0xabc4
movslq 0x10087eb(%rip), %rcx   # 0x100db00
leal 0x1(%rcx), %edx
movl %edx, 0x10087e2(%rip)   # 0x100db00
leaq 0x87db(%rip), %rdx      # 0xdb00
movb %al, (%rcx,%rdx)
andw $0x0, 0x5894(%rip)      # 0xabc4
andl $0x0, 0x5891(%rip)      # 0xabc8
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: copy_block(char*, unsigned int, int)
void copy_block(char* buf, u32 len, int header){
    bi_windup();              /* align on byte boundary */

    if (header) {
        put_short((u16)len);   
        put_short((u16)~len);
    }
    while (len--) {
        put_byte(*buf++);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r15d
movl %esi, %r14d
movq %rdi, %rbx
callq 0x52e6
testl %r15d, %r15d
je 0x536b
movswl %r14w, %edi
callq 0x46b1
movl %r14d, %eax
notl %eax
movswl %ax, %edi
callq 0x46b1
movslq 0x100878e(%rip), %rax   # 0x100db00
leal 0x1(%rax), %ecx
movl %r14d, %edx
xorl %esi, %esi
leaq 0x877f(%rip), %rdi      # 0xdb00
cmpl %esi, %edx
je 0x53a1
movb (%rbx,%rsi), %r8b
leal (%rcx,%rsi), %r9d
movl %r9d, 0x100876c(%rip)   # 0x100db00
leaq (%rax,%rsi), %r9
movb %r8b, (%rdi,%r9)
incq %rsi
jmp 0x5381
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: fill_window()
void fill_window() {
    u32 n, m;
    u32 more = (u32)(window_size - (u32)lookahead - (u32)strstart);
    /* Amount of free space at the end of the window. */
    
    // printf("more = %d\n", more);
    
    if (strstart >= WSIZE+MAX_DIST) {
        /* By the IN assertion, the window is not empty so we can't confuse
         * more == 0 with more == 64K on a 16 bit machine.
         */
        //Assert(window_size == (u32)2*WSIZE, "no sliding with BIG_MEM");
        
        memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE);
        match_start -= WSIZE;
        strstart    -= WSIZE; /* we now have strstart >= MAX_DIST: */
        if (rsync_chunk_end != 0xFFFFFFFF) {
            rsync_chunk_end -= WSIZE;
        }

        block_start -= (long) WSIZE;

        for (n = 0; n < HASH_SIZE; n++) {
            m = head[n];
            head[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL);
        }
        for (n = 0; n < WSIZE; n++) {
            m = prev[n];
            prev[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL);
            /* If n is not on any hash chain, prev[n] is garbage but
             * its value will never be used.
             */
        }
        more += WSIZE;
    }
    
    n = read_buf((char*)window+strstart+lookahead, more);
    if (n == 0) { // No more input
        return;
    } else {
        lookahead += n;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl 0x4b77(%rip), %ebx      # 0xa3d0
movl 0x5344(%rip), %r14d     # 0xaba4
movl 0x5335(%rip), %r15d     # 0xab9c
subl %r14d, %ebx
subl %r15d, %ebx
cmpl $0xfefa, %r15d          # imm = 0xFEFA
jb 0x5927
leaq 0x10082af(%rip), %rdi   # 0x100db30
leaq 0x10102a8(%rip), %rsi   # 0x1015b30
movl $0x8000, %edx           # imm = 0x8000
callq 0x2130
movl $0xffff8000, %eax       # imm = 0xFFFF8000
addl %eax, 0x5303(%rip)      # 0xaba0
addl %eax, %r15d
movl %r15d, 0x52f5(%rip)     # 0xab9c
movl 0x530f(%rip), %eax      # 0xabbc
cmpl $-0x1, %eax
je 0x58bd
addl $0xffff8000, %eax       # imm = 0xFFFF8000
movl %eax, 0x52ff(%rip)      # 0xabbc
addl $0xffff8000, 0x52c9(%rip) # imm = 0xFFFF8000
xorl %ecx, %ecx
leaq 0x1018260(%rip), %rax   # 0x101db30
cmpq $0x8000, %rcx           # imm = 0x8000
je 0x58fb
movswl 0x10000(%rax,%rcx,2), %edx
movl %edx, %esi
xorl $0xffff8000, %esi       # imm = 0xFFFF8000
sarl $0xf, %edx
andl %esi, %edx
movw %dx, 0x10000(%rax,%rcx,2)
incq %rcx
jmp 0x58d0
xorl %ecx, %ecx
cmpq $0x10000, %rcx          # imm = 0x10000
je 0x5921
movswl (%rcx,%rax), %edx
movl %edx, %esi
xorl $0xffff8000, %esi       # imm = 0xFFFF8000
sarl $0xf, %edx
andl %esi, %edx
movw %dx, (%rcx,%rax)
addq $0x2, %rcx
jmp 0x58fd
addl $0x8000, %ebx           # imm = 0x8000
movl %r15d, %eax
leaq 0x10081ff(%rip), %rdi   # 0x100db30
addq %r14, %rdi
addq %rax, %rdi
movl %ebx, %esi
callq 0x4756
testl %eax, %eax
je 0x5948
addl %eax, 0x525c(%rip)      # 0xaba4
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: rsync_roll(unsigned int, unsigned int)
void rsync_roll(u32 start, u32 num) {
    unsigned i;

    if (start < RSYNC_WIN) {
        /* before window fills. */
        for (i = start; i < RSYNC_WIN; i++) {
            if (i == start + num) return;
            rsync_sum += (u32)window[i];
        }
        num -= (RSYNC_WIN - start);
        start = RSYNC_WIN;
    }

    /* buffer after window full */
    for (i = start; i < start+num; i++) {
        /* New character in */
        rsync_sum += (u32)window[i];
        /* Old character out */
        rsync_sum -= (u32)window[i - RSYNC_WIN];
        if (rsync_chunk_end == 0xFFFFFFFF && RSYNC_SUM_MATCH(rsync_sum)) {
            rsync_chunk_end = i;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl 0x525b(%rip), %eax      # 0xabb8
cmpl $0x1000, %edi           # imm = 0x1000
jae 0x5999
leal (%rsi,%rdi), %edx
movl %edi, %ecx
leaq 0x10081bf(%rip), %r8    # 0x100db30
movq %rcx, %r9
cmpq $0x1000, %r9            # imm = 0x1000
je 0x599d
cmpq %r9, %rdx
je 0x5a06
movzbl (%r9,%r8), %r10d
addl %r10d, %eax
movl %eax, 0x5224(%rip)      # 0xabb8
incq %r9
jmp 0x5974
movl %edi, %ecx
jmp 0x59aa
addl %edi, %esi
addl $0xfffff000, %esi       # imm = 0xFFFFF000
movl $0x1000, %edi           # imm = 0x1000
addl %esi, %edi
movl 0x520a(%rip), %esi      # 0xabbc
cmpq $0x1001, %rcx           # imm = 0x1001
movl $0x1000, %edx           # imm = 0x1000
cmovaeq %rcx, %rdx
leaq 0x1008167(%rip), %rcx   # 0x100db30
cmpq %rdi, %rdx
jae 0x5a06
movzbl (%rdx,%rcx), %r8d
addl %r8d, %eax
movzbl -0x1000(%rdx,%rcx), %r8d
subl %r8d, %eax
movl %eax, 0x51d0(%rip)      # 0xabb8
cmpl $-0x1, %esi
jne 0x5a01
movl %eax, %r8d
andl $0xfff, %r8d            # imm = 0xFFF
jne 0x5a01
movl %edx, 0x51bd(%rip)      # 0xabbc
movl %edx, %esi
incq %rdx
jmp 0x59c9
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: lm_init(unsigned short*)
void lm_init(u16* flags) {
    u32 j;

    if (level < 1 || level > 9) { 
        printf("bad pack level\n");
        return;
    }
    compr_level = level;

    /* Initialize the hash table. */
#if defined(MAXSEG_64K) && HASH_BITS == 15
    for (j = 0;  j < HASH_SIZE; j++) head[j] = 0;
#else
    bzero((char*)head, HASH_SIZE*sizeof(*head));
#endif
    /* prev will be initialized on the fly */

    /* rsync params */
    rsync_chunk_end = 0xFFFFFFFF;
    rsync_sum = 0;

    /* Set the default configuration parameters:
     */
    max_lazy_match   = configuration_table[level].max_lazy;
    good_match       = configuration_table[level].good_length;
#ifndef FU_SEARCH
    nice_match       = configuration_table[level].nice_length;
#endif
    max_chain_length = configuration_table[level].max_chain;
    if (level == 1) {
       *flags |= FAST;
    } else if (level == 9) {
       *flags |= SOW;
    }
    /* ??? reduce max_chain_length for binary files */

    strstart = 0;
    block_start = 0;

    lookahead = read_buf((char*)window, sizeof(int) <= 2 ? (unsigned)WSIZE : 2*WSIZE);

    if (lookahead == 0) {
       return;
    }
    
    /* Make sure that we always have enough lookahead. This is important
     * if input comes from a device su8 as a tty.
     */
    while (lookahead < MIN_LOOKAHEAD && !NO_MORE_INPUT){ 
        fill_window();
    }

    ins_h = 0;
    for (j=0; j<MIN_MATCH-1; j++) { 
        UPDATE_HASH(ins_h, window[j]);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl 0x4b86(%rip), %r14d     # 0xab70
leal -0xa(%r14), %eax
cmpl $-0xa, %eax
ja 0x6003
leaq 0x12f1(%rip), %rdi      # 0x72eb
popq %rbx
popq %r14
popq %rbp
jmp 0x2240
movq %rdi, %rbx
movl %r14d, 0x4ba3(%rip)     # 0xabb0
leaq 0x1027b1c(%rip), %rdi   # 0x102db30
movl $0x10000, %edx          # imm = 0x10000
xorl %esi, %esi
callq 0x20f0
orl $-0x1, 0x4b95(%rip)     # 0xabbc
andl $0x0, 0x4b8a(%rip)      # 0xabb8
leaq 0x43ab(%rip), %rax      # 0xa3e0
movzwl 0x2(%rax,%r14,8), %ecx
movl %ecx, 0x4b6b(%rip)      # 0xabac
movzwl (%rax,%r14,8), %ecx
movl %ecx, 0x4b68(%rip)      # 0xabb4
movzwl 0x4(%rax,%r14,8), %ecx
movl %ecx, 0x4b68(%rip)      # 0xabc0
movzwl 0x6(%rax,%r14,8), %eax
movl %eax, 0x4b44(%rip)      # 0xaba8
cmpl $0x1, %r14d
je 0x6076
cmpl $0x9, %r14d
jne 0x607d
movw $0x2, %ax
jmp 0x607a
movw $0x4, %ax
orw %ax, (%rbx)
andl $0x0, 0x4b18(%rip)      # 0xab9c
andl $0x0, 0x4b05(%rip)      # 0xab90
leaq 0x1007a9e(%rip), %rbx   # 0x100db30
movq %rbx, %rdi
movl $0x10000, %esi          # imm = 0x10000
callq 0x4756
movl %eax, 0x4aff(%rip)      # 0xaba4
testl %eax, %eax
je 0x60ef
cmpl $0x105, %eax            # imm = 0x105
ja 0x60cb
movl 0x1007a5a(%rip), %eax   # 0x100db10
cmpl %eax, 0x1007a58(%rip)   # 0x100db14
je 0x60cb
callq 0x5849
movl 0x4adb(%rip), %eax      # 0xaba4
jmp 0x60a9
xorl %eax, %eax
xorl %ecx, %ecx
cmpq $0x2, %rax
je 0x60e9
shll $0x5, %ecx
movzbl (%rax,%rbx), %edx
andl $0x7fe0, %ecx           # imm = 0x7FE0
xorl %edx, %ecx
incq %rax
jmp 0x60cf
movl %ecx, 0x4aa5(%rip)      # 0xab94
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: zip()
void zip() {
    u16 deflate_flags = 0;
    
    outcnt = 0;
    incnt = 0;
    
    put_byte(GZIP_MAGIC[0]);
    put_byte(GZIP_MAGIC[1]);
    put_byte(DEFATED);
    put_byte(0); // flags
    put_int(0); // Timestamp
    
    u32 crc = updcrc(NULL, 0);
    
    bi_init();
    ct_init();
    lm_init(&deflate_flags);
    
    put_byte(deflate_flags); /* extra flags */
    put_byte(0x03); /* OS identifier, 0x03 = Unix */
    
    deflate();
    
    put_int(crc);
    put_int(incnt); // was bytes_in
    
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
leaq -0x12(%rbp), %rbx
andw $0x0, (%rbx)
andl $0x0, 0x1007a06(%rip)   # 0x100db14
movl $0x88b37, 0x79e8(%rip)  # imm = 0x88B37
leaq 0x79e1(%rip), %r14      # 0xdb00
movl $0x4, 0x10079d7(%rip)   # 0x100db00
xorl %edi, %edi
callq 0x46d7
orl $-0x1, 0x4a3d(%rip)     # 0xab74
andw $0x0, 0x4a85(%rip)      # 0xabc4
andl $0x0, 0x4a82(%rip)      # 0xabc8
callq 0x5dbb
movq %rbx, %rdi
callq 0x5fdc
movb (%rbx), %al
movslq 0x10079a4(%rip), %rcx   # 0x100db00
movb %al, (%rcx,%r14)
leal 0x2(%rcx), %eax
movl %eax, 0x1007997(%rip)   # 0x100db00
movb $0x3, 0x1(%rcx,%r14)
callq 0x5a08
xorl %edi, %edi
callq 0x46d7
movl 0x1007993(%rip), %edi   # 0x100db14
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x46d7
// File: /workspace/github_c_makefile_star2_O2/DavidSM64[P]DKR-Decompressor/DKRGzip.c
// Function: dkr_gzip_compress
unsigned char* dkr_gzip_compress(unsigned char* input, int inputSize, int gzipLevel, int* outputSize) {
    if(inputSize > OUTPUT_BUFFER_SIZE) {
        printf("rare_gzip Error: Input file is too large, make sure it is under %d MiB.\n", OUTPUT_BUFFER_SIZE / 1024 / 1024);
        return NULL;
    }
    
    if(level < 4) {
        printf("rare_gzip Error: Currently only compression levels 4 to 9 are supported.\n");
        return NULL;
    }
    
    inbuf = input;
    inbufSize = inputSize;
    level = gzipLevel;
    
    zip();
    
    *outputSize = outcnt;
    return outbuf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpl $0x1000001, %esi        # imm = 0x1000001
jl 0x61b1
leaq 0x10ff(%rip), %rdi      # 0x72a2
xorl %ebx, %ebx
pushq $0x10
popq %rsi
xorl %eax, %eax
callq 0x2050
jmp 0x61f4
cmpl $0x3, 0x49b8(%rip)      # 0xab70
jg 0x61ca
leaq 0x1139(%rip), %rdi      # 0x72fa
callq 0x2240
xorl %ebx, %ebx
jmp 0x61f4
movq %rcx, %rbx
movq %rdi, 0x1007934(%rip)   # 0x100db08
movl %esi, 0x1007936(%rip)   # 0x100db10
movl %edx, 0x4990(%rip)      # 0xab70
callq 0x60f4
movl 0x1007915(%rip), %eax   # 0x100db00
movl %eax, (%rbx)
leaq 0x790c(%rip), %rbx      # 0xdb00
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/aremmell[P]libsir/tests/tests_shared.c
// Function: print_test_summary
void print_test_summary(size_t tgt_tests, size_t passed, double elapsed) {
    elapsed = (elapsed / 1e3);
    if (tgt_tests == passed) {
        (void)printf(SIR_EOL SIR_WHITEB("done: ")
            SIR_GREENB("%s%zu " SIR_ULINE("libsir") " %s " SIR_EMPH("passed") " in %.03fsec!")
            SIR_EOL SIR_EOL, tgt_tests > 1 ? "all " : "", tgt_tests, TEST_S(tgt_tests), elapsed);
    } else {
        (void)printf(SIR_EOL SIR_WHITEB("done: ")
            SIR_REDB("%zu of %zu " SIR_ULINE("libsir") " %s " SIR_EMPH("failed") " in %.03fsec")
            SIR_EOL SIR_EOL, tgt_tests - passed, tgt_tests, TEST_S(tgt_tests), elapsed);
    }
}

// Assembly:
movq %rdi, %rcx
divsd 0xc86a(%rip), %xmm0     # 0x10008
movq %rdi, %rdx
subq %rsi, %rdx
jne 0x37d7
cmpq $0x2, %rcx
leaq 0xc99e(%rip), %rax      # 0x1014f
leaq 0xcb0f(%rip), %rdx      # 0x102c7
cmovaeq %rax, %rdx
leaq 0xec90(%rip), %rax      # 0x12453
leaq 0xff45(%rip), %r8       # 0x1370f
cmovaeq %rax, %r8
leaq 0xc913(%rip), %rsi      # 0x100e8
jmp 0x37f4
cmpq $0x2, %rcx
leaq 0xec71(%rip), %rax      # 0x12453
leaq 0xff26(%rip), %r8       # 0x1370f
cmovaeq %rax, %r8
leaq 0xc960(%rip), %rsi      # 0x10154
pushq $0x1
popq %rdi
movb $0x1, %al
jmp 0x3410
// File: /workspace/github_c_makefile_star2_O2/aremmell[P]libsir/tests/tests_shared.c
// Function: mark_test_to_run
bool mark_test_to_run(const char* const name, sir_test* tests, size_t num_tests) {
    bool found = false;
    for (size_t t = 0; t < num_tests; t++) {
        if (_sir_strsame(name, tests[t].name, strnlen(name, SIR_MAXTESTNAME))) {
            found = tests[t].run = true;
            break;
        }
    }
    return found;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
xorl %ecx, %ecx
pushq $0x20
popq %r12
movq %rcx, %rbp
cmpq %rcx, %rbx
je 0x388b
movq (%r14), %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0x3210
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x38a0
leaq 0x1(%rbp), %rcx
addq $0x18, %r14
testb %al, %al
je 0x3856
movb $0x1, -0x8(%r14)
cmpq %rbx, %rbp
setb %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/aremmell[P]libsir/tests/tests_shared.c
// Function: print_test_list
void print_test_list(const sir_test* tests, size_t num_tests) {
    static const size_t tab_size = 4;

    size_t longest = 0;
    for (size_t i = 0; i < num_tests; i++) {
        size_t len = strnlen(tests[i].name, SIR_MAXTESTNAME);
        if (len > longest)
            longest = len;
    }

    (void)printf(SIR_EOL SIR_WHITE("Available tests:") SIR_EOL SIR_EOL);

    for (size_t i = 0; i < num_tests; i++) {
        (void)printf("\t%s", tests[i].name);

        size_t len = strnlen(tests[i].name, SIR_MAXTESTNAME);
        if (len < longest + tab_size) {
            for (size_t n = len; n < longest + tab_size; n++)
                (void)printf(" ");
        }

        if ((i % 2) != 0 || i == num_tests - 1)
            (void)printf(SIR_EOL);
    }

    (void)printf(SIR_EOL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
xorl %r12d, %r12d
pushq $0x20
popq %r15
movq %rdi, %rbx
movq %rsi, 0x8(%rsp)
movq %rsi, %r13
subq $0x1, %r13
jb 0x38ee
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x3210
cmpq %r12, %rax
cmovaq %rax, %r12
addq $0x18, %rbx
jmp 0x38d0
leaq 0xc90a(%rip), %rsi      # 0x101ff
pushq $0x1
popq %rbp
movl %ebp, %edi
xorl %eax, %eax
callq 0x3410
addq $0x4, %r12
movq 0x8(%rsp), %rax
decq %rax
movq %rax, 0x10(%rsp)
leaq 0x10ccf(%rip), %r13     # 0x145e8
xorl %ebx, %ebx
cmpq 0x8(%rsp), %rbx
je 0x398b
imulq $0x18, %rbx, %r15
movq (%r14,%r15), %rdx
movl %ebp, %edi
leaq 0xc8f4(%rip), %rsi      # 0x10227
xorl %eax, %eax
callq 0x3410
movq (%r14,%r15), %rdi
pushq $0x20
popq %rsi
callq 0x3210
cmpq %r12, %rax
jae 0x3964
movq %rax, %r15
cmpq %r12, %r15
jae 0x3964
movl %ebp, %edi
movq %r13, %rsi
xorl %eax, %eax
callq 0x3410
incq %r15
jmp 0x394e
testb $0x1, %bl
sete %al
cmpq 0x10(%rsp), %rbx
setne %cl
testb %al, %cl
jne 0x3986
movl %ebp, %edi
leaq 0xc947(%rip), %rsi      # 0x102c6
xorl %eax, %eax
callq 0x3410
incq %rbx
jmp 0x391b
leaq 0xc934(%rip), %rsi      # 0x102c6
pushq $0x1
popq %rdi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3410
// File: /workspace/github_c_makefile_star2_O2/aremmell[P]libsir/tests/tests_shared.c
// Function: print_usage_info
void print_usage_info(const sir_cl_arg* args, size_t num_args) {
    size_t longest = 0;
    for (size_t i = 0; i < num_args; i++) {
        size_t len = strnlen(args[i].flag, SIR_CL_MAXFLAG);
        if (len > longest)
            longest = len;
    }

    (void)fprintf(stderr, SIR_EOL SIR_WHITE("  Usage:") SIR_EOL SIR_EOL);

    for (size_t i = 0; i < num_args; i++) {
        (void)fprintf(stderr, "\t%s ", args[i].flag);

        size_t len = strnlen(args[i].flag, SIR_CL_MAXFLAG);
        if (len < longest)
            for (size_t n = len; n < longest; n++)
                (void)fprintf(stderr, " ");

        (void)fprintf(stderr, "%s%s%s" SIR_EOL, args[i].usage,
            strnlen(args[i].usage, SIR_CL_MAXUSAGE) > 0 ? " " : "", args[i].desc);
    }

    (void)fprintf(stderr, SIR_EOL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
xorl %ebx, %ebx
pushq $0x20
popq %r15
movq %rdi, (%rsp)
movq %rdi, %r14
movq %rsi, 0x8(%rsp)
movq %rsi, %r12
subq $0x1, %r12
jb 0x39eb
movq (%r14), %rdi
movq %r15, %rsi
callq 0x3210
cmpq %rbx, %rax
cmovaq %rax, %rbx
addq $0x18, %r14
jmp 0x39cd
movq 0x17606(%rip), %r15     # 0x1aff8
movq (%r15), %rdi
leaq 0xc82f(%rip), %rdx      # 0x1022b
pushq $0x1
popq %rbp
movl %ebp, %esi
xorl %eax, %eax
callq 0x3520
leaq 0x10bd9(%rip), %r13     # 0x145e8
xorl %eax, %eax
movq (%r15), %rdi
cmpq 0x8(%rsp), %rax
je 0x3aaa
movq %rax, 0x10(%rsp)
imulq $0x18, %rax, %r14
movq (%rsp), %r12
movq (%r12,%r14), %rcx
movl %ebp, %esi
leaq 0xc812(%rip), %rdx      # 0x1024b
xorl %eax, %eax
callq 0x3520
movq (%r12,%r14), %rdi
pushq $0x20
popq %rsi
callq 0x3210
cmpq %rbx, %rax
jae 0x3a6d
movq %rax, %r12
cmpq %rbx, %r12
jae 0x3a6d
movq (%r15), %rdi
movl %ebp, %esi
movq %r13, %rdx
xorl %eax, %eax
callq 0x3520
incq %r12
jmp 0x3a54
addq (%rsp), %r14
movq (%r15), %rdi
movq 0x8(%r14), %rcx
cmpb $0x0, (%rcx)
movq 0x10(%r14), %r9
movq %r13, %r8
leaq 0xc83e(%rip), %rax      # 0x102c7
cmoveq %rax, %r8
movl %ebp, %esi
leaq 0xc7ba(%rip), %rdx      # 0x10250
xorl %eax, %eax
callq 0x3520
movq 0x10(%rsp), %rax
incq %rax
jmp 0x3a11
leaq 0xc815(%rip), %rdx      # 0x102c6
pushq $0x1
popq %rsi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3520
// File: /workspace/github_c_makefile_star2_O2/aremmell[P]libsir/tests/tests_shared.c
// Function: print_test_error
bool print_test_error(bool result, bool expected) {
    char msg[SIR_MAXERROR] = {0};
    uint16_t code          = sir_geterror(msg);
    if (SIR_E_NOERROR != code) {
        if (!expected && !result)
            TEST_MSG(SIR_RED("!! Unexpected (%" PRIu16 ", %s)"), code, msg);
        else if (expected)
            TEST_MSG(SIR_GREEN("Expected (%" PRIu16 ", %s)"), code, msg);
    }
    return result;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movl %esi, %ebp
movl %edi, %ebx
movq %rsp, %r14
movl $0x100, %edx            # imm = 0x100
movq %r14, %rdi
xorl %esi, %esi
callq 0x31f0
movq %r14, %rdi
callq 0x94b8
cmpw $0x1, %ax
sete %cl
movl %ebx, %edx
xorb $0x1, %dl
orb %bpl, %dl
xorb $0x1, %dl
orb %cl, %dl
jne 0x3b33
leaq 0xc776(%rip), %rcx      # 0x10285
leaq 0xc742(%rip), %rsi      # 0x10258
testb %bpl, %bpl
cmovneq %rcx, %rsi
movzwl %ax, %edx
testb %bl, %bl
cmovneq %rcx, %rsi
pushq $0x1
popq %rdi
movq %rsp, %rcx
xorl %eax, %eax
callq 0x3410
movl %ebx, %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/aremmell[P]libsir/tests/tests_shared.c
// Function: find_cl_arg
const sir_cl_arg* find_cl_arg(const char* flag, const sir_cl_arg* args, size_t num_args) {
    for (size_t n = 0; n < num_args; n++) {
        const sir_cl_arg* arg = &args[n];
        if (_sir_strsame(flag, arg->flag, strnlen(arg->flag, SIR_CL_MAXFLAG)))
            return arg;
    }
    return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
incq %r14
addq $-0x18, %rbx
pushq $0x20
popq %r12
decq %r14
je 0x3bc1
movq 0x18(%rbx), %r13
addq $0x18, %rbx
movq %r13, %rdi
movq %r12, %rsi
callq 0x3210
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x38a0
testb %al, %al
je 0x3b95
jmp 0x3bc3
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/aremmell[P]libsir/tests/tests_shared.c
// Function: wait_for_keypress
void wait_for_keypress(void) {
    (void)printf(SIR_WHITEB(SIR_EMPH("press any key to exit...")) SIR_EOL);
    char ch = '\0';
    (void)_sir_getchar(&ch);
    SIR_UNUSED(ch);
}

// Assembly:
pushq %rax
leaq 0xc4df(%rip), %rsi      # 0x103a8
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x3410
leaq 0x7(%rsp), %rdi
movb $0x0, (%rdi)
callq 0xc1e6
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/aremmell[P]libsir/tests/tests_shared.c
// Function: sir_readline
size_t sir_readline(FILE* f, char* buf, size_t size) {
    if (!f || !buf || 0 == size)
        return 0;

    size_t idx = 0;

    while (idx < size) {
        int ch = getc(f);
        if (EOF == ch || '\r' == ch || '\n' == ch)
            break;
        buf[idx++] = (char)ch;
    }

    return (0 == ferror(f)) ? idx : 0;
}

// Assembly:
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
testq %rdx, %rdx
sete %al
orb %cl, %al
je 0x3f51
xorl %eax, %eax
retq
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
xorl %r12d, %r12d
movl $0x4801, %ebp           # imm = 0x4801
cmpq %r12, %r14
je 0x3f8d
movq %rbx, %rdi
callq 0x35a0
leal 0x1(%rax), %ecx
cmpl $0xe, %ecx
ja 0x3f84
btl %ecx, %ebp
jb 0x3f90
movb %al, (%r15,%r12)
incq %r12
jmp 0x3f6a
movq %r14, %r12
movq %rbx, %rdi
callq 0x30e0
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
cmoveq %r12, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq