LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: cJSONUtils_ApplyPatches
CJSON_PUBLIC(int) cJSONUtils_ApplyPatches(cJSON * const object, const cJSON * const patches)
{
    const cJSON *current_patch = NULL;
    int status = 0;

    if (!cJSON_IsArray(patches))
    {
        /* malformed patches. */
        return 1;
    }

    if (patches != NULL)
    {
        current_patch = patches->child;
    }

    while (current_patch != NULL)
    {
        status = apply_patch(object, current_patch, false);
        if (status != 0)
        {
            return status;
        }
        current_patch = current_patch->next;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x4e88
testl %eax, %eax
je 0x5bcc
xorl %eax, %eax
testq %r14, %r14
je 0x5bd1
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x5bd1
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x5bd6
testl %eax, %eax
jne 0x5bd1
movq (%r14), %r14
testq %r14, %r14
jne 0x5baf
xorl %eax, %eax
jmp 0x5bd1
movl $0x1, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: cJSONUtils_GeneratePatches
CJSON_PUBLIC(cJSON *) cJSONUtils_GeneratePatches(cJSON * const from, cJSON * const to)
{
    cJSON *patches = NULL;

    if ((from == NULL) || (to == NULL))
    {
        return NULL;
    }

    patches = cJSON_CreateArray();
    create_patches(patches, (const unsigned char*)"", from, to, false);

    return patches;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
je 0x634e
xorl %r15d, %r15d
jmp 0x6374
movq %rsi, %rbx
movq %rdi, %r14
callq 0x4398
movq %rax, %r15
leaq 0x214b(%rip), %rsi      # 0x84ae
movq %rax, %rdi
movq %r14, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x6382
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: cJSONUtils_GeneratePatchesCaseSensitive
CJSON_PUBLIC(cJSON *) cJSONUtils_GeneratePatchesCaseSensitive(cJSON * const from, cJSON * const to)
{
    cJSON *patches = NULL;

    if ((from == NULL) || (to == NULL))
    {
        return NULL;
    }

    patches = cJSON_CreateArray();
    create_patches(patches, (const unsigned char*)"", from, to, true);

    return patches;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
je 0x66fe
xorl %r15d, %r15d
jmp 0x6727
movq %rsi, %rbx
movq %rdi, %r14
callq 0x4398
movq %rax, %r15
leaq 0x1d9b(%rip), %rsi      # 0x84ae
movq %rax, %rdi
movq %r14, %rdx
movq %rbx, %rcx
movl $0x1, %r8d
callq 0x6382
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: merge_patch(cJSON*, cJSON const*, int)
static cJSON *merge_patch(cJSON *target, const cJSON * const patch, const cJSON_bool case_sensitive)
{
    cJSON *patch_child = NULL;

    if (!cJSON_IsObject(patch))
    {
        /* scalar value, array or NULL, just duplicate */
        cJSON_Delete(target);
        return cJSON_Duplicate(patch, 1);
    }

    if (!cJSON_IsObject(target))
    {
        cJSON_Delete(target);
        target = cJSON_CreateObject();
    }

    patch_child = patch->child;
    while (patch_child != NULL)
    {
        if (cJSON_IsNull(patch_child))
        {
            /* NULL is the indicator to remove a value, see RFC7396 */
            if (case_sensitive)
            {
                cJSON_DeleteItemFromObjectCaseSensitive(target, patch_child->string);
            }
            else
            {
                cJSON_DeleteItemFromObject(target, patch_child->string);
            }
        }
        else
        {
            cJSON *replace_me = NULL;
            cJSON *replacement = NULL;

            if (case_sensitive)
            {
                replace_me = cJSON_DetachItemFromObjectCaseSensitive(target, patch_child->string);
            }
            else
            {
                replace_me = cJSON_DetachItemFromObject(target, patch_child->string);
            }

            replacement = merge_patch(replace_me, patch_child, case_sensitive);
            if (replacement == NULL)
            {
                return NULL;
            }

            cJSON_AddItemToObject(target, patch_child->string, replacement);
        }
        patch_child = patch_child->next;
    }
    return target;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x4e9c
testl %eax, %eax
je 0x683d
movq %rbx, %rdi
callq 0x4e9c
testl %eax, %eax
jne 0x67c8
movq %rbx, %rdi
callq 0x2ce3
callq 0x4301
movq %rax, %rbx
movq 0x10(%r15), %r15
testq %r15, %r15
je 0x685e
movq %r15, %rdi
callq 0x4e60
movq 0x38(%r15), %rsi
movq %rbx, %rdi
testl %eax, %eax
je 0x67f4
testl %r14d, %r14d
je 0x680b
callq 0x4539
jmp 0x6838
testl %r14d, %r14d
je 0x6812
callq 0x44d1
movq %rax, %rdi
movq %r15, %rsi
movl $0x1, %edx
jmp 0x681f
callq 0x4527
jmp 0x6838
callq 0x447e
movq %rax, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x6789
testq %rax, %rax
je 0x685c
movq 0x38(%r15), %rsi
movq %rbx, %rdi
movq %rax, %rdx
callq 0x3b4d
movq (%r15), %r15
jmp 0x67cc
movq %rbx, %rdi
callq 0x2ce3
movq %r15, %rdi
movl $0x1, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4b97
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: decode_array_index_from_pointer(unsigned char const*, unsigned long*)
static cJSON_bool decode_array_index_from_pointer(const unsigned char * const pointer, size_t * const index)
{
    size_t parsed_index = 0;
    size_t position = 0;

    if ((pointer[0] == '0') && ((pointer[1] != '\0') && (pointer[1] != '/')))
    {
        /* leading zeroes are not permitted */
        return 0;
    }

    for (position = 0; (pointer[position] >= '0') && (pointer[0] <= '9'); position++)
    {
        parsed_index = (10 * parsed_index) + (size_t)(pointer[position] - '0');

    }

    if ((pointer[position] != '\0') && (pointer[position] != '/'))
    {
        return 0;
    }

    *index = parsed_index;

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb (%rdi), %al
cmpb $0x30, %al
jne 0x6a33
movzbl 0x1(%rdi), %ecx
testl %ecx, %ecx
je 0x6a3b
cmpl $0x2f, %ecx
je 0x6a3b
jmp 0x6a70
leal -0x30(%rax), %ecx
cmpb $0x9, %cl
ja 0x6a59
incq %rdi
xorl %ecx, %ecx
leaq (%rcx,%rcx,4), %rcx
movzbl %al, %eax
addl $-0x30, %eax
leaq (%rax,%rcx,2), %rcx
movb (%rdi), %al
incq %rdi
cmpb $0x2f, %al
ja 0x6a40
jmp 0x6a5b
xorl %ecx, %ecx
cmpb $0x2f, %al
je 0x6a66
movzbl %al, %eax
testl %eax, %eax
jne 0x6a70
movq %rcx, (%rsi)
movl $0x1, %eax
jmp 0x6a72
xorl %eax, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: overwrite_item(cJSON*, cJSON)
static void overwrite_item(cJSON * const root, const cJSON replacement)
{
    if (root == NULL)
    {
        return;
    }

    if (root->string != NULL)
    {
        cJSON_free(root->string);
    }
    if (root->valuestring != NULL)
    {
        cJSON_free(root->valuestring);
    }
    if (root->child != NULL)
    {
        cJSON_Delete(root->child);
    }

    memcpy(root, &replacement, sizeof(cJSON));
}

// Assembly:
testq %rdi, %rdi
je 0x6c2b
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x38(%rdi), %rdi
testq %rdi, %rdi
je 0x6be5
callq 0x509f
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x6bf3
callq 0x509f
leaq 0x10(%rbp), %r14
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x6c05
callq 0x2ce3
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups 0x20(%r14), %xmm2
movups 0x30(%r14), %xmm3
movups %xmm3, 0x30(%rbx)
movups %xmm2, 0x20(%rbx)
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: detach_path(cJSON*, unsigned char const*, int)
static cJSON *detach_path(cJSON *object, const unsigned char *path, const cJSON_bool case_sensitive)
{
    unsigned char *parent_pointer = NULL;
    unsigned char *child_pointer = NULL;
    cJSON *parent = NULL;
    cJSON *detached_item = NULL;

    /* copy path and split it in parent and child */
    parent_pointer = cJSONUtils_strdup(path);
    if (parent_pointer == NULL) {
        goto cleanup;
    }

    child_pointer = (unsigned char*)strrchr((char*)parent_pointer, '/'); /* last '/' */
    if (child_pointer == NULL)
    {
        goto cleanup;
    }
    /* split strings */
    child_pointer[0] = '\0';
    child_pointer++;

    parent = get_item_from_pointer(object, (char*)parent_pointer, case_sensitive);
    decode_pointer_inplace(child_pointer);

    if (cJSON_IsArray(parent))
    {
        size_t index = 0;
        if (!decode_array_index_from_pointer(child_pointer, &index))
        {
            goto cleanup;
        }
        detached_item = detach_item_from_array(parent, index);
    }
    else if (cJSON_IsObject(parent))
    {
        detached_item = cJSON_DetachItemFromObject(parent, (char*)child_pointer);
    }
    else
    {
        /* Couldn't find object to remove child from. */
        goto cleanup;
    }

cleanup:
    if (parent_pointer != NULL)
    {
        cJSON_free(parent_pointer);
    }

    return detached_item;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r14d
movq %rdi, %r13
movq %rsi, %rdi
callq 0x5999
testq %rax, %rax
je 0x6cbc
movq %rax, %rbx
movq %rax, %rdi
movl $0x2f, %esi
callq 0x2270
testq %rax, %rax
je 0x6d55
movq %rax, %r12
movb $0x0, (%rax)
leaq 0x1(%rax), %r15
movq %r13, %rdi
movq %rbx, %rsi
movl %r14d, %edx
callq 0x59db
movq %rax, %r14
addq $0x2, %r12
movq %r15, %rax
movzbl (%rax), %ecx
cmpl $0x7e, %ecx
je 0x6c96
testl %ecx, %ecx
jne 0x6cb4
jmp 0x6cc4
movzbl 0x1(%rax), %ecx
incq %rax
cmpl $0x31, %ecx
je 0x6caf
cmpl $0x30, %ecx
jne 0x6cca
movb $0x7e, -0x1(%r12)
jmp 0x6cb4
movb $0x2f, (%r12)
incq %rax
incq %r12
jmp 0x6c88
xorl %r15d, %r15d
jmp 0x6d60
movb $0x0, -0x1(%r12)
movq %r14, %rdi
callq 0x4e88
testl %eax, %eax
je 0x6d39
leaq -0x30(%rbp), %rsi
movq $0x0, (%rsi)
movq %r15, %rdi
callq 0x6a1a
testl %eax, %eax
je 0x6d55
movq -0x30(%rbp), %rax
addq $0x10, %r14
movq %r14, %r15
movq (%r15), %r15
addq $-0x1, %rax
setb %cl
testq %r15, %r15
je 0x6d0b
testb %cl, %cl
jne 0x6cf8
testq %r15, %r15
je 0x6d55
movq (%r15), %rax
movq 0x8(%r15), %rcx
testq %rcx, %rcx
je 0x6d1f
movq %rax, (%rcx)
testq %rax, %rax
je 0x6d28
movq %rcx, 0x8(%rax)
cmpq (%r14), %r15
jne 0x6d30
movq %rax, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
jmp 0x6d58
movq %r14, %rdi
callq 0x4e9c
testl %eax, %eax
je 0x6d55
movq %r14, %rdi
movq %r15, %rsi
callq 0x447e
movq %rax, %r15
jmp 0x6d58
xorl %r15d, %r15d
movq %rbx, %rdi
callq 0x509f
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: compare_strings(unsigned char const*, unsigned char const*, int)
static int compare_strings(const unsigned char *string1, const unsigned char *string2, const cJSON_bool case_sensitive)
{
    if ((string1 == NULL) || (string2 == NULL))
    {
        return 1;
    }

    if (string1 == string2)
    {
        return 0;
    }

    if (case_sensitive)
    {
        return strcmp((const char*)string1, (const char*)string2);
    }

    for(; tolower(*string1) == tolower(*string2); (void)string1++, string2++)
    {
        if (*string1 == '\0')
        {
            return 0;
        }
    }

    return tolower(*string1) - tolower(*string2);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
movl $0x1, %r12d
jne 0x6e70
movq %rsi, %r14
movq %rdi, %r15
xorl %r12d, %r12d
cmpq %rsi, %rdi
je 0x6e70
testl %edx, %edx
je 0x6e1f
movq %r15, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2210
movb (%r15), %r13b
movzbl %r13b, %edi
callq 0x2240
movl %eax, %r12d
movzbl (%r14), %edi
callq 0x2240
cmpl %eax, %r12d
jne 0x6e68
movl $0x1, %ebx
testb %r13b, %r13b
je 0x6e6d
movb (%r15,%rbx), %r13b
movzbl %r13b, %edi
callq 0x2240
movl %eax, %r12d
movzbl (%r14,%rbx), %edi
callq 0x2240
incq %rbx
cmpl %eax, %r12d
je 0x6e41
subl %eax, %r12d
jmp 0x6e70
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/riyuu/argv_parser.c
// Function: argv_parser(int, char**, char**, _riyuu_run*, unsigned char*)
bool argv_parser(int argc, char *argv[], char *envp[], riyuu_run *run, uint8_t *exit_code)
{
	int i;
	size_t len;
	run->command = no_command;
	run->config_file = NULL;

	for (i = 1; i < argc; i++) {

		len = strlen(argv[i]);

		if (len < 1) {
			printf("argv has been corrupted!\n");
			*exit_code = 1;
			return false;
		}

		if (argv[i][0] == '-') {
			if (len == 1) {
				printf(invalid_parameter, argv[i], i);
				*exit_code = 1;
				return false;
			}

			if (len == 2) {
				switch (argv[i][1]) {
					case 'v':
						show_version();
						return false;
					break;
				}
			}

		} else {
			COMMAND("server", run_server) else 
			COMMAND("connect", run_client) else {
				printf(invalid_command, argv[i], i);
			}
		}
	}

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0x0, (%rcx)
movq %rcx, -0x38(%rbp)
movq $0x0, 0x8(%rcx)
cmpl $0x2, %edi
jl 0x70d8
movq %rsi, %r15
movq %r8, -0x30(%rbp)
movl %edi, %r14d
movl $0x1, %r12d
xorl %r13d, %r13d
movq (%r15,%r12,8), %rbx
movq %rbx, %rdi
callq 0x2140
testq %rax, %rax
je 0x70dd
cmpb $0x2d, (%rbx)
jne 0x706e
cmpq $0x2, %rax
je 0x70aa
cmpq $0x1, %rax
jne 0x70c8
jmp 0x7106
leaq 0x1241(%rip), %rdi      # 0x82b6
movq %rbx, %rsi
callq 0x2210
testl %eax, %eax
je 0x70b2
leaq 0x1235(%rip), %rdi      # 0x82bd
movq %rbx, %rsi
callq 0x2210
testl %eax, %eax
je 0x70be
leaq 0x124f(%rip), %rdi      # 0x82ea
movq %rbx, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2030
jmp 0x70c8
cmpb $0x76, 0x1(%rbx)
jne 0x70c8
jmp 0x711c
movq -0x38(%rbp), %rax
movl $0x1, (%rax)
jmp 0x70c8
movq -0x38(%rbp), %rax
movl $0x2, (%rax)
incq %r12
cmpq %r14, %r12
setae %r13b
jne 0x7043
movb $0x1, %r13b
jmp 0x70f0
leaq 0x1229(%rip), %rdi      # 0x830d
callq 0x22a0
movq -0x30(%rbp), %rax
movb $0x1, (%rax)
andb $0x1, %r13b
movl %r13d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11b8(%rip), %rdi      # 0x82c5
movq %rbx, %rsi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2030
jmp 0x70e9
leaq 0x1188(%rip), %rdi      # 0x82ab
leaq 0x1200(%rip), %rsi      # 0x832a
xorl %eax, %eax
callq 0x2030
jmp 0x70f0
nop
// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/riyuu/riyuu.c
// Function: riyuu_exec_run(_riyuu_run*)
uint8_t riyuu_exec_run(riyuu_run *run)
{
	switch (run->command) {
		case no_command:
		break;

		case run_server: {
			riyuu_server_config config;
			if (riyuu_server_config_parse(run, &config)) {
				return riyuu_server_run(&config);
			}
		}
		break;

		case run_client:
			riyuu_client_run();
		break;
	}

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movl (%rdi), %eax
movb $0x1, %bl
cmpl $0x2, %eax
je 0x7165
cmpl $0x1, %eax
jne 0x716a
leaq -0x18(%rbp), %rsi
callq 0x7308
testb %al, %al
je 0x716a
leaq -0x18(%rbp), %rdi
callq 0x7518
movl %eax, %ebx
jmp 0x716a
callq 0x7174
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/riyuu/server/riyuu_server.c
// Function: riyuu_tcp_bind(char*, unsigned short)
void riyuu_tcp_bind(char *addr, uint16_t port)
{
	socklen_t clilen;
	int sockfd, *new_sock_fd;
	struct sockaddr_in serv_addr, cli_addr;
	threadpool thpool;

	sockfd = socket(AF_INET, SOCK_STREAM, 0);

	if (sockfd < 0) {
		perror("Error opening socket");
		exit(1);
	}

	bzero((char *) &serv_addr, sizeof(serv_addr));
	serv_addr.sin_family = AF_INET;
	serv_addr.sin_addr.s_addr = inet_addr(addr);
	serv_addr.sin_port = htons(port);
	if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
		perror("Error on binding");
		exit(1);
	}
	listen(sockfd, 5);
	clilen = sizeof(cli_addr);

	printf("Listening on %s:%d...\n", addr, port);

	thpool = thpool_init(5);

	// signal(SIGPIPE, SIG_IGN);

	while (1) {
		new_sock_fd = (int *)malloc(sizeof(int));

		*new_sock_fd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen);
		if (*new_sock_fd < 0) {
			perror("Error on accept");
		}

		thpool_add_work(thpool, riyuu_thread_worker, (void *)new_sock_fd);
	}

	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %r12d
movq %rdi, %r15
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x2170
testl %eax, %eax
js 0x761f
movl %eax, %ebx
leaq -0x4c(%rbp), %r14
movq $0x0, 0x8(%r14)
movw $0x2, (%r14)
movq %r15, %rdi
callq 0x2310
movl %eax, 0x4(%r14)
movl %r12d, %eax
rolw $0x8, %ax
movw %ax, 0x2(%r14)
movl %ebx, %edi
movq %r14, %rsi
movl $0x10, %edx
callq 0x2280
testl %eax, %eax
js 0x7628
movl %ebx, %edi
movl $0x5, %esi
callq 0x2300
leaq -0x2c(%rbp), %rax
movl $0x10, (%rax)
movzwl %r12w, %edx
leaq 0xed9(%rip), %rdi       # 0x8498
movq %r15, %rsi
xorl %eax, %eax
callq 0x2030
movl $0x5, %edi
callq 0x2584
movq %rax, %r15
leaq -0x3c(%rbp), %r12
leaq 0xce(%rip), %r13        # 0x76af
movl $0x4, %edi
callq 0x2350
movq %rax, %r14
movl %ebx, %edi
movq %r12, %rsi
leaq -0x2c(%rbp), %rdx
callq 0x2220
movl %eax, (%r14)
testl %eax, %eax
jns 0x760f
leaq 0xea5(%rip), %rdi       # 0x84af
callq 0x20d0
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x2751
jmp 0x75e1
leaq 0xe4c(%rip), %rdi       # 0x8472
jmp 0x762f
leaq 0xe58(%rip), %rdi       # 0x8487
callq 0x20d0
movl $0x1, %edi
callq 0x21a0
// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/riyuu/server/riyuu_server.c
// Function: riyuu_socket_setopt(int)
bool riyuu_socket_setopt(int sock_fd)
{
	struct timeval timeout;

	timeout.tv_sec = 30;
	timeout.tv_usec = 0;

	if (setsockopt(sock_fd, SOL_SOCKET, SO_RCVTIMEO, (void *)&timeout, sizeof(timeout)) < 0) {
		perror("setsockopt failed\n");
		return false;
	}

	if (setsockopt(sock_fd, SOL_SOCKET, SO_SNDTIMEO, (void *)&timeout, sizeof(timeout)) < 0) {
		perror("setsockopt failed\n");
		return false;
	}

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebx
leaq -0x18(%rbp), %rcx
movq $0x1e, (%rcx)
movq $0x0, 0x8(%rcx)
movl $0x1, %esi
movl $0x14, %edx
movl $0x10, %r8d
callq 0x2060
testl %eax, %eax
js 0x769f
leaq -0x18(%rbp), %rcx
movl %ebx, %edi
movl $0x1, %esi
movl $0x15, %edx
movl $0x10, %r8d
callq 0x2060
movl %eax, %ecx
movb $0x1, %al
testl %ecx, %ecx
js 0x769f
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
leaq 0xd67(%rip), %rdi       # 0x840d
callq 0x20d0
xorl %eax, %eax
jmp 0x7698
// File: /workspace/github_c_makefile_star2_O3/ammarfaizi2[P]riyuu/src/riyuu/server/riyuu_server.c
// Function: riyuu_thread_worker(void*)
void *riyuu_thread_worker(void *_fd)
{
	#define sock_fd (*((int *)_fd))

	riyuu_data *req;
	riyuu_data *tmp;
	bool exec_return = false;

	if (!riyuu_socket_setopt(sock_fd)) {
		goto out;
	}

	req = (riyuu_data *)malloc(sizeof(riyuu_data));
	if (req == NULL) {
		printf("Cannot allocate memory!\n");
		goto out;
	}

	printf("A new client connected with fd: %d\n", sock_fd);

	while (1) {
		ssize_t n;

		// Read data size.
		n = read(sock_fd, &(req->data_size), sizeof(uint32_t));
		if (n < 0) {
			perror("Error read");
			break;
		}

		write(sock_fd, "OK", 2);

		PRINTF_DEBUG("Got data length: %d\n", req->data_size);

		// Read data.
		req->data = (char *)malloc(sizeof(char) * req->data_size);

		n = read(sock_fd, req->data, req->data_size);
		if (n < 0) {
			perror("Error read");
			break;
		}
		
		PRINTF_DEBUG("Got data: %s\n", req->data);

		// // Process the request.
		// exec_return = riyuu_exec_request(sock_fd, req);
		// free(req);

		// if (!exec_return) break;
	}

	out:
	close(sock_fd);
	free(_fd);

	#undef sock_fd

	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl (%rdi), %edi
callq 0x763e
testb %al, %al
je 0x76e6
movl $0x10, %edi
callq 0x2350
testq %rax, %rax
jne 0x7706
leaq 0xdde(%rip), %rdi       # 0x84bf
callq 0x22a0
movl (%rbx), %edi
callq 0x2080
movq %rbx, %rdi
callq 0x2340
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movl (%rbx), %esi
leaq 0xd0e(%rip), %rdi       # 0x8420
xorl %eax, %eax
callq 0x2030
movl (%rbx), %edi
movl $0x4, %edx
movq %r14, %rsi
callq 0x21e0
testq %rax, %rax
js 0x779d
leaq 0xd30(%rip), %r13       # 0x8464
movl (%rbx), %edi
movl $0x2, %edx
leaq 0xc0a(%rip), %rsi       # 0x834c
callq 0x22b0
movl (%r14), %r12d
leaq 0xcfe(%rip), %rdi       # 0x844f
movl %r12d, %esi
xorl %eax, %eax
callq 0x2030
movq %r12, %rdi
callq 0x2350
movq %rax, %r15
movq %rax, 0x8(%r14)
movl (%rbx), %edi
movq %rax, %rsi
movq %r12, %rdx
callq 0x21e0
testq %rax, %rax
js 0x779d
movq %r13, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x2030
movl (%rbx), %edi
movl $0x4, %edx
movq %r14, %rsi
callq 0x21e0
testq %rax, %rax
jns 0x7734
leaq 0xca0(%rip), %rdi       # 0x8444
callq 0x20d0
jmp 0x76e6
// File: /workspace/github_c_makefile_star2_O3/ls4154[P]hash-c/sha224.c
// Function: sha224_offline
void sha224_offline(struct sha224_ctx *ctx, byte_t *msg, len_t len)
{
	sha224_init(ctx);

	while (len >= 64) {
		sha224_update(ctx, msg);

		msg += 64;
		len -= 64;
	}

	sha224_update_last(ctx, msg, len);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movaps 0xa8c(%rip), %xmm0      # 0x2030
movups %xmm0, (%rdi)
movaps 0xa92(%rip), %xmm0      # 0x2040
movups %xmm0, 0x10(%rdi)
movq $0x0, 0x20(%rdi)
cmpq $0x40, %rdx
jb 0x15de
movq %r15, %rdi
movq %r14, %rsi
callq 0x12e6
addq $0x40, 0x20(%r15)
addq $0x40, %r14
addq $-0x40, %rbx
cmpq $0x3f, %rbx
ja 0x15c0
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0x1490
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/audio.c
// Function: AUD_init
void AUD_init(Audio* audio, int sampleRate) {
    SDL_Init(SDL_INIT_AUDIO);

    audio->sampleRate = sampleRate;
    for (int i = 0; i < 4; ++i) {
        AudioChannel channel;
        channel.frequency = 0.0;
        channel.amplitude = 4400.0;
        channel.time = 0.0;
        audio->channels[i] = channel;
    }

    SDL_AudioSpec want;
    want.freq = audio->sampleRate;
    want.format = AUDIO_S16SYS;
    want.channels = 1;
    want.samples = 2048;
    want.callback = audioCallback;
    want.userdata = audio;

    SDL_AudioSpec have;
    //SDL_OpenAudio(&want, &have);
    audio->deviceId = SDL_OpenAudioDevice(NULL, 0, &want, &have, SDL_AUDIO_ALLOW_ANY_CHANGE);

    SDL_PauseAudioDevice(audio->deviceId, false);
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x48, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movl $0x10, %edi
callq 0x2140
movl %ebp, 0x4(%rbx)
movl $0x18, %eax
xorps %xmm0, %xmm0
movhps 0x5c45(%rip), %xmm0     # xmm0 = xmm0[0,1],mem[0,1]
movups %xmm0, -0x10(%rbx,%rax)
movq $0x0, (%rbx,%rax)
addq $0x20, %rax
cmpq $0x98, %rax
jne 0x23c3
leaq 0x28(%rsp), %rdx
movl %ebp, (%rdx)
movw $0x8010, 0x4(%rdx)      # imm = 0x8010
movb $0x1, 0x6(%rdx)
movw $0x800, 0x8(%rdx)       # imm = 0x800
leaq 0x2e(%rip), %rax        # 0x2428
movq %rax, 0x10(%rdx)
movq %rbx, 0x18(%rdx)
leaq 0x8(%rsp), %rcx
xorl %edi, %edi
xorl %esi, %esi
movl $0xf, %r8d
callq 0x21d0
movl %eax, (%rbx)
movl %eax, %edi
xorl %esi, %esi
callq 0x21f0
addq $0x48, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/audio.c
// Function: audioCallback
void audioCallback(void *user_data, uint8_t *raw_buffer, int bytes) {
    Audio* audio = user_data;
    int16_t* snd = (int16_t*) raw_buffer;
	int len = bytes / sizeof(*snd);

    for (int i = 0; i < len; ++i) {
        snd[i] = 0;

        for (int j = 0; j < 3; ++j) {
            AudioChannel* channel = &(audio->channels[j]);
            double sine = sin(channel->time);
            double ampMultiplier = (sine > 0) - (sine < 0);
            snd[i] += (channel->amplitude * ampMultiplier) / 3;

            channel->time += channel->frequency * 2.0f * M_PI / audio->sampleRate;
            if (channel->time >= (2.0f * M_PI)) channel->time -= (2.0f * M_PI);
        }
    }
}

// Assembly:
sarl %edx
testl %edx, %edx
jle 0x252a
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movl %edx, %r15d
xorl %r12d, %r12d
movw $0x0, (%rbx,%r12,2)
movl $0x18, %r13d
movsd (%r14,%r13), %xmm0
callq 0x2090
movsd 0x5bb1(%rip), %xmm3     # 0x8018
movsd 0x5ba1(%rip), %xmm2     # 0x8010
xorpd %xmm1, %xmm1
xorl %eax, %eax
ucomisd %xmm1, %xmm0
seta %al
xorl %ecx, %ecx
ucomisd %xmm0, %xmm1
seta %cl
subl %ecx, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd -0x8(%r14,%r13), %xmm0
movswl (%rbx,%r12,2), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm2, %xmm0
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
movw %ax, (%rbx,%r12,2)
movsd -0x10(%r14,%r13), %xmm0
addsd %xmm0, %xmm0
mulsd %xmm3, %xmm0
movsd 0x5b5f(%rip), %xmm3     # 0x8028
movsd 0x5b4f(%rip), %xmm2     # 0x8020
xorps %xmm1, %xmm1
cvtsi2sdl 0x4(%r14), %xmm1
divsd %xmm1, %xmm0
addsd (%r14,%r13), %xmm0
movapd %xmm0, %xmm1
addsd %xmm2, %xmm1
movapd %xmm3, %xmm2
cmpnlesd %xmm0, %xmm2
andpd %xmm2, %xmm0
andnpd %xmm1, %xmm2
orpd %xmm0, %xmm2
movlpd %xmm2, (%r14,%r13)
addq $0x20, %r13
cmpq $0x78, %r13
jne 0x2454
incq %r12
cmpq %r15, %r12
jne 0x2447
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/audio.c
// Function: AUD_update
void AUD_update(Audio* audio, Memory* mem) {
    unsigned int x;

    x = ((mem->logicalMemory[REG_NR14] & 0x7) << 8) | mem->logicalMemory[REG_NR13];
    audio->channels[0].frequency = 131072.0 / (2048.0 - x);
    if (audio->channels[0].frequency < 100.0) audio->channels[0].frequency = 0.0;

    x = ((mem->logicalMemory[REG_NR24] & 0x7) << 8) | mem->logicalMemory[REG_NR23];
    audio->channels[1].frequency = 131072.0 / (2048.0 - x);
    if (audio->channels[1].frequency < 100.0) audio->channels[1].frequency = 0.0;

    x = ((mem->logicalMemory[REG_NR34] & 0x7) << 8) | mem->logicalMemory[REG_NR33];
    audio->channels[2].frequency = getBit(mem->logicalMemory[REG_NR30], 7) ? (65536.0 / (2048.0 - x)) : 0.0;
    if (audio->channels[0].frequency < 100.0) audio->channels[0].frequency = 0.0;
}

// Assembly:
movzbl 0xff14(%rsi), %eax
andl $0x7, %eax
shll $0x8, %eax
movzbl 0xff13(%rsi), %ecx
orl %eax, %ecx
cvtsi2sd %ecx, %xmm0
movsd 0x5ac5(%rip), %xmm1     # 0x8030
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movsd 0x5abd(%rip), %xmm3     # 0x8038
movapd %xmm3, %xmm0
divsd %xmm2, %xmm0
movsd 0x5ab5(%rip), %xmm2     # 0x8040
movapd %xmm0, %xmm4
cmpltsd %xmm2, %xmm4
andnpd %xmm0, %xmm4
movlpd %xmm4, 0x8(%rdi)
movzbl 0xff19(%rsi), %eax
andl $0x7, %eax
shll $0x8, %eax
movzbl 0xff18(%rsi), %ecx
orl %eax, %ecx
xorps %xmm4, %xmm4
cvtsi2sd %ecx, %xmm4
movapd %xmm1, %xmm5
subsd %xmm4, %xmm5
divsd %xmm5, %xmm3
movapd %xmm3, %xmm4
cmpltsd %xmm2, %xmm4
andnpd %xmm3, %xmm4
movlpd %xmm4, 0x28(%rdi)
cmpb $0x0, 0xff1a(%rsi)
xorpd %xmm3, %xmm3
jns 0x2612
movzbl 0xff1e(%rsi), %eax
andl $0x7, %eax
shll $0x8, %eax
movzbl 0xff1d(%rsi), %ecx
orl %eax, %ecx
xorps %xmm3, %xmm3
cvtsi2sd %ecx, %xmm3
subsd %xmm3, %xmm1
movsd 0x5a3a(%rip), %xmm3     # 0x8048
divsd %xmm1, %xmm3
ucomisd %xmm0, %xmm2
movsd %xmm3, 0x48(%rdi)
jbe 0x2625
movq $0x0, 0x8(%rdi)
retq
nop
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/cartridge.c
// Function: MBC1
static void MBC1(Memory* mem, uint16_t address, uint8_t value) {
    Cartridge* cart = mem->cartridge;

    if (address <= 0x1FFF) {
        cart->RAMG = value & 0xF;
        mem->extRamEnabled = (cart->RAMG == 0xA);

    } else if (address <= 0x3FFF) {
        cart->BANK1 = value & 0x1F;
        if (cart->BANK1 == 0x00) cart->BANK1 = 0x01;
        if (cart->MODE == 0) {
            MEM_setRomBank(mem, (cart->BANK2 << 5) | cart->BANK1);
        } else {
            MEM_setRomBank(mem, cart->BANK1);
        }

    } else if (address <= 0x5FFF) {
        cart->BANK2 = value & 0x3;
        if (cart->MODE == 0) {
            MEM_setRomBank(mem, (cart->BANK2 << 5) | cart->BANK1);
        } else {
            MEM_setRamBank(mem, cart->BANK2);
        }

    } else if (address <= 0x7FFF) {
        cart->MODE = value & 0x1;

    }
}

// Assembly:
movq 0x10038(%rdi), %rax
cmpl $0x1fff, %esi           # imm = 0x1FFF
ja 0x2698
andb $0xf, %dl
movb %dl, 0x14(%rax)
cmpb $0xa, %dl
sete 0x10034(%rdi)
retq
movzwl %si, %ecx
cmpl $0x3fff, %ecx           # imm = 0x3FFF
ja 0x26c5
andb $0x1f, %dl
movzbl %dl, %edx
cmpb $0x2, %dl
movl $0x1, %ecx
cmovael %edx, %ecx
movb %cl, 0x15(%rax)
cmpb $0x0, 0x17(%rax)
je 0x26ed
movzbl %cl, %esi
jmp 0x6f16
cmpl $0x5fff, %ecx           # imm = 0x5FFF
ja 0x26e1
andb $0x3, %dl
movb %dl, 0x16(%rax)
cmpb $0x0, 0x17(%rax)
je 0x26fd
movzbl %dl, %esi
jmp 0x6f63
testw %si, %si
js 0x26ec
andb $0x1, %dl
movb %dl, 0x17(%rax)
retq
movb 0x16(%rax), %al
shlb $0x5, %al
orb %cl, %al
movzbl %al, %esi
jmp 0x6f16
shlb $0x5, %dl
orb 0x15(%rax), %dl
movzbl %dl, %esi
jmp 0x6f16
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/cartridge.c
// Function: MBC3
static void MBC3(Memory* mem, uint16_t address, uint8_t value) {
    //unimplemented(MEM_getByte(mem, 0x0147)); // TODO: MBC3
    Cartridge* cart = mem->cartridge;

    if (address <= 0x1FFF) {
        cart->RAMG = value & 0xF;
        mem->extRamEnabled = (cart->RAMG == 0xA);

    } else if (address <= 0x3FFF) {
        cart->ROMB = value & 0x7F;
        if (cart->ROMB == 0) cart->ROMB = 1;
        MEM_setRomBank(mem, cart->ROMB);

    } else if (address <= 0x5FFF) {

    }
}

// Assembly:
movq 0x10038(%rdi), %rax
cmpl $0x1fff, %esi           # imm = 0x1FFF
ja 0x2889
andb $0xf, %dl
movb %dl, 0x14(%rax)
cmpb $0xa, %dl
sete 0x10034(%rdi)
retq
movzwl %si, %ecx
cmpl $0x3fff, %ecx           # imm = 0x3FFF
ja 0x28b0
andb $0x7f, %dl
movzbl %dl, %ecx
cmpb $0x2, %cl
movl $0x1, %edx
cmovael %ecx, %edx
movb %dl, 0x18(%rax)
movzbl %dl, %esi
jmp 0x6f16
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/cartridge.c
// Function: CART_mbcDispatch
void CART_mbcDispatch(Memory* mem, uint16_t address, uint8_t value) {
    uint8_t mbcCode = MEM_getByte(mem, 0x0147);
    void (*mbcFunction)(Memory*, uint16_t, uint8_t) = MBC_MAP[mbcCode];
    if (mbcFunction == NULL) {
        printf("Undefined MBC: 0x%x\n", mbcCode);
    } else {
        mbcFunction(mem, address, value);
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
movl $0x147, %esi            # imm = 0x147
callq 0x6ae9
movzbl %al, %esi
leaq 0x96fc(%rip), %rax      # 0xc150
movq (%rax,%rsi,8), %rax
testq %rax, %rax
je 0x2a6c
movzwl %bp, %esi
movzbl %bl, %edx
movq %r14, %rdi
popq %rbx
popq %r14
popq %rbp
jmpq *%rax
leaq 0x55dd(%rip), %rdi      # 0x8050
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x2050
nop
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_LD_nn_SP
static inline void ASM_LD_nn_SP(CPU* cpu, Memory* mem) {
    //cpu->SP = (MEM_getByte(mem, cpu->PC + 2) << 8) | MEM_getByte(mem, cpu->PC + 1);
    uint16_t address = (MEM_getByte(mem, cpu->PC + 2) << 8) | MEM_getByte(mem, cpu->PC + 1);
    MEM_setByte(mem, address, cpu->SP & 0xFF);
    MEM_setByte(mem, address + 1, (cpu->SP & 0xFF00) >> 8);
    cpu->PC += 3;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movl 0xc(%rdi), %esi
addl $0x2, %esi
movl $0xffff, %ebp           # imm = 0xFFFF
andl %ebp, %esi
movq %r14, %rdi
callq 0x6ae9
movzbl %al, %r15d
shll $0x8, %r15d
movl 0xc(%rbx), %esi
incl %esi
andl %ebp, %esi
movq %r14, %rdi
callq 0x6ae9
movzbl %al, %r12d
leal (%r15,%r12), %esi
movzbl 0xa(%rbx), %edx
andl %ebp, %esi
movq %r14, %rdi
callq 0x6b5a
leal (%r15,%r12), %esi
incl %esi
movzbl 0xb(%rbx), %edx
andl %ebp, %esi
movq %r14, %rdi
callq 0x6b5a
addw $0x3, 0xc(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_JP_cc_nn
static inline int ASM_JP_cc_nn(CPU* cpu, Memory* mem, int ccCode) {
    int cond = 0;
    switch (ccCode) {
        case PARAM_CC_Z:
            cond = CPU_getFlagZ(cpu);
            break;
        case PARAM_CC_NZ:
            cond = !CPU_getFlagZ(cpu);
            break;
        case PARAM_CC_C:
            cond = CPU_getFlagC(cpu);
            break;
        case PARAM_CC_NC:
            cond = !CPU_getFlagC(cpu);
            break;
    }
    if (cond) {
        cpu->PC = (MEM_getByte(mem, cpu->PC + 2) << 8) | MEM_getByte(mem, cpu->PC + 1);
        return 1;
    } else {
        cpu->PC += 3;
        return 0;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movzbl 0x2(%rdi), %eax
addl $-0x64, %edx
leaq 0x3ecf(%rip), %rcx      # 0x88a0
movslq (%rcx,%rdx,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
xorl %ecx, %ecx
testb %al, %al
setns %cl
jmp 0x49ea
xorl %ecx, %ecx
testb $0x10, %al
sete %cl
movl %ecx, %eax
jmp 0x49f9
shrl $0x4, %eax
andl $0x1, %eax
jmp 0x49f9
shrl $0x7, %eax
movzwl 0xc(%rbx), %esi
testl %eax, %eax
je 0x4a37
addl $0x2, %esi
movl $0xffff, %ebp           # imm = 0xFFFF
andl %ebp, %esi
movq %r14, %rdi
callq 0x6ae9
movzbl %al, %r15d
shll $0x8, %r15d
movl 0xc(%rbx), %esi
incl %esi
andl %ebp, %esi
movq %r14, %rdi
callq 0x6ae9
movzbl %al, %esi
orl %r15d, %esi
movl $0x1, %eax
jmp 0x4a3c
addl $0x3, %esi
xorl %eax, %eax
movw %si, 0xc(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_JR_cc_n
static inline int ASM_JR_cc_n(CPU* cpu, Memory* mem, int ccCode) {
    int cond = 0;
    switch (ccCode) {
        case PARAM_CC_Z:
            cond = CPU_getFlagZ(cpu);
            break;
        case PARAM_CC_NZ:
            cond = !CPU_getFlagZ(cpu);
            break;
        case PARAM_CC_C:
            cond = CPU_getFlagC(cpu);
            break;
        case PARAM_CC_NC:
            cond = !CPU_getFlagC(cpu);
            break;
    }
    if (cond) {
        cpu->PC += ((int8_t) MEM_getByte(mem, cpu->PC + 1)) + 2;
        return 1;
    } else {
        cpu->PC += 2;
        return 0;
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movzbl 0x2(%rdi), %eax
addl $-0x64, %edx
leaq 0x3e53(%rip), %rcx      # 0x88b0
movslq (%rcx,%rdx,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
xorl %ecx, %ecx
testb %al, %al
setns %cl
jmp 0x4a76
xorl %ecx, %ecx
testb $0x10, %al
sete %cl
movl %ecx, %eax
jmp 0x4a85
shrl $0x4, %eax
andl $0x1, %eax
jmp 0x4a85
shrl $0x7, %eax
movzwl 0xc(%rbx), %ecx
testl %eax, %eax
je 0x4aad
incl %ecx
movzwl %cx, %eax
movq %rsi, %rdi
movl %eax, %esi
callq 0x6ae9
movsbl %al, %ecx
addw 0xc(%rbx), %cx
addl $0x2, %ecx
movl $0x1, %eax
jmp 0x4ab2
addl $0x2, %ecx
xorl %eax, %eax
movw %cx, 0xc(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_LDI_HL_A
static inline void ASM_LDI_HL_A(CPU* cpu, Memory* mem) {
    uint16_t address = (cpu->H << 8) | cpu->L;
    MEM_setByte(mem, address, cpu->A);
    ++address;
    cpu->H = (address & 0xFF00) >> 8;
    cpu->L = address & 0x00FF;
    cpu->PC += 1;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzwl 0x8(%rdi), %ebp
movzbl 0x3(%rdi), %edx
movq %rsi, %rdi
movl %ebp, %esi
callq 0x6b5a
incl %ebp
movw %bp, 0x8(%rbx)
incw 0xc(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_LDI_A_HL
static inline void ASM_LDI_A_HL(CPU* cpu, Memory* mem) {
    uint16_t address = (cpu->H << 8) | cpu->L;
    cpu->A = MEM_getByte(mem, address);
    ++address;
    cpu->H = (address & 0xFF00) >> 8;
    cpu->L = address & 0x00FF;
    cpu->PC += 1;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbp
movzwl 0x8(%rdi), %ebx
movq %rsi, %rdi
movl %ebx, %esi
callq 0x6ae9
movb %al, 0x3(%rbp)
incl %ebx
movb %bh, 0x9(%rbp)
movb %bl, 0x8(%rbp)
incw 0xc(%rbp)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_LDD_HL_A
static inline void ASM_LDD_HL_A(CPU* cpu, Memory* mem) {
    uint16_t address = (cpu->H << 8) | cpu->L;
    MEM_setByte(mem, address, cpu->A);
    --address;
    cpu->H = (address & 0xFF00) >> 8;
    cpu->L = address & 0x00FF;
    cpu->PC += 1;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzwl 0x8(%rdi), %ebp
movzbl 0x3(%rdi), %edx
movq %rsi, %rdi
movl %ebp, %esi
callq 0x6b5a
decl %ebp
movw %bp, 0x8(%rbx)
incw 0xc(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_INC_m
static inline void ASM_INC_m(CPU* cpu, Memory* mem, uint16_t address) {
    uint8_t result = MEM_getByte(mem, address) + 1;
    CPU_setFlagZ(cpu, result == 0);
    CPU_setFlagN(cpu, 0);
    CPU_setFlagH(cpu, (MEM_getByte(mem, address) & 0x10) != (result & 0x10));
    MEM_setByte(mem, address, result);
    cpu->PC += 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
movl %edx, %esi
callq 0x6ae9
movl %eax, %r15d
incb %r15b
sete %al
movb 0x2(%rbx), %cl
andb $0x3f, %cl
shlb $0x7, %al
orb %cl, %al
movb %al, 0x2(%rbx)
movq %r14, %rdi
movl %ebp, %esi
callq 0x6ae9
xorb %r15b, %al
movb 0x2(%rbx), %cl
andb $-0x21, %cl
addb %al, %al
andb $0x20, %al
orb %cl, %al
movb %al, 0x2(%rbx)
movzbl %r15b, %edx
movq %r14, %rdi
movl %ebp, %esi
callq 0x6b5a
incw 0xc(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_ADD_A_m
static inline void ASM_ADD_A_m(CPU* cpu, Memory* mem, uint16_t address) {
    uint16_t result = cpu->A + MEM_getByte(mem, address);
    CPU_setFlagZ(cpu, ((uint8_t) result) == 0);
    CPU_setFlagN(cpu, 0);
    CPU_setFlagH(cpu, (((cpu->A & 0xF) + (MEM_getByte(mem, address) & 0xF)) & 0x10) == 0x10);
    CPU_setFlagC(cpu, result > 0xFF);
    cpu->A = (uint8_t) result;
    cpu->PC += 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movzbl 0x3(%rdi), %r12d
movq %rsi, %rdi
movl %edx, %esi
callq 0x6ae9
movzbl %al, %r15d
addl %r12d, %r15d
cmpl $0x100, %r15d           # imm = 0x100
setae %r12b
testb %r15b, %r15b
sete %al
movb 0x2(%rbx), %cl
movb 0x3(%rbx), %r13b
andb $0x3f, %cl
shlb $0x7, %al
orb %cl, %al
movb %al, 0x2(%rbx)
andb $0xf, %r13b
movq %r14, %rdi
movl %ebp, %esi
callq 0x6ae9
andb $0xf, %al
addb %r13b, %al
cmpb $0x10, %al
setae %al
movb 0x2(%rbx), %cl
andb $-0x31, %cl
shlb $0x5, %al
shlb $0x4, %r12b
orb %cl, %r12b
orb %al, %r12b
movb %r12b, 0x2(%rbx)
movb %r15b, 0x3(%rbx)
incw 0xc(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_XOR_m
static inline void ASM_XOR_m(CPU* cpu, Memory* mem, uint16_t address) {
    uint8_t result = MEM_getByte(mem, address) ^ cpu->A;
    CPU_setFlagZ(cpu, result == 0);
    CPU_setFlagN(cpu, 0);
    CPU_setFlagH(cpu, 0);
    CPU_setFlagC(cpu, 0);
    cpu->A = result;
    cpu->PC += 1;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq %rsi, %rdi
movl %edx, %esi
callq 0x6ae9
movb 0x2(%rbx), %cl
movb 0x3(%rbx), %dl
movl %edx, %esi
xorb %al, %sil
cmpb %dl, %al
sete %al
andb $0xf, %cl
shlb $0x7, %al
orb %cl, %al
movb %al, 0x2(%rbx)
movb %sil, 0x3(%rbx)
incw 0xc(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_RET_cc
static inline int ASM_RET_cc(CPU* cpu, Memory* mem, int ccCode) {
    int cond = 0;
    switch (ccCode) {
        case PARAM_CC_Z:
            cond = CPU_getFlagZ(cpu);
            break;
        case PARAM_CC_NZ:
            cond = !CPU_getFlagZ(cpu);
            break;
        case PARAM_CC_C:
            cond = CPU_getFlagC(cpu);
            break;
        case PARAM_CC_NC:
            cond = !CPU_getFlagC(cpu);
            break;
    }
    if (cond) {
        cpu->PC = MEM_popFromStack(mem, &(cpu->SP));
        return 1;
    } else {
        cpu->PC += 1;
        return 0;
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movzbl 0x2(%rdi), %eax
addl $-0x64, %edx
leaq 0x36fc(%rip), %rcx      # 0x88c0
movslq (%rcx,%rdx,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
xorl %ecx, %ecx
testb %al, %al
setns %cl
jmp 0x51dd
xorl %ecx, %ecx
testb $0x10, %al
sete %cl
movl %ecx, %eax
jmp 0x51ec
shrl $0x4, %eax
andl $0x1, %eax
jmp 0x51ec
shrl $0x7, %eax
testl %eax, %eax
je 0x520a
leaq 0xa(%rbx), %rax
movq %rsi, %rdi
movq %rax, %rsi
callq 0x6c73
movw %ax, 0xc(%rbx)
movl $0x1, %eax
jmp 0x5210
incw 0xc(%rbx)
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_CALL_cc_nn
static inline int ASM_CALL_cc_nn(CPU* cpu, Memory* mem, int ccCode) {
    int cond = 0;
    switch (ccCode) {
        case PARAM_CC_Z:
            cond = CPU_getFlagZ(cpu);
            break;
        case PARAM_CC_NZ:
            cond = !CPU_getFlagZ(cpu);
            break;
        case PARAM_CC_C:
            cond = CPU_getFlagC(cpu);
            break;
        case PARAM_CC_NC:
            cond = !CPU_getFlagC(cpu);
            break;
    }
    if (cond) {
        uint16_t jumpAddress = (MEM_getByte(mem, cpu->PC + 2) << 8) | MEM_getByte(mem, cpu->PC + 1);
        uint16_t nextAddress = cpu->PC + 3;
        MEM_pushToStack(mem, &(cpu->SP), nextAddress);
        cpu->PC = jumpAddress;
        return 1;
    } else {
        cpu->PC += 3;
        return 0;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movzbl 0x2(%rdi), %eax
addl $-0x64, %edx
leaq 0x3654(%rip), %rcx      # 0x88d0
movslq (%rcx,%rdx,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
xorl %ecx, %ecx
testb %al, %al
setns %cl
jmp 0x5295
xorl %ecx, %ecx
testb $0x10, %al
sete %cl
movl %ecx, %eax
jmp 0x52a4
shrl $0x4, %eax
andl $0x1, %eax
jmp 0x52a4
shrl $0x7, %eax
movzwl 0xc(%rbx), %ebp
testl %eax, %eax
je 0x52fc
addl $0x2, %ebp
movl $0xffff, %r15d          # imm = 0xFFFF
andl %r15d, %ebp
movq %r14, %rdi
movl %ebp, %esi
callq 0x6ae9
movzbl %al, %r12d
shll $0x8, %r12d
movl 0xc(%rbx), %esi
incl %esi
andl %r15d, %esi
movq %r14, %rdi
callq 0x6ae9
movzbl %al, %ebp
orl %r12d, %ebp
movl 0xc(%rbx), %edx
addl $0x3, %edx
leaq 0xa(%rbx), %rsi
andl %r15d, %edx
movq %r14, %rdi
callq 0x6c2c
movl $0x1, %eax
jmp 0x5301
addl $0x3, %ebp
xorl %eax, %eax
movw %bp, 0xc(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_CALL_nn
static inline void ASM_CALL_nn(CPU* cpu, Memory* mem) {
    uint16_t jumpAddress = (MEM_getByte(mem, cpu->PC + 2) << 8) | MEM_getByte(mem, cpu->PC + 1);
    uint16_t nextAddress = cpu->PC + 3;
    MEM_pushToStack(mem, &(cpu->SP), nextAddress);
    cpu->PC = jumpAddress;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movl 0xc(%rdi), %esi
addl $0x2, %esi
movl $0xffff, %ebp           # imm = 0xFFFF
andl %ebp, %esi
movq %r14, %rdi
callq 0x6ae9
movzbl %al, %r15d
shll $0x8, %r15d
movl 0xc(%rbx), %esi
incl %esi
andl %ebp, %esi
movq %r14, %rdi
callq 0x6ae9
movzbl %al, %r12d
orl %r15d, %r12d
movl 0xc(%rbx), %edx
addl $0x3, %edx
leaq 0xa(%rbx), %rsi
andl %ebp, %edx
movq %r14, %rdi
callq 0x6c2c
movw %r12w, 0xc(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_ADD_SP_n
static inline void ASM_ADD_SP_n(CPU* cpu, Memory* mem) {
    uint8_t nextByte = MEM_getByte(mem, cpu->PC + 1);
    uint16_t result = cpu->SP + (int8_t) nextByte;
    uint8_t lowResult = (cpu->SP & 0xFF) + nextByte;
    CPU_setFlagZ(cpu, 0);
    CPU_setFlagN(cpu, 0);
    CPU_setFlagH(cpu, ((((cpu->SP & 0xFF) & 0xF) + (nextByte & 0xF)) & 0x10) == 0x10);
    CPU_setFlagC(cpu, lowResult < nextByte);
    cpu->SP = result;
    cpu->PC += 2;
}

// Assembly:
pushq %rbx
movq %rsi, %rax
movq %rdi, %rbx
movl 0xc(%rdi), %ecx
incl %ecx
movzwl %cx, %esi
movq %rax, %rdi
callq 0x6ae9
movb 0x2(%rbx), %cl
movl %eax, %edx
andb $0xf, %dl
movzbl %dl, %edx
andb $0xf, %cl
movl 0xa(%rbx), %esi
movd %esi, %xmm0
movl %esi, %edi
andl $0xf, %edi
addl %edx, %edi
cmpl $0x10, %edi
setae %dl
shlb $0x5, %dl
addb %al, %sil
setb %sil
shlb $0x4, %sil
orb %cl, %sil
orb %dl, %sil
movb %sil, 0x2(%rbx)
movsbl %al, %eax
movdqa 0x2c82(%rip), %xmm1     # 0x8090
pinsrw $0x0, %eax, %xmm1
paddw %xmm0, %xmm1
movd %xmm1, 0xa(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_RLC_m
static inline void ASM_RLC_m(CPU* cpu, Memory* mem, uint16_t address) {
    uint8_t bit7 = getBit(MEM_getByte(mem, address), 7);
    MEM_setByte(mem, address, (MEM_getByte(mem, address) << 1) | bit7);
    CPU_setFlagZ(cpu, MEM_getByte(mem, address) == 0);
    CPU_setFlagN(cpu, 0);
    CPU_setFlagH(cpu, 0);
    CPU_setFlagC(cpu, (int) bit7);
    cpu->PC += 2;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
movl %edx, %esi
callq 0x6ae9
movl %eax, %ebp
movq %r15, %rdi
movl %r14d, %esi
callq 0x6ae9
movl %ebp, %ecx
shrb $0x7, %cl
addb %al, %al
orb %cl, %al
movzbl %al, %edx
movq %r15, %rdi
movl %r14d, %esi
callq 0x6b5a
movq %r15, %rdi
movl %r14d, %esi
callq 0x6ae9
testb %al, %al
sete %al
movb 0x2(%rbx), %cl
andb $0xf, %cl
shlb $0x7, %al
shrb $0x3, %bpl
andb $0x10, %bpl
orb %al, %bpl
orb %cl, %bpl
movb %bpl, 0x2(%rbx)
addw $0x2, 0xc(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/qad114[P]yobeboy/src/asm.h
// Function: ASM_RL_m
static inline void ASM_RL_m(CPU* cpu, Memory* mem, uint16_t address) {
    uint8_t bit7 = getBit(MEM_getByte(mem, address), 7);
    MEM_setByte(mem, address, (MEM_getByte(mem, address) << 1) | (uint8_t) CPU_getFlagC(cpu));
    CPU_setFlagZ(cpu, MEM_getByte(mem, address) == 0);
    CPU_setFlagN(cpu, 0);
    CPU_setFlagH(cpu, 0);
    CPU_setFlagC(cpu, (int) bit7);
    cpu->PC += 2;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
movl %edx, %esi
callq 0x6ae9
movl %eax, %ebp
movq %r15, %rdi
movl %r14d, %esi
callq 0x6ae9
addb %al, %al
movb 0x2(%rbx), %cl
shrb $0x4, %cl
andb $0x1, %cl
orb %al, %cl
movzbl %cl, %edx
movq %r15, %rdi
movl %r14d, %esi
callq 0x6b5a
movq %r15, %rdi
movl %r14d, %esi
callq 0x6ae9
testb %al, %al
sete %al
movb 0x2(%rbx), %cl
andb $0xf, %cl
shlb $0x7, %al
shrb $0x3, %bpl
andb $0x10, %bpl
orb %al, %bpl
orb %cl, %bpl
movb %bpl, 0x2(%rbx)
addw $0x2, 0xc(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq