LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/free/free.c
// Function: mp_info
void mp_info() {
    for (int i = 0; i < mp.bucket_number; ++i) {
        printf("bucket %3d, usage " SIZE_TYPE_SMALL_FORMAT
               "/" SIZE_TYPE_SMALL_FORMAT " %.2f%%, " SIZE_TYPE_SMALL_FORMAT
               " left\n",
               i, mp.length[i], mp.max_length[i],
               (mp.max_length[i] == 0
                    ? 100
                    : (double)mp.length[i] / mp.max_length[i] * 100),
               mp.max_length[i] - mp.length[i]);
    }
    printf("total: max_length: " SIZE_TYPE_BIG_FORMAT
           "  now_length: " SIZE_TYPE_BIG_FORMAT "\n",
           mp_get_max_length(), mp_get_length());
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl 0x4b23(%rip), %ecx      # 0x7194
testl %ecx, %ecx
jle 0x26d9
xorl %ebx, %ebx
leaq 0x1ab6(%rip), %r14      # 0x4134
movq 0x4afb(%rip), %rax      # 0x7180
movl (%rax,%rbx,4), %edx
movq 0x4af9(%rip), %rax      # 0x7188
movl (%rax,%rbx,4), %ecx
movsd 0x1a76(%rip), %xmm0     # 0x4110
testl %ecx, %ecx
je 0x26b8
xorps %xmm0, %xmm0
cvtsi2sd %edx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
divsd %xmm1, %xmm0
mulsd 0x1a58(%rip), %xmm0     # 0x4110
movl %ecx, %r8d
subl %edx, %r8d
movq %r14, %rdi
movl %ebx, %esi
movb $0x1, %al
callq 0x10b0
incq %rbx
movslq 0x4ac0(%rip), %rcx      # 0x7194
cmpq %rcx, %rbx
jl 0x267e
movl %ecx, %eax
testl %ecx, %ecx
jle 0x26fb
movq 0x4aa2(%rip), %rdx      # 0x7188
xorl %edi, %edi
xorl %esi, %esi
movslq (%rdx,%rdi,4), %r8
addq %r8, %rsi
incq %rdi
cmpq %rdi, %rax
jne 0x26ea
jmp 0x26fd
xorl %esi, %esi
testl %ecx, %ecx
jle 0x271d
movq 0x4a78(%rip), %rcx      # 0x7180
xorl %edi, %edi
xorl %edx, %edx
movslq (%rcx,%rdi,4), %r8
addq %r8, %rdx
incq %rdi
cmpq %rdi, %rax
jne 0x270c
jmp 0x271f
xorl %edx, %edx
leaq 0x1a37(%rip), %rdi      # 0x415d
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x10b0
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/free/free.c
// Function: mp_get_length
size_type_big mp_get_length() {
    size_type_big now_length = 0;
    for (int i = 0; i < mp.bucket_number; ++i) {
        now_length += mp.length[i];
    }
    return now_length;
}

// Assembly:
movslq 0x4a59(%rip), %rcx      # 0x7194
testq %rcx, %rcx
jle 0x275b
movq 0x4a39(%rip), %rdx      # 0x7180
xorl %esi, %esi
xorl %eax, %eax
movslq (%rdx,%rsi,4), %rdi
addq %rdi, %rax
incq %rsi
cmpq %rsi, %rcx
jne 0x274b
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/free/free.c
// Function: mp_get_max_length
size_type_big mp_get_max_length() {
    size_type_big max_length = 0;
    for (int i = 0; i < mp.bucket_number; ++i) {
        max_length += mp.max_length[i];
    }
    return max_length;
}

// Assembly:
movslq 0x4a2f(%rip), %rcx      # 0x7194
testq %rcx, %rcx
jle 0x2785
movq 0x4a17(%rip), %rdx      # 0x7188
xorl %esi, %esi
xorl %eax, %eax
movslq (%rdx,%rsi,4), %rdi
addq %rdi, %rax
incq %rsi
cmpq %rsi, %rcx
jne 0x2775
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/free/free.c
// Function: mp_new
void *mp_new(size_type_small length) {
    int bucket;
    for (bucket = 0; bucket < mp.bucket_number; ++bucket) {
        if (mp.length[bucket] + length <= mp.max_length[bucket]) {
            void *ptr = mp.head[bucket] + mp.length[bucket];
            mp.length[bucket] += length;
            return ptr;
        }
    }

    printf("Can not make more memory. The memory pool is "
           "only " SIZE_TYPE_BIG_FORMAT " bytes, "
           "and " SIZE_TYPE_BIG_FORMAT
           " used, can not make more " SIZE_TYPE_SMALL_FORMAT " bytes\n",
           mp_get_max_length(), mp_get_length(), length);
    mp.error_callback();
    return NULL;
}

// Assembly:
pushq %rbx
movl %edi, %ecx
movslq 0x4a02(%rip), %rax      # 0x7194
testq %rax, %rax
jle 0x27bd
movq 0x49e2(%rip), %rdx      # 0x7180
movq 0x49e3(%rip), %rdi      # 0x7188
xorl %esi, %esi
movslq (%rdx,%rsi,4), %rbx
leal (%rbx,%rcx), %r8d
cmpl (%rdi,%rsi,4), %r8d
jle 0x27dd
incq %rsi
cmpq %rsi, %rax
jne 0x27a7
testl %eax, %eax
jle 0x27ee
movq 0x49c0(%rip), %rdx      # 0x7188
xorl %edi, %edi
xorl %esi, %esi
movslq (%rdx,%rdi,4), %r8
addq %r8, %rsi
incq %rdi
cmpq %rdi, %rax
jne 0x27cc
jmp 0x27f0
movq 0x4994(%rip), %rax      # 0x7178
addq (%rax,%rsi,8), %rbx
movl %r8d, (%rdx,%rsi,4)
jmp 0x282b
xorl %esi, %esi
testl %eax, %eax
jle 0x2811
movq 0x4985(%rip), %rdi      # 0x7180
xorl %r8d, %r8d
xorl %edx, %edx
movslq (%rdi,%r8,4), %r9
addq %r9, %rdx
incq %r8
cmpq %r8, %rax
jne 0x2800
jmp 0x2813
xorl %edx, %edx
leaq 0x196c(%rip), %rdi      # 0x4186
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x10b0
xorl %eax, %eax
callq *0x496d(%rip)           # 0x7198
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/http/http.c
// Function: get_page
int get_page(char *prefix, char *url, char *ip, uint16_t port, char *reponse,
             int reponse_size) {
    int sock = socket(AF_INET, SOCK_STREAM, 0);

    struct sockaddr_in serv_addr;
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = inet_addr(ip);
    serv_addr.sin_port = htons(port);

    int con = connect(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
    if (con != 0) {
        return F;
    }

    char request[MAX_REQUEST_LENGTH] = "\0";
    strcat(request, "GET ");
    strcat(request, prefix);
    strcat(request, url);
    strcat(request, " HTTP/1.1\r\n");
    strcat(request, "Host:");
    strcat(request, ip);
    strcat(request, "\r\nConnection:Keep-alive\r\n\r\n");

    write(sock, request, sizeof(request));

    int read_length = 0;
    while (1) {
        int ret =
            read(sock, reponse + read_length, reponse_size - read_length - 1);
        if (ret <= 0) {
            break;
        }
        read_length += ret;
    }

    close(sock);
    return read_length;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x828, %rsp            # imm = 0x828
movl %r9d, %ebx
movq %r8, %r14
movl %ecx, %r12d
movq %rdx, %r15
movq %rsi, 0x8(%rsp)
movq %rdi, (%rsp)
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x1210
movl %eax, %ebp
leaq 0x10(%rsp), %r13
movw $0x2, (%r13)
movq %r15, %rdi
callq 0x1100
movl %eax, 0x4(%r13)
rolw $0x8, %r12w
movw %r12w, 0x2(%r13)
movl %ebp, %edi
movq %r13, %rsi
movl $0x10, %edx
callq 0x11d0
testl %eax, %eax
je 0x28ad
leaq 0x1817(%rip), %rax      # 0x40bc
movl (%rax), %r15d
jmp 0x2996
leaq 0x20(%rsp), %r12
movl $0x800, %edx            # imm = 0x800
movq %r12, %rdi
xorl %esi, %esi
callq 0x10c0
movq %r12, %rdi
callq 0x10a0
movl $0x20544547, 0x20(%rsp,%rax) # imm = 0x20544547
movb $0x0, 0x24(%rsp,%rax)
movq %r12, %rdi
movq (%rsp), %rsi
callq 0x11b0
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0x11b0
movq %r12, %rdi
callq 0x10a0
movabsq $0x2e312f5054544820, %rcx # imm = 0x2E312F5054544820
movq %rcx, 0x20(%rsp,%rax)
movl $0xa0d31, 0x28(%rsp,%rax) # imm = 0xA0D31
movq %r12, %rdi
callq 0x10a0
movl $0x74736f48, 0x20(%rsp,%rax) # imm = 0x74736F48
movw $0x3a, 0x24(%rsp,%rax)
movq %r12, %rdi
movq %r15, %rsi
callq 0x11b0
movq %r12, %rdi
callq 0x10a0
movups 0x18c5(%rip), %xmm0     # 0x4204
movups %xmm0, 0x20(%rsp,%rax)
movups 0x18c5(%rip), %xmm0     # 0x4210
movups %xmm0, 0x2c(%rsp,%rax)
movl $0x800, %edx            # imm = 0x800
movl %ebp, %edi
movq %r12, %rsi
callq 0x1070
xorl %r15d, %r15d
xorl %r13d, %r13d
movl %r15d, %r12d
movl %r15d, %esi
addq %r14, %rsi
movl %r15d, %eax
notl %eax
addl %ebx, %eax
movslq %eax, %rdx
movl %ebp, %edi
callq 0x10f0
testl %eax, %eax
movl %eax, %r15d
cmovlel %r13d, %r15d
addl %r12d, %r15d
testl %eax, %eax
jg 0x2965
movl %ebp, %edi
callq 0x10e0
movl %r15d, %eax
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/kmp/kmp.c
// Function: kmp_get_next
void kmp_get_next(char *s, int *next) {
    next[0] = -1;

    for (int i = 1;; ++i) {
        if (s[i] == '\0')
            break;
        int t = next[i - 1];
        while (t != -1 && s[t] != s[i - 1])
            t = next[t];
        next[i] = (s[i - 1] == s[t] ? t + 1 : 0);
    }
}

// Assembly:
movl $0xffffffff, (%rsi)     # imm = 0xFFFFFFFF
cmpb $0x0, 0x1(%rdi)
je 0x29f7
movl $0x1, %ecx
xorl %eax, %eax
leaq -0x1(%rcx), %r8
movq %r8, %rdx
movslq (%rsi,%rdx,4), %rdx
cmpq $-0x1, %rdx
je 0x29da
movb (%rdi,%rdx), %r9b
cmpb (%rdi,%r8), %r9b
jne 0x29c6
movb -0x1(%rdi,%rcx), %r8b
cmpb (%rdi,%rdx), %r8b
leal 0x1(%rdx), %edx
cmovnel %eax, %edx
movl %edx, (%rsi,%rcx,4)
cmpb $0x0, 0x1(%rdi,%rcx)
leaq 0x1(%rcx), %rcx
jne 0x29bf
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/kmp/kmp.c
// Function: kmp_char
void kmp_char(char c, char *pattern, int *pattern_pos, int *next, int *ans) {
    while (*pattern_pos != -1 && compare_char_macro(c, pattern[*pattern_pos])) {
        *pattern_pos = next[*pattern_pos];
    }
    if (!compare_char_macro(pattern[++(*pattern_pos)], '\0')) {
        ++(*ans);
        *pattern_pos =
            next[*pattern_pos - 1] + (next[*pattern_pos - 1] == 0 ? 0 : 1);
    }
}

// Assembly:
movl (%rdx), %eax
cmpl $-0x1, %eax
je 0x2a26
leaq 0x476a(%rip), %r9       # 0x7170
movq (%r9), %r10
incq %r10
movq %r10, (%r9)
movslq %eax, %r11
cmpb %dil, (%rsi,%r11)
je 0x2a26
movl (%rcx,%r11,4), %eax
movl %eax, (%rdx)
incq %r10
cmpl $-0x1, %eax
jne 0x2a0c
leaq 0x4743(%rip), %rdi      # 0x7170
incq (%rdi)
cltq
leaq 0x1(%rax), %rdi
movl %edi, (%rdx)
cmpb $0x0, 0x1(%rsi,%rax)
je 0x2a40
retq
incl (%r8)
movslq (%rdx), %rax
movl -0x4(%rcx,%rax,4), %eax
cmpl $0x1, %eax
sbbl $-0x1, %eax
movl %eax, (%rdx)
retq
nop
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/link_list/link_list.c
// Function: lk_init
link_list *lk_init() {
    link_list *lk = mp_new(sizeof(link_list));
    lk->head = lk->tail = NULL;
    lk->length = 0;
    return lk;
}

// Assembly:
pushq %rax
movl $0x20, %edi
callq 0x2788
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x0, 0x10(%rax)
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/link_list/link_list.c
// Function: lk_node
linked_node *lk_node(void *ptr) {
    linked_node *node = NULL;
    if (_link_node_unused == NULL) {
        node = mp_new(sizeof(linked_node));
    } else {
        node = _link_node_unused;
        _link_node_unused = _link_node_unused->next;
    }
    node->next = NULL;
    node->value = ptr;
    return node;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x4727(%rip), %rax      # 0x71a0
testq %rax, %rax
je 0x2a8b
movq 0x8(%rax), %rcx
movq %rcx, 0x4717(%rip)      # 0x71a0
jmp 0x2a95
movl $0x10, %edi
callq 0x2788
movq $0x0, 0x8(%rax)
movq %rbx, (%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/link_list/link_list.c
// Function: lk_add
void lk_add(link_list *lk, void *ptr) {
    linked_node *node = lk_node(ptr);
    if (lk_empty(lk)) {
        lk->head = lk->tail = node;
    } else {
        lk->tail->next = node;
        lk->tail = node;
    }
    ++lk->length;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x46ed(%rip), %rax      # 0x71a0
testq %rax, %rax
je 0x2ac5
movq 0x8(%rax), %rcx
movq %rcx, 0x46dd(%rip)      # 0x71a0
jmp 0x2acf
movl $0x10, %edi
callq 0x2788
movq $0x0, 0x8(%rax)
movq %r14, (%rax)
cmpq $0x0, (%rbx)
jne 0x2aed
cmpq $0x0, 0x8(%rbx)
movq %rbx, %rdx
movq %rbx, %rcx
je 0x2af5
leaq 0x8(%rbx), %rcx
movq 0x8(%rbx), %rdx
movq %rax, 0x8(%rdx)
movq %rax, (%rcx)
incl 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/link_list/link_list.c
// Function: lk_remove
void lk_remove(link_list *lk, linked_node *ptr) {
    linked_node *p = lk->head;

    if (p == ptr) {
        p = lk->head = ptr->next;
    } else {
        while (p != NULL && p->next != ptr) {
            p = p->next;
        }
        if (p != NULL && p->next == ptr) {
            p->next = ptr->next;
            --lk->length;
            ptr->next = _link_node_unused;
            _link_node_unused = ptr->next;
        }
    }
    if (lk->tail == ptr) {
        lk->tail = p;
    }
}

// Assembly:
movq (%rdi), %rcx
cmpq %rsi, %rcx
je 0x2b4c
testq %rcx, %rcx
je 0x2b55
movq %rcx, %rax
movq 0x8(%rcx), %rcx
cmpq %rsi, %rcx
jne 0x2b23
movq 0x8(%rsi), %rcx
movq %rcx, 0x8(%rax)
decl 0x10(%rdi)
movq 0x465a(%rip), %rcx      # 0x71a0
movq %rcx, 0x8(%rsi)
jmp 0x2b57
movq 0x8(%rsi), %rax
movq %rax, (%rdi)
jmp 0x2b57
xorl %eax, %eax
cmpq %rsi, 0x8(%rdi)
je 0x2b5e
retq
movq %rax, 0x8(%rdi)
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/link_list/link_list.c
// Function: lk_search
linked_node *lk_search(link_list *lk, void *target,
                       boolean (*compare)(void *value, void *target)) {
    if (lk_empty(lk)) {
        return NULL;
    }
    linked_node *ptr = lk->head;

    while (ptr != NULL) {
        if (compare(ptr->value, target)) {
            break;
        }
        ptr = ptr->next;
    }
    return ptr;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
cmpq $0x0, (%rdi)
jne 0x2b7b
cmpq $0x0, 0x8(%rdi)
je 0x2b96
movq (%rdi), %rbx
testq %rbx, %rbx
je 0x2b98
movq (%rbx), %rdi
movq %r15, %rsi
callq *%r14
testl %eax, %eax
jne 0x2b98
movq 0x8(%rbx), %rbx
jmp 0x2b7e
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/print/print.c
// Function: print
int print(int c, char *fmt, ...) {
    va_list args; //定义一个va_list类型的变量，用来储存单个参数
    va_start(args, fmt); //使args指向可变参数的第一个参数
    begin(c);
    int ret = vprintf(fmt, args); //必须用vprintf等带V的
    end();
    va_end(args); //结束可变参数的获取
    return ret;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %rbx
leaq 0x20(%rsp), %rsi
movq %rdx, 0x10(%rsi)
movq %rcx, 0x18(%rsi)
movq %r8, 0x20(%rsi)
movq %r9, 0x28(%rsi)
testb %al, %al
je 0x2c2c
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %r14
movq %rsi, 0x10(%r14)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%r14)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%r14)
callq 0x2ba4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1160
movl %eax, %ebx
leaq 0x15fb(%rip), %rdi      # 0x4260
xorl %eax, %eax
callq 0x10b0
movl %ebx, %eax
addq $0xd8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/print/print.c
// Function: print_ok
int print_ok(char *fmt, ...) {
    va_list args;
    va_start(args, fmt);
    begin(GREEN);
    int ret = vfprintf(stdout, fmt, args);
    end();
    va_end(args);
    return ret;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0x2cda
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %r14
movq %rdi, 0x10(%r14)
leaq 0xf0(%rsp), %rax
movq %rax, 0x8(%r14)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%r14)
leaq 0x152f(%rip), %rdi      # 0x4230
xorl %eax, %eax
callq 0x10b0
movq 0x42c9(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x11a0
movl %eax, %ebx
leaq 0x153a(%rip), %rdi      # 0x4260
xorl %eax, %eax
callq 0x10b0
movl %ebx, %eax
addq $0xd8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/radix_tree/radix_tree.c
// Function: rt_init
radix_tree *rt_init(int k) {
    radix_tree *rt = mp_new(sizeof(radix_tree));
    rt->k = k;
    rt->temp = bits_init();
    return rt;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0x18, %edi
callq 0x2788
movq %rax, %r14
movl %ebx, 0x8(%rax)
xorl %eax, %eax
callq 0x1798
movq %rax, 0x10(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/radix_tree/radix_tree.c
// Function: rt_add
void rt_add(radix_tree *rt, void *value, int size) {
    rt->temp->start = 0;
    rt->temp->end = size * 8;
    rt->temp->value = value;

    // printf("Add %s ", (char *)value);
    // bits_print(rt->temp);
    // printf("\n");

    rt->root = rtn_add(rt->root, rt->temp, rt->k, T);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rax
movl $0x0, 0x8(%rax)
shll $0x3, %edx
movl %edx, 0xc(%rax)
movq %rsi, (%rax)
movq (%rdi), %rdi
movl 0x8(%rbx), %edx
leaq 0x132b(%rip), %rcx      # 0x40b8
movl (%rcx), %ecx
movq %rax, %rsi
callq 0x2ee1
movq %rax, (%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/radix_tree/radix_tree.c
// Function: rt_exist
boolean rt_exist(radix_tree *rt, void *value, int size) {
    rt->temp->start = 0;
    rt->temp->end = size * 8;
    rt->temp->value = value;

    // printf("Search %s ", (char *)value);
    // bits_print(rt->temp);
    // printf("\n");

    return rtn_exist(rt->root, rt->temp, rt->k);
}

// Assembly:
movq 0x10(%rdi), %rax
movl $0x0, 0x8(%rax)
shll $0x3, %edx
movl %edx, 0xc(%rax)
movq %rsi, (%rax)
movq (%rdi), %rcx
movl 0x8(%rdi), %edx
movq %rcx, %rdi
movq %rax, %rsi
jmp 0x3023
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/radix_tree/radix_tree_node.c
// Function: rtn_get_child_key
int rtn_get_child_key(bits *value, int prefix, int k) {
    int l = bits_len(value);
    if (prefix > l) {
        print_err("Uncepted error: prefix %d and value is ", prefix);
        bits_print(value);
        print_err("\n");
        exit(1);
    }
    int key = 0;
    for (int i = 0; i < k && i + prefix < l; ++i) {
        key = (key << 1) | bits_get(value, i + prefix);
    }
    return key;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %r14d
movl %esi, %ebp
movq %rdi, %rbx
callq 0x19ce
cmpl %ebp, %eax
jl 0x2e67
testl %r14d, %r14d
jle 0x2e58
movl %eax, %r15d
xorl %r12d, %r12d
cmpl %ebp, %r15d
je 0x2e5b
addl %r12d, %r12d
movq %rbx, %rdi
movl %ebp, %esi
callq 0x1991
orl %eax, %r12d
incl %ebp
decl %r14d
jne 0x2e3a
jmp 0x2e5b
xorl %r12d, %r12d
movl %r12d, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x141a(%rip), %rdi      # 0x4288
movl %ebp, %esi
xorl %eax, %eax
callq 0x1230
movq %rbx, %rdi
callq 0x1a8b
leaq 0x122d(%rip), %rdi      # 0x40b3
xorl %eax, %eax
callq 0x1230
movl $0x1, %edi
callq 0x11c0
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/radix_tree/radix_tree_node.c
// Function: rtn_init
radix_tree_node *rtn_init(int k) {
    int m = pow2(k);
    ++_radix_node_number;
    _radix_nodemem += sizeof(radix_tree_node) + sizeof(radix_tree_node *) * m;
    radix_tree_node *rtn = mp_new(sizeof(radix_tree_node));
    rtn->children = mp_new(sizeof(radix_tree_node *) * m);
    return rtn;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
callq 0x2de4
incl 0x4302(%rip)            # 0x71a8
movl 0x4304(%rip), %ecx      # 0x71b0
leal (,%rax,8), %ebx
leal (%rcx,%rax,8), %eax
addl $0x18, %eax
movl %eax, 0x42f1(%rip)      # 0x71b0
movl $0x18, %edi
callq 0x2788
movq %rax, %r14
movl %ebx, %edi
callq 0x2788
movq %rax, (%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/radix_tree/radix_tree_node.c
// Function: rtn_exist
boolean rtn_exist(radix_tree_node *rtn, bits *value, int k) {
    if (rtn == NULL) {
        return F;
    }
    ++compare_number;

    int prefix = bits_prefix(rtn->value, value, k);
    if (prefix != bits_len(rtn->value)) {
        return F;
    }

    if (prefix == bits_len(value) && rtn->end_of_value == T) {
        return T;
    }

    int key = rtn_get_child_key(value, prefix, k);
    value->start += prefix;

    return rtn_exist(rtn->children[key], value, k);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x4133(%rip), %r12      # 0x7170
leaq 0x1074(%rip), %r13      # 0x40b8
testq %r15, %r15
je 0x309b
incq (%r12)
movq 0x10(%r15), %rdi
movq %r14, %rsi
movl %ebx, %edx
callq 0x19d5
movl %eax, %ebp
movq 0x10(%r15), %rdi
callq 0x19ce
cmpl %eax, %ebp
jne 0x309b
movq %r14, %rdi
callq 0x19ce
cmpl %eax, %ebp
jne 0x3080
movl (%r13), %eax
cmpl %eax, 0x8(%r15)
je 0x30a4
movq %r14, %rdi
movl %ebp, %esi
movl %ebx, %edx
callq 0x2e16
addl %ebp, 0x8(%r14)
movq (%r15), %rcx
cltq
movq (%rcx,%rax,8), %r15
jmp 0x3044
leaq 0x101a(%rip), %rax      # 0x40bc
movl (%rax), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/radix_tree/radix_tree_node.c
// Function: rtn_print
void rtn_print(radix_tree_node *rtn, int m) {
    if (rtn == NULL) {
        return;
    }
    printf("%p %d ", rtn, rtn->end_of_value);
    bits_print(rtn->value);
    printf("\n\t");
    for (int i = 0; i < m; ++i) {
        printf("%p ", rtn->children[i]);
    }
    printf("\n");

    for (int i = 0; i < m; ++i) {
        rtn_print(rtn->children[i], m);
    }
}

// Assembly:
testq %rdi, %rdi
je 0x314f
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movl 0x8(%rdi), %edx
leaq 0x11dc(%rip), %rdi      # 0x42b0
movq %r14, %rsi
xorl %eax, %eax
callq 0x10b0
movq 0x10(%r14), %rdi
callq 0x1a8b
leaq 0x11c9(%rip), %rdi      # 0x42b7
xorl %eax, %eax
callq 0x10b0
movl %ebx, %r12d
testl %ebx, %ebx
jle 0x311f
leaq 0x11b7(%rip), %r15      # 0x42ba
xorl %r13d, %r13d
movq (%r14), %rax
movq (%rax,%r13,8), %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0x10b0
incq %r13
cmpq %r13, %r12
jne 0x3106
movl $0xa, %edi
callq 0x1030
testl %ebx, %ebx
jle 0x3146
xorl %r15d, %r15d
movq (%r14), %rax
movq (%rax,%r15,8), %rdi
movl %ebx, %esi
callq 0x30b3
incq %r15
cmpq %r15, %r12
jne 0x3130
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/thread/thread.c
// Function: tp_new
thread_pool *tp_new(int thread_number, int mutex_number, thread_function tf) {
    thread_pool *tp = mp_new(sizeof(thread_pool));
    tp->thread_number = thread_number;
    tp->mutex_number = mutex_number;

    tp->thread_list = mp_new(sizeof(pthread_t) * thread_number);

    tp->mutex = mp_new(sizeof(pthread_mutex_t *) * mutex_number);
    for (int i = 0; i < tp->mutex_number; ++i) {
        tp->mutex[i] = mp_new(sizeof(pthread_mutex_t));
        pthread_mutex_init(tp->mutex[i], NULL);
    }

    for (int i = 0; i < tp->thread_number; ++i) {
        int ret = pthread_create(&tp->thread_list[i], NULL, tf, tp);
        if (ret != 0) {
            perror("pthread_create error:" + ret);
            exit(EXIT_FAILURE);
        }
    }

    return tp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movl %esi, %ebp
movl %edi, %r15d
movl $0x18, %edi
callq 0x2788
movq %rax, %r14
movl %r15d, (%rax)
movl %ebp, 0x4(%rax)
shll $0x3, %r15d
movl %r15d, %edi
callq 0x2788
movq %rax, 0x8(%r14)
shll $0x3, %ebp
movl %ebp, %edi
callq 0x2788
movq %rax, 0x10(%r14)
cmpl $0x0, 0x4(%r14)
jle 0x3338
xorl %r15d, %r15d
movl $0x28, %edi
callq 0x2788
movq 0x10(%r14), %rcx
movq %rax, (%rcx,%r15,8)
movq 0x10(%r14), %rax
movq (%rax,%r15,8), %rdi
xorl %esi, %esi
callq 0x11f0
incq %r15
movslq 0x4(%r14), %rax
cmpq %rax, %r15
jl 0x330b
cmpl $0x0, (%r14)
jle 0x336b
xorl %r15d, %r15d
xorl %r12d, %r12d
movq 0x8(%r14), %rdi
addq %r15, %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x1170
testl %eax, %eax
jne 0x3377
incq %r12
movslq (%r14), %rax
addq $0x8, %r15
cmpq %rax, %r12
jl 0x3344
movq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x12f1
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/thread/thread.c
// Function: tp_wait
void tp_wait(thread_pool *tp) {
    for (int i = 0; i < tp->thread_number; ++i) {
        int ret = pthread_join(tp->thread_list[i], NULL);
        if (ret != 0) {
            perror("pthread_join error: " + ret);
            exit(EXIT_FAILURE);
        }
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
cmpl $0x0, (%rdi)
jle 0x33ab
movq %rdi, %rbx
xorl %r14d, %r14d
movq 0x8(%rbx), %rax
movq (%rax,%r14,8), %rdi
xorl %esi, %esi
callq 0x11e0
testl %eax, %eax
jne 0x33b3
incq %r14
movslq (%rbx), %rax
cmpq %rax, %r14
jl 0x338d
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl %eax, %edi
callq 0x130c
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/thread/thread.c
// Function: tp_lock
void tp_lock(thread_pool *tp, int idx) {
    int ret = pthread_mutex_lock(tp->mutex[idx]);
    if (ret != 0) {
        perror("pthread_mutex_lock error: " + ret);
        exit(EXIT_FAILURE);
    }
}

// Assembly:
pushq %rax
movq 0x10(%rdi), %rax
movslq %esi, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1200
testl %eax, %eax
jne 0x33d1
popq %rax
retq
movl %eax, %edi
callq 0x1327
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/hash_search/array_search/../../utils/thread/thread.c
// Function: tp_unlock
void tp_unlock(thread_pool *tp, int idx) {
    int ret = pthread_mutex_unlock(tp->mutex[idx]);
    if (ret != 0) {
        perror("pthread_mutex_unlock error: " + ret);
        exit(EXIT_FAILURE);
    }
}

// Assembly:
pushq %rax
movq 0x10(%rdi), %rax
movslq %esi, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x1140
testl %eax, %eax
jne 0x33ef
popq %rax
retq
movl %eax, %edi
callq 0x1342
nop
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/pattern_match/strstr/strstr.c
// Function: rollback
void rollback(int index) {
    // pos[index] = 0;
    // return;
    int     temp = 2;
    boolean end = F;
    while (!end) {
        for (int i = pos[index] - temp, p = 0;; --i, ++p) {
            if (i <= 0) {
                // match
                pos[index] = compare_char(string[i], patterns[index][p]) == 0
                                 ? p + 1
                                 : 0;
                end = T;
                break;
            }
            if (compare_char(string[i], patterns[index][p]) != 0) {
                ++temp;
                break;
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xcb2(%rip), %rax       # 0x40bc
movl (%rax), %r12d
testl %r12d, %r12d
jne 0x34bf
movslq %edi, %rbx
leaq 0xc98(%rip), %rax       # 0x40b8
movl (%rax), %ebp
movl $0x2, %r14d
movq 0x3d89(%rip), %rax      # 0x71b8
movl (%rax,%rbx,4), %eax
subl %r14d, %eax
jle 0x346e
movl %eax, %r15d
xorl %r13d, %r13d
movq 0x3d7c(%rip), %rax      # 0x71c0
movsbl (%rax,%r15), %edi
movq 0x3d78(%rip), %rax      # 0x71c8
movq (%rax,%rbx,8), %rax
movsbl (%rax,%r13), %esi
callq 0x245c
testl %eax, %eax
jne 0x34b3
incq %r13
decq %r15
jne 0x343d
xorl %eax, %eax
jmp 0x3471
xorl %r13d, %r13d
movq 0x3d48(%rip), %rcx      # 0x71c0
cltq
movsbl (%rcx,%rax), %edi
movq 0x3d43(%rip), %rax      # 0x71c8
movq (%rax,%rbx,8), %rax
movl %r13d, %ecx
movsbl (%rax,%rcx), %esi
callq 0x245c
incl %r13d
testl %eax, %eax
movl $0x0, %eax
cmovnel %eax, %r13d
movq 0x3d0e(%rip), %rax      # 0x71b8
movl %r13d, (%rax,%rbx,4)
movl %ebp, %r12d
jmp 0x34b6
incl %r14d
testl %r12d, %r12d
je 0x3428
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/pattern_match/strstr/strstr.c
// Function: match
void match(char c, int index) {
    if (compare_char(c, patterns[index][pos[index]++]) == 0) {
        if (compare_char('\0', patterns[index][pos[index]]) == 0) {
            ++count[index];
            rollback(index);
        }
    } else {
        rollback(index);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq 0x3ced(%rip), %rax      # 0x71c8
movslq %esi, %r14
movq (%rax,%r14,8), %rax
movq 0x3ccf(%rip), %rcx      # 0x71b8
movslq (%rcx,%r14,4), %rdx
leal 0x1(%rdx), %esi
movl %esi, (%rcx,%r14,4)
movsbl (%rax,%rdx), %esi
callq 0x245c
testl %eax, %eax
je 0x350f
movl %ebx, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x33f8
movq 0x3cb2(%rip), %rax      # 0x71c8
movq (%rax,%r14,8), %rax
movq 0x3c97(%rip), %rcx      # 0x71b8
movslq (%rcx,%r14,4), %rcx
movsbl (%rax,%rcx), %esi
xorl %edi, %edi
callq 0x245c
testl %eax, %eax
je 0x353c
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x3c8d(%rip), %rax      # 0x71d0
incl (%rax,%r14,4)
jmp 0x3501
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/pattern_match/strstr/strstr.c
// Function: compare
int compare(void *args, int i, int j) {
    char **args_patterns = (char **)(((void **)args)[0]);
    int *  args_count = (int *)(((void **)args)[1]);

    int res = args_count[j] - args_count[i];
    if (res == 0) {
        res = compare_string(args_patterns[i], args_patterns[j]);
    }
    return res;
}

// Assembly:
movq 0x8(%rdi), %r8
movslq %edx, %rcx
movl (%r8,%rcx,4), %eax
movslq %esi, %rdx
subl (%r8,%rdx,4), %eax
je 0x355e
retq
movq (%rdi), %rax
movq (%rax,%rdx,8), %rdi
movq (%rax,%rcx,8), %rsi
jmp 0x2468
// File: /workspace/github_c_makefile_star2_O1/OhYee[P]computer_application_programming_experiment/pattern_match/strstr/strstr.c
// Function: swap
void swap(void *args, int i, int j) {
    char **args_patterns = (char **)(((void **)args)[0]);
    int *  args_count = (int *)(((void **)args)[1]);

    char *temp_parrtern = args_patterns[i];
    args_patterns[i] = args_patterns[j];
    args_patterns[j] = temp_parrtern;

    int temp_count = args_count[i];
    args_count[i] = args_count[j];
    args_count[j] = temp_count;
}

// Assembly:
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
movslq %esi, %rsi
movq (%rax,%rsi,8), %rdi
movslq %edx, %rdx
movq (%rax,%rdx,8), %r8
movq %r8, (%rax,%rsi,8)
movq %rdi, (%rax,%rdx,8)
movl (%rcx,%rsi,4), %eax
movl (%rcx,%rdx,4), %edi
movl %edi, (%rcx,%rsi,4)
movl %eax, (%rcx,%rdx,4)
retq
// File: /workspace/github_c_makefile_star2_O1/eridanhq[P]miraclelib/sysoff.c
// Function: main
int main(int argc, char *argv[])
{
	int memfd;
	void *mapped_base;

	memfd = open("/dev/mem", O_RDWR | O_SYNC);
	if (memfd == -1) {
		printf("Can't open /dev/mem.\n");
		exit(0);
	}

	// Map memory
	mapped_base = mmap( (void *) MEM0_BASE_ADDRESS, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, memfd, SPI_BASE_ADDRESS);
	if (mapped_base == (void *) -1) {
		printf("Can't map the memory to user space.\n");
		exit(0);
	}

	/* ----------- INSERT CODE BELOW THIS LINE ------------ */

	sys_off_tx(mapped_base);

	/* ----------- INSERT CODE ABOVE THIS LINE ------------ */

	if (munmap(mapped_base, MAP_SIZE) == -1) {
		printf("Can't unmap memory from user space.\n");
		exit(0);
	}
	close(memfd);
	return 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
leaq 0xdbd(%rip), %rdi       # 0x2004
movl $0x101002, %esi         # imm = 0x101002
xorl %eax, %eax
callq 0x10f0
cmpl $-0x1, %eax
je 0x12b0
movl %eax, %ebx
movl $0x40000000, %edi       # imm = 0x40000000
movl $0x400000, %esi         # imm = 0x400000
movl $0x64000000, %r9d       # imm = 0x64000000
movl $0x3, %edx
movl $0x11, %ecx
movl %eax, %r8d
callq 0x1080
cmpq $-0x1, %rax
je 0x12b9
movq %rax, %r14
movq %rax, %rdi
callq 0x154c
movl $0x400000, %esi         # imm = 0x400000
movq %r14, %rdi
callq 0x10e0
cmpl $-0x1, %eax
je 0x12c2
movl %ebx, %edi
callq 0x10c0
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0xd9e(%rip), %rdi       # 0x2055
jmp 0x12c9
leaq 0xd71(%rip), %rdi       # 0x2031
jmp 0x12c9
leaq 0xd44(%rip), %rdi       # 0x200d
callq 0x1060
xorl %edi, %edi
callq 0x1120
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/eridanhq[P]miraclelib/miraclelib.c
// Function: set_sample_rate_tx
void set_sample_rate_tx(double rate, void *mapped_base)
{

	uint64_t val;
	unsigned int val_msb;
	unsigned int val_lsb;

	val = (uint64_t) round(ldexp(rate/160e6,40)); // do rate calc
	val_msb = (val >> 32) & 0xFF; // upper 8 bits
	val_lsb = val & 0xFFFFFFFF; // lower 32 bits
	/*
	   printf("rate: %f\n",rate);
	   printf("val=0x%" PRIX64 "\n", val);
	   printf("MSB: 0x%X\n",val_msb);
	   printf("LSB: 0x%X\n",val_lsb);
	   */

	*((unsigned int *) (mapped_base + (MAP_SIZE - (2<<2)))) = val_lsb; // write rate val LSB to maxaddr - 2
	*((unsigned int *) (mapped_base + (MAP_SIZE - (3<<2)))) = val_msb; // write rate val MSB to maxaddr - 3
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
divsd 0xd4d(%rip), %xmm0      # 0x2070
movl $0x28, %edi
callq 0x1030
callq 0x1040
cvttsd2si %xmm0, %rax
movq %rax, %rcx
subsd 0xd36(%rip), %xmm0      # 0x2078
cvttsd2si %xmm0, %rdx
sarq $0x3f, %rcx
andq %rcx, %rdx
orq %rax, %rdx
movl %edx, 0x3ffff8(%rbx)
shrq $0x20, %rdx
movzbl %dl, %eax
movl %eax, 0x3ffff4(%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/eridanhq[P]miraclelib/miraclelib.c
// Function: set_sig_tx
void set_sig_tx(char *filename, void *mapped_base)
{
	int wave[WAVE_SIZE];
	int N, counter;

	
	read_bin_file(filename, wave, &N);	

	// write array to FIFO memory
	for (counter = 0; counter <= N; counter = counter +1)
	{
		*((unsigned int *) (mapped_base+(counter << 2))) = wave[counter];
	}

	*((unsigned int *) (mapped_base+ (MAP_SIZE - (1<<2)))) = N; // write to maxaddr


}

// Assembly:
pushq %r14
pushq %rbx
subq $0x258018, %rsp         # imm = 0x258018
movq %rsi, %rbx
leaq 0x10(%rsp), %rsi
leaq 0xc(%rsp), %r14
movq %r14, %rdx
callq 0x13e0
movl (%r14), %eax
testl %eax, %eax
js 0x13cf
leaq 0x4(,%rax,4), %rcx
xorl %edx, %edx
movl 0x10(%rsp,%rdx), %esi
movslq %edx, %rdi
movl %esi, (%rbx,%rdi)
addq $0x4, %rdx
cmpq %rdx, %rcx
jne 0x13bc
movl %eax, 0x3ffffc(%rbx)
addq $0x258018, %rsp         # imm = 0x258018
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/eridanhq[P]miraclelib/miraclelib.c
// Function: read_bin_file
void read_bin_file(char *filename, int *array, int *N)
{
	FILE *fp;
	int c, c1, c2, counter;
	unsigned int c3, c4;
	int Continue;

	system("mount /dev/mmcblk0p1 /mnt");        

	counter = 0;
	fp = fopen(filename, "r");
	if (fp == NULL)
	{
		printf("FILE NOT FOUND\n");
		exit(0);
	}

	Continue = 1;
	while(Continue)
	{

		c1 = fgetc(fp);
		c2 = fgetc(fp);
		c2 = c2 << 8;
		c = c1 + c2;
		c3 = c & (0x0fff);  // bitwise AND 
		c3 = c3 << 16;    // I channel
		c1 = fgetc(fp);
		c2 = fgetc(fp);
		c2 = c2 << 8;
		c  = c1 + c2;
		c4 = c & (0x0fff);  // Q channel
		c4 = c3 + c4;
		array[counter] = c4;
		counter++;

		if (feof(fp))
		{
			//printf("\n\rfeof found\n\r");
			*N = counter-2;
			Continue = 0;
		}
	}
	fclose(fp);
	system("umount /mnt");
	return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0xc9c(%rip), %rdi       # 0x2097
callq 0x1090
leaq 0xd94(%rip), %rsi       # 0x219b
movq %r15, %rdi
callq 0x1100
testq %rax, %rax
je 0x149c
movq %rax, %r15
movl $0xfffffffe, %r13d      # imm = 0xFFFFFFFE
movq %r15, %rdi
callq 0x10b0
movl %eax, %ebp
movq %r15, %rdi
callq 0x10b0
shll $0x18, %eax
shll $0x10, %ebp
addl %eax, %ebp
andl $0xfff0000, %ebp        # imm = 0xFFF0000
movq %r15, %rdi
callq 0x10b0
movl %eax, %r12d
movq %r15, %rdi
callq 0x10b0
shll $0x8, %eax
addl %r12d, %eax
andl $0xfff, %eax            # imm = 0xFFF
orl %ebp, %eax
movl %eax, (%r14)
movq %r15, %rdi
callq 0x10d0
incl %r13d
addq $0x4, %r14
testl %eax, %eax
je 0x1421
movl %r13d, (%rbx)
movq %r15, %rdi
callq 0x1070
leaq 0xc54(%rip), %rdi       # 0x20dd
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1090
leaq 0xd0d(%rip), %rdi       # 0x21b0
callq 0x1060
xorl %edi, %edi
callq 0x1120
// File: /workspace/github_c_makefile_star2_O1/eridanhq[P]miraclelib/miraclelib.c
// Function: safe_off_tx
void safe_off_tx(void *mapped_base)
{
	int pwr_supp_reg;

	pwr_supp_reg = read_reg_tx(36, mapped_base); // Get supply state
	write_reg_tx(66,0,mapped_base); // Turn off signal

	pwr_supp_reg = pwr_supp_reg | 0x1; // Turn on filter
	write_reg_tx(36,pwr_supp_reg,mapped_base);
	usleep(100000); // 100ms
	//printf("pwr_supp_reg = %d\n", pwr_supp_reg);

	pwr_supp_reg = pwr_supp_reg & 0x7; // Turn off comparator
	write_reg_tx(36,pwr_supp_reg,mapped_base);
	usleep(100000); // 100ms
	//printf("pwr_supp_reg = %d\n", pwr_supp_reg);

	pwr_supp_reg = pwr_supp_reg & 0x5; // Turn off 20V
	write_reg_tx(36,pwr_supp_reg,mapped_base);
	usleep(100000); // 100ms
	//printf("pwr_supp_reg = %d\n", pwr_supp_reg);

	pwr_supp_reg = pwr_supp_reg & 0x1; // Turn off 5V
	write_reg_tx(36,pwr_supp_reg,mapped_base);
	//printf("pwr_supp_reg = %d\n", pwr_supp_reg);
	return;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl $0x24, (%rdi)
movl $0xfa, %edi
callq 0x1130
movl (%rbx), %ebp
orl $0x1, %ebp
movl $0x80000024, %r14d      # imm = 0x80000024
movl %r14d, (%rbx)
movl %ebp, 0xcc(%rbx)
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x1130
movl %ebp, %eax
andl $0x7, %eax
movl %r14d, (%rbx)
movl %eax, 0xcc(%rbx)
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x1130
andl $0x5, %ebp
movl %r14d, (%rbx)
movl %ebp, 0xcc(%rbx)
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x1130
movl %r14d, (%rbx)
movl $0x1, 0xcc(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/eridanhq[P]miraclelib/miraclelib.c
// Function: sys_off_tx
void sys_off_tx(void *mapped_base)
{
	int pwr_supp_reg;
	// Get current state of power supplies (pwr_supp_reg)
	pwr_supp_reg = read_reg_tx(36, mapped_base);
	//printf("pwr_supp_reg = %d\n", pwr_supp_reg);
	if (pwr_supp_reg >= 14)
	{
		printf("Turning OFF system...");
		safe_off_tx(mapped_base);
		write_reg_tx(32,0x1,mapped_base); // CS select bit
		write_reg_tx(33,0x000840,mapped_base); // Page DAC0 for TXEN control update.
		write_reg_tx(33,0x059604,mapped_base); // SPI turn on TXENx feature, but turn DAC0 off.
	
		printf("done.\n");
	}
	else if (pwr_supp_reg == 1)
	{
		printf("System is already off.\n");
	}
	else if (pwr_supp_reg == 0)
	{
		printf("CANNOT CONNECT TO MIRACLE. CHECK FMC CONNECTION,\n");
		printf("MAKE SURE MIRACLE POWER IS ON, AND TRY AGAIN.\n");
	}
	else
	{
		printf("SYSTEM IN UNDEFINED STATE\n");
		printf("SAFELY TURNING OFF...");
		safe_off_tx(mapped_base);
		printf("done.\n");
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl $0x24, (%rdi)
movl $0xfa, %edi
callq 0x1130
movl (%rbx), %eax
cmpl $0xe, %eax
jl 0x158f
leaq 0xb7b(%rip), %rdi       # 0x20e9
xorl %eax, %eax
callq 0x10a0
movq %rbx, %rdi
callq 0x14d7
movl $0x80000021, (%rbx)     # imm = 0x80000021
movl $0x59604, 0xcc(%rbx)    # imm = 0x59604
jmp 0x15d8
cmpl $0x1, %eax
je 0x15ad
testl %eax, %eax
jne 0x15b6
leaq 0xc7f(%rip), %rdi       # 0x221e
callq 0x1060
leaq 0xca4(%rip), %rdi       # 0x224f
jmp 0x15df
leaq 0xc0b(%rip), %rdi       # 0x21bf
jmp 0x15df
leaq 0xc41(%rip), %rdi       # 0x21fe
callq 0x1060
leaq 0xb36(%rip), %rdi       # 0x20ff
xorl %eax, %eax
callq 0x10a0
movq %rbx, %rdi
callq 0x14d7
leaq 0xc39(%rip), %rdi       # 0x2218
popq %rbx
jmp 0x1060
// File: /workspace/github_c_makefile_star2_O1/eridanhq[P]miraclelib/miraclelib.c
// Function: sys_on_tx
void sys_on_tx(void *mapped_base)
{
	int pwr_supp_reg;
	
	pwr_supp_reg = read_reg_tx(36,mapped_base); // Check state of power supplies
	//printf("pwr_supp_reg = %d\n", pwr_supp_reg);
	if (pwr_supp_reg == 1 || pwr_supp_reg == 5) // Acceptable power states
	{
		printf("Turning ON system...");
		write_reg_tx(36,5,mapped_base); // ensure 5V supply and filter is on
		usleep(100000); // 100ms
		//printf("pwr_supp_reg = %d\n", pwr_supp_reg);
		write_reg_tx(36,7,mapped_base); // Turn on 25V supply
		usleep(100000); // 100ms
		//printf("pwr_supp_reg = %d\n", pwr_supp_reg);
		write_reg_tx(36,15,mapped_base); // Turn on comparator
		usleep(100000); // 100ms
		//printf("pwr_supp_reg = %d\n", pwr_supp_reg);
		write_reg_tx(36,14,mapped_base); // Turn off filter
		//printf("pwr_supp_reg = %d\n", pwr_supp_reg);
		
		// Enabled AD9173 output
		write_reg_tx(32,0x1,mapped_base); // CS select bit
		write_reg_tx(33,0x000840,mapped_base); // Page DAC0 for TXEN control update.
		write_reg_tx(33,0x05960C,mapped_base); // SPI turn on TXENx feature
		printf("done.\n");
	}
	else if (pwr_supp_reg == 14)
	{
		printf("System is already on.\n");
	}
	else if (pwr_supp_reg == 0) // Cannot connect to interposer
	{
		printf("CANNOT CONNECT TO MIRACLE. CHECK FMC CONNECTION,\n");
		printf("MAKE SURE MIRACLE POWER IS ON, AND TRY AGAIN.\n");
	}
	else // Weird power states.  Ideally should never get to this state
	{
		printf("SYSTEM IN UNDEFINED STATE\n");
		printf("SAFELY TURNING OFF...");
		safe_off_tx(mapped_base);
		printf("done.\n");
		printf("PLEASE TRY AGAIN.\n");
	}
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x24, (%rdi)
movl $0xfa, %edi
callq 0x1130
movl (%rbx), %eax
movl %eax, %ecx
andl $-0x5, %ecx
cmpl $0x1, %ecx
jne 0x1675
leaq 0xb07(%rip), %rdi       # 0x2115
xorl %eax, %eax
callq 0x10a0
movl $0x80000024, %ebp       # imm = 0x80000024
movl %ebp, (%rbx)
movl $0x5, 0xcc(%rbx)
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x1130
movl %ebp, (%rbx)
movl $0x7, 0xcc(%rbx)
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x1130
movl %ebp, (%rbx)
movl $0xf, 0xcc(%rbx)
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x1130
movl $0x80000021, (%rbx)     # imm = 0x80000021
movl $0x5960c, 0xcc(%rbx)    # imm = 0x5960C
leaq 0xba5(%rip), %rdi       # 0x2218
jmp 0x16d1
cmpl $0xe, %eax
je 0x1693
testl %eax, %eax
jne 0x169c
leaq 0xb99(%rip), %rdi       # 0x221e
callq 0x1060
leaq 0xbbe(%rip), %rdi       # 0x224f
jmp 0x16d1
leaq 0xb4e(%rip), %rdi       # 0x21e8
jmp 0x16d1
leaq 0xb5b(%rip), %rdi       # 0x21fe
callq 0x1060
leaq 0xa50(%rip), %rdi       # 0x20ff
xorl %eax, %eax
callq 0x10a0
movq %rbx, %rdi
callq 0x14d7
leaq 0xb53(%rip), %rdi       # 0x2218
callq 0x1060
leaq 0xb05(%rip), %rdi       # 0x21d6
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1060
// File: /workspace/github_c_makefile_star2_O1/eridanhq[P]miraclelib/miraclelib.c
// Function: stat_tx
void stat_tx(void *mapped_base)
{
	int pwr_supp_val, pwr_ctrl_val;
	double f;
	pwr_supp_val = read_reg_tx(36,mapped_base); // get system power state
	pwr_ctrl_val = read_reg_tx(66,mapped_base); // get power level
	f = get_freq_tx();
	if (pwr_supp_val == 1)
	{
		printf("System is OFF.\n");
	}
	else if (pwr_supp_val == 14)
	{
		printf("System is ON.\n"); 
		printf("Power level (0-32767): %d\n", pwr_ctrl_val);
		printf("TX frequency: %.0lf\n", f);
	}
	else if (pwr_supp_val == 0) // cannot connect to interposer
	{
		printf("CANNOT CONNECT TO MIRACLE. CHECK FMC CONNECTION,\n");
		printf("MAKE SURE MIRACLE POWER IS ON, AND TRY AGAIN.\n");
	}
	else // should never get to this, but just in case turn off safely
	{
		printf("SYSTEM IN UNDEFINED STATE\n");
		printf("SAFELY TURNING OFF...");
		safe_off_tx(mapped_base);
		printf("done.\n");
	}
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movl $0x24, (%rdi)
movl $0xfa, %edi
callq 0x1130
movl (%rbx), %r14d
movl $0x42, (%rbx)
movl $0xfa, %edi
callq 0x1130
movl (%rbx), %ebp
leaq 0xa99(%rip), %rdi       # 0x21ac
leaq 0xa81(%rip), %rsi       # 0x219b
callq 0x1100
leaq 0xa77(%rip), %rsi       # 0x219d
leaq 0x8(%rsp), %rdx
movq %rax, %rdi
xorl %eax, %eax
callq 0x1050
testl %r14d, %r14d
je 0x178b
cmpl $0xe, %r14d
je 0x174f
cmpl $0x1, %r14d
jne 0x17a0
leaq 0xb3e(%rip), %rdi       # 0x228b
jmp 0x17c9
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rsp)
leaq 0xb1c(%rip), %rdi       # 0x227d
callq 0x1060
leaq 0x9bd(%rip), %rdi       # 0x212a
movl %ebp, %esi
xorl %eax, %eax
callq 0x10a0
leaq 0x9c8(%rip), %rdi       # 0x2145
movsd (%rsp), %xmm0
movb $0x1, %al
callq 0x10a0
jmp 0x17ce
leaq 0xa8c(%rip), %rdi       # 0x221e
callq 0x1060
leaq 0xab1(%rip), %rdi       # 0x224f
jmp 0x17c9
leaq 0xa57(%rip), %rdi       # 0x21fe
callq 0x1060
leaq 0x94c(%rip), %rdi       # 0x20ff
xorl %eax, %eax
callq 0x10a0
movq %rbx, %rdi
callq 0x14d7
leaq 0xa4f(%rip), %rdi       # 0x2218
callq 0x1060
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/eridanhq[P]miraclelib/miraclelib.c
// Function: ad9173_freq_calc
void ad9173_freq_calc(uint64_t fLO, uint64_t *A, uint64_t *B, uint64_t *X)
{
	uint64_t fDAC, c1, c2, M, N, Y; // need 64-bit computation

	fDAC = (uint64_t) 9.6e9; // needs to match AD9173 DAC frequency
	c1 = gcd(fLO,fDAC); // compute GCD of fLO and fDAC

	/* DDS modulus works using following equation:
	 * fLO/fDAC = M/N
	 *          = (X + A/B)/(2^48)
	 */

	M =  fLO/c1; // compute rational fraction M/N
	N = fDAC/c1;

	*X = (M << 48)/N; // Computer integer X
	Y = (M << 48) - (*X)*N; // Compute remainder y
	c2 = gcd(Y,N);
	*A = Y/c2; // Compute A/B modulus
	*B = N/c2;

	//printf("X=0x%" PRIX64 "\n", *X);
	//printf("A=0x%" PRIX64 "\n", *A);
	//printf("B=0x%" PRIX64 "\n", *B);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r12
movabsq $0x23c346000, %r13      # imm = 0x23C346000
movq %r13, %rsi
callq 0x17d7
movq %rax, %rcx
movq %r12, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %rsi
movq %r13, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %r12
shlq $0x30, %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %r12
movq %rdx, %r13
movq %rax, (%r15)
movq %rdx, %rdi
movq %r12, %rsi
callq 0x17d7
movq %rax, %rcx
movq %r13, %rax
xorl %edx, %edx
divq %rcx
movq %rax, (%r14)
movq %r12, %rax
xorl %edx, %edx
divq %rcx
movq %rax, (%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/eridanhq[P]miraclelib/miraclelib.c
// Function: init_tx
int init_tx(void *mapped_base)
{
	int jesd_phase; // jesd phase readback value
	int done = 0; // done flag
	ad9173_resync(mapped_base); // Sync AD9173 subclass 1
	usleep(100000); //100 msec pause
	write_reg_tx(32,1,mapped_base); // CS to AD9173
	write_reg_tx(33,0x830200,mapped_base); // readback LMFC delay
	jesd_phase = read_reg_tx(34, mapped_base);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x1a59
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x1130
movl $0x830200, 0xcc(%rbx)   # imm = 0x830200
movl $0x22, (%rbx)
movl $0xfa, %edi
popq %rbx
jmp 0x1130
// File: /workspace/github_c_makefile_star2_O1/eridanhq[P]miraclelib/miraclelib.c
// Function: set_pwr_tx
void set_pwr_tx(int pwr_ctrl_reg, void *mapped_base)
{
	// Handle boundaries
	if (pwr_ctrl_reg > 32767) 
	{
		printf("Input is too large.\n\r");
		pwr_ctrl_reg = 32767;
	}
	else if(pwr_ctrl_reg < 0)
	{
		printf("Input is too small.\n\r");
		pwr_ctrl_reg = 0;
	}

	write_reg_tx(66, pwr_ctrl_reg, mapped_base); // set power level
	printf("Power is set to: %d\n", pwr_ctrl_reg);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
cmpl $0x7fff, %edi           # imm = 0x7FFF
jle 0x1b38
movl $0x7fff, %ebx           # imm = 0x7FFF
leaq 0x624(%rip), %rdi       # 0x215a
jmp 0x1b47
movl %edi, %ebx
testl %edi, %edi
jns 0x1b4e
xorl %ebx, %ebx
leaq 0x629(%rip), %rdi       # 0x2170
xorl %eax, %eax
callq 0x10a0
movl $0x80000042, (%r14)     # imm = 0x80000042
movl %ebx, 0xcc(%r14)
leaq 0x623(%rip), %rdi       # 0x2186
movl %ebx, %esi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x10a0