LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/niho[P]elmc/src/east.c
// Function: elm_ast_branch
elm_ast_val_t *elm_ast_branch(int i, elm_ast_val_t **xs) {
    assert(i == 3);
    assert(((elm_ast_t *)(xs[i - 1]))->tag == ELM_AST_EXPR);

    elm_ast_t *node = elm_ast_new(ELM_AST_BRANCH, NULL);
    elm_ast_add_child(node, xs[0]);
    elm_ast_add_child(node, xs[2]);

    free(xs[1]);
    
    return node;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x3, %edi
jne 0x1d04
movq %rsi, %rbx
movq 0x10(%rsi), %r15
cmpl $0x7, (%r15)
jne 0x1d23
movl $0x20, %edi
callq 0x1170
movq %rax, %r14
movl $0xc, (%rax)
xorl %eax, %eax
movq %rax, 0x8(%r14)
movl $0x0, 0x10(%r14)
movq %rax, 0x18(%r14)
movq (%rbx), %r12
movl $0x1, 0x10(%r14)
movl $0x8, %edi
callq 0x1170
movq %rax, 0x18(%r14)
movq %r12, (%rax)
movl $0x2, 0x10(%r14)
movl $0x10, %esi
movq %rax, %rdi
callq 0x11a0
movq %rax, 0x18(%r14)
movq %r15, 0x8(%rax)
movq 0x8(%rbx), %rdi
callq 0x1230
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0xb4bf(%rip), %rdi      # 0xd1ca
leaq 0xb41a(%rip), %rsi      # 0xd12c
leaq 0xb4b8(%rip), %rcx      # 0xd1d1
movl $0xa4, %edx
callq 0x10c0
leaq 0xb4dc(%rip), %rdi      # 0xd206
leaq 0xb3fb(%rip), %rsi      # 0xd12c
leaq 0xb499(%rip), %rcx      # 0xd1d1
movl $0xa5, %edx
callq 0x10c0
// File: /workspace/github_c_makefile_star2_O1/niho[P]elmc/src/east.c
// Function: elm_ast_decl
elm_ast_val_t *elm_ast_decl(int i, elm_ast_val_t **xs) {
    assert(i == 3);
    assert(((elm_ast_t *)(xs[0]))->tag == ELM_AST_FUNC);
    assert(((elm_ast_t *)(xs[2]))->tag == ELM_AST_EXPR);

    elm_ast_t *node = elm_ast_new(ELM_AST_DECL, NULL);
    elm_ast_add_child(node, xs[0]);
    elm_ast_add_child(node, xs[2]);

    free(xs[1]);

    return node;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x3, %edi
jne 0x1e1c
movq %rsi, %rbx
movq (%rsi), %r12
cmpl $0xf, (%r12)
jne 0x1e3b
movq 0x10(%rbx), %r15
cmpl $0x7, (%r15)
jne 0x1e5a
movl $0x20, %edi
callq 0x1170
movq %rax, %r14
movl $0xe, (%rax)
xorl %eax, %eax
movq %rax, 0x8(%r14)
movq %rax, 0x18(%r14)
movl $0x1, 0x10(%r14)
movl $0x8, %edi
callq 0x1170
movq %rax, 0x18(%r14)
movq %r12, (%rax)
movl $0x2, 0x10(%r14)
movl $0x10, %esi
movq %rax, %rdi
callq 0x11a0
movq %rax, 0x18(%r14)
movq %r15, 0x8(%rax)
movq 0x8(%rbx), %rdi
callq 0x1230
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq 0xb3a7(%rip), %rdi      # 0xd1ca
leaq 0xb302(%rip), %rsi      # 0xd12c
leaq 0xb405(%rip), %rcx      # 0xd236
movl $0xb7, %edx
callq 0x10c0
leaq 0xb427(%rip), %rdi      # 0xd269
leaq 0xb2e3(%rip), %rsi      # 0xd12c
leaq 0xb3e6(%rip), %rcx      # 0xd236
movl $0xb8, %edx
callq 0x10c0
leaq 0xb434(%rip), %rdi      # 0xd295
leaq 0xb2c4(%rip), %rsi      # 0xd12c
leaq 0xb3c7(%rip), %rcx      # 0xd236
movl $0xb9, %edx
callq 0x10c0
// File: /workspace/github_c_makefile_star2_O1/niho[P]elmc/src/east.c
// Function: elm_ast_func
elm_ast_val_t *elm_ast_func(int i, elm_ast_val_t **xs) {
    elm_ast_t *node = elm_ast_new(ELM_AST_FUNC, NULL);

    assert(((elm_ast_t *)(xs[0]))->tag == ELM_AST_VAR);
    assert(((elm_ast_t *)(xs[0]))->contents != NULL);

    node->contents = malloc(sizeof(char) * strlen(((elm_ast_t *)(xs[0]))->contents));
    strcpy(node->contents, ((elm_ast_t *)(xs[0]))->contents);
    elm_ast_delete(xs[0]);

    if (i > 1) {
        for (int x = 1; x < i; x++) {
            elm_ast_add_child(node, xs[x]);
        }
    }

    return node;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
movl $0x20, %edi
callq 0x1170
movq %rax, %r14
movl $0xf, (%rax)
xorl %eax, %eax
movq %rax, 0x8(%r14)
movl $0x0, 0x10(%r14)
movq %rax, 0x18(%r14)
movq (%rbx), %r15
cmpl $0x6, (%r15)
jne 0x1f4b
movq 0x8(%r15), %r12
testq %r12, %r12
je 0x1f6a
movq %r12, %rdi
callq 0x1090
movq %rax, %rdi
callq 0x1170
movq %rax, 0x8(%r14)
movq %rax, %rdi
movq %r12, %rsi
callq 0x1050
movq %r15, %rdi
callq 0x1f89
cmpl $0x2, %ebp
jl 0x1f39
movslq 0x10(%r14), %r12
movq 0x18(%r14), %rax
movl %ebp, %r13d
addq $0x8, %rbx
decq %r13
leaq 0x8(,%r12,8), %r15
movq (%rbx), %rbp
movq %rax, %rdi
movq %r15, %rsi
callq 0x11a0
movq %rbp, -0x8(%rax,%r15)
addq $0x8, %rbx
incl %r12d
addq $0x8, %r15
decq %r13
jne 0x1f0e
movl %r12d, 0x10(%r14)
movq %rax, 0x18(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb36f(%rip), %rdi      # 0xd2c1
leaq 0xb1d3(%rip), %rsi      # 0xd12c
leaq 0xb38c(%rip), %rcx      # 0xd2ec
movl $0xc7, %edx
callq 0x10c0
leaq 0xb3ae(%rip), %rdi      # 0xd31f
leaq 0xb1b4(%rip), %rsi      # 0xd12c
leaq 0xb36d(%rip), %rcx      # 0xd2ec
movl $0xc8, %edx
callq 0x10c0
// File: /workspace/github_c_makefile_star2_O1/niho[P]elmc/src/east.c
// Function: elm_ast_delete
void elm_ast_delete(elm_ast_t *a) {
    if (a == NULL) { return; }

    for (int i = 0; i < a->children_num; i++) {
        elm_ast_delete(a->children[i]);
    }

    free(a->children);
    free(a->contents);
    free(a);
}

// Assembly:
testq %rdi, %rdi
je 0x1fd8
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpl $0x0, 0x10(%rdi)
jle 0x1fb7
xorl %r14d, %r14d
movq 0x18(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x1f89
incq %r14
movslq 0x10(%rbx), %rax
cmpq %rax, %r14
jl 0x1f9e
movq 0x18(%rbx), %rdi
callq 0x1230
movq 0x8(%rbx), %rdi
callq 0x1230
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1230
retq
// File: /workspace/github_c_makefile_star2_O1/niho[P]elmc/src/east.c
// Function: elm_ast_module
elm_ast_val_t *elm_ast_module(int i, elm_ast_val_t **xs) {
    elm_ast_t *node = elm_ast_new(ELM_AST_MODULE, NULL);
    for (int x = 0; x < i; x++) {
        elm_ast_add_child(node, xs[x]);
    }
    return node;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
movl $0x20, %edi
callq 0x1170
movq %rax, %r14
movl $0x10, (%rax)
xorl %eax, %eax
movq %rax, 0x8(%r14)
movl $0x0, 0x10(%r14)
movq %rax, 0x18(%r14)
testl %ebp, %ebp
jle 0x2050
movslq 0x10(%r14), %r12
movq 0x18(%r14), %rax
movl %ebp, %r13d
leaq 0x8(,%r12,8), %r15
movq (%rbx), %rbp
movq %rax, %rdi
movq %r15, %rsi
callq 0x11a0
movq %rbp, -0x8(%rax,%r15)
addq $0x8, %rbx
incl %r12d
addq $0x8, %r15
decq %r13
jne 0x2025
movl %r12d, 0x10(%r14)
movq %rax, 0x18(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/niho[P]elmc/src/east.c
// Function: elm_ast_traverse_start
elm_ast_trav_t *elm_ast_traverse_start(elm_ast_t *ast, elm_ast_trav_order_t order) {
    elm_ast_trav_t *trav;
    trav = malloc(sizeof(elm_ast_trav_t));
    trav->curr_node = ast;
    trav->parent = NULL;
    trav->curr_child = 0;
    trav->order = order;
    return trav;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movl $0x18, %edi
callq 0x1170
movq %r14, (%rax)
movq $0x0, 0x8(%rax)
movl $0x0, 0x10(%rax)
movl %ebx, 0x14(%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/niho[P]elmc/src/east.c
// Function: elm_ast_traverse_next
elm_ast_t *elm_ast_traverse_next(elm_ast_trav_t **trav) {
    elm_ast_trav_t *n_trav, *to_free;
    elm_ast_t *ret = NULL;
    int cchild;

    if(*trav == NULL) return NULL;

    switch((*trav)->order) {
        case ELM_AST_TRAV_ORDER_PRE:
            ret = (*trav)->curr_node;
            
            while(*trav != NULL &&
                    (*trav)->curr_child >= (*trav)->curr_node->children_num)
            {
                to_free = *trav;
                *trav = (*trav)->parent;
                free(to_free);
            }
            
            if(*trav == NULL) {
                break;
            }

            n_trav = malloc(sizeof(elm_ast_trav_t));

            cchild = (*trav)->curr_child;
            n_trav->curr_node = (*trav)->curr_node->children[cchild];
            n_trav->parent = *trav;
            n_trav->curr_child = 0;
            n_trav->order = (*trav)->order;

            (*trav)->curr_child++;
            *trav = n_trav;

            break;
        case ELM_AST_TRAV_ORDER_POST:
            break;
    }

    return ret;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq (%rdi), %rax
testq %rax, %rax
je 0x24b3
cmpl $0x0, 0x14(%rax)
je 0x24be
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
movq %rdi, %r14
movq (%rax), %rbx
movq (%r14), %r15
testq %r15, %r15
sete %al
je 0x24b5
movl 0x10(%r15), %ecx
movq (%r15), %rdx
cmpl 0x10(%rdx), %ecx
jl 0x24ec
movq 0x8(%r15), %rax
movq %rax, (%r14)
movq %r15, %rdi
callq 0x1230
jmp 0x24c4
testb %al, %al
jne 0x24b5
movl $0x18, %edi
callq 0x1170
movslq 0x10(%r15), %rcx
movq (%r15), %rdx
movq 0x18(%rdx), %rdx
movq (%rdx,%rcx,8), %rcx
movq %rcx, (%rax)
movq %r15, 0x8(%rax)
movl $0x0, 0x10(%rax)
movl 0x14(%r15), %ecx
movl %ecx, 0x14(%rax)
incl 0x10(%r15)
movq %rax, (%r14)
jmp 0x24b5
// File: /workspace/github_c_makefile_star2_O1/niho[P]elmc/src/east.c
// Function: elm_ast_traverse_free
void elm_ast_traverse_free(elm_ast_trav_t **trav) {
    elm_ast_trav_t *n_trav;

    while(*trav != NULL) {
        n_trav = (*trav)->parent;
        free(*trav);
        *trav = n_trav;
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x254a
movq 0x8(%rdi), %r14
callq 0x1230
movq %r14, (%rbx)
movq %r14, %rdi
testq %r14, %r14
jne 0x2536
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_c_makefile_star2_O1/niho[P]elmc/src/eparse.c
// Function: elm_parse
int elm_parse(const char *filename, const char *string, elm_result_t *r) {
    elm_parser_t *p = elm_parser_init();
    mpc_result_t result;
    if (mpc_parse(filename, string, p->Module, &result)) {
        r->output = (elm_ast_t *)result.output;
        elm_parser_cleanup(p);
        return 1;
    } else {
        r->error = elm_error(result.error);  
        elm_parser_cleanup(p);
        return 0;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r12
callq 0x25c3
movq %rax, %r14
movq 0x80(%rax), %rdx
movq %rsp, %r13
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rcx
callq 0x47a1
movl $0x1, %ebp
movq (%r13), %r15
testl %eax, %eax
jne 0x25a7
movl $0x8, %edi
callq 0x1170
movq %r15, (%rax)
xorl %ebp, %ebp
movq %rax, %r15
movq %r15, (%rbx)
movq %r14, %rdi
callq 0x2fe1
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/niho[P]elmc/src/eparse.c
// Function: elm_parser_cleanup
static void elm_parser_cleanup(elm_parser_t *p) {
    mpc_cleanup(17,
            p->Comment,
            p->True,
            p->False,
            p->Number,
            p->Float,
            p->Char,
            p->String,
            p->Literal,
            p->Var,
            p->Value,
            p->Expr,
            p->List,
            p->Tuple,
            p->If,
            p->Case,
            p->Decl,
            p->Module);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq (%rdi), %rsi
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rcx
movq 0x18(%rdi), %r8
movq 0x20(%rdi), %r9
movups 0x28(%rdi), %xmm0
movq 0x38(%rdi), %rax
movq 0x48(%rdi), %r10
movq 0x50(%rdi), %r11
movq 0x58(%rdi), %rbx
movq 0x60(%rdi), %r14
movq 0x68(%rdi), %r15
movq 0x70(%rdi), %r12
movq 0x78(%rdi), %r13
movq 0x40(%rdi), %rbp
movq 0x80(%rdi), %rdi
movq %rdi, 0x58(%rsp)
movq %rbp, 0x50(%rsp)
movq %r13, 0x48(%rsp)
movq %r12, 0x40(%rsp)
movq %r15, 0x38(%rsp)
movq %r14, 0x30(%rsp)
movq %rbx, 0x28(%rsp)
movq %r11, 0x20(%rsp)
movq %r10, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movups %xmm0, (%rsp)
movl $0x11, %edi
xorl %eax, %eax
callq 0x51aa
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/niho[P]elmc/src/eparse.c
// Function: elm_parse_file
int elm_parse_file(const char *filename, FILE *file, elm_result_t *r) {
    elm_parser_t *p = elm_parser_init();
    mpc_result_t result;
    if (mpc_parse_file(filename, file, p->Module, &result)) {
        r->output = (elm_ast_t *)result.output;
        elm_parser_cleanup(p);
        return 1;
    } else {
        r->error = elm_error(result.error);  
        elm_parser_cleanup(p);
        return 0;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r12
callq 0x25c3
movq %rax, %r14
movq 0x80(%rax), %rdx
movq %rsp, %r13
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %rcx
callq 0x49c9
movl $0x1, %ebp
movq (%r13), %r15
testl %eax, %eax
jne 0x30d5
movl $0x8, %edi
callq 0x1170
movq %r15, (%rax)
xorl %ebp, %ebp
movq %rax, %r15
movq %r15, (%rbx)
movq %r14, %rdi
callq 0x2fe1
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/niho[P]elmc/src/eparse.c
// Function: elm_parse_contents
int elm_parse_contents(const char *filename, elm_result_t *r) {
    elm_parser_t *p = elm_parser_init();
    mpc_result_t result;
    if (mpc_parse_contents(filename, p->Module, &result)) {
        r->output = (elm_ast_t *)result.output;
        elm_parser_cleanup(p);
        return 1;
    } else {
        r->error = elm_error(result.error);
        elm_parser_cleanup(p);
        return 0;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r15
callq 0x25c3
movq %rax, %r14
movq 0x80(%rax), %rsi
leaq 0x8(%rsp), %r12
movq %r15, %rdi
movq %r12, %rdx
callq 0x4b59
movl $0x1, %ebp
movq (%r12), %r15
testl %eax, %eax
jne 0x31b0
movl $0x8, %edi
callq 0x1170
movq %r15, (%rax)
xorl %ebp, %ebp
movq %rax, %r15
movq %r15, (%rbx)
movq %r14, %rdi
callq 0x2fe1
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/niho[P]elmc/src/eparse.c
// Function: is_unreserved
static int is_unreserved(mpc_val_t **xs) {
    if (strcmp(xs[0], "if") == 0)
        return 0;
    if (strcmp(xs[0], "then") == 0)
        return 0;
    if (strcmp(xs[0], "else") == 0)
        return 0;
    if (strcmp(xs[0], "case") == 0)
        return 0;
    if (strcmp(xs[0], "of") == 0)
        return 0;
    if (strcmp(xs[0], "->") == 0)
        return 0;
    if (strcmp(xs[0], "_") == 0)
        return 0;
    if (strcmp(xs[0], "=") == 0)
        return 0;
    return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq (%rdi), %r14
leaq 0xa28e(%rip), %rsi      # 0xd497
movq %r14, %rdi
callq 0x1120
xorl %ebx, %ebx
testl %eax, %eax
je 0x32a3
leaq 0xa2fa(%rip), %rsi      # 0xd51c
movq %r14, %rdi
callq 0x1120
testl %eax, %eax
je 0x32a3
leaq 0xa2ec(%rip), %rsi      # 0xd521
movq %r14, %rdi
callq 0x1120
testl %eax, %eax
je 0x32a3
leaq 0xa252(%rip), %rsi      # 0xd49a
movq %r14, %rdi
callq 0x1120
testl %eax, %eax
je 0x32a3
leaq 0xa2cb(%rip), %rsi      # 0xd526
movq %r14, %rdi
callq 0x1120
testl %eax, %eax
je 0x32a3
leaq 0xa2bb(%rip), %rsi      # 0xd529
movq %r14, %rdi
callq 0x1120
testl %eax, %eax
je 0x32a3
leaq 0xa9bd(%rip), %rsi      # 0xdc3e
movq %r14, %rdi
callq 0x1120
testl %eax, %eax
je 0x32a3
leaq 0xaadb(%rip), %rsi      # 0xdd6f
movq %r14, %rdi
callq 0x1120
xorl %ebx, %ebx
testl %eax, %eax
setne %bl
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/teavpn/main.c
// Function: main
int main(int argc, char **_argv, char **envp)
{
	uint8_t exit_code;
	teavpn_config config;

	argv = _argv;

	if (!argv_parser(&config, argc, _argv, envp)) {
		exit_code = 1;
		goto ret;
	}

	switch (config.type) {
		case teavpn_server_config:
			exit_code = teavpn_tcp_server(&(config.config.server));
			break;
		case teavpn_client_config:
			exit_code = teavpn_tcp_client(&(config.config.client));
			break;
		default:
			printf("Invalid config type\n");
			exit_code = 1;
			break;
	}

	ret:
	return exit_code;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x58, %rsp
movq %rdx, %rcx
movq %rsi, %rdx
movl %edi, %esi
movq %fs:0x28, %rax
movq %rax, -0x10(%rbp)
movq %rdx, 0x8837(%rip)      # 0xb258
leaq -0x58(%rbp), %rdi
callq 0x339c
movb $0x1, %bl
testb %al, %al
je 0x2a60
movl -0x18(%rbp), %eax
cmpl $0x1, %eax
je 0x2a47
testl %eax, %eax
jne 0x2a54
leaq -0x58(%rbp), %rdi
callq 0x45fc
jmp 0x2a50
leaq -0x58(%rbp), %rdi
callq 0x39f4
movl %eax, %ebx
jmp 0x2a60
leaq 0x45a9(%rip), %rdi      # 0x7004
callq 0x2090
movq %fs:0x28, %rax
cmpq -0x10(%rbp), %rax
jne 0x2a79
movzbl %bl, %eax
addq $0x58, %rsp
popq %rbx
popq %rbp
retq
callq 0x2110
nop
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/teavpn/helpers.c
// Function: ip_read_conv
uint32_t ip_read_conv(const char *read)
{
	uint32_t ret = 0;
	uint8_t bufptr = 0, i = 0;
	char buf[4] = "\0\0\0";

	while (((*read) != '\0') && ((*read) != '/')) {
		buf[bufptr] = *read;
		read++;
		bufptr++;
		if ((bufptr == 3) || ((*read) == '.')) {
			bufptr = 0;
			ret |= atoi(buf) << i;
			i += 8;
			read++; // skip dot
		}
	}

	if (i < 32) {
		ret |= atoi(buf) << i;
	}

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r15
movq %fs:0x28, %rax
movq %rax, -0x28(%rbp)
leaq -0x2c(%rbp), %r12
movl $0x0, (%r12)
xorl %ebx, %ebx
xorl %r14d, %r14d
addq $0x2, %r15
xorl %eax, %eax
movq %r15, %rcx
movq %rcx, %r15
movzbl -0x2(%rcx), %ecx
testl %ecx, %ecx
je 0x2b55
cmpl $0x2f, %ecx
je 0x2b55
movb %cl, -0x2c(%rbp,%rax)
cmpb $0x2, %al
je 0x2b40
leaq 0x1(%r15), %rcx
incq %rax
cmpb $0x2e, -0x1(%r15)
jne 0x2b1a
movq %r12, %rdi
callq 0x2380
movl %r14d, %ecx
shll %cl, %eax
orl %eax, %ebx
addb $0x8, %r14b
jmp 0x2b11
cmpb $0x1f, %r14b
ja 0x2b6b
leaq -0x2c(%rbp), %rdi
callq 0x2380
movl %r14d, %ecx
shll %cl, %eax
orl %eax, %ebx
movq %fs:0x28, %rax
cmpq -0x28(%rbp), %rax
jne 0x2b89
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x2110
nop
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/teavpn/cli_arg.c
// Function: show_help_command
static void show_help_command(char *appname)
{
	printf("Usage: %s [command] [options]\n\n", appname);
	printf("Available commands:\n");
	printf("\tserver\t\tMake TeaVPN server.\n");
	printf("\tconnect\t\tConnect to TeaVPN server.\n");
	printf("\nDetailed information: %s [command] --help\n", appname);
	fflush(stdout);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x3904(%rip), %rdi      # 0x72a1
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2150
leaq 0x393f(%rip), %rdi      # 0x72ed
callq 0x2090
leaq 0x3947(%rip), %rdi      # 0x7301
callq 0x2090
leaq 0x3958(%rip), %rdi      # 0x731e
callq 0x2090
leaq 0x38ef(%rip), %rdi      # 0x72c1
movq %rbx, %rsi
xorl %eax, %eax
callq 0x2150
movq 0x75ed(%rip), %rax      # 0xafd0
movq (%rax), %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x22d0
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/teavpn/server/tcp.c
// Function: connection_zero
static void connection_zero(register uint16_t i)
{
	connections[i].fd = -1;
	connections[i].connected = false;
	connections[i].error = 0;
	connections[i].seq = 0;
	connections[i].priv_ip = 0;
	memset(&(connections[i].addr), 0, sizeof(connections[i].addr));
	memset(&(connections[i].mutex), 0, sizeof(connections[i].mutex));
	pthread_mutex_init(&(connections[i].mutex), NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x555d(%rip), %rax      # 0xb378
movl %edi, %ecx
leaq (%rcx,%rcx,4), %rcx
shll $0x4, %ecx
leaq (%rax,%rcx), %rdi
addq $0x18, %rdi
movl $0xffffffff, -0x18(%rdi) # imm = 0xFFFFFFFF
movw $0x0, -0x14(%rdi)
xorl %eax, %eax
movq %rax, -0x10(%rdi)
movl $0x0, -0x8(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, 0x20(%rdi)
movq %rax, 0x30(%rdi)
xorl %esi, %esi
popq %rbp
jmp 0x23d0
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/teavpn/server/tcp.c
// Function: get_bufchan_index
static int16_t get_bufchan_index()
{
	static bool sleep_state = false;
	static uint8_t buf_chan_wait = 0;

	for (int16_t i = 0; i < BUFCHAN_ALLOC; i++) {
		if (bufchan[i].ref_count == 0) {
			if (buf_chan_wait > 0) buf_chan_wait--;
			return i;
		}
	}

	if (buf_chan_wait > 30) {
		sleep_state = true;
	} else {
		if (buf_chan_wait <= 100) buf_chan_wait++;
	}

	if (sleep_state) {
		debug_log(1, "Buffer channel got sleep state...\n");
		usleep(10000);
		buf_chan_wait--;
		if (buf_chan_wait <= 20) {
			debug_log(1, "Sleep state has been released\n");
			sleep_state = false;
		}
	}

	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq 0x5502(%rip), %rcx      # 0xb370
cmpw $0x0, (%rcx)
je 0x5ea0
addq $0x1030, %rcx           # imm = 0x1030
movw $0xffff, %ax            # imm = 0xFFFF
cmpw $0x16, %ax
je 0x5eba
incl %eax
cmpw $0x0, (%rcx)
leaq 0x1030(%rcx), %rcx
jne 0x5e7f
cmpw $0x17, %ax
setae %cl
leal 0x1(%rax), %ebx
jmp 0x5ea4
xorl %ecx, %ecx
xorl %ebx, %ebx
movb 0x5579(%rip), %al       # 0xb423
testb %al, %al
je 0x5eb6
decb %al
movb %al, 0x556d(%rip)       # 0xb423
testb %cl, %cl
je 0x5f34
movb 0x5563(%rip), %al       # 0xb423
cmpb $0x1f, %al
jb 0x5ecd
movb $0x1, 0x5557(%rip)      # 0xb422
jmp 0x5ed5
incb %al
movb %al, 0x554e(%rip)       # 0xb423
movw $0xffff, %bx            # imm = 0xFFFF
cmpb $0x1, 0x5542(%rip)      # 0xb422
jne 0x5f34
leaq 0x553b(%rip), %r14      # 0xb424
cmpb $0x0, (%r14)
je 0x5efd
leaq 0x2402(%rip), %rdi      # 0x82f8
xorl %eax, %eax
callq 0x605c
movl $0x2710, %edi           # imm = 0x2710
callq 0x2400
movb 0x5516(%rip), %al       # 0xb423
decb %al
movb %al, 0x550e(%rip)       # 0xb423
cmpb $0x14, %al
ja 0x5f34
cmpb $0x0, (%r14)
je 0x5f2d
leaq 0x23f5(%rip), %rdi      # 0x831b
xorl %eax, %eax
callq 0x605c
movb $0x0, 0x54ee(%rip)      # 0xb422
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/teavpn/server/auth.c
// Function: teavpn_auth_check
FILE *teavpn_auth_check(server_config *config, struct teavpn_packet_auth *auth)
{
	size_t len;
	FILE *h1 = NULL, *h2 = NULL;
	char file[512], buffer[255];

	sprintf(file, "%s/users/%s/password", config->data_dir, auth->username);

	// printf("%s\n", file);
	// fflush(stdout);

	h1 = fopen(file, "r");
	if (h1 == NULL) {
		return NULL;
	}

	if (fgets(buffer, 254, h1)) {
		len = strlen(buffer);

		if (buffer[len - 1] == '\n') {
			buffer[len - 1] = '\0';
		}

		// printf("rpassword: \"%s\"\n", buffer);
		// printf("auth_pas: \"%s\"\n", auth->password);
		// fflush(stdout);

		if (!strcmp(auth->password, buffer)) {
			sprintf(file, "%s/users/%s/ip", config->data_dir, auth->username);
			h2 = fopen(file, "r");
		}
	}

	fclose(h1);
	return h2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
movq %rsi, %r12
movq %rdi, %r15
movq %fs:0x28, %rax
movq %rax, -0x30(%rbp)
movq 0x18(%rdi), %rdx
leaq 0x2(%rsi), %r14
leaq 0x23c8(%rip), %rsi      # 0x833a
xorl %r13d, %r13d
leaq -0x230(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2390
leaq 0x10ff(%rip), %rsi      # 0x708f
movq %rbx, %rdi
callq 0x2340
testq %rax, %rax
je 0x6030
movq %rax, %rbx
leaq -0x330(%rbp), %r13
movq %r13, %rdi
movl $0xfe, %esi
movq %rax, %rdx
callq 0x21e0
testq %rax, %rax
je 0x5ff2
movq %r13, %rdi
callq 0x2100
cmpb $0xa, -0x1(%rax,%r13)
jne 0x5fd8
movb $0x0, -0x331(%rbp,%rax)
addq $0x102, %r12            # imm = 0x102
leaq -0x330(%rbp), %rsi
movq %r12, %rdi
callq 0x2220
testl %eax, %eax
je 0x5ff7
xorl %r13d, %r13d
jmp 0x6028
movq 0x18(%r15), %rdx
leaq 0x234d(%rip), %rsi      # 0x834f
leaq -0x230(%rbp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2390
leaq 0x1072(%rip), %rsi      # 0x708f
movq %r15, %rdi
callq 0x2340
movq %rax, %r13
movq %rbx, %rdi
callq 0x20f0
movq %fs:0x28, %rax
cmpq -0x30(%rbp), %rax
jne 0x6054
movq %r13, %rax
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2110
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/teavpn/teavpn.c
// Function: _internal_debug_log
uint8_t __internal_debug_log(const char *msg, ...)
{
	va_list argp;
	time_t rawtime;
	struct tm *timeinfo;

	time(&rawtime);
	timeinfo = localtime(&rawtime);
	char *time = asctime(timeinfo);
	time[24] = '\0';

	va_start(argp, msg);
	fprintf(stdout, "[%s]: ", time);
	vfprintf(stdout, msg, argp);
	fprintf(stdout, "\n");
	va_end(argp);
	fflush(stdout);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
andq $-0x10, %rsp
subq $0xf0, %rsp
movq %rdi, %rbx
movq %rsp, %r15
movq %rsi, 0x8(%r15)
movq %rdx, 0x10(%r15)
movq %rcx, 0x18(%r15)
movq %r8, 0x20(%r15)
movq %r9, 0x28(%r15)
testb %al, %al
je 0x60bf
movaps %xmm0, 0x30(%rsp)
movaps %xmm1, 0x40(%rsp)
movaps %xmm2, 0x50(%rsp)
movaps %xmm3, 0x60(%rsp)
movaps %xmm4, 0x70(%rsp)
movaps %xmm5, 0x80(%rsp)
movaps %xmm6, 0x90(%rsp)
movaps %xmm7, 0xa0(%rsp)
movq %fs:0x28, %rax
movq %rax, 0xe0(%rsp)
leaq 0xb8(%rsp), %r14
movq %r14, %rdi
callq 0x2280
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2130
movb $0x0, 0x18(%rax)
movabsq $0x3000000008, %rcx     # imm = 0x3000000008
leaq 0xc0(%rsp), %r14
movq %rcx, (%r14)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%r14)
movq %r15, 0x10(%r14)
movq 0x4eb4(%rip), %r15      # 0xafd0
movq (%r15), %rdi
leaq 0x2238(%rip), %rsi      # 0x835e
movq %rax, %rdx
xorl %eax, %eax
callq 0x2240
movq (%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2360
movq (%r15), %rsi
movl $0xa, %edi
callq 0x21c0
movq (%r15), %rdi
callq 0x22d0
movq %fs:0x28, %rax
cmpq 0xe0(%rsp), %rax
jne 0x6173
xorl %eax, %eax
leaq -0x18(%rbp), %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x2110
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/teavpn/teavpn.c
// Function: tun_alloc
int tun_alloc(char *dev, int flags)
{
	struct ifreq ifr;
	int fd, err;

	if ((fd = open("/dev/net/tun", O_RDWR)) < 0) {
		perror("Opening /dev/net/tun");
		return fd;
	}

	memset(&ifr, 0, sizeof(ifr));

	ifr.ifr_flags = flags;

	if (*dev) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
		strncpy(ifr.ifr_name, dev, IFNAMSIZ);
#pragma GCC diagnostic pop
	}

	if ((err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0) {
		perror("ioctl(TUNSETIFF)");
		close(fd);
		return err;
	}

	strcpy(dev, ifr.ifr_name);
	return fd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movl %esi, %r15d
movq %rdi, %r14
movq %fs:0x28, %rax
movq %rax, -0x20(%rbp)
leaq 0x21ce(%rip), %rdi      # 0x836d
movl $0x2, %esi
xorl %eax, %eax
callq 0x2320
movl %eax, %ebx
testl %eax, %eax
js 0x621e
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x30(%rbp)
movw %r15w, -0x40(%rbp)
cmpb $0x0, (%r14)
je 0x61e0
leaq -0x50(%rbp), %rdi
movl $0x10, %edx
movq %r14, %rsi
callq 0x2060
leaq -0x50(%rbp), %rdx
movl $0x400454ca, %esi       # imm = 0x400454CA
movl %ebx, %edi
xorl %eax, %eax
callq 0x2190
testl %eax, %eax
js 0x622c
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x2070
movq %fs:0x28, %rax
cmpq -0x20(%rbp), %rax
jne 0x6247
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2140(%rip), %rdi      # 0x8365
callq 0x2350
jmp 0x6202
movl %eax, %r15d
leaq 0x2144(%rip), %rdi      # 0x837a
callq 0x2350
movl %ebx, %edi
callq 0x21a0
movl %r15d, %ebx
jmp 0x6202
callq 0x2110
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: thpool_init
struct thpool_* thpool_init(int num_threads){

	threads_on_hold   = 0;
	threads_keepalive = 1;

	if (num_threads < 0){
		num_threads = 0;
	}

	/* Make new thread pool */
	thpool_* thpool_p;
	thpool_p = (struct thpool_*)malloc(sizeof(struct thpool_));
	if (thpool_p == NULL){
		err("thpool_init(): Could not allocate memory for thread pool\n");
		return NULL;
	}
	thpool_p->num_threads_alive   = 0;
	thpool_p->num_threads_working = 0;

	/* Initialise the job queue */
	if (jobqueue_init(&thpool_p->__jobqueue) == -1){
		err("thpool_init(): Could not allocate memory for job queue\n");
		free(thpool_p);
		return NULL;
	}

	/* Make threads in pool */
	thpool_p->threads = (struct thread**)malloc(num_threads * sizeof(struct thread *));
	if (thpool_p->threads == NULL){
		err("thpool_init(): Could not allocate memory for threads\n");
		jobqueue_destroy(&thpool_p->__jobqueue);
		free(thpool_p);
		return NULL;
	}

	pthread_mutex_init(&(thpool_p->thcount_lock), NULL);
	pthread_cond_init(&thpool_p->threads_all_idle, NULL);

	/* Thread init */
	int n;
	for (n=0; n<num_threads; n++){
		thread_init(thpool_p, &thpool_p->threads[n], n);
#if THPOOL_DEBUG
			printf("THPOOL_DEBUG: Created thread %d in pool \n", n);
#endif
	}

	/* Wait for threads to initialize */
	while (thpool_p->num_threads_alive != num_threads) {}

	return thpool_p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %r14d
xorl %r15d, %r15d
movl %r15d, 0x51c1(%rip)     # 0xb428
movl $0x1, 0x51bb(%rip)      # 0xb42c
testl %edi, %edi
movl $0x0, %r13d
cmovgl %edi, %r13d
movl $0xb0, %edi
callq 0x22c0
testq %rax, %rax
je 0x6392
movq %rax, %rbx
movl %r15d, 0x8(%rax)
movl %r15d, 0xc(%rax)
movl %r15d, 0xa8(%rax)
movl $0x60, %edi
callq 0x22c0
xorps %xmm0, %xmm0
movups %xmm0, 0x90(%rbx)
movq %rax, 0xa0(%rbx)
testq %rax, %rax
je 0x6399
leaq 0x68(%rbx), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x23d0
movq 0xa0(%rbx), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x23d0
leaq 0x28(%r12), %rdi
xorl %esi, %esi
callq 0x22a0
movl $0x0, 0x58(%r12)
movl %r13d, %edi
shlq $0x3, %rdi
callq 0x22c0
movq %rax, (%rbx)
testq %rax, %rax
je 0x63a3
leaq 0x10(%rbx), %rdi
xorl %esi, %esi
callq 0x23d0
movq %rbx, %rdi
addq $0x38, %rdi
xorl %esi, %esi
callq 0x22a0
testl %r14d, %r14d
jle 0x6378
movl %r14d, %r15d
xorl %r12d, %r12d
movq (%rbx), %r14
movl $0x18, %edi
callq 0x22c0
movq %rax, (%r14,%r12,8)
movq %rbx, 0x10(%rax)
movl %r12d, (%rax)
leaq 0x8(%rax), %rdi
xorl %esi, %esi
leaq 0x30c(%rip), %rdx       # 0x6667
movq %rax, %rcx
callq 0x2310
movq (%r14,%r12,8), %rax
movq 0x8(%rax), %rdi
callq 0x22e0
incq %r12
cmpq %r12, %r15
jne 0x6336
movl 0x8(%rbx), %eax
cmpl %r13d, %eax
jne 0x6378
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2890
jmp 0x63ae
movq %rbx, %rdi
callq 0x285d
jmp 0x63ae
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2820
xorl %ebx, %ebx
jmp 0x6380
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: thpool_add_work
int thpool_add_work(thpool_* thpool_p, void* (*function_p)(void*), void* arg_p){
	job* newjob;

	newjob=(struct job*)malloc(sizeof(struct job));
	if (newjob==NULL){
		err("thpool_add_work(): Could not allocate memory for new job\n");
		return -1;
	}

	/* add function and argument */
	newjob->function=function_p;
	newjob->arg=arg_p;

	/* add job to queue */
	jobqueue_push(&thpool_p->__jobqueue, newjob);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
movl $0x18, %edi
callq 0x22c0
testq %rax, %rax
je 0x64a5
movq %rax, %r15
movq %r12, 0x8(%rax)
movq %r14, 0x10(%rax)
leaq 0x68(%rbx), %r14
movq %r14, %rdi
callq 0x23f0
movq $0x0, (%r15)
movl 0xa8(%rbx), %eax
testl %eax, %eax
je 0x6470
movq 0x98(%rbx), %rcx
movq %r15, (%rcx)
jmp 0x6477
movq %r15, 0x90(%rbx)
movq %r15, 0x98(%rbx)
incl %eax
movl %eax, 0xa8(%rbx)
movq 0xa0(%rbx), %rdi
callq 0x68cf
movq %r14, %rdi
callq 0x22b0
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x28bf
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x649c
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: thpool_wait
void thpool_wait(thpool_* thpool_p){
	pthread_mutex_lock(&thpool_p->thcount_lock);
	while (thpool_p->__jobqueue.len || thpool_p->num_threads_working) {
		pthread_cond_wait(&thpool_p->threads_all_idle, &thpool_p->thcount_lock);
	}
	pthread_mutex_unlock(&thpool_p->thcount_lock);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x10(%rdi), %rbx
movq %rbx, %rdi
callq 0x23f0
leaq 0x38(%r14), %r15
cmpl $0x0, 0xa8(%r14)
jne 0x64df
cmpl $0x0, 0xc(%r14)
je 0x64ec
movq %r15, %rdi
movq %rbx, %rsi
callq 0x20e0
jmp 0x64ce
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x22b0
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: thpool_destroy
void thpool_destroy(thpool_* thpool_p){
	/* No need to destory if it's NULL */
	if (thpool_p == NULL) return ;

	volatile int threads_total = thpool_p->num_threads_alive;

	/* End each thread 's infinite loop */
	threads_keepalive = 0;

	/* Give one second to kill idle threads */
	double TIMEOUT = 1.0;
	time_t start, end;
	double tpassed = 0.0;
	time (&start);
	while (tpassed < TIMEOUT && thpool_p->num_threads_alive){
		bsem_post_all(thpool_p->__jobqueue.has_jobs);
		time (&end);
		tpassed = difftime(end,start);
	}

	/* Poll remaining threads */
	while (thpool_p->num_threads_alive){
		bsem_post_all(thpool_p->__jobqueue.has_jobs);
		sleep(1);
	}

	/* Job queue cleanup */
	jobqueue_destroy(&thpool_p->__jobqueue);
	/* Deallocs */
	int n;
	for (n=0; n < threads_total; n++){
		thread_destroy(thpool_p->threads[n]);
	}
	free(thpool_p->threads);
	free(thpool_p);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %fs:0x28, %rax
movq %rax, -0x18(%rbp)
testq %rdi, %rdi
je 0x65cc
movq %rdi, %rbx
movl 0x8(%rdi), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, 0x4efa(%rip)      # 0xb42c
leaq -0x20(%rbp), %rdi
callq 0x2280
leaq -0x28(%rbp), %r14
cmpl $0x0, 0x8(%rbx)
je 0x658c
movq 0xa0(%rbx), %rdi
callq 0x65e9
movq %r14, %rdi
callq 0x2280
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x2160
movsd 0x1e22(%rip), %xmm1     # 0x8390
ucomisd %xmm0, %xmm1
ja 0x653f
jmp 0x658c
movq 0xa0(%rbx), %rdi
callq 0x65e9
movl $0x1, %edi
callq 0x23c0
cmpl $0x0, 0x8(%rbx)
jne 0x6576
leaq 0x68(%rbx), %rdi
callq 0x63b2
cmpl $0x0, -0x2c(%rbp)
jle 0x65bc
xorl %r14d, %r14d
movq (%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x2030
incq %r14
movslq -0x2c(%rbp), %rax
cmpq %rax, %r14
jl 0x65a4
movq (%rbx), %rdi
callq 0x2030
movq %rbx, %rdi
callq 0x2030
movq %fs:0x28, %rax
cmpq -0x18(%rbp), %rax
jne 0x65e4
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
callq 0x2110
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: bsem_post_all
static void bsem_post_all(bsem *bsem_p) {
	pthread_mutex_lock(&bsem_p->mutex);
	bsem_p->v = 1;
	pthread_cond_broadcast(&bsem_p->cond);
	pthread_mutex_unlock(&bsem_p->mutex);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x23f0
movl $0x1, 0x58(%rbx)
leaq 0x28(%rbx), %rdi
callq 0x2080
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x22b0
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: thread_hold
static void thread_hold(int sig_id) {
    (void)sig_id;
	threads_on_hold = 1;
	while (threads_on_hold){
		sleep(1);
	}
}

// Assembly:
movl $0x1, 0x4bd2(%rip)      # 0xb428
cmpl $0x0, 0x4bcb(%rip)      # 0xb428
je 0x6877
pushq %rbp
movq %rsp, %rbp
movl $0x1, %edi
callq 0x23c0
cmpl $0x0, 0x4bb4(%rip)      # 0xb428
jne 0x6863
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: jobqueue_pull
static struct job* jobqueue_pull(jobqueue* jobqueue_p){

	pthread_mutex_lock(&jobqueue_p->rwmutex);
	job* job_p = jobqueue_p->front;

	switch(jobqueue_p->len){

		case 0:  /* if no jobs in queue */
		  			break;

		case 1:  /* if one job in queue */
					jobqueue_p->front = NULL;
					jobqueue_p->rear  = NULL;
					jobqueue_p->len = 0;
					break;

		default: /* if >1 jobs in queue */
					jobqueue_p->front = job_p->prev;
					jobqueue_p->len--;
					/* more than one job in queue -> post it */
					bsem_post(jobqueue_p->has_jobs);

	}

	pthread_mutex_unlock(&jobqueue_p->rwmutex);
	return job_p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x23f0
movq 0x28(%rbx), %r14
movl 0x40(%rbx), %eax
testl %eax, %eax
je 0x68bf
cmpl $0x1, %eax
jne 0x68aa
leaq 0x28(%rbx), %rax
movl $0x0, 0x40(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
jmp 0x68bf
movq (%r14), %rcx
movq %rcx, 0x28(%rbx)
decl %eax
movl %eax, 0x40(%rbx)
movq 0x38(%rbx), %rdi
callq 0x68cf
movq %rbx, %rdi
callq 0x22b0
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: bsem_post
static void bsem_post(bsem *bsem_p) {
	pthread_mutex_lock(&bsem_p->mutex);
	bsem_p->v = 1;
	pthread_cond_signal(&bsem_p->cond);
	pthread_mutex_unlock(&bsem_p->mutex);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x23f0
movl $0x1, 0x58(%rbx)
leaq 0x28(%rbx), %rdi
callq 0x21f0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x22b0
// File: /workspace/github_c_makefile_star2_O1/zhoudian64[P]OS2-exp/mmap_example.c
// Function: main
int main() {
	// U may use dprintf instead of trying to oreooreo fds.
	int fd = open("./data.bin", O_RDWR | O_CREAT, 0666);
	dprintf(fd, "%d\n",8);

	char *p = mmap(NULL, sizeof(char), PROT_READ, MAP_SHARED, fd, 0);
	while (1) {
		printf("%c\n", *p);
		sleep(1);
	}
	munmap(p, sizeof(int));
	close(fd);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
leaq 0xe7a(%rip), %rdi       # 0x2004
movl $0x42, %esi
movl $0x1b6, %edx            # imm = 0x1B6
xorl %eax, %eax
callq 0x1060
movl %eax, %ebx
leaq 0xe6b(%rip), %rsi       # 0x200f
movl %eax, %edi
movl $0x8, %edx
xorl %eax, %eax
callq 0x1050
movl $0x1, %esi
xorl %edi, %edi
movl $0x1, %edx
movl $0x1, %ecx
movl %ebx, %r8d
xorl %r9d, %r9d
callq 0x1030
movq %rax, %rbx
leaq 0xe3b(%rip), %r14       # 0x2013
movsbl (%rbx), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x1040
movl $0x1, %edi
callq 0x1070
jmp 0x11d8
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/test/test_kstring.c
// Function: test_kputuw_from_to
static int test_kputuw_from_to(kstring_t *str, unsigned int s, unsigned int e) {
    unsigned int i = s;

    for (;;) {
        str->l = 0;
        memset(str->s, 0xff, str->m);
        if (kputuw(i, str) < 0 || !str->s) {
            perror("kputuw");
            return -1;
        }
        if (str->l >= str->m || str->s[str->l] != '\0') {
            fprintf(stderr, "No NUL termination on string from kputuw\n");
            return -1;
        }
        if (i != strtoul(str->s, NULL, 10)) {
            fprintf(stderr,
                    "kputuw wrote the wrong value, expected %u, got %s\n",
                    i, str->s);
            return -1;
        }
        if (i >= e) break;
        i++;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movl %esi, %ebx
movq %rdi, %r14
movq $0x0, (%rdi)
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rdi
movl $0xff, %esi
callq 0x10a0
movl %ebx, %edi
movq %r14, %rsi
callq 0x28eb
testl %eax, %eax
js 0x28a4
cmpl %ebx, %ebp
cmovbel %ebx, %ebp
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x28a4
movq (%r14), %rax
cmpq 0x8(%r14), %rax
jae 0x28b6
cmpb $0x0, (%rdi,%rax)
jne 0x28b6
movl %ebx, %r15d
xorl %esi, %esi
movl $0xa, %edx
callq 0x1070
cmpq %r15, %rax
jne 0x28bd
cmpl %ebx, %ebp
je 0x28b2
incl %ebx
movq $0x0, (%r14)
movq 0x8(%r14), %rdx
movq 0x10(%r14), %rdi
movl $0xff, %esi
callq 0x10a0
movl %ebx, %edi
movq %r14, %rsi
callq 0x28eb
testl %eax, %eax
jns 0x284b
leaq 0x17af(%rip), %rdi      # 0x405a
callq 0x10e0
jmp 0x28db
xorl %eax, %eax
jmp 0x28e0
callq 0x13e0
jmp 0x28db
movq 0x4714(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
movq 0x10(%r14), %rcx
leaq 0x18a8(%rip), %rsi      # 0x417a
movl %ebx, %edx
xorl %eax, %eax
callq 0x1160
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/test/test_kstring.c
// Function: test_kputw_from_to
static int test_kputw_from_to(kstring_t *str, int s, int e) {
    int i = s;

    for (;;) {
        str->l = 0;
        memset(str->s, 0xff, str->m);
        if (kputw(i, str) < 0 || !str->s) {
            perror("kputw");
            return -1;
        }
        if (str->l >= str->m || str->s[str->l] != '\0') {
            fprintf(stderr, "No NUL termination on string from kputw\n");
            return -1;
        }
        if (i != strtol(str->s, NULL, 10)) {
            fprintf(stderr,
                    "kputw wrote the wrong value, expected %d, got %s\n",
                    i, str->s);
            return -1;
        }
        if (i >= e) break;
        i++;
    }
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %r14
movslq %esi, %rbx
cmpl %ebx, %edx
cmovlel %ebx, %edx
movslq %edx, %r12
xorl %r13d, %r13d
movq $0x0, (%r14)
movq 0x8(%r14), %rdx
movq 0x10(%r14), %rdi
movl $0xff, %esi
callq 0x10a0
movl %ebx, %edi
testq %rbx, %rbx
jns 0x2add
movq (%r14), %rax
addq $0x3, %rax
cmpq %rax, 0x8(%r14)
jae 0x2ac7
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %r15
shrq %r15
testq %rcx, %rcx
cmovneq %r13, %r15
addq %rax, %r15
movq 0x10(%r14), %rdi
movq %r15, %rsi
callq 0x1190
testq %rax, %rax
je 0x2b23
movq %rax, 0x10(%r14)
movq %r15, 0x8(%r14)
movl %ebx, %edi
negl %edi
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, (%r14)
movb $0x2d, (%rcx,%rax)
movq %r14, %rsi
callq 0x28eb
testl %eax, %eax
js 0x2b23
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x2b23
movq (%r14), %rax
cmpq 0x8(%r14), %rax
jae 0x2b31
cmpb $0x0, (%rdi,%rax)
jne 0x2b31
xorl %esi, %esi
movl $0xa, %edx
callq 0x1140
cmpq %rax, %rbx
jne 0x2b38
cmpq %rbx, %r12
je 0x2b1f
incq %rbx
jmp 0x2a6a
xorl %eax, %eax
jmp 0x2b5b
leaq 0x1537(%rip), %rdi      # 0x4061
callq 0x10e0
jmp 0x2b56
callq 0x13fc
jmp 0x2b56
movq 0x4499(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
movq 0x10(%r14), %rcx
leaq 0x1689(%rip), %rsi      # 0x41d6
movl %ebx, %edx
xorl %eax, %eax
callq 0x1160
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/test/test_kstring.c
// Function: test_kputll_from_to
static int test_kputll_from_to(kstring_t *str, long long s, long long e) {
    long long i = s;

    for (;;) {
        str->l = 0;
        memset(str->s, 0xff, str->m);
        if (kputll(i, str) < 0 || !str->s) {
            perror("kputll");
            return -1;
        }
        if (str->l >= str->m || str->s[str->l] != '\0') {
            fprintf(stderr, "No NUL termination on string from kputll\n");
            return -1;
        }
        if (i != strtoll(str->s, NULL, 10)) {
            fprintf(stderr,
                    "kputll wrote the wrong value, expected %lld, got %s\n",
                    i, str->s);
            return -1;
        }
        if (i >= e) break;
        i++;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1a50(%rip), %r13      # 0x45d0
movabsq $0x28f5c28f5c28f5c3, %rbp # imm = 0x28F5C28F5C28F5C3
movq $0x0, (%r14)
movq 0x8(%r14), %rdx
movq 0x10(%r14), %rdi
movl $0xff, %esi
callq 0x10a0
movq (%r14), %rax
addq $0x17, %rax
cmpq %rax, 0x8(%r14)
jae 0x2be9
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %r12
shrq %r12
testq %rcx, %rcx
movl $0x0, %ecx
cmovneq %rcx, %r12
addq %rax, %r12
movq 0x10(%r14), %rdi
movq %r12, %rsi
callq 0x1190
testq %rax, %rax
je 0x2ce4
movq %rax, 0x10(%r14)
movq %r12, 0x8(%r14)
movq %rbx, %rdx
testq %rbx, %rbx
jns 0x2c09
movq %rbx, %rdx
negq %rdx
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rax), %rsi
movq %rsi, (%r14)
movb $0x2d, (%rcx,%rax)
movq %rdx, %rax
shrq $0x20, %rax
jne 0x2c29
movl %edx, %edi
movq %r14, %rsi
callq 0x28eb
testl %eax, %eax
jns 0x2caa
jmp 0x2ce4
movl $0x14, %ecx
movabsq $-0x7538dcfb76180001, %rax # imm = 0x8AC7230489E7FFFF
cmpq %rax, %rdx
ja 0x2c52
movl $0x1, %eax
xorl %ecx, %ecx
incl %ecx
addq %rax, %rax
leaq (%rax,%rax,4), %rax
cmpq %rax, %rdx
jae 0x2c44
movq 0x10(%r14), %rsi
addq (%r14), %rsi
leal -0x2(%rcx), %edi
movq %rdx, %r8
movq %rdx, %rax
shrq $0x2, %rax
mulq %rbp
shrq $0x2, %rdx
imulq $0x64, %rdx, %rax
movq %r8, %r9
subq %rax, %r9
movl %edi, %eax
movzwl (%r13,%r9,2), %r9d
movw %r9w, (%rsi,%rax)
addl $-0x2, %edi
cmpq $0x3e7, %r8             # imm = 0x3E7
ja 0x2c5c
cmpl $-0x1, %edi
jne 0x2c9a
orb $0x30, %dl
movb %dl, (%rsi)
movl %ecx, %eax
addq (%r14), %rax
movq %rax, (%r14)
movq 0x10(%r14), %rcx
movb $0x0, (%rcx,%rax)
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x2ce4
movq (%r14), %rax
cmpq 0x8(%r14), %rax
jae 0x2cf2
cmpb $0x0, (%rdi,%rax)
jne 0x2cf2
xorl %esi, %esi
movl $0xa, %edx
callq 0x1050
cmpq %rax, %rbx
jne 0x2cf9
cmpq %r15, %rbx
jge 0x2ce0
incq %rbx
jmp 0x2b8a
xorl %eax, %eax
jmp 0x2d1d
leaq 0x137c(%rip), %rdi      # 0x4067
callq 0x10e0
jmp 0x2d18
callq 0x1418
jmp 0x2d18
movq 0x42d8(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
movq 0x10(%r14), %rcx
leaq 0x1524(%rip), %rsi      # 0x4232
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1160
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/goghcrow[P]dubbo_ab/dubbo_client.c
// Function: cli_reconnect
static void cli_reconnect(struct dubbo_client *cli)
{
    LOG_INFO("重新连接...");
    cli_close(cli);
    if (!cli_connect(cli))
    {
        LOG_ERROR("重连失败");
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0xd92b(%rip), %r14      # 0xfff8
movq (%r14), %rdi
leaq 0x8d91(%rip), %rsi      # 0xb468
leaq 0x8dc2(%rip), %rdx      # 0xb4a0
leaq 0x88bd(%rip), %rcx      # 0xafa2
movl $0x113, %r8d            # imm = 0x113
xorl %eax, %eax
callq 0x21e0
movq %rbx, %rdi
callq 0x9996
movq %rbx, %rdi
callq 0x8e4c
testb %al, %al
je 0x270b
popq %rbx
popq %r14
popq %rbp
retq
movq (%r14), %rdi
leaq 0x8d99(%rip), %rsi      # 0xb4ae
leaq 0x8d84(%rip), %rdx      # 0xb4a0
leaq 0x887f(%rip), %rcx      # 0xafa2
movl $0x117, %r8d            # imm = 0x117
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x21e0
// File: /workspace/github_c_makefile_star2_O1/goghcrow[P]dubbo_ab/lib/ae/ae.c
// Function: aeMain
void aeMain(aeEventLoop *eventLoop) {
    eventLoop->stop = 0;
    while (!eventLoop->stop) {
        if (eventLoop->beforesleep != NULL)
            eventLoop->beforesleep(eventLoop);
        aeProcessEvents(eventLoop, AE_ALL_EVENTS|AE_CALL_AFTER_SLEEP);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x0, 0x30(%rdi)
movq 0x40(%rbx), %rax
testq %rax, %rax
je 0x3733
movq %rbx, %rdi
callq *%rax
movq %rbx, %rdi
movl $0xb, %esi
callq 0x328f
cmpl $0x0, 0x30(%rbx)
je 0x3725
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/goghcrow[P]dubbo_ab/lib/utf8_decode.c
// Function: utf8_decode_init
void utf8_decode_init(char p[], int length) {
    the_index = 0;
    the_input = p;
    the_length = length;
    the_char = 0;
    the_byte = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
movl %eax, 0xca84(%rip)      # 0x10200
movq %rdi, 0xca85(%rip)      # 0x10208
movl %esi, 0xca87(%rip)      # 0x10210
movl %eax, 0xca85(%rip)      # 0x10214
movl %eax, 0xca83(%rip)      # 0x10218
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/goghcrow[P]dubbo_ab/lib/cJSON.c
// Function: cJSON_AddItemToObject
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
{
    if (item == NULL)
    {
        return;
    }

    /* call cJSON_AddItemToObjectCS for code reuse */
    cJSON_AddItemToObjectCS(object, (char*)cJSON_strdup((const unsigned char*)string, &global_hooks), item);
    /* remove cJSON_StringIsConst flag */
    item->type &= ~cJSON_StringIsConst;
}

// Assembly:
testq %rdx, %rdx
je 0x4a8f
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
testq %rsi, %rsi
je 0x4a6c
movq %r15, %rdi
callq 0x20d0
movq %rax, %r13
incq %r13
movq %r13, %rdi
callq *0xb78c(%rip)           # 0x101e0
testq %rax, %rax
je 0x4a6c
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2200
jmp 0x4a6f
xorl %r12d, %r12d
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x4a90
andb $-0x3, 0x19(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq