LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/00pauln00[P]yapio/yapio.c
// Function: yapio_stats_reporting
static void *
yapio_stats_reporting(void *unused_arg)
{
    int remaining_test_contexts_to_report = 0;

    yapio_timer_t start_time;
    yapio_get_time(&start_time);

    do
    {
        pthread_mutex_lock(&yapioThreadMutex);

        remaining_test_contexts_to_report =
            yapio_stats_report_iterate(start_time);

        if (remaining_test_contexts_to_report)
            pthread_cond_wait(&yapioThreadCond, &yapioThreadMutex);

        pthread_mutex_unlock(&yapioThreadMutex);
    } while (remaining_test_contexts_to_report && !yapioHaltStonewallThread);

    log_msg(YAPIO_LL_DEBUG,
            "remaining_test_contexts_to_report=%d yapioHaltStonewallThread=%d",
            remaining_test_contexts_to_report, yapioHaltStonewallThread);

    if (remaining_test_contexts_to_report)
        yapio_stats_report_iterate(start_time);

    return unused_arg;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %rdi
callq 0x692b
leaq 0xe10553(%rip), %r15    # 0xe16ac8
leaq 0xe1159c(%rip), %r12    # 0xe17b18
movq %r15, %rdi
callq 0x2360
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x699d
movl %eax, %r14d
testl %eax, %eax
je 0x65a5
movq %r12, %rdi
movq %r15, %rsi
callq 0x22c0
movq %r15, %rdi
callq 0x23a0
movb 0xe11595(%rip), %al     # 0xe17b48
testl %r14d, %r14d
je 0x65bc
testb $0x1, %al
je 0x657c
cmpl $0x3, 0x5c55(%rip)      # 0xc218
jge 0x65e8
testl %r14d, %r14d
je 0x65d9
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x699d
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movzbl %al, %r10d
andl $0x1, %r10d
movq 0x59e9(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movl 0x5c67(%rip), %r8d      # 0xc268
leaq 0x2b99(%rip), %rsi      # 0x91a1
leaq 0x1ba0(%rip), %rdx      # 0x81af
leaq 0x2bdb(%rip), %rcx      # 0x91f1
movl $0xaca, %r9d            # imm = 0xACA
xorl %eax, %eax
pushq %r10
pushq %r14
callq 0x2380
popq %rcx
popq %rdx
jmp 0x65c5
// File: /workspace/github_c_makefile_star2_O2/00pauln00[P]yapio/yapio.c
// Function: yapio_get_time_duration
static void
yapio_get_time_duration(yapio_timer_t *result, const yapio_timer_t *end)
{
    result->tv_sec = end->tv_sec - result->tv_sec;
    result->tv_nsec = end->tv_nsec - result->tv_nsec;

    if (result->tv_nsec < 0)
    {
        result->tv_sec--;
        result->tv_nsec += YAPIO_NSEC_PER_SEC;
    }

    if (result->tv_nsec < 0 || result->tv_nsec >= YAPIO_NSEC_PER_SEC)
        result->tv_nsec = 0;
}

// Assembly:
movdqu (%rsi), %xmm0
movdqu (%rdi), %xmm1
psubq %xmm1, %xmm0
movdqu %xmm0, (%rdi)
pshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
movq %xmm1, %rax
testq %rax, %rax
jns 0x6d70
movq %xmm0, %rcx
decq %rcx
movq %rcx, (%rdi)
addq $0x3b9aca00, %rax       # imm = 0x3B9ACA00
movq %rax, 0x8(%rdi)
cmpq $0x3b9aca00, %rax       # imm = 0x3B9ACA00
jb 0x6d7d
andq $0x0, 0x8(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O2/00pauln00[P]yapio/yapio.c
// Function: yapio_stonewall_thread
static void *
yapio_stonewall_thread(void *unused_arg)
{
    if (yapioUseStoneWalling)
        do
        {
            if (!yapioStoneWallNsecs--)
            {
                yapioStoneWalled = true;
                log_msg(YAPIO_LL_DEBUG, "yapioStoneWalled=%d",
                        yapioStoneWalled);
                break;
            }
            else
            {
                sleep(1);
            }
        } while (!yapioHaltStonewallThread);

    return unused_arg;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpb $0x1, 0x54a8(%rip)      # 0xc258
jne 0x6de0
pushq $0x1
popq %rbp
subl $0x1, 0x2054cc(%rip)    # 0x20c288
jb 0x6dd0
movl %ebp, %edi
callq 0x21a0
cmpb $0x1, 0xe10d7c(%rip)    # 0xe17b48
jne 0x6db5
jmp 0x6de0
movb $0x1, 0xe10d81(%rip)    # 0xe17b58
cmpl $0x3, 0x543a(%rip)      # 0xc218
jge 0x6dea
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq 0x51ef(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movl 0x546d(%rip), %r8d      # 0xc268
movl $0x1, (%rsp)
leaq 0x2574(%rip), %rsi      # 0x937d
leaq 0x139f(%rip), %rdx      # 0x81af
leaq 0x2589(%rip), %rcx      # 0x93a0
movl $0xb1e, %r9d            # imm = 0xB1E
xorl %eax, %eax
callq 0x2380
jmp 0x6de0
// File: /workspace/github_c_makefile_star2_O2/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)
pushq $0x10
popq %rsi
movq %rdx, %rdi
callq 0x22d0
movq %rax, %r14
cmpl $0x3, 0x5332(%rip)      # 0xc218
jge 0x6ef4
movq %r14, (%r15)
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
movq 0x50e5(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movl 0x5363(%rip), %r8d      # 0xc268
shlq $0x4, %rbx
leaq 0x1d3a(%rip), %rsi      # 0x8c4a
leaq 0x1298(%rip), %rdx      # 0x81af
leaq 0x2629(%rip), %rcx      # 0x9547
movl $0x752, %r9d            # imm = 0x752
xorl %eax, %eax
pushq %rbx
pushq %r14
callq 0x2380
popq %rcx
popq %rdx
jmp 0x6ee8
// File: /workspace/github_c_makefile_star2_O2/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 0x23f0
movl %eax, %edi
callq 0x22b0
testl %ebp, %ebp
je 0x7178
movb $0x1, %bl
cmpl %r14d, %ebp
je 0x717a
callq 0x2370
movl %eax, %ecx
movl %r14d, %eax
cltd
idivl %ebp
movl %eax, %esi
movl %ecx, %eax
cltd
idivl %esi
testl %edx, %edx
jne 0x717a
xorl %ebx, %ebx
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
movq %rdi, %rbx
movq 0x50c1(%rip), %rax      # 0xc250
cmpq %rdi, 0xb020(%rax)
setbe %cl
movl 0x5079(%rip), %eax      # 0xc218
testl %eax, %eax
setns %dl
andb %cl, %dl
cmpb $0x1, %dl
je 0x7209
movl %esi, %r14d
cmpl $0x4, %eax
jge 0x71cf
movq 0x50a6(%rip), %rax      # 0xc260
shlq $0x4, %rbx
movl %r14d, (%rax,%rbx)
orb $0x40, 0xf(%rax,%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x4e0a(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movl 0x5088(%rip), %r8d      # 0xc268
leaq 0x249e(%rip), %rsi      # 0x9685
leaq 0xfbb(%rip), %rdx       # 0x81a9
leaq 0x246d(%rip), %rcx      # 0x9662
movl $0x611, %r9d            # imm = 0x611
xorl %eax, %eax
pushq %rbx
pushq %r14
callq 0x2380
popq %rcx
popq %rdx
jmp 0x71b3
movq 0x4dd0(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movl 0x504e(%rip), %r8d      # 0xc268
subq $0x8, %rsp
leaq 0x240e(%rip), %rsi      # 0x9633
leaq 0xf6c(%rip), %rdx       # 0x8198
leaq 0x242f(%rip), %rcx      # 0x9662
movl $0x60f, %r9d            # imm = 0x60F
xorl %eax, %eax
pushq %rbx
callq 0x2380
popq %rcx
popq %rdx
pushq $0x1
popq %rdi
callq 0x5874
// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %ebp
movl %edi, %r14d
testl %edi, %edi
movl $0x0, %r15d
cmovgl %edi, %r15d
addq $0x8, %rbx
leaq 0x22b7(%rip), %r13      # 0x9830
xorl %r12d, %r12d
cmpq %r12, %r15
je 0x75df
movl %r14d, %edi
movl %ebp, %esi
callq 0x713e
testb %al, %al
je 0x759e
cmpl $0x3, 0x4c82(%rip)      # 0xc218
jge 0x75aa
orb $-0x80, 0x7(%rbx)
decl %ebp
incq %r12
decl %r14d
addq $0x10, %rbx
jmp 0x757c
movq 0x4a2f(%rip), %rax      # 0xbfe0
movq (%rax), %rdi
movl 0x4cad(%rip), %r8d      # 0xc268
movl %r12d, (%rsp)
leaq 0x201b(%rip), %rsi      # 0x95e1
leaq 0xbe2(%rip), %rdx       # 0x81af
movq %r13, %rcx
movl $0x593, %r9d            # imm = 0x593
xorl %eax, %eax
callq 0x2380
jmp 0x7598
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/00pauln00[P]yapio/yapio.c
// Function: yapio_get_content_word
static unsigned long long
yapio_get_content_word(const yapio_blk_md_t *md, size_t word_num)
{
    unsigned long long content_word =
        (yapio_get_blk_magic(md->ybm_blk_number) + md->ybm_writer_rank +
         md->ybm_blk_number + md->ybm_owner_rank_fpp + word_num);

    return content_word;
}

// Assembly:
movq 0x8(%rdi), %rcx
movabsq $0x3fffffffffffffff, %rax # imm = 0x3FFFFFFFFFFFFFFF
andq %rcx, %rax
andl $0x3, %ecx
leaq 0x2677(%rip), %rdx      # 0x9c80
movslq (%rdi), %r8
addq %rax, %r8
movslq 0x4(%rdi), %rax
addq %r8, %rax
addq (%rdx,%rcx,8), %rsi
addq %rsi, %rax
retq
// File: /workspace/github_c_makefile_star2_O2/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
leaq 0x10(%rsp), %rsi
andq $0x0, (%rsi)
leaq 0x8(%rsp), %rdi
andq $0x0, (%rdi)
movq 0x2cdd(%rip), %rax      # 0x3fd0
movq (%rax), %rdx
callq 0x10e0
cmpq $-0x1, %rax
jne 0x130d
leaq 0xeb2(%rip), %rdi       # 0x21ba
callq 0x1060
movq 0x8(%rsp), %rdi
callq 0x1030
addq $0x18, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %rdi
callq 0x1130
leaq 0x8(%rsp), %rdi
callq 0x10c0
cmpq $-0x1, %rax
je 0x14c3
leaq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x1050
xorl %eax, %eax
addq $0x48, %rsp
retq
movq 0x2b2e(%rip), %rax      # 0x3ff8
movq (%rax), %rcx
leaq 0xbf2(%rip), %rdi       # 0x20c6
pushq $0x4
popq %rsi
pushq $0x1
popq %rdx
callq 0x1100
jmp 0x14ad
// File: /workspace/github_c_makefile_star2_O2/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 0x5540(%rip), %rsi      # 0x8fc0
xorl %ebp, %ebp
xorl %edi, %edi
callq 0x4158
movq %rax, %rbx
cmpl $0xa, %ebp
je 0x3aa7
movl %ebp, %edi
callq 0x3a67
movq %rbx, %rdi
movq %rax, %rsi
callq 0x421f
incl %ebp
jmp 0x3a8c
pushq $0x5a
popq %rdi
leaq 0x4(%rsp), %rdx
movq %rsp, %rcx
movq %rbx, %rsi
callq 0x4099
xorb $0x1, %al
movzbl %al, %edi
leaq 0x1852(%rip), %rsi      # 0x5318
leaq 0x1919(%rip), %rcx      # 0x53e6
leaq 0x1854(%rip), %r8       # 0x5328
pushq $0x13
popq %rdx
xorl %eax, %eax
callq 0x239c
testl %eax, %eax
je 0x3b5d
pushq $0xf
popq %rdi
leaq 0x4(%rsp), %rdx
movq %rsp, %rcx
movq %rbx, %rsi
callq 0x4099
movzbl %al, %edi
leaq 0x1819(%rip), %rsi      # 0x5318
leaq 0x18e0(%rip), %rcx      # 0x53e6
leaq 0x183a(%rip), %r8       # 0x5347
pushq $0x14
popq %rdx
xorl %eax, %eax
callq 0x239c
testl %eax, %eax
je 0x3b5d
movl (%rsp), %eax
addl 0x4(%rsp), %eax
xorl %edi, %edi
cmpl $0xf, %eax
sete %dil
leaq 0x17e6(%rip), %rsi      # 0x5318
leaq 0x18ad(%rip), %rcx      # 0x53e6
leaq 0x1825(%rip), %r8       # 0x5365
pushq $0x15
popq %rdx
xorl %eax, %eax
callq 0x239c
testl %eax, %eax
je 0x3b5d
movq %rbx, %rdi
callq 0x432e
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
callq 0x2bc0
// File: /workspace/github_c_makefile_star2_O2/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 $0x18, %rsp
movq %rcx, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movq %rsi, %r12
movl %edi, %ebp
leaq -0x29(%rip), %rdi       # 0x4094
xorl %r15d, %r15d
xorl %esi, %esi
xorl %edx, %edx
callq 0x4418
movq %rax, %r13
movq %r12, %rdi
callq 0x4192
testl %eax, %eax
movl $0x0, %r14d
movl %eax, 0x4(%rsp)
cmovgl %eax, %r14d
cmpl %r15d, %r14d
je 0x4134
movq %r12, %rdi
movl %r15d, %esi
callq 0x4196
movq %rax, %rbx
movl %ebp, %eax
subl (%rbx), %eax
movl %eax, (%rsp)
movq %r13, %rdi
movq %rsp, %rsi
callq 0x44d8
testq %rax, %rax
jne 0x4121
movq %r13, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x4508
incl %r15d
jmp 0x40e4
movl (%rbx), %eax
movq 0x8(%rsp), %rcx
movl %eax, (%rcx)
movl (%rsp), %eax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
cmpl 0x4(%rsp), %r15d
setl %bl
movq %r13, %rdi
callq 0x45ef
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/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 0x446e
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
pushq $0x20
popq %rdi
callq 0x21a0
movq %rax, %r12
leaq 0x4b(%rip), %rdi        # 0x448b
leaq 0x57(%rip), %rsi        # 0x449e
callq 0x4688
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 0x19c4(%rip), %rdi      # 0x5e39
leaq 0x19cd(%rip), %rsi      # 0x5e49
leaq 0x19e9(%rip), %rcx      # 0x5e6c
pushq $0x2b
popq %rdx
callq 0x2110
// File: /workspace/github_c_makefile_star2_O2/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), %rcx
testq %rcx, %rcx
je 0x44b8
movq (%rbx), %rdi
callq *%rcx
movq 0x10(%rbx), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x44c7
movq 0x8(%rbx), %rdi
callq *%rax
movq %rbx, %rdi
popq %rbx
jmp 0x22a0
// File: /workspace/github_c_makefile_star2_O2/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 %rsi, %rbx
movq %rsp, %rsi
movq %rbx, (%rsi)
andq $0x0, 0x8(%rsi)
movq %rdx, %r14
movq %rdi, %r15
movq %rdi, 0x10(%rsi)
movq (%rdi), %rdi
callq 0x4900
testq %rax, %rax
je 0x456e
movq %rax, %r12
movq (%rax), %rdi
cmpq %rbx, %rdi
je 0x454e
movq 0x10(%r15), %rax
testq %rax, %rax
je 0x454e
callq *%rax
movq 0x8(%r12), %rdi
cmpq %r14, %rdi
je 0x4563
movq 0x18(%r15), %rax
testq %rax, %rax
je 0x4563
callq *%rax
movq %rbx, (%r12)
movq %r14, 0x8(%r12)
jmp 0x458c
pushq $0x18
popq %rdi
callq 0x21a0
movq %rbx, (%rax)
movq %r14, 0x8(%rax)
movq %r15, 0x10(%rax)
movq (%r15), %rdi
movq %rax, %rsi
callq 0x46da
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rsp, %rax
movq %rsi, (%rax)
andq $0x0, 0x8(%rax)
movq %rdi, %rbx
movq %rdi, 0x10(%rax)
movq (%rdi), %rdi
movq %rax, %rsi
callq 0x4900
movq %rax, %r14
testq %rax, %rax
je 0x45cf
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x47d0
testq %r14, %r14
setne %al
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/chatziko-k08[P]lecture-code/programs/pair_sum/../../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 0x46b7
movq %rsi, %rbx
movq %rdi, %r14
pushq $0x20
popq %rdi
callq 0x21a0
andq $0x0, (%rax)
andl $0x0, 0x8(%rax)
movq %r14, 0x10(%rax)
movq %rbx, 0x18(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x177b(%rip), %rdi      # 0x5e39
leaq 0x17dd(%rip), %rsi      # 0x5ea2
leaq 0x17f6(%rip), %rcx      # 0x5ec2
movl $0x165, %edx            # imm = 0x165
callq 0x2110
// File: /workspace/github_c_makefile_star2_O2/chatziko-k08[P]lecture-code/programs/pair_sum/../../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 0x476e
movq %r8, %r15
movq %rsi, %r13
movq %rdi, %rbx
movq 0x10(%rdi), %rsi
movq %r14, %rdi
callq *%r13
testl %eax, %eax
je 0x4796
js 0x47a8
movq 0x8(%rbx), %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %r15, %r8
callq 0x4726
movq %rax, 0x8(%rbx)
jmp 0x47bf
movb $0x1, (%r12)
pushq $0x20
popq %rdi
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 0x47bf
movq (%rbx), %rdi
movq %r13, %rsi
movq %r14, %rdx
movq %r12, %rcx
movq %r15, %r8
callq 0x4726
movq %rax, (%rbx)
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x4bcf
// File: /workspace/github_c_makefile_star2_O2/chatziko-k08[P]lecture-code/programs/pair_sum/../../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 0x4888
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 0x48a1
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 0x4825
movq %rax, (%rbx,%rbp,8)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4bcf
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 0x48e9
testq %r14, %r14
je 0x48f3
movq %rsp, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x4cb1
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 0x4875
movq %rbx, %rdi
callq 0x22a0
jmp 0x488f
movq %rbx, %rdi
callq 0x22a0
movq %r15, %r14
jmp 0x488f
// File: /workspace/github_c_makefile_star2_O2/chatziko-k08[P]lecture-code/programs/pair_sum/../../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, %rbx
movq %rsi, %r15
movq %rdi, %r14
testq %r14, %r14
je 0x494e
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq *%r15
testl %eax, %eax
je 0x494e
notl %eax
shrl $0x1f, %eax
movq (%r14,%rax,8), %r14
jmp 0x4930
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/chatziko-k08[P]lecture-code/programs/pair_sum/../../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 0x49b7
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x4979
movq 0x8(%rbx), %rdi
movq %r14, %rsi
callq 0x4979
testq %r14, %r14
je 0x49a8
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_O2/chatziko-k08[P]lecture-code/programs/pair_sum/../../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 0x4a1b
movq 0x10(%r14), %rdi
movq 0x10(%rbx), %rsi
callq *%r15
testl %eax, %eax
jns 0x4a25
movq (%rbx), %rbx
jmp 0x4a02
movq (%rbx), %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x49d3
movq 0x8(%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x49f4
testq %rax, %rax
cmoveq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/chatziko-k08[P]lecture-code/programs/pair_sum/../../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 0x4a78
movq 0x10(%r14), %rdi
movq 0x10(%rbx), %rsi
callq *%r15
testl %eax, %eax
jle 0x4a86
movq 0x8(%rbx), %rbx
jmp 0x4a5e
movq 0x8(%rbx), %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x49bd
movq (%rbx), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4a50
testq %rax, %rax
cmoveq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/chatziko-k08[P]lecture-code/programs/pair_sum/../../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 %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
testq %rbx, %rbx
je 0x4b94
movq (%rbx), %rax
testq %rax, %rax
je 0x4ae6
movq 0x10(%rax), %rdi
movq 0x10(%rbx), %rsi
callq *%r14
testl %eax, %eax
js 0x4aea
xorl %eax, %eax
jmp 0x4b00
movb $0x1, %al
jmp 0x4b00
movq (%rbx), %rdi
callq 0x49d3
movq 0x10(%rax), %rdi
movq 0x10(%rbx), %rsi
callq *%r14
shrl $0x1f, %eax
movq 0x8(%rbx), %rcx
testq %rcx, %rcx
je 0x4b35
testb %al, %al
je 0x4b54
movq 0x10(%rcx), %rdi
movq 0x10(%rbx), %rsi
callq *%r14
testl %eax, %eax
jle 0x4b54
movq 0x8(%rbx), %rdi
callq 0x49bd
movq 0x10(%rax), %rdi
movq 0x10(%rbx), %rsi
callq *%r14
testl %eax, %eax
setg %al
xorl %ebp, %ebp
testb %al, %al
je 0x4b68
movq (%rbx), %rax
testq %rax, %rax
je 0x4b46
movl 0x18(%rax), %ebp
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x4b58
movl 0x18(%rax), %eax
jmp 0x4b5a
xorl %ebp, %ebp
jmp 0x4b68
xorl %eax, %eax
cmpl %eax, %ebp
cmovgl %ebp, %eax
incl %eax
cmpl %eax, 0x18(%rbx)
sete %bpl
movq %rbx, %rdi
callq 0x4b9f
testb %bpl, %bpl
je 0x4b94
incl %eax
cmpl $0x2, %eax
ja 0x4b94
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x4ab8
testb %al, %al
je 0x4b94
movq 0x8(%rbx), %rbx
jmp 0x4ac2
testq %rbx, %rbx
sete %al
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/chatziko-k08[P]lecture-code/programs/pair_sum/../../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 %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x4c46
movq %rbx, %rdi
callq 0x4b9f
cmpl $0x2, %eax
jl 0x4c0e
movq (%rbx), %r14
movq %r14, %rdi
callq 0x4b9f
testl %eax, %eax
jns 0x4c02
movq %r14, %rdi
callq 0x4c90
movq %rax, (%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4c6f
cmpl $-0x2, %eax
jg 0x4c3b
movq 0x8(%rbx), %r14
movq %r14, %rdi
callq 0x4b9f
testl %eax, %eax
jle 0x4c2f
movq %r14, %rdi
callq 0x4c6f
movq %rax, 0x8(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4c90
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/chatziko-k08[P]lecture-code/programs/pair_sum/../../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:
pushq %rbx
movq (%rdi), %rbx
movq 0x8(%rbx), %rax
movq %rdi, 0x8(%rbx)
movq %rax, (%rdi)
callq 0x4c46
movq %rbx, %rdi
callq 0x4c46
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/chatziko-k08[P]lecture-code/programs/pair_sum/../../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:
pushq %rbx
movq 0x8(%rdi), %rbx
movq (%rbx), %rax
movq %rdi, (%rbx)
movq %rax, 0x8(%rdi)
callq 0x4c46
movq %rbx, %rdi
callq 0x4c46
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/chatziko-k08[P]lecture-code/programs/pair_sum/../../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 0x4cce
callq 0x4cb1
movq %rax, (%rbx)
movq %rbx, %rdi
popq %rbx
jmp 0x4bcf
movq %rbx, (%rsi)
movq 0x8(%rbx), %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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 %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
subl $0x1, %ebx
jb 0x1751
callq 0x1140
testl %eax, %eax
je 0x1759
cmpl $-0x1, %eax
jne 0x1684
movq 0x2952(%rip), %r14      # 0x3ff8
movq (%r14), %rcx
leaq 0x970(%rip), %rdi       # 0x2020
pushq $0x9
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x1120
movq (%r14), %rcx
leaq 0x95e(%rip), %rdi       # 0x2026
pushq $0x3
popq %rsi
movq %rbx, %rdx
callq 0x1120
movq (%r14), %rcx
leaq 0xa2b(%rip), %rdi       # 0x2108
pushq $0x11
popq %rsi
movq %rbx, %rdx
callq 0x1120
movq (%r14), %rcx
leaq 0x95b(%rip), %rdi       # 0x204d
pushq $0x2
popq %rsi
movq %rbx, %rdx
callq 0x1120
movq (%r14), %rdi
leaq 0x949(%rip), %rsi       # 0x2050
leaq 0xa0c(%rip), %rdx       # 0x211a
xorl %eax, %eax
callq 0x10e0
movq (%r14), %rdi
leaq 0x94d(%rip), %rsi       # 0x206c
pushq $0x14
popq %rdx
xorl %eax, %eax
callq 0x10e0
movq (%r14), %rsi
pushq $0xa
popq %rdi
callq 0x10c0
movq (%r14), %rcx
leaq 0x93b(%rip), %rdi       # 0x2079
pushq $0xa
popq %rsi
movq %rbx, %rdx
callq 0x1120
pushq $0x1
popq %rdi
callq 0x1110
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x9c4(%rip), %rdi       # 0x2124
movl %ebx, %esi
xorl %eax, %eax
callq 0x10a0
jmp 0x1769
// File: /workspace/github_c_makefile_star2_O2/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 0x2832(%rip), %rax      # 0x3fc8
movq (%rax), %rdi
xorl %esi, %esi
callq 0x1090
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x12ad
movl (%r14), %edi
callq 0x167e
callq 0x157e
xorl %eax, %eax
addq $0x2010, %rsp           # imm = 0x2010
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x5c98
testl %eax, %eax
je 0x23e4
pushq $0x1
popq %rbp
jmp 0x24ce
cmpl $0x2, (%rbx)
jl 0x2401
cvtss2sd 0x8(%rbx), %xmm0
cvtss2sd 0x4(%rbx), %xmm1
leaq 0x5ce6(%rip), %rdi      # 0x80e0
movb $0x2, %al
callq 0x24d5
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 0x246c
movl 0x390(%rbx), %esi
cvtss2sd 0x394(%rbx), %xmm0
cvtss2sd 0x398(%rbx), %xmm1
leaq 0x5ca2(%rip), %rdi      # 0x80f2
movl %eax, %edx
movb $0x2, %al
callq 0x24d5
cmpl $0x0, (%rbx)
jle 0x246c
leaq 0x5d07(%rip), %rdi      # 0x816c
xorl %eax, %eax
callq 0x24d5
movq %rbx, %rdi
callq 0x3d04
pushq $-0x1
popq %rbp
testl %eax, %eax
jne 0x24ce
movslq 0x390(%rbx), %rax
imulq $0xc, %rax, %r14
movq %r14, %rdi
callq 0x20d0
movq %rax, 0x1580(%rbx)
testq %rax, %rax
je 0x24c0
movq %r14, %rdi
callq 0x20d0
movq %rax, 0x1588(%rbx)
testq %rax, %rax
je 0x24c0
leaq 0x5ce2(%rip), %rdi      # 0x8197
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x24d5
jmp 0x24ce
leaq 0x5cbc(%rip), %rdi      # 0x8183
xorl %eax, %eax
callq 0x255d
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x4a03(%rip), %xmm1     # 0x8008
ucomiss %xmm0, %xmm1
jbe 0x3628
movl %edx, %eax
cmpl $0x2, %eax
jl 0x3622
movss -0x8(%rdi,%rax,4), %xmm0
movss %xmm0, -0x4(%rsi,%rax,4)
decq %rax
jmp 0x360c
andl $0x0, (%rsi)
xorl %eax, %eax
retq
movss (%rdi), %xmm1
andl $0x0, (%rsi)
movslq %edx, %rax
pushq $0x1
popq %rcx
cmpq %rax, %rcx
jge 0x3625
movss -0x4(%rsi,%rcx,4), %xmm2
subss %xmm2, %xmm1
divss %xmm0, %xmm1
addss %xmm2, %xmm1
movss (%rdi,%rcx,4), %xmm2
movss %xmm1, (%rsi,%rcx,4)
incq %rcx
movaps %xmm2, %xmm1
jmp 0x3635
// File: /workspace/github_c_makefile_star2_O2/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 0x59bf
movq 0x1588(%rbx), %rdi
callq 0x2140
movq 0x1580(%rbx), %rdi
callq 0x2140
xorl %eax, %eax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/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, %xmm4
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movaps %xmm0, %xmm3
mulss %xmm0, %xmm3
movaps %xmm4, %xmm2
mulss %xmm4, %xmm2
addss %xmm3, %xmm2
sqrtss %xmm2, %xmm2
xorps %xmm3, %xmm3
ucomiss %xmm3, %xmm4
jne 0x36e1
jp 0x36e1
ucomiss %xmm3, %xmm0
jbe 0x373d
movaps 0x4de1(%rip), %xmm0     # 0x84c0
jmp 0x3744
movss %xmm1, 0xc(%rsp)
divss %xmm4, %xmm0
cvtss2sd %xmm0, %xmm0
movaps %xmm4, 0x20(%rsp)
movaps %xmm2, 0x10(%rsp)
callq 0x2150
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 0x3735
cvtss2sd %xmm1, %xmm1
addsd 0x4d79(%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 0x3748
movaps 0x4d6c(%rip), %xmm0     # 0x84b0
movss %xmm2, %xmm0            # xmm0 = xmm2[0],xmm0[1,2,3]
addq $0x38, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/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, 0x4(%rsp)
cvtss2sd %xmm0, %xmm1
movaps %xmm1, 0x20(%rsp)
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
callq 0x20f0
movaps %xmm0, 0x10(%rsp)
movsd 0x8(%rsp), %xmm0
callq 0x22b0
movapd 0x10(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd 0x20(%rsp), %xmm0
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm1, %xmm0
cvtpd2ps %xmm0, %xmm0
movss 0x4(%rsp), %xmm1
addq $0x38, %rsp
retq
// File: /workspace/github_c_makefile_star2_O2/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:
movaps %xmm1, %xmm2
mulss %xmm1, %xmm2
movaps %xmm0, %xmm3
mulss %xmm0, %xmm3
addss %xmm2, %xmm3
sqrtss %xmm3, %xmm2
movaps %xmm0, %xmm3
shufps $0x55, %xmm0, %xmm3     # xmm3 = xmm3[1,1],xmm0[1,1]
movss %xmm3, 0x4(%rdi)
divss %xmm2, %xmm0
movss %xmm0, (%rdi)
divss %xmm2, %xmm1
movss %xmm1, 0x8(%rdi)
movaps %xmm2, %xmm0
retq
nop
// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %r15
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
sqrtss %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, 0x20(%rsp)
movss %xmm1, 0xc(%rsp)
callq 0x5215
testl %eax, %eax
js 0x5205
movq 0x10(%rsp), %r12
movl 0x18(%rsp), %ebp
leaq 0x30(%rsp), %r14
movaps 0x20(%rsp), %xmm0
movss 0xc(%rsp), %xmm1
movq %r12, %rdi
movl %ebp, %esi
movq %r14, %rdx
movq %r15, %rcx
callq 0x5546
andl $0x0, (%rbx)
movslq %ebp, %rcx
movslq %r12d, %rdx
shlq $0x3, %rdx
addq 0x1478(%r15), %rdx
xorps %xmm0, %xmm0
xorl %eax, %eax
shlq $0x2, %rcx
xorl %esi, %esi
cmpq $0x2, %rsi
je 0x5208
movq (%rdx,%rsi,8), %rdi
addq %rcx, %rdi
xorl %r8d, %r8d
cmpq $0x2, %r8
je 0x51fc
movss (%r14,%r8,4), %xmm1
mulss (%rdi,%r8,4), %xmm1
addss %xmm1, %xmm0
movss %xmm0, (%rbx)
incq %r8
jmp 0x51dd
incq %rsi
addq $0x8, %r14
jmp 0x51cd
pushq $0x1
popq %rax
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/radforddc[P]icpc_siggen/fields.c
// Function: grid_weights
static int grid_weights(cyl_pt pt, cyl_int_pt ipt, float out[2][2],
			MJD_Siggen_Setup *setup){
  float r, z;

  r = (pt.r - setup->rmin)/setup->rstep - ipt.r;
  z = (pt.z - setup->zmin)/setup->zstep - ipt.z;

  out[0][0] = (1.0 - r) * (1.0 - z);
  out[0][1] = (1.0 - r) *        z;
  out[1][0] =        r  * (1.0 - z);
  out[1][1] =        r  *        z;
  return 0;
}

// Assembly:
subss 0x3b0(%rcx), %xmm0
divss 0x3b8(%rcx), %xmm0
cvtsi2ss %edi, %xmm2
subss %xmm2, %xmm0
subss 0x3bc(%rcx), %xmm1
divss 0x3c4(%rcx), %xmm1
cvtsi2ss %esi, %xmm2
subss %xmm2, %xmm1
cvtss2sd %xmm0, %xmm2
movsd 0x2b16(%rip), %xmm3     # 0x8098
movapd %xmm3, %xmm4
subsd %xmm2, %xmm4
cvtss2sd %xmm1, %xmm5
subsd %xmm5, %xmm3
unpcklpd %xmm4, %xmm4            # xmm4 = xmm4[0,0]
movapd %xmm3, %xmm6
unpcklpd %xmm5, %xmm6            # xmm6 = xmm6[0],xmm5[0]
mulpd %xmm4, %xmm6
cvtpd2ps %xmm6, %xmm4
mulsd %xmm2, %xmm3
cvtsd2ss %xmm3, %xmm2
movlpd %xmm4, (%rdx)
movss %xmm2, 0x8(%rdx)
mulss %xmm0, %xmm1
movss %xmm1, 0xc(%rdx)
retq
// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x1470(%rdi), %r14
xorl %r15d, %r15d
movss 0x3b4(%rbx), %xmm0
subss 0x3b0(%rbx), %xmm0
divss 0x3b8(%rbx), %xmm0
callq 0x2180
movq 0x1470(%rbx), %rdi
cmpq %r15, %rax
jl 0x5a18
movq (%rdi,%r15,8), %rdi
callq 0x2140
movq 0x1478(%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x2140
incq %r15
jmp 0x59d1
callq 0x2140
movq 0x1478(%rbx), %rdi
callq 0x2140
movq 0x3d8(%rbx), %rdi
callq 0x2140
andq $0x0, 0x3d8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
pushq $0x1
popq %rax
popq %rbx
popq %r14
popq %r15
retq