LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/00pauln00[P]yapio/yapio.c
// Function: yapio_test_context_alloc
static yapio_blk_md_t *
yapio_test_context_alloc(yapio_test_ctx_t *ytc,
                         enum yapio_test_ctx_mdh_in_out in_out, size_t nblks)
{
    if (in_out >= YAPIO_TEST_CTX_MDH_MAX)
    {
        errno = EINVAL;
        return NULL;
    }

    yapio_test_ctx_md_t *ytcmh = &ytc->ytc_in_out_md_ops[in_out];

    ytcmh->ytcmh_num_ops = nblks;
    ytcmh->ytcmh_ops = YAPIO_CALLOC(nblks, sizeof(yapio_blk_md_t));

    return ytcmh->ytcmh_ops;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movl %esi, %eax
shlq $0x4, %rax
leaq (%rdi,%rax), %r15
addq $0x68, %r15
movl %ebx, 0x8(%r15)
movl $0x10, %esi
movq %rdx, %rdi
callq 0x22e0
movq %rax, %r14
cmpl $0x3, 0x5872(%rip)      # 0xd220
jge 0x79bc
movq %r14, (%r15)
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
movq 0x561d(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
movl 0x589b(%rip), %r8d      # 0xd268
shlq $0x4, %rbx
leaq 0x12be(%rip), %rsi      # 0x8c96
leaq 0x81c(%rip), %rdx       # 0x81fb
leaq 0x1bad(%rip), %rcx      # 0x9593
movl $0x752, %r9d            # imm = 0x752
xorl %eax, %eax
pushq %rbx
pushq %r14
callq 0x2390
addq $0x10, %rsp
jmp 0x79b0
// File: /workspace/github_c_makefile_star2_O1/00pauln00[P]yapio/yapio.c
// Function: yapio_test_context_sequential_setup_for_rank
static void
yapio_test_context_sequential_setup_for_rank(yapio_test_ctx_t *ytc, int rank)
{
    int num_ops = 0;

    /* The local mode test case does not require the 'MDH_OUT' buffers at all.
     */
    enum yapio_test_ctx_mdh_in_out in_out = ytc->ytc_remote_locality ?
        YAPIO_TEST_CTX_MDH_OUT : YAPIO_TEST_CTX_MDH_IN;

    yapio_blk_md_t *md =
        yapio_test_ctx_to_md_array(ytc, in_out, &num_ops);

    if (!md)
        log_msg(YAPIO_LL_FATAL, "ytc_ops_md[%d] is NULL", rank);

    int skips_left = ytc->ytc_sparse_io;
    int i;
    for (i = 0; i < num_ops; i++)
    {
        size_t src_idx = ytc->ytc_backwards ? num_ops - i - 1 : i;

        bool skip_io = skip_io_or_not(num_ops - i, skips_left);

        /* update writer in case of write (which isn't skipped) */
        if (!ytc->ytc_read && !skip_io)
        {
            log_msg(YAPIO_LL_DEBUG, "update writer rank for op #%d\n", i);
            yapio_source_md_update_writer_rank(src_idx, rank);
        }

        md[i] = yapioSourceBlkMd[src_idx];

        if (skip_io)
        {
            log_msg(YAPIO_LL_DEBUG, "skip IO # %d\n", i);
            md[i].ybm_skip_io = 1;
            skips_left--;
        }

        unsigned long x = md[i].ybm_blk_number;
        log_msg(YAPIO_LL_TRACE, "writer_rank=%d md->ybm_blk_number=%zd",
                md[i].ybm_writer_rank, x);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, 0x4(%rsp)
movzbl (%rdi), %eax
andl $0x4, %eax
movl 0x70(%rdi,%rax,4), %ecx
movq %rcx, 0x8(%rsp)
movq %rdi, 0x10(%rsp)
movq 0x68(%rdi,%rax,4), %r15
testq %r15, %r15
jne 0x7a39
cmpl $0x0, 0x57ed(%rip)      # 0xd220
jns 0x7b12
cmpl $0x0, 0x8(%rsp)
jle 0x7b03
movq 0x10(%rsp), %rax
movl 0xa8(%rax), %ebp
xorl %r12d, %r12d
movq 0x8(%rsp), %rax
movl %eax, %r14d
movl %r14d, %edi
leal -0x1(%rdi), %r14d
movq 0x10(%rsp), %rax
testb $0x2, (%rax)
movl %r12d, %eax
cmovnel %r14d, %eax
movslq %eax, %r13
movl %ebp, %esi
callq 0x7b1b
movl %eax, %ebx
testb %al, %al
jne 0x7aa0
movq 0x10(%rsp), %rax
movb (%rax), %al
andb $0x8, %al
jne 0x7aa0
cmpl $0x3, 0x578e(%rip)      # 0xd220
jge 0x7af9
movq %r13, %rdi
movl 0x4(%rsp), %esi
callq 0x7b5e
movq 0x57b9(%rip), %rax      # 0xd260
shlq $0x4, %r13
movups (%rax,%r13), %xmm0
movups %xmm0, (%r15)
testb %bl, %bl
je 0x7ac8
cmpl $0x3, 0x5761(%rip)      # 0xd220
jge 0x7aef
orb $-0x80, 0xf(%r15)
decl %ebp
cmpl $0x4, 0x5751(%rip)      # 0xd220
jge 0x7ae5
incq %r12
addq $0x10, %r15
cmpq %r12, 0x8(%rsp)
jne 0x7a5a
jmp 0x7b03
movq %r15, %rdi
callq 0x2b6b
jmp 0x7ad1
movq %r12, %rdi
callq 0x2b2f
jmp 0x7ac1
movq %r12, %rdi
callq 0x2af3
jmp 0x7a94
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl 0x4(%rsp), %edi
callq 0x2bbb
// File: /workspace/github_c_makefile_star2_O1/00pauln00[P]yapio/yapio.c
// Function: skip_io_or_not
static bool
skip_io_or_not(int ops_left, int skips_left)
{
    /* for random number generation */
    srand(time(NULL));

    /* skip randomly or skip all remaining IOs
     * because there's no room for choosing */
    if (skips_left &&
        (skips_left == ops_left || rand() % (ops_left / skips_left)))
        return true;
    else
        return false;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movl %edi, %r14d
xorl %edi, %edi
callq 0x2400
movl %eax, %edi
callq 0x22c0
testl %ebp, %ebp
je 0x7b55
movb $0x1, %bl
cmpl %r14d, %ebp
je 0x7b57
callq 0x2380
movl %eax, %ecx
movl %r14d, %eax
cltd
idivl %ebp
movl %eax, %esi
movl %ecx, %eax
cltd
idivl %esi
testl %edx, %edx
jne 0x7b57
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/00pauln00[P]yapio/yapio.c
// Function: yapio_source_md_update_writer_rank
static void
yapio_source_md_update_writer_rank(size_t source_md_idx, int new_writer_rank)
{
    if (source_md_idx >= yapioMyTestGroup->ytg_num_blks_per_rank)
        log_msg(YAPIO_LL_FATAL, "out of bounds source_md_idx=%zu",
                source_md_idx);

    log_msg(YAPIO_LL_TRACE, "%d %zu", new_writer_rank, source_md_idx);

    yapioSourceBlkMd[source_md_idx].ybm_writer_rank = new_writer_rank;
    yapioSourceBlkMd[source_md_idx].ybm_not_hole = 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movq 0x56e1(%rip), %rax      # 0xd250
cmpq %rdi, 0xb020(%rax)
ja 0x7b81
cmpl $0x0, 0x56a1(%rip)      # 0xd220
jns 0x7be2
cmpl $0x4, 0x5698(%rip)      # 0xd220
jge 0x7ba6
movq 0x56cf(%rip), %rax      # 0xd260
shlq $0x4, %rbx
movl %r14d, (%rax,%rbx)
orb $0x40, 0xf(%rax,%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x5433(%rip), %rax      # 0xcfe0
movq (%rax), %rdi
movl 0x56b1(%rip), %r8d      # 0xd268
leaq 0x1b13(%rip), %rsi      # 0x96d1
leaq 0x630(%rip), %rdx       # 0x81f5
leaq 0x1ae2(%rip), %rcx      # 0x96ae
movl $0x611, %r9d            # imm = 0x611
xorl %eax, %eax
pushq %rbx
pushq %r14
callq 0x2390
addq $0x10, %rsp
jmp 0x7b8a
movq %rbx, %rdi
callq 0x2bfd
// File: /workspace/github_c_makefile_star2_O1/00pauln00[P]yapio/yapio.c
// Function: select_holes
static void
select_holes(int num_ops, int skips_left, yapio_blk_md_t *md)
{
    int i;
    for (i = 0; i < num_ops; i++)
    {
        if (skip_io_or_not(num_ops - i, skips_left))
        {
            log_msg(YAPIO_LL_DEBUG, "skip IO # %d\n", i);
            md[i].ybm_skip_io = 1;
            skips_left--;
        }
    }
}

// Assembly:
testl %edi, %edi
jle 0x7ef7
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %ebp
movl %edi, %r14d
addq $0x8, %rbx
xorl %r15d, %r15d
movl %r14d, %edi
movl %ebp, %esi
callq 0x7b1b
testb %al, %al
je 0x7ed5
cmpl $0x3, 0x5353(%rip)      # 0xd220
jge 0x7ee3
orb $-0x80, 0x7(%rbx)
decl %ebp
incq %r15
addq $0x10, %rbx
decq %r14
jne 0x7eb8
jmp 0x7eed
movq %r15, %rdi
callq 0x2cd6
jmp 0x7ecf
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]libcperciva/tests/valgrind/potential-memleaks.c
// Function: pl_freebsd_getdelim
static void
pl_freebsd_getdelim(void)
{
	size_t linecap = 0;
	char * line = NULL;

	if (getline(&line, &linecap, stdin) == -1)
		printf("error in getline()\n");

	/* Clean up. */
	free(line);
}

// Assembly:
subq $0x18, %rsp
xorl %eax, %eax
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
movq 0x2c18(%rip), %rax      # 0x3fd0
movq (%rax), %rdx
callq 0x10e0
cmpq $-0x1, %rax
jne 0x13d2
leaq 0xded(%rip), %rdi       # 0x21ba
callq 0x1060
movq 0x8(%rsp), %rdi
callq 0x1030
addq $0x18, %rsp
retq
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]libcperciva/tests/valgrind/potential-memleaks.c
// Function: pl_workthread_strerror_localtime
static void *
pl_workthread_strerror_localtime(void * cookie)
{
	char * str = strerror(1);
	time_t now;
	struct tm tm;

	(void)cookie; /* UNUSED */
	(void)str; /* UNUSED */

	if (time(&now) == (time_t)(-1))
		fprintf(stderr, "time");
	localtime_r(&now, &tm);

	return (NULL);
}

// Assembly:
subq $0x48, %rsp
movl $0x1, %edi
callq 0x1130
leaq 0x8(%rsp), %rdi
callq 0x10c0
cmpq $-0x1, %rax
je 0x14fe
leaq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1050
xorl %eax, %eax
addq $0x48, %rsp
retq
callq 0x11f8
jmp 0x14e8
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]libcperciva/tests/valgrind/potential-memleaks.c
// Function: pl_freebsd_getaddrinfo_name
static void
pl_freebsd_getaddrinfo_name(const char * addr)
{
	struct addrinfo hints;
	struct addrinfo * res;
	const char * ports = "80";
	int error;

	/* Create hints structure. */
	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_protocol = IPPROTO_TCP;

	/* Perform DNS lookup. */
	if ((error = getaddrinfo(addr, ports, &hints, &res)) != 0) {
		/* Only print an error if we're online. */
		if (error != EAI_AGAIN) {
			fprintf(stderr, "Error looking up %s: %s", addr,
			    gai_strerror(error));
		}
		return;
	}

	/* Clean up. */
	freeaddrinfo(res);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movaps %xmm0, 0x20(%rdx)
movabsq $0x600000001, %rax      # imm = 0x600000001
movq %rax, 0x8(%rdx)
leaq 0xc3e(%rip), %rsi       # 0x2175
leaq 0x8(%rsp), %rcx
callq 0x1110
cmpl $-0x3, %eax
je 0x1554
testl %eax, %eax
jne 0x155c
movq 0x8(%rsp), %rdi
callq 0x1140
addq $0x48, %rsp
popq %rbx
popq %r14
retq
movq 0x2a95(%rip), %rcx      # 0x3ff8
movq (%rcx), %r14
movl %eax, %edi
callq 0x1070
leaq 0xc04(%rip), %rsi       # 0x2178
movq %r14, %rdi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x10a0
jmp 0x1554
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/pair_sum/pair_sum_test.c
// Function: test_pair_sum
void test_pair_sum(void) {
	Vector numbers = vector_create(0, free);
	for (int i = 0; i < 10; i++)
		vector_insert_last(numbers, create_int(i));

	int a, b;
	TEST_ASSERT(!pair_sum(90, numbers, &a, &b));
	TEST_ASSERT( pair_sum(15, numbers, &a, &b));
	TEST_ASSERT(a + b == 15);

	vector_destroy(numbers);
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq 0x62dc(%rip), %rsi      # 0x9fc0
xorl %ebp, %ebp
xorl %edi, %edi
callq 0x4430
movq %rax, %rbx
movl $0x4, %edi
callq 0x21a0
movl %ebp, (%rax)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4501
incl %ebp
cmpl $0xa, %ebp
jne 0x3cf0
leaq 0x4(%rsp), %rdx
movq %rsp, %rcx
movl $0x5a, %edi
movq %rbx, %rsi
callq 0x4351
xorb $0x1, %al
movzbl %al, %edi
leaq 0x25e9(%rip), %rsi      # 0x6318
leaq 0x26b3(%rip), %rcx      # 0x63e9
leaq 0x25eb(%rip), %r8       # 0x6328
movl $0x13, %edx
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x3dd2
leaq 0x4(%rsp), %rdx
movq %rsp, %rcx
movl $0xf, %edi
movq %rbx, %rsi
callq 0x4351
movzbl %al, %edi
leaq 0x25a8(%rip), %rsi      # 0x6318
leaq 0x2672(%rip), %rcx      # 0x63e9
leaq 0x25c9(%rip), %r8       # 0x6347
movl $0x14, %edx
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x3dd2
movl (%rsp), %eax
addl 0x4(%rsp), %eax
xorl %edi, %edi
cmpl $0xf, %eax
sete %dil
leaq 0x2573(%rip), %rsi      # 0x6318
leaq 0x263d(%rip), %rcx      # 0x63e9
leaq 0x25b2(%rip), %r8       # 0x6365
movl $0x15, %edx
xorl %eax, %eax
callq 0x25cc
testl %eax, %eax
je 0x3dd2
movq %rbx, %rdi
callq 0x461a
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
callq 0x2e13
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/pair_sum/pair_sum.c
// Function: pair_sum
bool pair_sum(int target, Vector numbers, int* res_a, int* res_b) {
	// Στο map θα αποθηκεύουμε τα στοιχεία του vector. Δεν κάνουμε malloc
	// οπότε δε θέλουμε και free, εμείς αποθηκεύουμε στοιχεία που έχουν δημιουργηθεί αλλού!
	Map seen = map_create((CompareFunc)compare_ints, NULL, NULL);
	bool result = false;

	int size = vector_size(numbers);
	for (int i = 0; i < size; i++) {
		int* a = vector_get_at(numbers, i);
		int b = target - *a;

		if (map_find(seen, &b) != NULL) {
			*res_a = *a;
			*res_b = b;
			result = true;
			break;
		}

		map_insert(seen, a, a);		// Για value θέλουμε μια οποιαδήποτε μη-NULL τιμή, οπότε το θέτουμε και αυτό ίσο με a
	}

	map_destroy(seen);
	return result;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq %rsi, %r15
movl %edi, 0xc(%rsp)
leaq -0x2b(%rip), %rdi       # 0x434c
xorl %r13d, %r13d
xorl %esi, %esi
xorl %edx, %edx
callq 0x4714
movq %rax, %r12
movq %r15, %rdi
callq 0x4470
testl %eax, %eax
jle 0x4411
movl %eax, %ebx
decl %ebx
movq $0x0, 0x10(%rsp)
movq %r15, %rdi
movl %r13d, %esi
callq 0x4474
movq %rax, %rbp
movl 0xc(%rsp), %eax
subl (%rbp), %eax
movl %eax, 0x8(%rsp)
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
callq 0x47d8
movq %rax, %r14
testq %rax, %rax
je 0x43eb
movl (%rbp), %eax
movq 0x18(%rsp), %rcx
movl %eax, (%rcx)
movl 0x8(%rsp), %eax
movq 0x20(%rsp), %rcx
movl %eax, (%rcx)
movb $0x1, %al
movq %rax, 0x10(%rsp)
jmp 0x43f9
movq %r12, %rdi
movq %rbp, %rsi
movq %rbp, %rdx
callq 0x480b
testq %r14, %r14
jne 0x440a
leal 0x1(%r13), %eax
cmpl %r13d, %ebx
movl %eax, %r13d
jne 0x439f
movq 0x10(%rsp), %rbx
jmp 0x4413
xorl %ebx, %ebx
movq %r12, %rdi
callq 0x48fa
andb $0x1, %bl
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/pair_sum/../../modules/UsingADTSet/ADTMap.c
// Function: map_create
Map map_create(CompareFunc compare, DestroyFunc destroy_key, DestroyFunc destroy_value) {
	assert(compare != NULL);	// LCOV_EXCL_LINE

	Map map = malloc(sizeof(*map));
	map->set = set_create((CompareFunc)compare_map_nodes, (DestroyFunc)destroy_map_node);
	map->compare = compare;
	map->destroy_key = destroy_key;
	map->destroy_value = destroy_value;
	return map;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x476c
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl $0x20, %edi
callq 0x21a0
movq %rax, %r12
leaq 0x4d(%rip), %rdi        # 0x478b
leaq 0x59(%rip), %rsi        # 0x479e
callq 0x4998
movq %rax, (%r12)
movq %r15, 0x8(%r12)
movq %r14, 0x10(%r12)
movq %rbx, 0x18(%r12)
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0x26c9(%rip), %rdi      # 0x6e3c
leaq 0x26d2(%rip), %rsi      # 0x6e4c
leaq 0x26ee(%rip), %rcx      # 0x6e6f
movl $0x2b, %edx
callq 0x2110
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/pair_sum/../../modules/UsingADTSet/ADTMap.c
// Function: destroy_map_node
static void destroy_map_node(MapNode node) {
	if (node->owner->destroy_key != NULL)
		node->owner->destroy_key(node->key);

	if (node->owner->destroy_value != NULL)
		node->owner->destroy_value(node->value);

	free(node);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rax
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x47b4
movq (%rbx), %rdi
callq *%rax
movq 0x10(%rbx), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x47c7
movq 0x8(%rbx), %rdi
callq *%rax
movq %rbx, %rdi
popq %rbx
jmp 0x22a0
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/pair_sum/../../modules/UsingADTSet/ADTMap.c
// Function: map_insert
void map_insert(Map map, Pointer key, Pointer value) {
	struct map_node search_node = { .key = key, .owner = map };

	MapNode node = set_find(map->set, &search_node);
	if (node != NULL) {
		if (key != node->key && map->destroy_key != NULL)
			map->destroy_key(node->key);

		if (value != node->value && map->destroy_value != NULL)
			map->destroy_value(node->value);

		node->key = key;
		node->value = value;
		return;
	}

	node = malloc(sizeof(*node));
	node->key = key;
	node->value = value;
	node->owner = map;

	set_insert(map->set, node);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq %rsp, %rsi
movq %r14, (%rsi)
movq $0x0, 0x8(%rsi)
movq %rdi, 0x10(%rsi)
movq (%rdi), %rdi
callq 0x4c1a
testq %rax, %rax
je 0x4874
movq %rax, %r12
movq (%rax), %rdi
cmpq %r14, %rdi
je 0x4854
movq 0x10(%r15), %rax
testq %rax, %rax
je 0x4854
callq *%rax
movq 0x8(%r12), %rdi
cmpq %rbx, %rdi
je 0x4869
movq 0x18(%r15), %rax
testq %rax, %rax
je 0x4869
callq *%rax
movq %r14, (%r12)
movq %rbx, 0x8(%r12)
jmp 0x4894
movl $0x18, %edi
callq 0x21a0
movq %r14, (%rax)
movq %rbx, 0x8(%rax)
movq %r15, 0x10(%rax)
movq (%r15), %rdi
movq %rax, %rsi
callq 0x49f2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/pair_sum/../../modules/UsingADTSet/ADTMap.c
// Function: map_remove
bool map_remove(Map map, Pointer key) {
	struct map_node search_node = { .key = key, .owner = map };

	MapNode node = set_find(map->set, &search_node);
	if (node == NULL)
		return false;

	set_remove(map->set, node);

	return true;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq %rsp, %rax
movq %rsi, (%rax)
movq $0x0, 0x8(%rax)
movq %rdi, 0x10(%rax)
movq (%rdi), %rdi
movq %rax, %rsi
callq 0x4c1a
movq %rax, %r14
testq %rax, %rax
je 0x48da
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x4aea
testq %r14, %r14
setne %al
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/set_example/../../modules/UsingAVL/ADTSet.c
// Function: set_create
Set set_create(CompareFunc compare, DestroyFunc destroy_value) {
	assert(compare != NULL);	// LCOV_EXCL_LINE

	// δημιουργούμε το stuct
	Set set = malloc(sizeof(*set));
	set->root = NULL;			// κενό δέντρο
	set->size = 0;
	set->compare = compare;
	set->destroy_value = destroy_value;

	return set;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x49cf
movq %rsi, %rbx
movq %rdi, %r14
movl $0x20, %edi
callq 0x21a0
movq $0x0, (%rax)
movl $0x0, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %rbx, 0x18(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x2466(%rip), %rdi      # 0x6e3c
leaq 0x24c8(%rip), %rsi      # 0x6ea5
leaq 0x24e1(%rip), %rcx      # 0x6ec5
movl $0x165, %edx            # imm = 0x165
callq 0x2110
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/set_example/../../modules/UsingAVL/ADTSet.c
// Function: node_insert
static SetNode node_insert(SetNode node, CompareFunc compare, Pointer value, bool* inserted, Pointer* old_value) {
	// Αν το υποδέντρο είναι κενό, δημιουργούμε νέο κόμβο ο οποίος γίνεται ρίζα του υποδέντρου
	if (node == NULL) {
		*inserted = true;			// κάναμε προσθήκη
		return node_create(value);
	}

	// Το πού θα γίνει η προσθήκη εξαρτάται από τη διάταξη της τιμής
	// value σε σχέση με την τιμή του τρέχοντος κόμβου (node->value)
	//
	int compare_res = compare(value, node->value);
	if (compare_res == 0) {
		// βρήκαμε ισοδύναμη τιμή, κάνουμε update
		*inserted = false;
		*old_value = node->value;
		node->value = value;

	} else if (compare_res < 0) {
		// value < node->value, συνεχίζουμε αριστερά.
		node->left = node_insert(node->left, compare, value, inserted, old_value);

	} else {
		// value > node->value, συνεχίζουμε δεξιά
		node->right = node_insert(node->right, compare, value, inserted, old_value);
	}

	return node_repair_balance(node);	// AVL
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r12
movq %rdx, %r14
testq %rdi, %rdi
je 0x4a86
movq %r8, %r15
movq %rsi, %r13
movq %rdi, %rbx
movq 0x10(%rdi), %rsi
movq %r14, %rdi
callq *%r13
testl %eax, %eax
je 0x4ab0
js 0x4ac2
movq 0x8(%rbx), %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %r15, %r8
callq 0x4a3e
movq %rax, 0x8(%rbx)
jmp 0x4ad9
movb $0x1, (%r12)
movl $0x20, %edi
callq 0x21a0
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %r14, 0x10(%rax)
movl $0x1, 0x18(%rax)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movb $0x0, (%r12)
movq 0x10(%rbx), %rax
movq %rax, (%r15)
movq %r14, 0x10(%rbx)
jmp 0x4ad9
movq (%rbx), %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %r15, %r8
callq 0x4a3e
movq %rax, (%rbx)
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x4ee5
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/set_example/../../modules/UsingAVL/ADTSet.c
// Function: node_remove
static SetNode node_remove(SetNode node, CompareFunc compare, Pointer value, bool* removed, Pointer* old_value) {
	if (node == NULL) {
		*removed = false;		// κενό υποδέντρο, δεν υπάρχει η τιμή
		return NULL;
	}

	int compare_res = compare(value, node->value);
	if (compare_res == 0) {
		// Βρέθηκε ισοδύναμη τιμή στον node, οπότε τον διαγράφουμε. Το πώς θα γίνει αυτό εξαρτάται από το αν έχει παιδιά.
		*removed = true;
		*old_value = node->value;

		if (node->left == NULL) {
			// Δεν υπάρχει αριστερό υποδέντρο, οπότε διαγράφεται απλά ο κόμβος και νέα ρίζα μπαίνει το δεξί παιδί
			SetNode right = node->right;	// αποθήκευση πριν το free!
			free(node);
			return right;

		} else if (node->right == NULL) {
			// Δεν υπάρχει δεξί υποδέντρο, οπότε διαγράφεται απλά ο κόμβος και νέα ρίζα μπαίνει το αριστερό παιδί
			SetNode left = node->left;		// αποθήκευση πριν το free!
			free(node);
			return left;

		} else {
			// Υπάρχουν και τα δύο παιδιά. Αντικαθιστούμε την τιμή του node με την μικρότερη του δεξιού υποδέντρου, η οποία
			// αφαιρείται. Η συνάρτηση node_remove_min κάνει ακριβώς αυτή τη δουλειά.

			SetNode min_right;
			node->right = node_remove_min(node->right, &min_right);

			// Σύνδεση του min_right στη θέση του node
			min_right->left = node->left;
			min_right->right = node->right;

			free(node);

			return node_repair_balance(min_right);	// AVL
		}
	}

	// compare_res != 0, συνεχίζουμε στο αριστερό ή δεξί υποδέντρο, η ρίζα δεν αλλάζει.
	if (compare_res < 0)
		node->left  = node_remove(node->left,  compare, value, removed, old_value);
	else
		node->right = node_remove(node->right, compare, value, removed, old_value);

	return node_repair_balance(node);	// AVL
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
testq %rdi, %rdi
je 0x4ba2
movq %r8, %r14
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
movq 0x10(%rdi), %rsi
movq %rdx, %rdi
callq *%r13
testl %eax, %eax
je 0x4bbb
movl %eax, %ebp
notl %ebp
shrl $0x1f, %ebp
movq (%rbx,%rbp,8), %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x4b3f
movq %rax, (%rbx,%rbp,8)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4ee5
movb $0x0, (%r15)
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, (%r15)
movq 0x10(%rbx), %rax
movq %rax, (%r14)
movq (%rbx), %r15
movq 0x8(%rbx), %r14
testq %r15, %r15
je 0x4c03
testq %r14, %r14
je 0x4c0d
movq %rsp, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x5038
movq %rax, 0x8(%rbx)
movq (%rbx), %rcx
movq (%r15), %r14
movq %rcx, (%r14)
movq %rax, 0x8(%r14)
movq %rbx, %rdi
callq 0x22a0
movq %r14, %rdi
jmp 0x4b8f
movq %rbx, %rdi
callq 0x22a0
jmp 0x4ba9
movq %rbx, %rdi
callq 0x22a0
movq %r15, %r14
jmp 0x4ba9
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/set_example/../../modules/UsingAVL/ADTSet.c
// Function: node_find_equal
static SetNode node_find_equal(SetNode node, CompareFunc compare, Pointer value) {
	// κενό υποδέντρο, δεν υπάρχει η τιμή
	if (node == NULL)
		return NULL;
	
	// Το πού βρίσκεται ο κόμβος που ψάχνουμε εξαρτάται από τη διάταξη της τιμής
	// value σε σχέση με την τιμή του τρέχοντος κόμβο (node->value)
	//
	int compare_res = compare(value, node->value);			// αποθήκευση για να μην καλέσουμε την compare 2 φορές
	if (compare_res == 0)									// value ισοδύναμη της node->value, βρήκαμε τον κόμβο
		return node;
	else if (compare_res < 0)								// value < node->value, ο κόμβος που ψάχνουμε είναι στο αριστερό υποδέντρο
		return node_find_equal(node->left, compare, value);
	else													// value > node->value, ο κόμβος που ψάχνουμε είνια στο δεξιό υποδέντρο
		return node_find_equal(node->right, compare, value);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
testq %rbx, %rbx
je 0x4c68
movq 0x10(%rbx), %rsi
movq %r14, %rdi
callq *%r15
testl %eax, %eax
je 0x4c6a
notl %eax
shrl $0x1f, %eax
movq (%rbx,%rax,8), %rbx
jmp 0x4c4a
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/set_example/../../modules/UsingAVL/ADTSet.c
// Function: node_destroy
static void node_destroy(SetNode node, DestroyFunc destroy_value) {
	if (node == NULL)
		return;
	
	// πρώτα destroy τα παιδιά, μετά free το node
	node_destroy(node->left, destroy_value);
	node_destroy(node->right, destroy_value);

	if (destroy_value != NULL)
		destroy_value(node->value);

	free(node);
}

// Assembly:
testq %rdi, %rdi
je 0x4cd3
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x4c95
movq 0x8(%rbx), %rdi
movq %r14, %rsi
callq 0x4c95
testq %r14, %r14
je 0x4cc4
movq 0x10(%rbx), %rdi
callq *%r14
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x22a0
retq
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/set_example/../../modules/UsingAVL/ADTSet.c
// Function: node_find_previous
static SetNode node_find_previous(SetNode node, CompareFunc compare, SetNode target) {
	if (node == target) {
		// Ο target είναι η ρίζα του υποδέντρου, o προηγούμενός του είναι ο μεγαλύτερος του αριστερού υποδέντρου.
		// (Aν δεν υπάρχει αριστερό παιδί, τότε ο κόμβος με τιμή value είναι ο μικρότερος του υποδέντρου, οπότε
		// η node_find_max θα επιστρέψει NULL όπως θέλουμε.)
		return node_find_max(node->left);

	} else if (compare(target->value, node->value) < 0) {
		// Ο target είναι στο αριστερό υποδέντρο, οπότε και ο προηγούμενός του είναι εκεί.
		return node_find_previous(node->left, compare, target);

	} else {
		// Ο target είναι στο δεξί υποδέντρο, ο προηγούμενός του μπορεί να είναι επίσης εκεί, διαφορετικά
		// ο προηγούμενός του είναι ο ίδιος ο node.
		SetNode res = node_find_previous(node->right, compare, target);
		return res != NULL ? res : node;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
cmpq %r14, %rbx
je 0x4d37
movq 0x10(%r14), %rdi
movq 0x10(%rbx), %rsi
callq *%r15
testl %eax, %eax
jns 0x4d41
movq (%rbx), %rbx
jmp 0x4d1e
movq (%rbx), %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x4cef
movq 0x8(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4d10
testq %rax, %rax
cmoveq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/set_example/../../modules/UsingAVL/ADTSet.c
// Function: node_find_next
static SetNode node_find_next(SetNode node, CompareFunc compare, SetNode target) {
	if (node == target) {
		// Ο target είναι η ρίζα του υποδέντρου, o προηγούμενός του είναι ο μεγαλύτερος του αριστερού υποδέντρου.
		// (Aν δεν υπάρχει αριστερό παιδί, τότε ο κόμβος με τιμή value είναι ο μικρότερος του υποδέντρου, οπότε
		// η node_find_max θα επιστρέψει NULL όπως θέλουμε.)
		return node_find_min(node->right);

	} else if (compare(target->value, node->value) > 0) {
		// Ο target είναι στο αριστερό υποδέντρο, οπότε και ο προηγούμενός του είναι εκεί.
		return node_find_next(node->right, compare, target);

	} else {
		// Ο target είναι στο δεξί υποδέντρο, ο προηγούμενός του μπορεί να είναι επίσης εκεί, διαφορετικά
		// ο προηγούμενός του είναι ο ίδιος ο node.
		SetNode res = node_find_next(node->left, compare, target);
		return res != NULL ? res : node;
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
cmpq %r14, %rbx
je 0x4d94
movq 0x10(%r14), %rdi
movq 0x10(%rbx), %rsi
callq *%r15
testl %eax, %eax
jle 0x4da2
movq 0x8(%rbx), %rbx
jmp 0x4d7a
movq 0x8(%rbx), %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x4cd9
movq (%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4d6c
testq %rax, %rax
cmoveq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/set_example/../../modules/UsingAVL/ADTSet.c
// Function: node_is_avl
bool node_is_avl(SetNode node, CompareFunc compare) {
	if (node == NULL)
		return true;

	// Ελέγχουμε την ιδιότητα:
	// κάθε κόμβος είναι > αριστερό παιδί, > δεξιότερο κόμβο του αριστερού υποδέντρου, < δεξί παιδί, < αριστερότερο κόμβο του δεξιού υποδέντρου.
	// Είναι ισοδύναμη με την BST ιδιότητα (κάθε κόμβος είναι > αριστερό υποδέντρο και < δεξί υποδέντρο) αλλά ευκολότερο να ελεγθεί.
	bool res = true;
	if(node->left != NULL)
		res = res && compare(node->left->value, node->value) < 0 && compare(node_find_max(node->left)->value, node->value) < 0;
	if(node->right != NULL)
		res = res && compare(node->right->value, node->value) > 0 && compare(node_find_min(node->right)->value, node->value) > 0;

	// Το ύψος είναι σωστό
	res = res && node->height == 1 + int_max(node_height(node->left), node_height(node->right));

	// Ο κόμβος έχει την AVL ιδιότητα
	int balance = node_balance(node);
	res = res && balance >= -1 && balance <= 1;

	// Τα υποδέντρα είναι σωστά
	res = res &&
		node_is_avl(node->left, compare) &&
		node_is_avl(node->right, compare);

	return res;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
testq %r14, %r14
je 0x4ecc
movq (%r14), %rax
testq %rax, %rax
je 0x4e01
movq 0x10(%rax), %rdi
movq 0x10(%r14), %rsi
callq *%rbx
testl %eax, %eax
js 0x4e05
xorl %eax, %eax
jmp 0x4e1a
movb $0x1, %al
jmp 0x4e1a
movq (%r14), %rdi
callq 0x4cef
movq 0x10(%rax), %rdi
movq 0x10(%r14), %rsi
callq *%rbx
shrl $0x1f, %eax
movq 0x8(%r14), %rcx
testq %rcx, %rcx
je 0x4e51
testb %al, %al
je 0x4e4f
movq 0x10(%rcx), %rdi
movq 0x10(%r14), %rsi
callq *%rbx
testl %eax, %eax
jle 0x4e4f
movq 0x8(%r14), %rdi
callq 0x4cd9
movq 0x10(%rax), %rdi
movq 0x10(%r14), %rsi
callq *%rbx
testl %eax, %eax
setg %al
jmp 0x4e51
xorl %eax, %eax
xorl %ecx, %ecx
testb %al, %al
je 0x4e80
movq (%r14), %rax
testq %rax, %rax
je 0x4e62
movl 0x18(%rax), %ecx
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x4e70
movl 0x18(%rax), %eax
jmp 0x4e72
xorl %eax, %eax
cmpl %eax, %ecx
cmovgl %ecx, %eax
incl %eax
cmpl %eax, 0x18(%r14)
sete %cl
movq (%r14), %rdi
testq %rdi, %rdi
je 0x4e8f
movl 0x18(%rdi), %eax
incl %eax
jmp 0x4e94
movl $0x1, %eax
movq 0x8(%r14), %rdx
testq %rdx, %rdx
je 0x4ea2
movl 0x18(%rdx), %edx
jmp 0x4ea4
xorl %edx, %edx
subl %edx, %eax
cmpl $0x3, %eax
setb %al
andb %al, %cl
cmpb $0x1, %cl
jne 0x4ec8
movq %rbx, %rsi
callq 0x4dd4
testb %al, %al
je 0x4ec8
movq 0x8(%r14), %r14
jmp 0x4dde
xorl %eax, %eax
jmp 0x4ece
movb $0x1, %al
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/set_example/../../modules/UsingAVL/ADTSet.c
// Function: node_repair_balance
static SetNode node_repair_balance(SetNode node) {
	node_update_height(node);

	int balance = node_balance(node);
	if (balance > 1) {
		// το αριστερό υπόδεντρο είναι unbalanced
		if (node_balance(node->left) >= 0) 
			return node_rotate_right(node);
		else 
			return node_rotate_left_right(node);

	} else if (balance < -1) {
		// το δεξί υπόδεντρο είναι unbalanced
		if (node_balance(node->right) <= 0)
			return node_rotate_left(node);
		else
			return node_rotate_right_left(node);
	}

	// δεν χρειάστηκε να πραγματοποιηθεί rotation
	return node;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
xorl %ecx, %ecx
movl $0x0, %edx
testq %rdi, %rdi
je 0x4efb
movl 0x18(%rdi), %edx
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x4f07
movl 0x18(%rax), %ecx
cmpl %ecx, %edx
cmovgl %edx, %ecx
incl %ecx
xorl %edx, %edx
movl %ecx, 0x18(%rbx)
movl $0x0, %ecx
testq %rdi, %rdi
je 0x4f20
movl 0x18(%rdi), %ecx
testq %rax, %rax
je 0x4f28
movl 0x18(%rax), %edx
subl %edx, %ecx
cmpl $0x2, %ecx
jl 0x4f5f
movq (%rdi), %rdx
xorl %eax, %eax
movl $0x0, %ecx
testq %rdx, %rdx
je 0x4f41
movl 0x18(%rdx), %ecx
movq 0x8(%rdi), %rdx
testq %rdx, %rdx
je 0x4f4d
movl 0x18(%rdx), %eax
cmpl %eax, %ecx
jge 0x4f59
callq 0x4fea
movq %rax, (%rbx)
movq %rbx, %rdi
popq %rbx
jmp 0x4f9d
cmpl $-0x2, %ecx
jg 0x4f98
movq (%rax), %rsi
xorl %ecx, %ecx
movl $0x0, %edx
testq %rsi, %rsi
je 0x4f76
movl 0x18(%rsi), %edx
movq 0x8(%rax), %rsi
testq %rsi, %rsi
je 0x4f82
movl 0x18(%rsi), %ecx
cmpl %ecx, %edx
jle 0x4f92
movq %rax, %rdi
callq 0x4f9d
movq %rax, 0x8(%rbx)
movq %rbx, %rdi
popq %rbx
jmp 0x4fea
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/set_example/../../modules/UsingAVL/ADTSet.c
// Function: node_rotate_right
static SetNode node_rotate_right(SetNode node) {
	SetNode left_node = node->left;
	SetNode left_right = left_node->right;

	left_node->right = node;
	node->left = left_right;

	node_update_height(node);
	node_update_height(left_node);
	
	return left_node;
}

// Assembly:
movq (%rdi), %rax
movq 0x8(%rax), %rsi
movq %rdi, 0x8(%rax)
movq %rsi, (%rdi)
xorl %ecx, %ecx
movl $0x0, %edx
testq %rsi, %rsi
je 0x4fba
movl 0x18(%rsi), %edx
movq 0x8(%rdi), %rsi
testq %rsi, %rsi
je 0x4fc6
movl 0x18(%rsi), %ecx
cmpl %ecx, %edx
cmovgl %edx, %ecx
incl %ecx
movl %ecx, 0x18(%rdi)
movq (%rax), %rdx
testq %rdx, %rdx
je 0x4fdd
movl 0x18(%rdx), %edx
jmp 0x4fdf
xorl %edx, %edx
cmpl %ecx, %edx
cmovgl %edx, %ecx
incl %ecx
movl %ecx, 0x18(%rax)
retq
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/set_example/../../modules/UsingAVL/ADTSet.c
// Function: node_rotate_left
static SetNode node_rotate_left(SetNode node) {
	SetNode right_node = node->right;
	SetNode left_subtree = right_node->left;

	right_node->left = node;
	node->right = left_subtree;

	node_update_height(node);
	node_update_height(right_node);
	
	return right_node;
}

// Assembly:
movq 0x8(%rdi), %rax
movq (%rax), %rdx
movq %rdi, (%rax)
movq %rdx, 0x8(%rdi)
movq (%rdi), %r8
xorl %ecx, %ecx
movl $0x0, %esi
testq %r8, %r8
je 0x500b
movl 0x18(%r8), %esi
testq %rdx, %rdx
je 0x5013
movl 0x18(%rdx), %ecx
cmpl %ecx, %esi
cmovgl %esi, %ecx
incl %ecx
movl %ecx, 0x18(%rdi)
movq 0x8(%rax), %rdx
testq %rdx, %rdx
je 0x502b
movl 0x18(%rdx), %edx
jmp 0x502d
xorl %edx, %edx
cmpl %edx, %ecx
cmovgl %ecx, %edx
incl %edx
movl %edx, 0x18(%rax)
retq
// File: /workspace/github_c_makefile_star2_O1/chatziko-k08[P]lecture-code/programs/set_example/../../modules/UsingAVL/ADTSet.c
// Function: node_remove_min
static SetNode node_remove_min(SetNode node, SetNode* min_node) {
	if (node->left == NULL) {
		// Δεν έχουμε αριστερό υποδέντρο, οπότε ο μικρότερος είναι ο ίδιος ο node
		*min_node = node;
		return node->right;		// νέα ρίζα είναι το δεξιό παιδί

	} else {
		// Εχουμε αριστερό υποδέντρο, οπότε η μικρότερη τιμή είναι εκεί. Συνεχίζουμε αναδρομικά
		// και ενημερώνουμε το node->left με τη νέα ρίζα του υποδέντρου.
		node->left = node_remove_min(node->left, min_node);

		return node_repair_balance(node);	// AVL
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x5055
callq 0x5038
movq %rax, (%rbx)
movq %rbx, %rdi
popq %rbx
jmp 0x4ee5
movq %rbx, (%rsi)
movq 0x8(%rbx), %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/cirocosta[P]stress/src/cpu.c
// Function: start_workers
void
start_workers(int n)
{
	int pid;

	while (n--) {
		switch (pid = fork()) {
			case -1:
				_STRESS_MUST(0, "Fork returned -1.");
				break;
			case 0:
				printf("[%d] - child started\n", n);
				while (1) {
				}
				break;
		}
	}
}

// Assembly:
pushq %rbx
movl %edi, %ebx
subl $0x1, %ebx
jb 0x17f6
callq 0x1140
testl %eax, %eax
je 0x17f8
cmpl $-0x1, %eax
jne 0x17de
callq 0x139c
popq %rbx
retq
leaq 0x925(%rip), %rdi       # 0x2124
movl %ebx, %esi
xorl %eax, %eax
callq 0x10a0
jmp 0x1808
// File: /workspace/github_c_makefile_star2_O1/cirocosta[P]stress/src/cpu.c
// Function: main
int
main(int argc, char** argv)
{
	stress_args_t args = { 0 };

	setbuf(stdout, NULL);
	stress_parse_args(argc, argv, &args);
	start_workers(args.n);
	stress_wait_until_signalized();

	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x2010, %rsp           # imm = 0x2010
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x8(%rsp), %r14
movl $0x2008, %edx           # imm = 0x2008
movq %r14, %rdi
xorl %esi, %esi
callq 0x10b0
movq 0x2793(%rip), %rax      # 0x3fc8
movq (%rax), %rdi
xorl %esi, %esi
callq 0x1090
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x15a9
movl (%r14), %edi
callq 0x17db
callq 0x16d2
xorl %eax, %eax
addq $0x2010, %rsp           # imm = 0x2010
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/radforddc[P]icpc_siggen/calc_signal.c
// Function: signal_calc_init
int signal_calc_init(char *config_file_name, MJD_Siggen_Setup *setup) {

  if (read_config(config_file_name, setup)) return 1;

  TELL_CHATTY("r: %.2f  z: %.2f\n", setup->xtal_radius, setup->xtal_length);
  setup->ntsteps_out = setup->time_steps_calc /
    lrintf(setup->step_time_out/setup->step_time_calc);
  TELL_NORMAL("Will use %d time steps in calculations, each %.2f ns long;\n"
	      "the output signals will have %d time steps, each %.2f ns long\n", 
	      setup->time_steps_calc, setup->step_time_calc,
	      setup->ntsteps_out, setup->step_time_out);

  TELL_NORMAL("Reading field data...\n");
  if (field_setup(setup) != 0) return -1;
  
  if ((setup->dpath_e = (point *) malloc(setup->time_steps_calc*sizeof(point))) == NULL ||
      (setup->dpath_h = (point *) malloc(setup->time_steps_calc*sizeof(point))) == NULL) {
    error("Path malloc failed\n");
    return -1;
  }

  tell("Setup of signal calculation done\n");
  return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
callq 0x63a8
movl $0x1, %ebp
testl %eax, %eax
jne 0x259b
cmpl $0x2, (%rbx)
jl 0x24d2
cvtss2sd 0x8(%rbx), %xmm0
cvtss2sd 0x4(%rbx), %xmm1
leaq 0x5c15(%rip), %rdi      # 0x80e0
movb $0x2, %al
callq 0x25b2
movslq 0x390(%rbx), %r14
movss 0x398(%rbx), %xmm0
divss 0x394(%rbx), %xmm0
callq 0x2180
movq %rax, %rcx
movq %r14, %rax
cqto
idivq %rcx
movl %eax, 0x3ac(%rbx)
cmpl $0x0, (%rbx)
jle 0x2530
movl 0x390(%rbx), %esi
xorps %xmm0, %xmm0
cvtss2sd 0x394(%rbx), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x398(%rbx), %xmm1
leaq 0x5bcb(%rip), %rdi      # 0x80f2
movl %eax, %edx
movb $0x2, %al
callq 0x25b2
cmpl $0x0, (%rbx)
jle 0x2543
leaq 0x5c30(%rip), %rdi      # 0x816c
xorl %eax, %eax
callq 0x25b2
movq %rbx, %rdi
callq 0x3fe8
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x259b
movslq 0x390(%rbx), %rax
shlq $0x2, %rax
leaq (%rax,%rax,2), %r14
movq %r14, %rdi
callq 0x20d0
movq %rax, 0x1580(%rbx)
testq %rax, %rax
je 0x25a2
movq %r14, %rdi
callq 0x20d0
movq %rax, 0x1588(%rbx)
testq %rax, %rax
je 0x25a2
leaq 0x5c05(%rip), %rdi      # 0x8197
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x25b2
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x5bda(%rip), %rdi      # 0x8183
xorl %eax, %eax
callq 0x22e0
jmp 0x259b
// File: /workspace/github_c_makefile_star2_O1/radforddc[P]icpc_siggen/calc_signal.c
// Function: rc_integrate
int rc_integrate(float *s_in, float *s_out, float tau, int time_steps){
  int   j;
  float s_in_old, s;  /* DCR: added so that it's okay to
			 call this function with s_out == s_in */
  
  if (tau < 1.0f) {
    for (j = time_steps-1; j > 0; j--) s_out[j] = s_in[j-1];
    s_out[0] = 0.0;
  } else {
    s_in_old = s_in[0];
    s_out[0] = 0.0;
    for (j = 1; j < time_steps; j++) {
      s = s_out[j-1] + (s_in_old - s_out[j-1])/tau;
      s_in_old = s_in[j];
      s_out[j] = s;
    }
  }
  return 0;
}

// Assembly:
movss 0x48a8(%rip), %xmm1     # 0x8008
ucomiss %xmm0, %xmm1
jbe 0x378c
cmpl $0x2, %edx
jl 0x3784
movl %edx, %eax
incq %rax
movss -0xc(%rdi,%rax,4), %xmm0
movss %xmm0, -0x8(%rsi,%rax,4)
decq %rax
cmpq $0x2, %rax
jg 0x376f
movl $0x0, (%rsi)
jmp 0x37c4
movss (%rdi), %xmm1
movl $0x0, (%rsi)
cmpl $0x2, %edx
jl 0x37c4
movl %edx, %eax
movss (%rsi), %xmm2
movl $0x1, %ecx
subss %xmm2, %xmm1
divss %xmm0, %xmm1
addss %xmm1, %xmm2
movss (%rdi,%rcx,4), %xmm1
movss %xmm2, (%rsi,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x37a6
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/radforddc[P]icpc_siggen/calc_signal.c
// Function: signal_calc_finalize
int signal_calc_finalize(MJD_Siggen_Setup *setup){
  fields_finalize(setup);
  free(setup->dpath_h);
  free(setup->dpath_e);
  return 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x6023
movq 0x1588(%rbx), %rdi
callq 0x2140
movq 0x1580(%rbx), %rdi
callq 0x2140
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/radforddc[P]icpc_siggen/cyl_point.c
// Function: cart_to_cyl
struct cyl_pt cart_to_cyl(struct point cart_pt){
  struct cyl_pt cyl_pt;

  cyl_pt.r = sqrt(cart_pt.x*cart_pt.x + cart_pt.y*cart_pt.y);
  if (cart_pt.x == 0.0){
    if (cart_pt.y > 0.0) cyl_pt.phi = M_PI/2;
    else cyl_pt.phi = -M_PI/2;
  }else{
    cyl_pt.phi = atan(cart_pt.y/cart_pt.x);
    if (cart_pt.x < 0) cyl_pt.phi += M_PI;
  }
  cyl_pt.z = cart_pt.z;
  
  return cyl_pt;
}

// Assembly:
subq $0x38, %rsp
movaps %xmm0, %xmm3
movaps %xmm0, %xmm4
shufps $0x55, %xmm0, %xmm4     # xmm4 = xmm4[1,1],xmm0[1,1]
movaps %xmm4, %xmm2
mulss %xmm4, %xmm2
mulss %xmm0, %xmm0
addss %xmm2, %xmm0
xorps %xmm5, %xmm5
ucomiss %xmm5, %xmm0
jb 0x383e
xorps %xmm2, %xmm2
sqrtss %xmm0, %xmm2
jmp 0x3869
movss %xmm1, 0xc(%rsp)
movaps %xmm3, 0x20(%rsp)
movaps %xmm4, 0x10(%rsp)
callq 0x22c0
xorps %xmm5, %xmm5
movaps 0x10(%rsp), %xmm4
movaps 0x20(%rsp), %xmm3
movss 0xc(%rsp), %xmm1
movaps %xmm0, %xmm2
ucomiss %xmm5, %xmm3
jne 0x3881
jp 0x3881
xorps %xmm0, %xmm0
ucomiss %xmm0, %xmm4
jbe 0x38e3
movaps 0x4c41(%rip), %xmm0     # 0x84c0
jmp 0x38ea
movss %xmm1, 0xc(%rsp)
divss %xmm3, %xmm4
xorps %xmm0, %xmm0
cvtss2sd %xmm4, %xmm0
movaps %xmm3, 0x20(%rsp)
movaps %xmm2, 0x10(%rsp)
callq 0x2150
xorps %xmm1, %xmm1
cvtsd2ss %xmm0, %xmm1
movaps %xmm1, %xmm0
movaps 0x10(%rsp), %xmm2
movlhps %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0]
shufps $0xe2, %xmm2, %xmm0     # xmm0 = xmm0[2,0],xmm2[2,3]
xorps %xmm2, %xmm2
ucomiss 0x20(%rsp), %xmm2
jbe 0x38db
cvtss2sd %xmm1, %xmm1
addsd 0x4bd3(%rip), %xmm1     # 0x84a0
cvtsd2ss %xmm1, %xmm1
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
shufps $0xe2, %xmm0, %xmm1     # xmm1 = xmm1[2,0],xmm0[2,3]
movaps %xmm1, %xmm0
movss 0xc(%rsp), %xmm1
jmp 0x38ee
movaps 0x4bc6(%rip), %xmm0     # 0x84b0
movss %xmm2, %xmm0            # xmm0 = xmm2[0],xmm0[1,2,3]
addq $0x38, %rsp
retq
// File: /workspace/github_c_makefile_star2_O1/radforddc[P]icpc_siggen/cyl_point.c
// Function: cyl_to_cart
struct point cyl_to_cart(struct cyl_pt cyl_pt){
  struct point cart_pt;

  cart_pt.x = cyl_pt.r * cos(cyl_pt.phi);
  cart_pt.y = cyl_pt.r * sin(cyl_pt.phi);
  cart_pt.z = cyl_pt.z;

  return cart_pt;
}

// Assembly:
subq $0x38, %rsp
movss %xmm1, 0xc(%rsp)
xorps %xmm1, %xmm1
cvtss2sd %xmm0, %xmm1
movsd %xmm1, 0x10(%rsp)
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x18(%rsp)
callq 0x20f0
mulsd 0x10(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movsd 0x18(%rsp), %xmm0
callq 0x22a0
mulsd 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtsd2ss %xmm0, %xmm1
movaps 0x20(%rsp), %xmm0
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movss 0xc(%rsp), %xmm1
addq $0x38, %rsp
retq
// File: /workspace/github_c_makefile_star2_O1/radforddc[P]icpc_siggen/cyl_point.c
// Function: vector_norm_cyl
float vector_norm_cyl(struct cyl_pt pt, struct cyl_pt *e){
  float norm;

  norm = sqrt(pt.r*pt.r + pt.z*pt.z);
  e->phi = pt.phi;
  e->r = pt.r/norm;
  e->z = pt.z/norm;

  return norm;
}

// Assembly:
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movaps %xmm0, %xmm3
movaps %xmm1, %xmm2
mulss %xmm1, %xmm2
mulss %xmm0, %xmm0
addss %xmm2, %xmm0
xorps %xmm2, %xmm2
ucomiss %xmm2, %xmm0
jb 0x3ac4
sqrtss %xmm0, %xmm0
jmp 0x3adf
movss %xmm1, 0xc(%rsp)
movaps %xmm3, 0x10(%rsp)
callq 0x22c0
movaps 0x10(%rsp), %xmm3
movss 0xc(%rsp), %xmm1
movaps %xmm3, %xmm2
shufps $0x55, %xmm3, %xmm2     # xmm2 = xmm2[1,1],xmm3[1,1]
movss %xmm2, 0x4(%rbx)
divss %xmm0, %xmm3
movss %xmm3, (%rbx)
divss %xmm0, %xmm1
movss %xmm1, 0x8(%rbx)
addq $0x20, %rsp
popq %rbx
retq
nop
// File: /workspace/github_c_makefile_star2_O1/radforddc[P]icpc_siggen/fields.c
// Function: wpotential
int wpotential(point pt, float *wp, MJD_Siggen_Setup *setup){
  float w[2][2];
  int   i, j;
  cyl_int_pt ipt;
  cyl_pt cyl;

  // cyl = cart_to_cyl(pt);  // do not need to know phi, so save call to atan
  cyl.r = sqrt(pt.x*pt.x + pt.y*pt.y);
  cyl.z = pt.z;

  if (nearest_field_grid_index(cyl, &ipt, setup) < 0) return 1;
  grid_weights(cyl, ipt, w, setup);
  *wp = 0.0;
  for (i = 0; i < 2; i++){
    for (j = 0; j < 2; j++){
      *wp += w[i][j]*setup->wpot[ipt.r+i][ipt.z+j];
    }
  }

  return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movaps %xmm0, %xmm2
mulps %xmm0, %xmm2
shufps $0x55, %xmm2, %xmm2     # xmm2 = xmm2[1,1,1,1]
mulss %xmm0, %xmm0
addss %xmm2, %xmm0
xorps %xmm2, %xmm2
ucomiss %xmm2, %xmm0
movss %xmm1, 0xc(%rsp)
jb 0x56e2
sqrtss %xmm0, %xmm0
jmp 0x56ed
callq 0x22c0
movss 0xc(%rsp), %xmm1
leaq 0x10(%rsp), %rdi
movaps %xmm0, 0x20(%rsp)
movq %r14, %rsi
callq 0x5814
testl %eax, %eax
js 0x5807
movaps 0x20(%rsp), %xmm5
subss 0x3b0(%r14), %xmm5
divss 0x3b8(%r14), %xmm5
movslq 0x18(%rsp), %rax
xorps %xmm0, %xmm0
cvtsi2ssl 0x10(%rsp), %xmm0
movss 0xc(%rsp), %xmm6
subss 0x3bc(%r14), %xmm6
divss 0x3c4(%r14), %xmm6
subss %xmm0, %xmm5
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
subss %xmm0, %xmm6
xorps %xmm0, %xmm0
cvtss2sd %xmm5, %xmm0
movsd 0x2936(%rip), %xmm1     # 0x8098
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
cvtss2sd %xmm6, %xmm3
subsd %xmm3, %xmm1
movapd %xmm2, %xmm4
mulsd %xmm1, %xmm4
cvtsd2ss %xmm4, %xmm4
leaq 0x30(%rsp), %rcx
movss %xmm4, (%rcx)
mulsd %xmm3, %xmm2
cvtsd2ss %xmm2, %xmm2
movss %xmm2, 0x4(%rcx)
mulsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x8(%rcx)
mulss %xmm5, %xmm6
movss %xmm6, 0xc(%rcx)
movl $0x0, (%rbx)
movslq 0x10(%rsp), %rdx
shlq $0x3, %rdx
addq 0x1478(%r14), %rdx
xorps %xmm0, %xmm0
xorl %esi, %esi
shlq $0x2, %rax
movq (%rdx,%rsi,8), %rdi
addq %rax, %rdi
xorl %r8d, %r8d
movss (%rcx,%r8,4), %xmm1
mulss (%rdi,%r8,4), %xmm1
addss %xmm1, %xmm0
movss %xmm0, (%rbx)
incq %r8
cmpq $0x1, %r8
je 0x57d6
leaq 0x1(%rsi), %rdi
addq $0x8, %rcx
testq %rsi, %rsi
movq %rdi, %rsi
je 0x57cc
xorl %eax, %eax
jmp 0x580c
movl $0x1, %eax
addq $0x48, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/radforddc[P]icpc_siggen/fields.c
// Function: fields_finalize
int fields_finalize(MJD_Siggen_Setup *setup){
  int i;

  for (i = 0; i < lrintf((setup->rmax - setup->rmin)/setup->rstep) + 1; i++){
    free(setup->efld[i]);
    free(setup->wpot[i]);
  }
  free(setup->efld);
  free(setup->wpot);
  free(setup->v_lookup);
  setup->efld = NULL;
  setup->wpot = NULL;
  setup->v_lookup = NULL;

  return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movss 0x3b4(%rdi), %xmm0
subss 0x3b0(%rdi), %xmm0
divss 0x3b8(%rdi), %xmm0
callq 0x2180
testq %rax, %rax
js 0x609a
movq $-0x1, %r14
movq 0x1470(%rbx), %rax
movq 0x8(%rax,%r14,8), %rdi
callq 0x2140
movq 0x1478(%rbx), %rax
movq 0x8(%rax,%r14,8), %rdi
callq 0x2140
movss 0x3b4(%rbx), %xmm0
subss 0x3b0(%rbx), %xmm0
divss 0x3b8(%rbx), %xmm0
callq 0x2180
incq %r14
cmpq %r14, %rax
jg 0x6053
movq 0x1470(%rbx), %rdi
callq 0x2140
movq 0x1478(%rbx), %rdi
callq 0x2140
movq 0x3d8(%rbx), %rdi
callq 0x2140
movq $0x0, 0x3d8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x1470(%rbx)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/radforddc[P]icpc_siggen/fields.c
// Function: set_temp
void set_temp(float temp, MJD_Siggen_Setup *setup){
  if (temp < MIN_TEMP || temp > MAX_TEMP){
    error("temperature out of range: %f\n", temp);
  }else{
    setup->xtal_temp = temp;
    error("temperature set to %f\n", temp);
    /* re-read velocities and correct them to the new temperature value */
    setup_velo(setup);
  }
}

// Assembly:
movaps %xmm0, %xmm1
cvtss2sd %xmm0, %xmm0
movss 0x23e1(%rip), %xmm2     # 0x84d0
ucomiss %xmm1, %xmm2
ja 0x6120
ucomiss 0x23d9(%rip), %xmm1     # 0x84d4
ja 0x6120
pushq %rbx
movq %rdi, %rbx
movss %xmm1, 0x388(%rdi)
leaq 0x2538(%rip), %rdi      # 0x8648
movb $0x1, %al
callq 0x22e0
movq %rbx, %rdi
popq %rbx
jmp 0x49fd
leaq 0x2503(%rip), %rdi      # 0x862a
movb $0x1, %al
jmp 0x22e0
nop