LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/demo-glib.c
// Function: main
int main(int argc, char *argv[])
{
  TERMKEY_CHECK_VERSION;

  tk = termkey_new(0, 0);

  if(!tk) {
    fprintf(stderr, "Cannot allocate termkey instance\n");
    exit(1);
  }

  GMainLoop *loop = g_main_loop_new(NULL, FALSE);

  g_io_add_watch(g_io_channel_unix_new(0), G_IO_IN, stdin_io, NULL);

  g_main_loop_run(loop);

  termkey_destroy(tk);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
pushq $0x17
popq %rsi
xorl %edi, %edi
callq 0x1080
xorl %edi, %edi
xorl %esi, %esi
callq 0x10b0
movq %rax, 0x2e5c(%rip)      # 0x40b8
testq %rax, %rax
je 0x12a5
xorl %edi, %edi
xorl %esi, %esi
callq 0x10a0
movq %rax, %rbx
xorl %edi, %edi
callq 0x1050
leaq 0x4e(%rip), %rdx        # 0x12c9
pushq $0x1
popq %rsi
movq %rax, %rdi
xorl %ecx, %ecx
callq 0x10d0
movq %rbx, %rdi
callq 0x1130
movq 0x2e21(%rip), %rdi      # 0x40b8
callq 0x1030
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq 0x2d44(%rip), %rax      # 0x3ff0
movq (%rax), %rcx
leaq 0xd4e(%rip), %rdi       # 0x2004
pushq $0x21
popq %rsi
pushq $0x1
popq %rdx
callq 0x1120
pushq $0x1
popq %rdi
callq 0x1070
// File: /workspace/github_c_makefile_star2_O2/neovim[P]libtermkey/demo-glib.c
// Function: stdin_io
static gboolean stdin_io(GIOChannel *source, GIOCondition condition, gpointer data)
{
  if(condition && G_IO_IN) {
    if(timeout_id)
      g_source_remove(timeout_id);

    termkey_advisereadable(tk);

    TermKeyResult ret;
    TermKeyKey key;
    while((ret = termkey_getkey(tk, &key)) == TERMKEY_RES_KEY) {
      on_key(tk, &key);
    }

    if(ret == TERMKEY_RES_AGAIN)
      timeout_id = g_timeout_add(termkey_get_waittime(tk), key_timer, NULL);
  }

  return TRUE;
}

// Assembly:
testl %esi, %esi
je 0x1347
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x28, %rsp
movl 0x2de4(%rip), %edi      # 0x40c0
testl %edi, %edi
je 0x12e5
callq 0x10f0
movq 0x2dcc(%rip), %rdi      # 0x40b8
callq 0x1100
leaq -0x28(%rbp), %rbx
movq 0x2dbc(%rip), %rdi      # 0x40b8
movq %rbx, %rsi
callq 0x10c0
cmpl $0x1, %eax
jne 0x131a
movq 0x2da8(%rip), %rdi      # 0x40b8
movq %rbx, %rsi
callq 0x134b
jmp 0x12f5
cmpl $0x3, %eax
jne 0x1341
movq 0x2d92(%rip), %rdi      # 0x40b8
callq 0x10e0
leaq 0x47(%rip), %rsi        # 0x1379
movl %eax, %edi
xorl %edx, %edx
callq 0x1110
movl %eax, 0x2d7f(%rip)      # 0x40c0
addq $0x28, %rsp
popq %rbx
popq %rbp
pushq $0x1
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/ammarfaizi2[P]riyuu/src/main.c
// Function: main
int main(int argc, char *argv[], char *envp[])
{
	uint8_t exit_code = 0;
	riyuu_run run;

	if (argc == 1) {
		show_help(argv[0]);
		goto out;
	}

	if (!argv_parser(argc, argv, envp, &run, &exit_code)) {
		goto out;
	}

	exit_code = riyuu_exec_run(&run);

out:
	exit(exit_code);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb $0x0, -0x1(%rbp)
cmpl $0x1, %edi
jne 0x2479
movq (%rsi), %rdi
callq 0x659c
xorl %eax, %eax
jmp 0x249b
leaq -0x18(%rbp), %rcx
leaq -0x1(%rbp), %r8
callq 0x65cc
testb %al, %al
je 0x2498
leaq -0x18(%rbp), %rdi
callq 0x66c4
movb %al, -0x1(%rbp)
jmp 0x249b
movb -0x1(%rbp), %al
movzbl %al, %edi
callq 0x21a0
nop
// File: /workspace/github_c_makefile_star2_O2/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: cJSONUtils_strdup(unsigned char const*)
static unsigned char* cJSONUtils_strdup(const unsigned char* const string)
{
    size_t length = 0;
    unsigned char *copy = NULL;

    length = strlen((const char*)string) + sizeof("");
    copy = (unsigned char*) cJSON_malloc(length);
    if (copy == NULL)
    {
        return NULL;
    }
    memcpy(copy, string, length);

    return copy;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x2140
movq %rax, %r14
incq %r14
movq %r14, %rdi
callq 0x4abb
testq %rax, %rax
je 0x51ed
movq %rax, %rdi
movq %rbx, %rsi
movq %r14, %rdx
popq %rbx
popq %r14
popq %rbp
jmp 0x2040
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: pointer_encoded_length(unsigned char const*)
static size_t pointer_encoded_length(const unsigned char *string)
{
    size_t length;
    for (length = 0; *string != '\0'; (void)string++, length++)
    {
        /* character needs to be escaped? */
        if ((*string == '~') || (*string == '/'))
        {
            length++;
        }
    }

    return length;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
movzbl (%rdi), %ecx
cmpl $0x2f, %ecx
je 0x520b
cmpl $0x7e, %ecx
je 0x520b
testl %ecx, %ecx
jne 0x520e
jmp 0x5216
incq %rax
incq %rdi
incq %rax
jmp 0x51f8
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: get_item_from_pointer(cJSON*, char const*, int)
static cJSON *get_item_from_pointer(cJSON * const object, const char * pointer, const cJSON_bool case_sensitive)
{
    cJSON *current_element = object;

    if (pointer == NULL)
    {
        return NULL;
    }

    /* follow path of the pointer */
    while ((pointer[0] == '/') && (current_element != NULL))
    {
        pointer++;
        if (cJSON_IsArray(current_element))
        {
            size_t index = 0;
            if (!decode_array_index_from_pointer((const unsigned char*)pointer, &index))
            {
                return NULL;
            }

            current_element = get_array_item(current_element, index);
        }
        else if (cJSON_IsObject(current_element))
        {
            current_element = current_element->child;
            /* GetObjectItem. */
            while ((current_element != NULL) && !compare_pointers((unsigned char*)current_element->string, (const unsigned char*)pointer, case_sensitive))
            {
                current_element = current_element->next;
            }
        }
        else
        {
            return NULL;
        }

        /* skip to the next path token or end of string */
        while ((pointer[0] != '\0') && (pointer[0] != '/'))
        {
            pointer++;
        }
    }

    return current_element;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rsi, %rsi
je 0x53b4
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %rbx
movb (%rsi), %al
movl %edx, -0x34(%rbp)
testq %rbx, %rbx
je 0x53b6
cmpb $0x2f, %al
jne 0x53b6
incq %r15
movq %rbx, %rdi
callq 0x48cc
testl %eax, %eax
je 0x52da
andq $0x0, -0x40(%rbp)
movq %r15, %rdi
leaq -0x40(%rbp), %rsi
callq 0x6084
testl %eax, %eax
je 0x53b4
movq -0x40(%rbp), %rax
addq $0x10, %rbx
movq (%rbx), %rbx
addq $-0x1, %rax
setb %cl
testq %rbx, %rbx
je 0x539e
testb %cl, %cl
jne 0x52be
jmp 0x539e
movq %rbx, %rdi
callq 0x48e0
testl %eax, %eax
je 0x53b4
addq $0x10, %rbx
movq %r15, -0x30(%rbp)
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x5397
movq 0x38(%rbx), %r14
testq %r14, %r14
je 0x52f2
movzbl (%r14), %edi
movzbl (%r15), %r13d
testl %edi, %edi
je 0x536c
cmpl $0x7e, %r13d
je 0x5330
testl %r13d, %r13d
je 0x536c
cmpl $0x2f, %r13d
je 0x536c
testl %r12d, %r12d
je 0x534b
cmpb %r13b, %dil
je 0x5364
jmp 0x538e
movb 0x1(%r15), %al
incq %r15
cmpl $0x7e, %edi
jne 0x5340
cmpb $0x30, %al
je 0x5364
cmpl $0x2f, %edi
jne 0x538e
cmpb $0x31, %al
je 0x5364
jmp 0x538e
callq 0x2250
movl %eax, %r12d
movl %r13d, %edi
callq 0x2250
cmpl %eax, %r12d
movl -0x34(%rbp), %r12d
jne 0x538e
incq %r14
incq %r15
jmp 0x5307
testl %edi, %edi
sete %al
testl %r13d, %r13d
sete %cl
cmpl $0x2f, %r13d
sete %dl
orb %cl, %dl
xorb %al, %dl
movq -0x30(%rbp), %r15
jne 0x52f2
jmp 0x539e
movq -0x30(%rbp), %r15
jmp 0x52f2
xorl %ebx, %ebx
jmp 0x539e
incq %r15
movzbl (%r15), %eax
testl %eax, %eax
je 0x527d
cmpl $0x2f, %eax
jne 0x539b
jmp 0x527d
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x48cc
testl %eax, %eax
je 0x5401
xorl %r14d, %r14d
testq %r15, %r15
je 0x5407
addq $0x10, %r15
jmp 0x540c
pushq $0x1
popq %r14
jmp 0x5428
xorl %r15d, %r15d
jmp 0x540f
movq (%r15), %r15
testq %r15, %r15
je 0x5428
movq %rbx, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x5436
testl %eax, %eax
je 0x540c
movl %eax, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ammarfaizi2[P]riyuu/src/third_party/cjson/cJSON_Utils.c
// Function: compose_patch(cJSON*, unsigned char const*, unsigned char const*, unsigned char const*, cJSON const*)
static void compose_patch(cJSON * const patches, const unsigned char * const operation, const unsigned char * const path, const unsigned char *suffix, const cJSON * const value)
{
    cJSON *patch = NULL;

    if ((patches == NULL) || (operation == NULL) || (path == NULL))
    {
        return;
    }

    patch = cJSON_CreateObject();
    if (patch == NULL)
    {
        return;
    }
    cJSON_AddItemToObject(patch, "op", cJSON_CreateString((const char*)operation));

    if (suffix == NULL)
    {
        cJSON_AddItemToObject(patch, "path", cJSON_CreateString((const char*)path));
    }
    else
    {
        size_t suffix_length = pointer_encoded_length(suffix);
        size_t path_length = strlen((const char*)path);
        unsigned char *full_path = (unsigned char*)cJSON_malloc(path_length + suffix_length + sizeof("/"));

        sprintf((char*)full_path, "%s/", (const char*)path);
        encode_string_as_pointer(full_path + path_length + 1, suffix);

        cJSON_AddItemToObject(patch, "path", cJSON_CreateString((const char*)full_path));
        cJSON_free(full_path);
    }

    if (value != NULL)
    {
        cJSON_AddItemToObject(patch, "value", cJSON_Duplicate(value, 1));
    }
    cJSON_AddItemToArray(patches, patch);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, -0x38(%rbp)
movq %rcx, %r12
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
testq %rdx, %rdx
sete %al
orb %cl, %al
jne 0x5a16
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rbx
callq 0x4079
testq %rax, %rax
je 0x5a16
movq %rax, %r15
movq %r14, %rdi
callq 0x3f40
leaq 0x18d1(%rip), %rsi      # 0x7261
movq %r15, %rdi
movq %rax, %rdx
callq 0x3afb
testq %r12, %r12
je 0x5a25
movq %r12, %rdi
callq 0x51f2
movq %rax, %r14
movq %r13, %rdi
callq 0x2140
movq %rax, -0x30(%rbp)
leaq (%r14,%rax), %rdi
addq $0x2, %rdi
callq 0x4abb
movq %rax, %r14
leaq 0x18af(%rip), %rsi      # 0x7281
movq %rax, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x22d0
movq -0x30(%rbp), %rax
leaq (%r14,%rax), %rdi
incq %rdi
movq %r12, %rsi
callq 0x5218
movq %r14, %rdi
callq 0x3f40
leaq 0x184e(%rip), %rsi      # 0x724f
movq %r15, %rdi
movq %rax, %rdx
callq 0x3afb
movq %r14, %rdi
callq 0x4ac6
jmp 0x5a3f
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %rdi
callq 0x3f40
leaq 0x181b(%rip), %rsi      # 0x724f
movq %r15, %rdi
movq %rax, %rdx
callq 0x3afb
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x5a62
pushq $0x1
popq %rsi
callq 0x466e
leaq 0x17fd(%rip), %rsi      # 0x7254
movq %r15, %rdi
movq %rax, %rdx
callq 0x3afb
movq %rbx, %rdi
movq %r15, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3ab2
// File: /workspace/github_c_makefile_star2_O2/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 0x5a9a
xorl %r15d, %r15d
jmp 0x5ac0
movq %rsi, %rbx
movq %rdi, %r14
callq 0x40ea
movq %rax, %r15
leaq 0x19ff(%rip), %rsi      # 0x74ae
movq %rax, %rdi
movq %r14, %rdx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x5ace
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x5da2
xorl %r15d, %r15d
jmp 0x5dc9
movq %rsi, %rbx
movq %rdi, %r14
callq 0x40ea
movq %rax, %r15
leaq 0x16f7(%rip), %rsi      # 0x74ae
pushq $0x1
popq %r8
movq %rax, %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x5ace
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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, %r15d
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x48e0
testl %eax, %eax
je 0x5ebd
movq %r14, %rdi
callq 0x48e0
testl %eax, %eax
jne 0x5e56
movq %r14, %rdi
callq 0x2c35
callq 0x4079
movq %rax, %r14
addq $0x10, %rbx
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x5edd
movq %rbx, %rdi
callq 0x48a4
movq 0x38(%rbx), %rsi
movq %r14, %rdi
testl %eax, %eax
je 0x5e81
testl %r15d, %r15d
je 0x5e8d
callq 0x41e6
jmp 0x5e5a
testl %r15d, %r15d
je 0x5e94
callq 0x41b5
jmp 0x5e99
callq 0x41d4
jmp 0x5e5a
callq 0x4196
movq %rax, %rdi
movq %rbx, %rsi
movl %r15d, %edx
callq 0x5e17
testq %rax, %rax
je 0x5eda
movq 0x38(%rbx), %rsi
movq %r14, %rdi
movq %rax, %rdx
callq 0x3afb
jmp 0x5e5a
movq %r14, %rdi
callq 0x2c35
pushq $0x1
popq %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x466e
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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:
movb (%rdi), %al
cmpb $0x30, %al
jne 0x6097
movzbl 0x1(%rdi), %ecx
cmpl $0x2f, %ecx
je 0x6097
testl %ecx, %ecx
jne 0x60de
pushq %rbp
movq %rsp, %rbp
incq %rdi
xorl %ecx, %ecx
movl %eax, %r8d
movzbl %r8b, %edx
cmpb $0x39, %al
ja 0x60c6
cmpb $0x30, %r8b
jb 0x60c6
imulq $0xa, %rcx, %rcx
addl $-0x30, %edx
addq %rcx, %rdx
movb (%rdi), %r8b
incq %rdi
movq %rdx, %rcx
jmp 0x60a3
cmpb $0x2f, %r8b
je 0x60d0
testl %edx, %edx
jne 0x60da
movq %rcx, (%rsi)
movl $0x1, %eax
jmp 0x60dc
xorl %eax, %eax
popq %rbp
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x6289
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x38(%rdi), %rdi
testq %rdi, %rdi
je 0x6243
callq 0x4ac6
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x6251
callq 0x4ac6
leaq 0x10(%rbp), %r14
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x6263
callq 0x2c35
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_O2/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 %r12
pushq %rbx
subq $0x10, %rsp
movl %edx, %r14d
movq %rdi, %r12
movq %rsi, %rdi
callq 0x51b9
testq %rax, %rax
je 0x6355
movq %rax, %rbx
pushq $0x2f
popq %rsi
movq %rax, %rdi
callq 0x2280
testq %rax, %rax
je 0x6376
movq %rax, %r15
movb $0x0, (%rax)
incq %r15
movq %r12, %rdi
movq %rbx, %rsi
movl %r14d, %edx
callq 0x5255
movq %rax, %r14
movq %r15, %rdi
callq 0x6391
movq %r14, %rdi
callq 0x48cc
testl %eax, %eax
je 0x635a
leaq -0x28(%rbp), %rsi
andq $0x0, (%rsi)
movq %r15, %rdi
callq 0x6084
testl %eax, %eax
je 0x6376
movq -0x28(%rbp), %rax
addq $0x10, %r14
movq %r14, %r15
movq (%r15), %r15
addq $-0x1, %rax
setb %cl
testq %r15, %r15
je 0x6327
testb %cl, %cl
jne 0x6314
testq %r15, %r15
je 0x6379
movq (%r15), %rax
movq 0x8(%r15), %rcx
testq %rcx, %rcx
je 0x633b
movq %rax, (%rcx)
testq %rax, %rax
je 0x6344
movq %rcx, 0x8(%rax)
cmpq (%r14), %r15
jne 0x634c
movq %rax, (%r14)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
jmp 0x6379
xorl %r15d, %r15d
jmp 0x6381
movq %r14, %rdi
callq 0x48e0
testl %eax, %eax
je 0x6376
movq %r14, %rdi
movq %r15, %rsi
callq 0x4196
movq %rax, %r15
jmp 0x6379
xorl %r15d, %r15d
movq %rbx, %rdi
callq 0x4ac6
movq %r15, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
je 0x63f6
pushq $0x1
popq %r15
jmp 0x644d
movq %rsi, %rbx
movq %rdi, %r14
cmpq %rsi, %rdi
je 0x644a
testl %edx, %edx
je 0x641e
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2220
xorl %r12d, %r12d
movb (%r14,%r12), %r13b
movzbl %r13b, %edi
callq 0x2250
movl %eax, %r15d
movzbl (%rbx,%r12), %edi
callq 0x2250
subl %eax, %r15d
jne 0x644d
testb %r13b, %r13b
je 0x644a
incq %r12
jmp 0x6421
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq %rax
movq %r8, -0x30(%rbp)
movq %rcx, %r15
movq %rsi, %r12
andl $0x0, (%rcx)
andq $0x0, 0x8(%rcx)
movslq %edi, %r13
pushq $0x1
popq %rbx
cmpq %r13, %rbx
jge 0x6692
movq (%r12,%rbx,8), %r14
movq %r14, %rdi
callq 0x2140
testq %rax, %rax
je 0x667f
cmpb $0x2d, (%r14)
jne 0x6623
cmpq $0x2, %rax
je 0x665e
cmpq $0x1, %rax
jne 0x6677
jmp 0x66a7
leaq 0xc8c(%rip), %rdi       # 0x72b6
movq %r14, %rsi
callq 0x2220
testl %eax, %eax
je 0x6667
leaq 0xc80(%rip), %rdi       # 0x72bd
movq %r14, %rsi
callq 0x2220
testl %eax, %eax
je 0x6670
leaq 0xc9a(%rip), %rdi       # 0x72ea
movq %r14, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2030
jmp 0x6677
cmpb $0x76, 0x1(%r14)
jne 0x6677
jmp 0x66bc
movl $0x1, (%r15)
jmp 0x6677
movl $0x2, (%r15)
incq %rbx
jmp 0x65f2
leaq 0xc87(%rip), %rdi       # 0x730d
callq 0x22b0
movq -0x30(%rbp), %rax
movb $0x1, (%rax)
cmpq %r13, %rbx
setge %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc17(%rip), %rdi       # 0x72c5
movq %r14, %rsi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2030
jmp 0x668b
callq 0x65b2
jmp 0x6692
nop
// File: /workspace/github_c_makefile_star2_O2/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 0x66f5
cmpl $0x1, %eax
jne 0x66fa
leaq -0x18(%rbp), %rsi
callq 0x689c
testb %al, %al
je 0x66fa
leaq -0x18(%rbp), %rdi
callq 0x6a8a
movl %eax, %ebx
jmp 0x66fa
callq 0x6704
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/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, %r14
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x2170
testl %eax, %eax
js 0x6b87
movl %eax, %ebx
leaq -0x4c(%rbp), %r15
andq $0x0, 0x8(%r15)
movw $0x2, (%r15)
movq %r14, %rdi
callq 0x2320
movl %eax, 0x4(%r15)
movl %r12d, %eax
rolw $0x8, %ax
movw %ax, 0x2(%r15)
pushq $0x10
popq %rdx
movl %ebx, %edi
movq %r15, %rsi
callq 0x2290
testl %eax, %eax
js 0x6b90
pushq $0x5
popq %r15
movl %ebx, %edi
movl %r15d, %esi
callq 0x2310
leaq -0x2c(%rbp), %rax
movl $0x10, (%rax)
movzwl %r12w, %edx
leaq 0x96e(%rip), %rdi       # 0x7498
movq %r14, %rsi
xorl %eax, %eax
callq 0x2030
movl %r15d, %edi
callq 0x24a4
movq %rax, %r14
leaq -0x3c(%rbp), %r13
leaq 0xbc(%rip), %r15        # 0x6c06
pushq $0x4
popq %rdi
callq 0x2360
movq %rax, %r12
movl %ebx, %edi
movq %r13, %rsi
leaq -0x2c(%rbp), %rdx
callq 0x2230
movl %eax, (%r12)
testl %eax, %eax
jns 0x6b77
leaq 0x93d(%rip), %rdi       # 0x74af
callq 0x20d0
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2674
jmp 0x6b4a
leaq 0x8e4(%rip), %rdi       # 0x7472
jmp 0x6b97
leaq 0x8f0(%rip), %rdi       # 0x7487
callq 0x20d0
pushq $0x1
popq %rdi
callq 0x21a0
// File: /workspace/github_c_makefile_star2_O2/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)
andq $0x0, 0x8(%rcx)
pushq $0x1
popq %rsi
pushq $0x14
popq %rdx
pushq $0x10
popq %r8
callq 0x2060
testl %eax, %eax
js 0x6bf6
pushq $0x1
popq %rsi
pushq $0x15
popq %rdx
leaq -0x18(%rbp), %rcx
pushq $0x10
popq %r8
movl %ebx, %edi
callq 0x2060
movl %eax, %ecx
movb $0x1, %al
testl %ecx, %ecx
js 0x6bf6
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
leaq 0x810(%rip), %rdi       # 0x740d
callq 0x20d0
xorl %eax, %eax
jmp 0x6bef
// File: /workspace/github_c_makefile_star2_O2/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 0x6ba4
testb %al, %al
je 0x6c3b
pushq $0x10
popq %rdi
callq 0x2360
testq %rax, %rax
jne 0x6c5b
leaq 0x889(%rip), %rdi       # 0x74bf
callq 0x22b0
movl (%rbx), %edi
callq 0x2080
movq %rbx, %rdi
callq 0x2350
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 0x7b9(%rip), %rdi       # 0x7420
xorl %eax, %eax
callq 0x2030
leaq 0x7ef(%rip), %r12       # 0x7464
movl (%rbx), %edi
movq %r14, %rsi
pushq $0x4
popq %rdx
callq 0x21f0
testq %rax, %rax
js 0x6cdc
movl (%rbx), %edi
leaq 0x6bc(%rip), %rsi       # 0x734c
pushq $0x2
popq %rdx
callq 0x22c0
movl (%r14), %r15d
leaq 0x7ad(%rip), %rdi       # 0x744f
movl %r15d, %esi
xorl %eax, %eax
callq 0x2030
movq %r15, %rdi
callq 0x2360
movq %rax, %r13
movq %rax, 0x8(%r14)
movl (%rbx), %edi
movq %rax, %rsi
movq %r15, %rdx
callq 0x21f0
testq %rax, %rax
js 0x6cdc
movq %r12, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x2030
jmp 0x6c75
leaq 0x761(%rip), %rdi       # 0x7444
callq 0x20d0
jmp 0x6c3b
// File: /workspace/github_c_makefile_star2_O2/ls4154[P]hash-c/sha224_check.c
// Function: main
int main(int argc, char **argv)
{
	int fd = STDIN_FILENO;
	if (argc > 1 && (fd = open(argv[1], O_RDONLY)) < 0) {
		fprintf(stderr, "%s : cannot access '%s'\n", argv[0], argv[1]);
		exit(EXIT_FAILURE);
	}

	struct sha224_ctx ctx;
	sha224_init(&ctx);

	int total = 0;
	int rd = 0;
	while ((rd = read(fd, buffer + total, CHUNK_SIZE - total)) > 0) {
		total += rd;
		if (total >= CHUNK_SIZE) {
			sha224_update(&ctx, buffer);
			total = 0;
		}
	}
	sha224_update_last(&ctx, buffer, total);

	for (int i = 0; i < WORD_CNT - 1; ++i)
		printf("%08x", ctx.h[i]);
	printf("\n");

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorl %ebp, %ebp
movl $0x0, %ebx
cmpl $0x2, %edi
jl 0x11d0
movq %rsi, %r14
movq 0x8(%rsi), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x1080
movl %eax, %ebx
testl %eax, %eax
js 0x1266
movq %rsp, %r14
movq %r14, %rdi
callq 0x1290
leaq 0x2e8e(%rip), %r15      # 0x4070
pushq $0x40
popq %r13
movl %ebp, %r12d
leaq (%r15,%r12), %rsi
movl %r13d, %edx
subl %ebp, %edx
movl %ebx, %edi
callq 0x1050
testl %eax, %eax
jle 0x1218
addl %eax, %r12d
movl %r12d, %ebp
cmpl $0x40, %r12d
jl 0x11e6
movq %r14, %rdi
movq %r15, %rsi
callq 0x12ab
xorl %ebp, %ebp
jmp 0x11e6
leaq 0x2e51(%rip), %rsi      # 0x4070
movq %rsp, %rdi
movq %r12, %rdx
callq 0x148d
leaq 0xdec(%rip), %rbx       # 0x201d
xorl %r14d, %r14d
cmpq $0x7, %r14
je 0x124d
movl (%rsp,%r14,4), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1040
incq %r14
jmp 0x1234
pushq $0xa
popq %rdi
callq 0x1030
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2d8b(%rip), %rax      # 0x3ff8
movq (%rax), %rdi
movq (%r14), %rdx
movq 0x8(%r14), %rcx
leaq 0xd86(%rip), %rsi       # 0x2004
xorl %eax, %eax
callq 0x1060
pushq $0x1
popq %rdi
callq 0x1090
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/ls4154[P]hash-c/sha224.c
// Function: sha224_update_last
void sha224_update_last(struct sha224_ctx *ctx, byte_t *chunk, len_t len)
{
	ctx->len += len;
	len_t bit_len = ctx->len * 8;

	byte_t padding[64];
	memset(padding, 0, sizeof(padding));

	memcpy(padding, chunk, len);
	*(padding + len) = 0x80;

	if (len >= 56) {
		_sha224_iterate(ctx, padding);
		memset(padding, 0, sizeof(padding));
	}

	byte_t *ptr = padding + 56;
	for (int i = 7; i >= 0; --i) {
		*ptr = (bit_len >> 8 * i) & 0xFF;
		++ptr;
	}
	_sha224_iterate(ctx, padding);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdx, %r14
movq %rdi, %rbx
movq 0x20(%rdi), %r15
addq %rdx, %r15
movq %r15, 0x20(%rdi)
xorps %xmm0, %xmm0
movq %rsp, %rdi
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x1070
movb $-0x80, (%rsp,%r14)
cmpq $0x38, %r14
jb 0x14f0
movq %rsp, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12bb
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%r14)
movaps %xmm0, 0x20(%r14)
movaps %xmm0, 0x10(%r14)
movaps %xmm0, (%r14)
shlq $0x3, %r15
pushq $0x7
popq %rax
pushq $0x38
popq %rcx
leaq 0x38(%rsp), %rdx
testl %eax, %eax
js 0x1516
movq %r15, %rsi
shrq %cl, %rsi
movb %sil, (%rdx)
incq %rdx
decl %eax
addl $-0x8, %ecx
jmp 0x14ff
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x12bb
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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
callq 0x1290
cmpq $0x40, %rbx
jb 0x1559
movq %r15, %rdi
movq %r14, %rsi
callq 0x12ab
addq $0x40, %r14
addq $-0x40, %rbx
jmp 0x153e
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
popq %rbx
popq %r14
popq %r15
jmp 0x148d
// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x10
popq %rdi
callq 0x2140
movl %ebp, 0x4(%rbx)
pushq $0x18
popq %rax
xorps %xmm0, %xmm0
movhps 0x4c69(%rip), %xmm0     # xmm0 = xmm0[0,1],mem[0,1]
cmpq $0x98, %rax
je 0x23b7
movups %xmm0, -0x10(%rbx,%rax)
andq $0x0, (%rbx,%rax)
addq $0x20, %rax
jmp 0x239f
leaq 0x28(%rsp), %rdx
movl %ebp, (%rdx)
movw $0x8010, 0x4(%rdx)      # imm = 0x8010
movb $0x1, 0x6(%rdx)
movw $0x800, 0x8(%rdx)       # imm = 0x800
leaq 0x2c(%rip), %rax        # 0x2401
movq %rax, 0x10(%rdx)
movq %rbx, 0x18(%rdx)
leaq 0x8(%rsp), %rcx
pushq $0xf
popq %r8
xorl %edi, %edi
xorl %esi, %esi
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_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
sarl %ebx
xorl %r12d, %r12d
testl %ebx, %ebx
cmovlel %r12d, %ebx
pushq $0x18
popq %r13
cmpq %rbx, %r12
je 0x24ea
andw $0x0, (%r14,%r12,2)
movq %r13, %rbp
cmpq $0x78, %rbp
je 0x24e2
movsd (%r15,%rbp), %xmm0
callq 0x2090
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
seta %al
xorl %ecx, %ecx
ucomisd %xmm0, %xmm1
seta %cl
subl %ecx, %eax
cvtsi2sd %eax, %xmm0
mulsd -0x8(%r15,%rbp), %xmm0
divsd 0x4b9b(%rip), %xmm0     # 0x7010
movswl (%r14,%r12,2), %eax
cvtsi2sd %eax, %xmm1
addsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
movw %ax, (%r14,%r12,2)
movsd -0x10(%r15,%rbp), %xmm0
addsd %xmm0, %xmm0
mulsd 0x4b7a(%rip), %xmm0     # 0x7018
cvtsi2sdl 0x4(%r15), %xmm1
divsd %xmm1, %xmm0
addsd (%r15,%rbp), %xmm0
movapd %xmm0, %xmm1
addsd 0x4b66(%rip), %xmm1     # 0x7020
movsd 0x4b66(%rip), %xmm2     # 0x7028
cmpnlesd %xmm0, %xmm2
andpd %xmm2, %xmm0
andnpd %xmm1, %xmm2
orpd %xmm0, %xmm2
movlpd %xmm2, (%r15,%rbp)
addq $0x20, %rbp
jmp 0x2435
incq %r12
jmp 0x2423
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/qad114[P]yobeboy/src/audio.c
// Function: AUD_destroy
void AUD_destroy(Audio* audio) {
    SDL_PauseAudioDevice(audio->deviceId, true);
    SDL_AudioQuit();
    free(audio);
    audio = NULL;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %edi
pushq $0x1
popq %rsi
callq 0x21f0
callq 0x2270
movq %rbx, %rdi
popq %rbx
jmp 0x21b0
// File: /workspace/github_c_makefile_star2_O2/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 0x4af9(%rip), %xmm1     # 0x7030
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movsd 0x4af1(%rip), %xmm3     # 0x7038
movapd %xmm3, %xmm0
divsd %xmm2, %xmm0
movsd 0x4ae9(%rip), %xmm2     # 0x7040
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
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 0x25d8
movzbl 0xff1e(%rsi), %eax
andl $0x7, %eax
shll $0x8, %eax
movzbl 0xff1d(%rsi), %ecx
orl %eax, %ecx
cvtsi2sd %ecx, %xmm3
subsd %xmm3, %xmm1
movsd 0x4a74(%rip), %xmm3     # 0x7048
divsd %xmm1, %xmm3
ucomisd %xmm0, %xmm2
movsd %xmm3, 0x48(%rdi)
jbe 0x25e8
andq $0x0, 0x8(%rdi)
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/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
cmpw $0x1fff, %si            # imm = 0x1FFF
ja 0x2657
andb $0xf, %dl
movb %dl, 0x14(%rax)
cmpb $0xa, %dl
sete 0x10034(%rdi)
retq
cmpw $0x3fff, %si            # imm = 0x3FFF
ja 0x267e
andb $0x1f, %dl
movzbl %dl, %edx
cmpb $0x2, %dl
pushq $0x1
popq %rcx
cmovael %edx, %ecx
movb %cl, 0x15(%rax)
cmpb $0x0, 0x17(%rax)
je 0x26a5
movzbl %cl, %esi
jmp 0x6590
cmpw $0x5fff, %si            # imm = 0x5FFF
ja 0x2699
andb $0x3, %dl
movb %dl, 0x16(%rax)
cmpb $0x0, 0x17(%rax)
je 0x26b5
movzbl %dl, %esi
jmp 0x65d9
testw %si, %si
js 0x26a4
andb $0x1, %dl
movb %dl, 0x17(%rax)
retq
movb 0x16(%rax), %al
shlb $0x5, %al
orb %cl, %al
movzbl %al, %esi
jmp 0x6590
shlb $0x5, %dl
orb 0x15(%rax), %dl
movzbl %dl, %esi
jmp 0x6590
// File: /workspace/github_c_makefile_star2_O2/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
cmpw $0x1fff, %si            # imm = 0x1FFF
ja 0x2775
andb $0xf, %dl
movb %dl, 0x14(%rax)
cmpb $0xa, %dl
sete 0x10034(%rdi)
retq
cmpw $0x3fff, %si            # imm = 0x3FFF
ja 0x2796
andb $0x7f, %dl
movzbl %dl, %ecx
cmpb $0x2, %cl
pushq $0x1
popq %rdx
cmovael %ecx, %edx
movb %dl, 0x18(%rax)
movzbl %dl, %esi
jmp 0x6590
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x6168
movzbl %al, %esi
leaq 0x88fe(%rip), %rax      # 0xb150
movq (%rax,%rsi,8), %rax
testq %rax, %rax
je 0x286a
movzwl %bp, %esi
movzbl %bl, %edx
movq %r14, %rdi
popq %rbx
popq %r14
popq %rbp
jmpq *%rax
leaq 0x47df(%rip), %rdi      # 0x7050
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x2050
// File: /workspace/github_c_makefile_star2_O2/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 0x30de(%rip), %rcx      # 0x78a0
movslq (%rcx,%rdx,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
xorl %ecx, %ecx
testb %al, %al
setns %cl
jmp 0x47db
xorl %ecx, %ecx
testb $0x10, %al
sete %cl
movl %ecx, %eax
jmp 0x47ea
shrl $0x4, %eax
andl $0x1, %eax
jmp 0x47ea
shrl $0x7, %eax
movzwl 0xc(%rbx), %esi
testl %eax, %eax
je 0x4826
addl $0x2, %esi
movl $0xffff, %ebp           # imm = 0xFFFF
andl %ebp, %esi
movq %r14, %rdi
callq 0x6168
movzbl %al, %r15d
shll $0x8, %r15d
movl 0xc(%rbx), %esi
incl %esi
andl %ebp, %esi
movq %r14, %rdi
callq 0x6168
movzbl %al, %esi
orl %r15d, %esi
pushq $0x1
popq %rax
jmp 0x482b
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_O2/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 0x3064(%rip), %rcx      # 0x78b0
movslq (%rcx,%rdx,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
xorl %ecx, %ecx
testb %al, %al
setns %cl
jmp 0x4865
xorl %ecx, %ecx
testb $0x10, %al
sete %cl
movl %ecx, %eax
jmp 0x4874
shrl $0x4, %eax
andl $0x1, %eax
jmp 0x4874
shrl $0x7, %eax
movzwl 0xc(%rbx), %ecx
testl %eax, %eax
je 0x489a
incl %ecx
movzwl %cx, %eax
movq %rsi, %rdi
movl %eax, %esi
callq 0x6168
movsbl %al, %ecx
addw 0xc(%rbx), %cx
addl $0x2, %ecx
pushq $0x1
popq %rax
jmp 0x489f
addl $0x2, %ecx
xorl %eax, %eax
movw %cx, 0xc(%rbx)
popq %rbx
retq