LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: notifyAll
bool notifyAll(struct service* s) {
    char *cmds = NULL;
    if(asprintf(&cmds, "notify %s %s", s->name, statestr(s->state)) == -1) {
        return false;
    }
    struct buf cmdb = { .dat = cmds, .len = strlen(cmds) + 1 };
    bool oks[s->notify_n];
    size_t nok = 0;
    for(size_t i = 0; i < s->notify_n; i++) {
        switch(notify(s->notify[i], s, cmdb)) {
        case notify_success:
            oks[i] = true;
            nok++;
            break;
        case notify_gone:
            oks[i] = false;
            break;
        case notify_fail:
            free(cmds);
            return false;
        }
    }
    if(nok != s->notify_n) {
        //compact the buffer
        struct conn **not = s->notify;
        for(size_t i = 0; i < s->notify_n; i++) {
            if(oks[i]) { *(not++) = s->notify[i]; }
        }
        //shrink memory allocation with realloc
        not = realloc(s->notify, sizeof(struct conn *) * nok);
        if(not == NULL) {   //reallocation failed - just change the notify_n
            s->notify_n = nok;
        } else {
            s->notify = not;
            s->notify_n = nok;
        }
    }
    free(cmds);
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
leaq -0x38(%rbp), %r15
andq $0x0, (%r15)
movq %rdi, %rbx
movq (%rdi), %r12
movl 0x8(%rdi), %edi
callq 0x1357
leaq 0x1a9d(%rip), %rsi      # 0x3057
xorl %r14d, %r14d
movq %r15, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1170
cmpl $-0x1, %eax
je 0x16af
movq -0x38(%rbp), %rdi
movq %rdi, -0x48(%rbp)
callq 0x10a0
movq %rax, %r12
movq %rsp, -0x40(%rbp)
incq %r12
movq 0x18(%rbx), %rax
movq %rsp, %r13
addq $0xf, %rax
andq $-0x10, %rax
subq %rax, %r13
movq %r13, %rsp
movq $0x0, -0x30(%rbp)
xorl %r15d, %r15d
movq 0x18(%rbx), %rax
cmpq %rax, %r15
setae %r14b
jae 0x164f
movq 0x10(%rbx), %rax
movq (%rax,%r15,8), %rdi
movq -0x48(%rbp), %rdx
movq %r12, %rcx
callq 0x13dc
cmpl $0x1, %eax
je 0x1640
cmpl $0x2, %eax
jne 0x16a2
movb $0x0, (%r13,%r15)
jmp 0x164a
movb $0x1, (%r13,%r15)
incq -0x30(%rbp)
incq %r15
jmp 0x160d
cmpq %rax, -0x30(%rbp)
je 0x16a2
movq 0x10(%rbx), %rcx
xorl %edx, %edx
cmpq %rdx, %rax
je 0x167c
cmpb $0x1, (%r13,%rdx)
jne 0x1677
movq 0x10(%rbx), %rsi
movq (%rsi,%rdx,8), %rsi
movq %rsi, (%rcx)
addq $0x8, %rcx
incq %rdx
jmp 0x165b
movq 0x10(%rbx), %rdi
movq -0x30(%rbp), %rax
leaq (,%rax,8), %rsi
callq 0x1160
testq %rax, %rax
je 0x169a
movq %rax, 0x10(%rbx)
movq -0x30(%rbp), %rax
movq %rax, 0x18(%rbx)
movq -0x38(%rbp), %rdi
callq 0x1030
movq -0x40(%rbp), %rsp
movl %r14d, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: findService
struct service* findService(char* name) {
    struct service *s;
    for(s = services.first; s != NULL; s = s->next) {
        if(streq(s->name, name)) {
            return s;
        }
    }
    return s;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x4a81(%rip), %rbx      # 0x6150
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x16ec
movq (%rbx), %rdi
movq %r14, %rsi
callq 0x1120
testl %eax, %eax
je 0x16ec
addq $0x20, %rbx
jmp 0x16cf
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: newService
struct service* newService() {
    struct service* new = alalloc(struct service);
    if(new == NULL) {
        return NULL;
    }
    if(services.first == NULL) {
        services.first = new;
        return new;
    }
    struct service *s, *n;
    for(s = n = services.first; n != NULL; n = n->next) { s = n; }
    s->next = new;
    return new;
}

// Assembly:
pushq %rax
pushq $0x28
popq %rdi
callq 0x134c
testq %rax, %rax
je 0x1732
movq 0x4a44(%rip), %rcx      # 0x6150
testq %rcx, %rcx
je 0x1728
movq %rcx, %rdx
testq %rdx, %rdx
je 0x1722
movq %rdx, %rcx
movq 0x20(%rdx), %rdx
jmp 0x1714
addq $0x20, %rcx
jmp 0x172f
leaq 0x4a21(%rip), %rcx      # 0x6150
movq %rax, (%rcx)
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: rmService
void rmService(char* name) {
    struct service *s, *n;
    for(s = n = services.first; (n != NULL) && (!streq(n->name, name)); n = n->next) { s = n; }
    if(n == NULL) {
        fprintf(stderr, "[FATAL] Service %s does not exist\n", name);
        exit(65);
    }
    s->next = n->next;
    //notifications should already have been dealt with
    free(n->name);
    free(n);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x4a0a(%rip), %rcx      # 0x6150
movq %rcx, %rdx
testq %rdx, %rdx
je 0x178d
movq %rdx, %r14
movq %rcx, %r12
movq (%rdx), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1120
movq 0x20(%r14), %rdx
movq %r14, %rcx
testl %eax, %eax
jne 0x1749
movq %rdx, 0x20(%r12)
movq %r15, %rdi
callq 0x1030
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x1030
movq 0x4864(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
leaq 0x18c6(%rip), %rsi      # 0x3064
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1130
pushq $0x41
popq %rdi
callq 0x11f0
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: readBuf
bool readBuf(struct buf *b, int fd) {  //read data from fd into the buffer
    byte dat[1024];
    size_t n = read(fd, dat, 1024);
    if(n < 0) {
        return false;
    } else if(n == 0) {
        return true;
    }
    byte* nd = arralloc(byte, n + b->len);
    if(nd == NULL) {
        return false;
    }
    memcpy(nd, b->dat, b->len);
    memcpy(nd + b->len, dat, n);
    free(b->dat);
    b->dat = nd;
    b->len += n;
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movl %esi, %eax
movq %rdi, %rbx
movq %rsp, %rsi
movl $0x400, %edx            # imm = 0x400
movl %eax, %edi
callq 0x10f0
movb $0x1, %bpl
testq %rax, %rax
je 0x182a
movq %rax, %r14
movq 0x8(%rbx), %r12
leaq (%r12,%rax), %rdi
callq 0x134c
testq %rax, %rax
je 0x1828
movq %rax, %r15
movq (%rbx), %r13
movq %rax, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x1140
movq %r15, %rdi
addq %r12, %rdi
movq %rsp, %rsi
movq %r14, %rdx
callq 0x1140
movq %r13, %rdi
callq 0x1030
movq %r15, (%rbx)
addq %r14, 0x8(%rbx)
jmp 0x182a
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: writeBuf
bool writeBuf(struct buf* b, int fd) { //write data from buffer into fd
    size_t n = write(fd, b->dat, b->len);
    if(n < 1) {
        return false;
    }
    byte* nd = arralloc(byte, n - b->len);
    if(nd == NULL) {
        return false;
    }
    memcpy(nd, b->dat + n, b->len - n);
    free(b->dat);
    b->dat = nd;
    b->len -= n;
    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %esi, %eax
movq %rdi, %rbx
movq (%rdi), %rsi
movq 0x8(%rdi), %rdx
movl %eax, %edi
callq 0x1090
testq %rax, %rax
je 0x18a1
movq %rax, %r14
movq 0x8(%rbx), %r12
movq %rax, %rdi
subq %r12, %rdi
callq 0x134c
testq %rax, %rax
je 0x18a1
movq %rax, %r15
movq (%rbx), %r13
leaq (%r14,%r13), %rsi
subq %r14, %r12
movq %rax, %rdi
movq %r12, %rdx
callq 0x1140
movq %r13, %rdi
callq 0x1030
movq %r15, (%rbx)
subq %r14, 0x8(%rbx)
movb $0x1, %al
jmp 0x18a3
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: set_noblock
void set_noblock(int fd) {
    int flags = fcntl(fd, F_GETFL, 0);
    if(flags < 0) {
        goto fail;
    }
    flags |= O_NONBLOCK;
    if(fcntl(fd, F_SETFL, flags) == -1) {
        goto fail;
    }
    return;
fail:
    fprintf(stderr, "[FATAL] Failed to SET O_NONBLOCK on %d: %s\n", fd, strerror(errno));
    exit(65);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
pushq $0x3
popq %rsi
xorl %edx, %edx
xorl %eax, %eax
callq 0x1080
testl %eax, %eax
js 0x18e3
orl $0x800, %eax            # imm = 0x800
pushq $0x4
popq %rsi
movl %ebx, %edi
movl %eax, %edx
xorl %eax, %eax
callq 0x1080
cmpl $-0x1, %eax
je 0x18e3
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x470e(%rip), %rax      # 0x5ff8
movq (%rax), %r14
callq 0x1040
movl (%rax), %edi
callq 0x1220
leaq 0x1787(%rip), %rsi      # 0x3087
movq %r14, %rdi
movl %ebx, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1130
pushq $0x41
popq %rdi
callq 0x11f0
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: addSock
void addSock(int fd) {  //add a socket to epoll
    printf("Sock: %d\n", fd);
    if(listen(fd, backlog) == -1) {
        fprintf(stderr, "[FATAL] Failed to run listen on %d: %s\n", fd, strerror(errno));
        exit(65);
    }
    struct epolldat *d = alalloc(struct epolldat);
    if(d == NULL) {
        fprintf(stderr, "[FATAL] Failed to allocate epolldat for %d: %s\n", fd, strerror(errno));
        exit(65);
    }
    d->typecode = epoll_socket;
    d->sockfd = fd;
    //register with epoll
    struct epoll_event ev = {.events = EPOLLIN, .data = {.ptr = d}};
    if(epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev) == -1) {
        fprintf(stderr, "[FATAL] Failed to register with epoll: %s\n", strerror(errno));
        exit(65);
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebx
leaq 0x178c(%rip), %rdi      # 0x30b3
movl %ebx, %esi
xorl %eax, %eax
callq 0x10c0
movl 0x4802(%rip), %esi      # 0x6138
movl %ebx, %edi
callq 0x1150
cmpl $-0x1, %eax
je 0x197c
pushq $0x10
popq %rdi
callq 0x134c
testq %rax, %rax
je 0x199b
pushq $0x1
popq %rsi
movl %esi, (%rax)
movl %ebx, 0x8(%rax)
leaq 0xc(%rsp), %rcx
movl %esi, (%rcx)
movq %rax, 0x4(%rcx)
movl 0x47e0(%rip), %edi      # 0x6148
movl %ebx, %edx
callq 0x10e0
cmpl $-0x1, %eax
je 0x19c9
addq $0x18, %rsp
popq %rbx
popq %r14
retq
movq 0x4675(%rip), %rax      # 0x5ff8
movq (%rax), %r14
callq 0x1040
movl (%rax), %edi
callq 0x1220
leaq 0x1724(%rip), %rsi      # 0x30bd
jmp 0x19b8
movq 0x4656(%rip), %rax      # 0x5ff8
movq (%rax), %r14
callq 0x1040
movl (%rax), %edi
callq 0x1220
leaq 0x172d(%rip), %rsi      # 0x30e5
movq %r14, %rdi
movl %ebx, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1130
jmp 0x19f3
movq 0x4628(%rip), %rax      # 0x5ff8
movq (%rax), %rbx
callq 0x1040
movl (%rax), %edi
callq 0x1220
leaq 0x172f(%rip), %rsi      # 0x3115
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1130
pushq $0x41
popq %rdi
callq 0x11f0
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: handle_epoll
void handle_epoll(struct epoll_event ev) {  //handle an epoll event
    struct epolldat d = *((struct epolldat*)ev.data.ptr);
    switch(d.typecode) {
    case epoll_conn:
        handle_conn(d.c, ev.events);
        break;
    case epoll_socket:
        handle_socket(d.sockfd, ev.events);
        break;
    }
}

// Assembly:
leaq 0x8(%rsp), %rax
movq 0x4(%rax), %rdx
movl (%rdx), %ecx
movq 0x8(%rdx), %rdi
cmpl $0x1, %ecx
je 0x1a1a
testl %ecx, %ecx
jne 0x1a21
movl (%rax), %esi
jmp 0x1a22
movl (%rax), %esi
jmp 0x1bd6
retq
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: handle_socket
void handle_socket(int sockfd, uint32_t events) {
    if(EPOLL_MODE(events, EPOLLIN)) {
        int fd = accept(sockfd, NULL, NULL);
        if(fd == -1) {
            fprintf(stderr, "[ERROR] Failed to accept connection: %s\n", strerror(errno));
            return;
        }
        struct conn *c = newConn(fd);
        if(c == NULL) {
            fprintf(stderr, "[ERROR] Failed to create conn with fd %d\n", fd);
            if(close(fd) == -1) {
                fprintf(stderr, "[FATAL] Failed to close fd %d\n", fd);
                exit(65);
            }
            return;
        }
    } else if(EPOLL_MODE(events, EPOLLPRI)) {
        fprintf(stderr, "[FATAL] Recieved EPOLLPRI on socket fd %d\n", sockfd);
        exit(65);
    } else if(EPOLL_MODE(events, EPOLLERR)) {
        fprintf(stderr, "[FATAL] Recieved EPOLLERR on socket fd %d\n", sockfd);
        exit(65);
    } else {
        fprintf(stderr, "[FATAL] Recieved unrecognized epoll event %d on socket fd %d\n", events, sockfd);
        exit(65);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %edx
movl %edi, %ecx
testb $0x1, %dl
je 0x1c72
movl %ecx, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x11c0
cmpl $-0x1, %eax
je 0x1c0d
movl %eax, %ebx
movl %eax, %edi
callq 0x1d50
testq %rax, %rax
je 0x1c3e
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x43e4(%rip), %rax      # 0x5ff8
movq (%rax), %rbx
callq 0x1040
movl (%rax), %edi
callq 0x1220
leaq 0x1550(%rip), %rsi      # 0x317a
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1130
movq 0x43b3(%rip), %r14      # 0x5ff8
movq (%r14), %rdi
leaq 0x1554(%rip), %rsi      # 0x31a3
movl %ebx, %edx
xorl %eax, %eax
callq 0x1130
movl %ebx, %edi
callq 0x10d0
cmpl $-0x1, %eax
jne 0x1c05
movq (%r14), %rdi
leaq 0x155f(%rip), %rsi      # 0x31cd
movl %ebx, %edx
jmp 0x1cab
movq 0x437f(%rip), %rax      # 0x5ff8
testb $0x2, %dl
jne 0x1c96
movq (%rax), %rdi
testb $0x8, %dl
jne 0x1ca2
leaq 0x15b5(%rip), %rsi      # 0x3242
xorl %eax, %eax
callq 0x1130
jmp 0x1cb2
movq (%rax), %rdi
leaq 0x154c(%rip), %rsi      # 0x31ec
jmp 0x1ca9
leaq 0x156e(%rip), %rsi      # 0x3217
movl %ecx, %edx
xorl %eax, %eax
callq 0x1130
pushq $0x41
popq %rdi
callq 0x11f0
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: epoll_cycle
void epoll_cycle() {    //run epoll wait with a timeout and handle the events
    struct epoll_event ev[4];
    int n = epoll_wait(epollfd, ev, 4, 50);
    if(n == -1) {
        fprintf(stderr, "[FATAL] epoll_wait failed: %s\n", strerror(errno));
        exit(65);
        return;
    }
    for(int i = 0; i < n; i++) {
        handle_epoll(ev[i]);
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
movl 0x4481(%rip), %edi      # 0x6148
leaq 0x10(%rsp), %rsi
pushq $0x4
popq %rdx
pushq $0x32
popq %rcx
callq 0x1180
cmpl $-0x1, %eax
je 0x1d1e
xorl %ebx, %ebx
testl %eax, %eax
cmovlel %ebx, %eax
imulq $0xc, %rax, %r14
cmpq %rbx, %r14
je 0x1d16
movl 0x18(%rsp,%rbx), %eax
movl %eax, 0x8(%rsp)
movq 0x10(%rsp,%rbx), %rax
movq %rax, (%rsp)
movl 0x8(%rsp), %eax
movq (%rsp), %rcx
pushq %rax
pushq %rcx
callq 0x19fb
addq $0x10, %rsp
addq $0xc, %rbx
jmp 0x1ce7
addq $0x48, %rsp
popq %rbx
popq %r14
retq
movq 0x42d3(%rip), %rax      # 0x5ff8
movq (%rax), %rbx
callq 0x1040
movl (%rax), %edi
callq 0x1220
leaq 0x1405(%rip), %rsi      # 0x3140
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1130
pushq $0x41
popq %rdi
callq 0x11f0
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: newConn
struct conn *newConn(int fd) { //create a new conn with fd
    printf("[INFO] New connection: %d\n", fd);
    //set up conn data
    struct conn *c = alalloc(struct conn);
    if(c == NULL) {
        return NULL;
    }
    c->e.typecode = epoll_conn;
    c->e.c = c;
    c->fd = fd;
    c->txoff = true;
    //register with epoll
    struct epoll_event ev = {.events = EPOLLIN, .data = {.ptr = &c->e}};
    if(epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev) == -1) {
        fprintf(stderr, "[FATAL] Failed to register with epoll: %s\n", strerror(errno));
        exit(65);
    }
    ref(c); //referenced by epoll
    //tell read and write not to block
    set_noblock(fd);
    return c;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebx
leaq 0x13ff(%rip), %rdi      # 0x315f
movl %ebx, %esi
xorl %eax, %eax
callq 0x10c0
pushq $0x40
popq %rdi
callq 0x134c
movq %rax, %r14
testq %rax, %rax
je 0x1db9
andl $0x0, (%r14)
movq %r14, 0x8(%r14)
movl %ebx, 0x14(%r14)
movb $0x1, 0x19(%r14)
leaq 0xc(%rsp), %rcx
movl $0x1, (%rcx)
movq %r14, 0x4(%rcx)
movl 0x43a9(%rip), %edi      # 0x6148
pushq $0x1
popq %rsi
movl %ebx, %edx
callq 0x10e0
cmpl $-0x1, %eax
je 0x1dc4
incl 0x10(%r14)
movl %ebx, %edi
callq 0x18ad
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r14
retq
movq 0x422d(%rip), %rax      # 0x5ff8
movq (%rax), %rbx
callq 0x1040
movl (%rax), %edi
callq 0x1220
leaq 0x1334(%rip), %rsi      # 0x3115
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1130
pushq $0x41
popq %rdi
callq 0x11f0
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: conn_has_cmd
bool conn_has_cmd(struct conn *c) { //is there is a full command in the buffer?
    if(c->closed) { return false; }
    struct buf b = c->rx;
    for(size_t i = 0; i < b.len; i++) {
        switch(b.dat[i]) {
        case '\n':
            b.dat[i] = '\0';
        case '\0':
            return true;
        }
    }
    return false;
}

// Assembly:
cmpb $0x0, 0x18(%rdi)
je 0x1dff
xorl %eax, %eax
retq
movq 0x20(%rdi), %rcx
movq 0x28(%rdi), %rsi
xorl %edx, %edx
cmpq %rdx, %rsi
setne %al
je 0x1dfe
movzbl (%rcx,%rdx), %edi
testl %edi, %edi
je 0x1dfe
cmpl $0xa, %edi
je 0x1e23
incq %rdx
jmp 0x1e09
movb $0x0, (%rcx,%rdx)
movb $0x1, %al
retq
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: handle_scmd
void handle_scmd(struct conn *c) {
    ref(c);
    //extract command from rx buffer
    char *cmds = strdup(c->rx.dat);
    if(cmds == NULL) {
        fprintf(stderr, "[ERROR] Failed to extract command from conn %d\n", c->fd);
        close_conn(c);
        goto end;
    }
    //slide & shrink rx buffer
    memmove(c->rx.dat, c->rx.dat + strlen(cmds) + 1, c->rx.len - (strlen(cmds) + 1));
    c->rx.len -= strlen(cmds) + 1;
    byte *ndat = realloc(c->rx.dat, c->rx.len);
    if(ndat != NULL) {
        c->rx.dat = ndat;
    }
    //split command and args
    if(!hasSpace(cmds)) {
        fprintf(stderr, "[ERROR] Invalid command syntax (sent by conn %d): \"%s\"\n", c->fd, cmds);
        free(cmds);
        close_conn(c);
        goto end;
    }
    char *cmd, *args;
    for(cmd = args = cmds; *args != ' '; args++) {}
    *args = '\0';
    args++;
    //run handler
    if(streq(cmd, "start")) {
        cmd_start(c, args);
    } else if(streq(cmd, "stop")) {
        cmd_stop(c, args);
    } else if(streq(cmd, "state")) {
        cmd_state(c, args);
    } else {
        fprintf(stderr, "[ERROR] Unrecognized command \"%s\" sent on conn %d\n", cmd, c->fd);
        free(cmds);
        close_conn(c);
        goto end;
    }
    //cleanup
    free(cmds);
end:
    deref(c);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
incl 0x10(%rdi)
movq 0x20(%rdi), %r15
movq %r15, %rdi
callq 0x1210
testq %rax, %rax
je 0x1f3b
movq %rax, %r14
movq %rax, %rdi
callq 0x10a0
leaq (%r15,%rax), %rsi
incq %rsi
notq %rax
addq 0x28(%rbx), %rax
movq %r15, %rdi
movq %rax, %rdx
callq 0x11a0
movq %r14, %rdi
callq 0x10a0
notq %rax
addq 0x28(%rbx), %rax
movq %rax, 0x28(%rbx)
movq 0x20(%rbx), %rdi
movq %rax, %rsi
callq 0x1160
testq %rax, %rax
je 0x1e96
movq %rax, 0x20(%rbx)
movq %r14, %rdi
callq 0x20aa
testb %al, %al
je 0x1f58
movq %r14, %r15
cmpb $0x20, (%r15)
leaq 0x1(%r15), %r15
jne 0x1ea9
movb $0x0, -0x1(%r15)
leaq 0x152b(%rip), %rsi      # 0x33ea
movq %r14, %rdi
callq 0x1120
testl %eax, %eax
je 0x1f02
leaq 0x1524(%rip), %rsi      # 0x33f6
movq %r14, %rdi
callq 0x1120
testl %eax, %eax
je 0x1f0f
leaq 0x183f(%rip), %rsi      # 0x3724
movq %r14, %rdi
callq 0x1120
testl %eax, %eax
jne 0x1f78
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2560
jmp 0x1f1a
movq %rbx, %rdi
movq %r15, %rsi
callq 0x20bc
jmp 0x1f1a
movq %rbx, %rdi
movq %r15, %rsi
callq 0x231e
movq %r14, %rdi
callq 0x1030
subl $0x1, 0x10(%rbx)
jae 0x1f35
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x1030
popq %rbx
popq %r14
popq %r15
retq
movq 0x40b6(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
movl 0x14(%rbx), %edx
leaq 0x176d(%rip), %rsi      # 0x36bc
xorl %eax, %eax
callq 0x1130
jmp 0x1f9e
movq 0x4099(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
movl 0x14(%rbx), %edx
leaq 0x1780(%rip), %rsi      # 0x36ec
movq %r14, %rcx
xorl %eax, %eax
callq 0x1130
jmp 0x1f96
movq 0x4079(%rip), %rax      # 0x5ff8
movq (%rax), %rdi
movl 0x14(%rbx), %ecx
leaq 0x179e(%rip), %rsi      # 0x372a
movq %r14, %rdx
xorl %eax, %eax
callq 0x1130
movq %r14, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x14b8
jmp 0x1f22
// File: /workspace/github_c_makefile_star2_O2/panux[P]linit/src/linitd.c
// Function: fexec
bool fexec(int argc, char **argv) { //forks and exec's
    switch(fork()) {
    case -1:    //failure
        return false;
    case 0:;    //child
        char *args[argc + 1];
        for(int i = 0; i < argc; i++) {
            args[i] = argv[i];
        }
        args[argc] = NULL;
        if(execvpe(args[0], args, environ) == -1) {
            fprintf(stderr, "[FATAL] exec failed: %s\n", strerror(errno));
            exit(65);
        }
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movl %edi, %ebx
callq 0x1230
cmpl $-0x1, %eax
je 0x2027
testl %eax, %eax
jne 0x2023
movq %rsp, %r15
leal 0x1(%rbx), %eax
movq %rsp, %rsi
leaq 0xf(,%rax,8), %rax
andq $-0x10, %rax
subq %rax, %rsi
movq %rsi, %rsp
xorl %eax, %eax
testl %ebx, %ebx
movl $0x0, %ecx
cmovgl %ebx, %ecx
cmpq %rax, %rcx
je 0x2001
movq (%r14,%rax,8), %rdx
movq %rdx, (%rsi,%rax,8)
incq %rax
jmp 0x1fef
movslq %ebx, %rax
andq $0x0, (%rsi,%rax,8)
movq (%rsi), %rdi
movq 0x3fcd(%rip), %rax      # 0x5fe0
movq (%rax), %rdx
callq 0x10b0
cmpl $-0x1, %eax
je 0x2034
movq %r15, %rsp
movb $0x1, %al
jmp 0x2029
xorl %eax, %eax
leaq -0x18(%rbp), %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x3fbd(%rip), %rax      # 0x5ff8
movq (%rax), %rbx
callq 0x1040
movl (%rax), %edi
callq 0x1220
leaq 0x137a(%rip), %rsi      # 0x33cb
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x1130
pushq $0x41
popq %rdi
callq 0x11f0
// File: /workspace/github_c_makefile_star2_O2/saulvargas[P]re-C-sys/test_itemsim.c
// Function: main
int main(int argc, char** argv) {
    FILE* user_data;
    FILE* item_data;
    int N_users;
    int N_items;
    int N_prefs;
    int binary;
    recdata_t* recdata;
    recdata_t* cerdata;
    int iid;
    int i;
    similarity_t* similarity;
    idpairs_t* pairs;

    if (!read_args(argc, argv, &user_data, &item_data, &N_users, &N_items, &N_prefs, &binary)) {
        return EXIT_FAILURE;
    }

    recdata = recdata_simple_create(user_data, item_data, N_users, N_items, N_prefs, binary);
    cerdata = recdata_transposed_create(recdata);
    
    fclose(user_data);
    fclose(item_data);

    if (!binary) {
        similarity = similarity_veccosine_create(cerdata);
    } else {
        similarity = similarity_setcosine_create(cerdata);
    }

    for (iid = 0; iid < recdata->N_items; iid++) {
        pairs = similarity_calculate(similarity, iid, 10);

        for (i = 0; i < idpairs_size(pairs); i++) {
            printf("%d\t%d\t%.4f\n", iid, idpairs_keys(pairs)[i], idpairs_values(pairs)[i]);
        }
        
        idpairs_close_deep(pairs);
    }
 
    similarity_close(similarity);
    
    recdata_close(recdata);
    recdata_close(cerdata);
   
    return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
leaq 0x8(%rsp), %rax
leaq 0xc(%rsp), %r10
leaq 0x28(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x14(%rsp), %r8
leaq 0x10(%rsp), %r9
pushq %rax
pushq %r10
callq 0x2494
popq %rcx
popq %rdx
testl %eax, %eax
je 0x12a1
movq 0x28(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl 0x14(%rsp), %edx
movl 0x10(%rsp), %ecx
movl 0xc(%rsp), %r8d
movl 0x8(%rsp), %r9d
callq 0x1692
movq %rax, 0x18(%rsp)
movq %rax, %rdi
callq 0x1771
movq %rax, %rbx
movq 0x28(%rsp), %rdi
callq 0x1060
movq 0x20(%rsp), %rdi
callq 0x1060
cmpl $0x0, 0x8(%rsp)
movq %rbx, 0x30(%rsp)
movq %rbx, %rdi
je 0x12a9
callq 0x1926
jmp 0x12ae
pushq $0x1
popq %rax
jmp 0x133f
callq 0x1bb9
movq %rax, %r15
xorl %r12d, %r12d
leaq 0x1d49(%rip), %r13      # 0x3004
movq 0x18(%rsp), %rax
cmpl 0x4(%rax), %r12d
jge 0x1321
movq %r15, %rdi
movl %r12d, %esi
pushq $0xa
popq %rdx
callq 0x17c4
movq %rax, %r14
xorl %ebx, %ebx
movq %r14, %rdi
callq 0x240b
cltq
cmpq %rax, %rbx
jge 0x1314
movq %r14, %rdi
callq 0x240e
movl (%rax,%rbx,4), %ebp
movq %r14, %rdi
callq 0x2413
movsd (%rax,%rbx,8), %xmm0
movq %r13, %rdi
movl %r12d, %esi
movl %ebp, %edx
movb $0x1, %al
callq 0x1080
incq %rbx
jmp 0x12d9
movq %r14, %rdi
callq 0x23e7
incl %r12d
jmp 0x12bb
movq %r15, %rdi
callq 0x17d4
movq 0x18(%rsp), %rdi
callq 0x1388
movq 0x30(%rsp), %rdi
callq 0x1388
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/ohkimur[P]the-c-programming-language-2nd-edition-solutions/chapter_5/exercise_5_11/detab.c
// Function: main
int main(int argc, char *argv[])
{
  if (!is_tab_stop_arg_list_valid(argc, argv))
  {
    puts("Error: invalid tab stop list.\n");
    return EXIT_FAILURE;
  }

  int c;
  size_t arg_pos = 1;
  size_t line_pos = 0;
  size_t tab_stop = DEFAULT_TAB_LENGTH;
  size_t nr_of_spaces;
  size_t nr_of_custom_tab_stops = argc - 1;

  while ((c = getchar()) != EOF)
  {
    if (c == '\t')
    {
      if (nr_of_custom_tab_stops)
      {
        tab_stop = atoi(argv[arg_pos++]);
        --nr_of_custom_tab_stops;
      }
      else if (argc > 1)
      {
        tab_stop = 1;
      }

      nr_of_spaces = tab_stop - line_pos % tab_stop;

      while (nr_of_spaces)
      {
        putchar(' ');
        ++line_pos;
        --nr_of_spaces;
      }
    }
    else
    {
      putchar(c);
      ++line_pos;

      if (c == '\n')
      {
        arg_pos = 1;
        line_pos = 0;
        nr_of_custom_tab_stops = argc - 1;
      }
    }
  }

  return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, %r14d
movq %rsi, 0x10(%rsp)
callq 0x1275
testl %eax, %eax
je 0x1257
leal -0x1(%r14), %eax
movslq %eax, %r13
pushq $0x8
popq %rbx
pushq $0x1
popq %rax
xorl %r15d, %r15d
pushq $0x20
popq %rbp
movq %rax, (%rsp)
movq %r13, 0x8(%rsp)
callq 0x1060
cmpl $-0x1, %eax
je 0x1253
movl %eax, %r12d
cmpl $0x9, %eax
je 0x11ff
movl %r12d, %edi
callq 0x1030
incq %r15
cmpl $0xa, %r12d
jne 0x11cb
pushq $0x1
popq %rax
movq %rax, (%rsp)
xorl %r15d, %r15d
movq 0x8(%rsp), %r13
jmp 0x11cb
testq %r13, %r13
je 0x1225
movq 0x10(%rsp), %rax
movq (%rsp), %rcx
movq (%rax,%rcx,8), %rdi
incq %rcx
movq %rcx, (%rsp)
callq 0x1070
movslq %eax, %rbx
decq %r13
jmp 0x1233
cmpl $0x2, %r14d
pushq $0x1
popq %rax
cmovgeq %rax, %rbx
xorl %r13d, %r13d
movq %r15, %rax
xorl %edx, %edx
divq %rbx
movq %rbx, %r12
subq %rdx, %r12
subq $0x1, %r12
jb 0x11cb
movl %ebp, %edi
callq 0x1030
incq %r15
jmp 0x1241
xorl %eax, %eax
jmp 0x1266
leaq 0xda6(%rip), %rdi       # 0x2004
callq 0x1040
pushq $0x1
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/chatziko-k08[P]lecture-code/programs/fibonacci/fibonacci_test.c
// Function: syllables_no
int syllables_no(char* s) {
	int num = 1;
	for (; *s != '\0'; s++)
		if (*s == ' ' || *s == '-')
			num++;

	return num;
}

// Assembly:
pushq $0x1
popq %rax
movzbl (%rdi), %ecx
cmpl $0x20, %ecx
je 0x3a7d
cmpl $0x2d, %ecx
je 0x3a7d
testl %ecx, %ecx
jne 0x3a7f
jmp 0x3a84
incl %eax
incq %rdi
jmp 0x3a6a
retq
// File: /workspace/github_c_makefile_star2_O2/chatziko-k08[P]lecture-code/programs/fibonacci/fibonacci.c
// Function: fibonacci
int fibonacci(int n) {
	if (memory == NULL) {
		// Αρχικοποίηση της μνήμης με τα πρώτα 2 στοιχεία της ακολουθίας
		memory = int_vector_create(0);
		int_vector_insert_last(memory, 0);
		int_vector_insert_last(memory, 1);
	}

	// Αν δεν έχουμε ήδη το αποτέλεσμα το υπολογίζουμε και το αποθηκεύουμε
	if (n >= int_vector_size(memory)) {
		int res = fibonacci(n-2) + fibonacci(n-1);
		int_vector_insert_last(memory, res);
	}

	return int_vector_get_at(memory, n);
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %edi, %ebx
movq 0x4b6c(%rip), %rdi      # 0x9438
testq %rdi, %rdi
jne 0x48ff
xorl %edi, %edi
callq 0x494c
movq %rax, 0x4b59(%rip)      # 0x9438
movq %rax, %rdi
xorl %esi, %esi
callq 0x49b5
movq 0x4b48(%rip), %rdi      # 0x9438
pushq $0x1
popq %rsi
callq 0x49b5
movq 0x4b39(%rip), %rdi      # 0x9438
callq 0x499a
cmpl %ebx, %eax
jg 0x492a
leal -0x2(%rbx), %edi
callq 0x48c0
movl %eax, %ebp
leal -0x1(%rbx), %edi
callq 0x48c0
addl %eax, %ebp
movq 0x4b15(%rip), %rdi      # 0x9438
movl %ebp, %esi
callq 0x49b5
movq 0x4b07(%rip), %rdi      # 0x9438
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x49ab
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/tools/mergelcp.c
// Function: file_open
FILE* file_open(char *c_file, const char * c_mode){
  
  FILE* f_in;
  f_in = fopen(c_file, c_mode);
  if (!f_in) {perror (__func__); exit(EXIT_FAILURE);}
  fseek(f_in, 0, SEEK_SET);
  
return f_in;
}

// Assembly:
pushq %rbx
callq 0x1160
testq %rax, %rax
je 0x130b
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x1140
movq %rbx, %rax
popq %rbx
retq
leaq 0x2dfe(%rip), %rdi      # 0x4110
callq 0x1170
pushq $0x1
popq %rdi
callq 0x11c0
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/tools/mergelcp.c
// Function: usage
void usage(char *name){
  printf("\n\tUsage: %s [options] FILE POS_SIZE LCP_SIZE \n\n",name);
  puts("Multiway k-merge sort for the lists of pairs <pos, lcp>.");
  puts("Input:\tFILE.pair.lcp with the lists and FILE.size.lcp");
  puts("with their start positions in FILE.pair.lcp");
  puts("Output:\tFILE.lcp contains <lcp> sorted by <pos>.\n");
  puts("Available options:");
  puts("\t-h\tthis help message");
  puts("\t-s\tHEAP_SIZE");
  puts("\t-t\ttime");
  puts("\t-k\tk-truncated LCP merging");
  puts("\t-v\tverbose\n");
  exit(EXIT_FAILURE);
}

// Assembly:
pushq %rax
movq %rdi, %rsi
leaq 0x2be0(%rip), %rdi      # 0x4133
xorl %eax, %eax
callq 0x10d0
leaq 0x2c02(%rip), %rdi      # 0x4163
callq 0x1080
leaq 0x2c2f(%rip), %rdi      # 0x419c
callq 0x1080
leaq 0x2c59(%rip), %rdi      # 0x41d2
callq 0x1080
leaq 0x2c79(%rip), %rdi      # 0x41fe
callq 0x1080
leaq 0x2c9f(%rip), %rdi      # 0x4230
callq 0x1080
leaq 0x2ca6(%rip), %rdi      # 0x4243
callq 0x1080
leaq 0x2cb0(%rip), %rdi      # 0x4259
callq 0x1080
leaq 0x2cb2(%rip), %rdi      # 0x4267
callq 0x1080
leaq 0x2caf(%rip), %rdi      # 0x4270
callq 0x1080
leaq 0x2cbf(%rip), %rdi      # 0x428c
callq 0x1080
pushq $0x1
popq %rdi
callq 0x11c0
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/tools/heap.c
// Function: write_buffer
void write_buffer(heap *h, FILE *f_out, int level) {

  int i;
  if(level){
    for(i=0; i<h->out_idx; i++){
      fwrite(&h->out_buffer[i], h->pos_size+h->lcp_size, 1, f_out);
    }
  }
  else{
    for(i=0; i<h->out_idx; i++){
      uint64_t lcp = lcp(h->out_buffer[i]);
      fwrite(&lcp, h->lcp_size, 1, f_out);
    }
  }
  h->out_idx = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
testl %edx, %edx
je 0x2804
xorl %r12d, %r12d
pushq $0x1
popq %r15
xorl %r13d, %r13d
movslq 0x210(%rbx), %rax
cmpq %rax, %r13
jge 0x285b
movq 0x208(%rbx), %rdi
addq %r12, %rdi
movslq 0x214(%rbx), %rax
movslq 0x218(%rbx), %rsi
addq %rax, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x11d0
incq %r13
addq $0x10, %r12
jmp 0x27c5
xorl %r13d, %r13d
movq %rsp, %r15
pushq $0x1
popq %r12
xorl %ebp, %ebp
movslq 0x210(%rbx), %rax
cmpq %rax, %rbp
jge 0x285b
movq 0x208(%rbx), %rax
movslq 0x218(%rbx), %rsi
movq %rsi, %rcx
shlq $0x4, %rcx
leaq 0x1d48(%rip), %rdx      # 0x4580
movq (%rcx,%rdx), %rcx
andq (%rax,%r13), %rcx
movq %rcx, (%rsp)
movq %r15, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x11d0
incq %rbp
addq $0x10, %r13
jmp 0x2810
andl $0x0, 0x210(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/tools/heap.c
// Function: heap_free
void heap_free(heap *h, FILE *f_out, int level) {

  int i;
  for (i=0; i<h->size; i++){
    //fclose(h->heap[i]->f_in);
    free(h->heap[i]->buffer);
    free(h->heap[i]);
  }

  #if OUTPUT_BUFFER 
    if(h->out_idx) write_buffer(h, f_out, level);
    free(h->out_buffer);
  #endif
  
  fclose(h->f_in);
      
  free(h->heap);
  free(h);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
xorl %r15d, %r15d
movslq 0x8(%rbx), %rax
cmpq %rax, %r15
jge 0x28ac
movq (%rbx), %rax
movq (%rax,%r15,8), %rax
movq (%rax), %rdi
callq 0x2e3a
movq (%rbx), %rax
movq (%rax,%r15,8), %rdi
callq 0x2e3a
incq %r15
jmp 0x2883
cmpl $0x0, 0x210(%rbx)
je 0x28c2
movq %rbx, %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x27a6
movq 0x208(%rbx), %rdi
callq 0x2e3a
movq 0x200(%rbx), %rdi
callq 0x10b0
movq (%rbx), %rdi
callq 0x2e3a
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2e3a
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/tools/heap.c
// Function: heapfy_up
void heapfy_up(heap *h, int i) {

  int p = (int) floor((i-1)/2);

  while (i>0 && key(i) < key(p)) {  
      
    heap_node *auxn = h->heap[i];
    h->heap[i] = h->heap[p];
    h->heap[p] = auxn;

    i = p;
    p = (int) floor((i-1)/2);
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl $0x2, %ecx
leal -0x1(%rsi), %eax
cltd
idivl %ecx
testl %esi, %esi
jle 0x2950
movq (%rdi), %rdx
movl %esi, %r8d
movq (%rdx,%r8,8), %r9
movq (%r9), %r10
movslq 0x8(%r9), %r11
shlq $0x4, %r11
movq (%r10,%r11), %rbx
movslq %eax, %rsi
movq (%rdx,%rsi,8), %rax
movq (%rax), %r14
movslq 0x8(%rax), %r15
shlq $0x4, %r15
cmpq (%r14,%r15), %rbx
movq 0x8(%r10,%r11), %r10
sbbq 0x8(%r14,%r15), %r10
jae 0x2950
movq %rax, (%rdx,%r8,8)
movq (%rdi), %rax
movq %r9, (%rax,%rsi,8)
jmp 0x28fe
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/tools/heap.c
// Function: heapfy_down
void heapfy_down(heap *h, int i) {

  int last = h->size-1;

  // Selects the child s of i with smaller cost:
  int l = 2*i+1;
  int r = l+1;
  int s;
  if (r <= last)
    s = key(l) < key(r) ? l : r;    
  else if (l == last)
    s = l;
  else
    return;

  // Swaps down:
  while (key(i) > key(s)) {   
    
    heap_node *aux = h->heap[i];
    h->heap[i] = h->heap[s];
    h->heap[s] = aux;

    i = s;
    l = 2*i+1;
    r = l+1;

    if (r <= last)
      s = key(l) < key(r) ? l : r;      
    else if (l == last)
      s = l;
    else
      return;
  }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl 0x8(%rdi), %eax
leal -0x1(%rax), %ecx
leal 0x1(,%rsi,2), %r8d
leal 0x2(,%rsi,2), %edx
cmpl %eax, %edx
jge 0x29b7
movq (%rdi), %r9
movslq %r8d, %r10
movq (%r9,%r10,8), %r10
movq (%r10), %r11
movslq 0x8(%r10), %r10
shlq $0x4, %r10
movq (%r11,%r10), %rbx
movslq %edx, %r14
movq (%r9,%r14,8), %r9
movq (%r9), %r14
movslq 0x8(%r9), %r9
shlq $0x4, %r9
cmpq (%r14,%r9), %rbx
movq 0x8(%r11,%r10), %r10
sbbq 0x8(%r14,%r9), %r10
cmovbl %r8d, %edx
jmp 0x29c2
movl %ecx, %edx
cmpl %ecx, %r8d
jne 0x2a70
movslq %esi, %r8
movl %edx, %esi
movq (%rdi), %r9
movq (%r9,%r8,8), %rdx
movq (%rdx), %rbx
movslq 0x8(%rdx), %r14
shlq $0x4, %r14
movslq %esi, %r10
movq (%r9,%r10,8), %r11
movq (%r11), %r15
movslq 0x8(%r11), %r12
shlq $0x4, %r12
movq (%r15,%r12), %r13
cmpq (%rbx,%r14), %r13
movq 0x8(%r15,%r12), %r15
sbbq 0x8(%rbx,%r14), %r15
jae 0x2a70
movq %r11, (%r9,%r8,8)
movq (%rdi), %r8
movq %rdx, (%r8,%r10,8)
leal 0x1(,%r10,2), %edx
leal 0x2(,%r10,2), %r8d
cmpl %eax, %r8d
jge 0x2a66
movq (%rdi), %r9
movslq %edx, %r10
movq (%r9,%r10,8), %r10
movq (%r10), %r11
movslq 0x8(%r10), %r10
shlq $0x4, %r10
movq (%r11,%r10), %rbx
movslq %r8d, %r14
movq (%r9,%r14,8), %r9
movq (%r9), %r14
movslq 0x8(%r9), %r9
shlq $0x4, %r9
cmpq (%r14,%r9), %rbx
movq 0x8(%r11,%r10), %r10
sbbq 0x8(%r14,%r9), %r10
jb 0x29c2
movl %r8d, %edx
jmp 0x29c2
cmpl %ecx, %edx
movl %ecx, %edx
je 0x29c2
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/tools/heap.c
// Function: read_buffer
void  read_buffer(heap *h, heap_node *node){

//  fseek(h->f_in, node->seek*sizeof(pair), SEEK_SET);
    fseek(h->f_in, node->seek*(h->pos_size+h->lcp_size), SEEK_SET);

    int i;
    for(i=0; i<h->input_size; i++){
      node->buffer[i]=0;
      int e = fread(&node->buffer[i], h->pos_size+h->lcp_size, 1, h->f_in);
      if(e!=1) {perror(__func__); exit(1);}
      if(node->buffer[i]==MAX_KEY) break; 
    }

    node->seek += h->input_size;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq 0x200(%rdi), %rdi
movslq 0x214(%r14), %rax
movslq 0x218(%r14), %rsi
addq %rax, %rsi
imulq 0x10(%rbx), %rsi
xorl %r13d, %r13d
xorl %edx, %edx
callq 0x1140
pushq $-0x1
popq %rbp
movq 0x220(%r14), %rax
incq %rbp
cmpq %rbp, %rax
jbe 0x2b39
movq (%rbx), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi,%r13)
addq %r13, %rdi
movslq 0x214(%r14), %rax
movslq 0x218(%r14), %rsi
addq %rax, %rsi
movq 0x200(%r14), %rcx
pushq $0x1
popq %rdx
callq 0x1090
cmpl $0x1, %eax
jne 0x2b4c
leaq 0x10(%r13), %r12
movq (%rbx), %r15
movl 0x218(%r14), %eax
addl 0x214(%r14), %eax
shll $0x3, %eax
movb $-0x80, %cl
subb %al, %cl
movzbl %cl, %edx
pushq $-0x1
popq %rdi
movq %rdi, %rsi
callq 0x30f0
xorq 0x8(%r15,%r13), %rdx
xorq (%r15,%r13), %rax
orq %rdx, %rax
movq %r12, %r13
jne 0x2ab5
movq 0x220(%r14), %rax
addq %rax, 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a02(%rip), %rdi      # 0x4555
callq 0x1170
pushq $0x1
popq %rdi
callq 0x11c0
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/tools/heap.c
// Function: heap_insert
int heap_insert(heap *h, size_t pos) {

  if (!h->heap[h->size])
    h->heap[h->size] = malloc(sizeof(heap_node));

  if (!h->heap[h->size]) 
    return errno = ENOMEM;

  heap_node *node = h->heap[h->size];

  //alloc buffer <pos, lcp>
  node->buffer = (pair*) malloc(h->input_size*sizeof(pair));
  if (!node->buffer) 
    return errno = ENOMEM;
  node->idx = 0;
  
  //load buffer
  node->seek = pos;
  read_buffer(h, node);

  #if DEBUG
    int i;
    for(i=0; i<h->input_size; i++) 
      printf("<%lu, %lu (%lu)> ", lcp(node->buffer[i]), pos(node->buffer[i]), node->buffer[i]);
    printf("**\n");
  #endif
  
  heapfy_up(h,h->size++);

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %r12
movslq 0x8(%rdi), %r14
movq (%r12,%r14,8), %r13
testq %r13, %r13
jne 0x2b9d
pushq $0x18
popq %rdi
callq 0x2d64
movq %rax, (%r12,%r14,8)
movq (%rbx), %rax
movq (%rax,%r14,8), %r13
testq %r13, %r13
je 0x2c63
movq 0x220(%rbx), %rdi
shlq $0x4, %rdi
callq 0x2d64
movq %rax, (%r13)
testq %rax, %rax
je 0x2c63
andl $0x0, 0x8(%r13)
movq %r15, 0x10(%r13)
movq %rbx, %rdi
movq %r13, (%rsp)
movq %r13, %rsi
callq 0x2a7a
xorl %r15d, %r15d
xorl %r14d, %r14d
cmpq %r14, 0x220(%rbx)
jbe 0x2c42
movq (%rsp), %rax
movq (%rax), %rax
movq (%rax,%r15), %r12
movq 0x8(%rax,%r15), %r13
movslq 0x218(%rbx), %rax
leal (,%rax,8), %ecx
shlq $0x4, %rax
leaq 0x1976(%rip), %rdx      # 0x4580
movq (%rax,%rdx), %rbp
andq %r12, %rbp
movzbl %cl, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x30f0
leaq 0x193b(%rip), %rdi      # 0x4561
movq %rbp, %rsi
movq %rax, %rdx
movq %r12, %rcx
movq %r13, %r8
xorl %eax, %eax
callq 0x10d0
incq %r14
addq $0x10, %r15
jmp 0x2bd8
leaq 0x17f7(%rip), %rdi      # 0x4440
callq 0x1080
movl 0x8(%rbx), %esi
leal 0x1(%rsi), %eax
movl %eax, 0x8(%rbx)
movq %rbx, %rdi
callq 0x28f4
xorl %eax, %eax
jmp 0x2c71
callq 0x1050
movl $0xc, (%rax)
pushq $0xc
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/felipelouza[P]egap/tools/heap.c
// Function: heap_delete_min
pair heap_delete_min(heap *h) {

  heap_node *node = h->heap[0];

  pair tmp=0;
  tmp= node->buffer[node->idx];

  if(++node->idx == h->input_size){ //load from disk
    node->idx = 0; 
    read_buffer(h, node);
  }

  heapfy_down(h,0);
  
  return tmp;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rax
movq (%rax), %rsi
movq (%rsi), %rax
movslq 0x8(%rsi), %rcx
movq %rcx, %rdx
shlq $0x4, %rdx
movq (%rax,%rdx), %r14
movq 0x8(%rax,%rdx), %r15
incq %rcx
movl %ecx, 0x8(%rsi)
cmpq %rcx, 0x220(%rdi)
jne 0x2cc0
andl $0x0, 0x8(%rsi)
movq %rbx, %rdi
callq 0x2a7a
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2956
movq %r14, %rax
movq %r15, %rdx
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/devkot[P]SearchEngine/Crawler/utilities.c
// Function: initialize
int initialize(FILE *fileName, DocumentNode *documentArray){
    int maxLength = 1, curLength = 0, lineId = 0, docWords;
    char lineBuffer[100000], *newDoc;

    // start reading the file until EOF is read
    while(fgets(lineBuffer, 99999, fileName)){                  // read docfile contents
        strtok(lineBuffer, "\n");                               // remove the useless \n character at the end of the line

        curLength = strlen(lineBuffer);
        if( curLength > maxLength)
            maxLength = curLength;

        // every document will have the length of the line read
        newDoc = (char *) malloc(strlen(lineBuffer) +1);
        // copy the useful content (just the text) of lineBuffer to newDoc
        strcpy(newDoc, lineBuffer);

        docWords = 1;                                           // init at 1 so we don't have to increment it for this instance
        strtok(lineBuffer, "/");

        while((strtok(NULL, "/"))){                             // count the path's words
            docWords++;
        }

        addDocument(documentArray, lineId, newDoc, docWords);   // add document to our array
        lineId++;
    }
    return maxLength;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x186c8, %rsp          # imm = 0x186C8
movq %rsi, -0x38(%rbp)
movq %rdi, -0x40(%rbp)
pushq $0x1
popq %rax
movl %eax, -0x2c(%rbp)
xorl %r15d, %r15d
leaq -0x186f0(%rbp), %r14
leaq 0x1ada(%rip), %r13      # 0x4261
movq %r14, %rdi
movl $0x1869f, %esi          # imm = 0x1869F
movq -0x40(%rbp), %rdx
callq 0x2170
testq %rax, %rax
je 0x2829
movq %r15, -0x48(%rbp)
movq %r14, %rdi
leaq 0x1cac(%rip), %rsi      # 0x445b
callq 0x22d0
movq %r14, %rdi
callq 0x20d0
movq %rax, %r15
leaq 0x1(%rax), %rdi
callq 0x2240
movq %rax, %rbx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2050
movq %r14, %r12
movq %r14, %rdi
movq %r13, %rsi
callq 0x22d0
xorl %r14d, %r14d
xorl %edi, %edi
movq %r13, %rsi
callq 0x22d0
incl %r14d
testq %rax, %rax
jne 0x27e7
movl -0x2c(%rbp), %eax
cmpl %r15d, %eax
cmovlel %r15d, %eax
movl %eax, -0x2c(%rbp)
movq -0x48(%rbp), %r15
movq %r15, %rax
shlq $0x4, %rax
movq -0x38(%rbp), %rcx
movq %rbx, (%rcx,%rax)
movl %r14d, 0x8(%rcx,%rax)
incq %r15
movq %r12, %r14
jmp 0x2787
movl -0x2c(%rbp), %eax
addq $0x186c8, %rsp          # imm = 0x186C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/devkot[P]SearchEngine/Crawler/utilities.c
// Function: destroyDocuments
void destroyDocuments(DocumentNode *documentNodes, int nLines){
    int i;

    for (i = 0;i < nLines; i++)
        free(documentNodes[i].text);
    free(documentNodes);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
xorl %r15d, %r15d
testl %esi, %esi
cmovlel %r15d, %r14d
shlq $0x4, %r14
cmpq %r15, %r14
je 0x2884
movq (%rbx,%r15), %rdi
callq 0x2030
addq $0x10, %r15
jmp 0x2870
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x2030
// File: /workspace/github_c_makefile_star2_O2/devkot[P]SearchEngine/Crawler/utilities.c
// Function: determineWorkload
int determineWorkload(int nDocs, int numWorkers, int *remainder){
    int increment = 0;

    if ((nDocs % numWorkers) == 0){
        increment = nDocs / numWorkers;            // determine how many files each worker will get
    }
    else if ((nDocs % numWorkers) > 0){
        increment = nDocs / numWorkers;
        (*remainder) = nDocs % numWorkers;
    }

    return increment;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdx, %rcx
movl %edi, %eax
cltd
idivl %esi
testl %edx, %edx
je 0x28ac
jle 0x28b3
movl %edx, (%rcx)
jmp 0x28b5
movl %edi, %eax
cltd
idivl %esi
jmp 0x28b5
xorl %eax, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/devkot[P]SearchEngine/Crawler/utilities.c
// Function: splitWorkload
int *splitWorkload(int increment, int *remainder, int numWorkers) {
    int i, *workerLoad;

    workerLoad = (int *) malloc(sizeof(int) * numWorkers);

    for(i = 0; i < numWorkers; i++){
        if(*remainder > 0) {
            workerLoad[i] = increment + 1;          // split the remainder between the workers
            (*remainder)--;
        }
        else
            workerLoad[i] = increment;
    }

    return workerLoad;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %r14d
movslq %edx, %r15
leaq (,%r15,4), %rdi
callq 0x2240
leal 0x1(%r14), %ecx
xorl %edx, %edx
testl %r15d, %r15d
cmovlel %edx, %r15d
cmpq %rdx, %r15
je 0x2900
movl (%rbx), %esi
movl %r14d, %edi
testl %esi, %esi
jle 0x28f8
decl %esi
movl %esi, (%rbx)
movl %ecx, %edi
movl %edi, (%rax,%rdx,4)
incq %rdx
jmp 0x28e4
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/devkot[P]SearchEngine/Crawler/utilities.c
// Function: distributeDocs
void distributeDocs(DocumentNode *documentArray, int *incrementArray, int numWorkers, int *fdIn){
    int i, j, lines = 0;
    char tempSize[5], sizeTriple[4] = "000", sizeDouble[3] = "00", sizeSimple[2] = "0";

    for(i = 0; i < numWorkers; i++){
        for(j = 0; j < incrementArray[i]; j++){
            // Pipe atomicity is guaranteed at 4096 bytes max so make the size payload contain 4 digits
            if(strlen(documentArray[lines].text) < 10 )
                sprintf(tempSize, "%s%d",sizeTriple, (int) strlen(documentArray[lines].text));
            else if(strlen(documentArray[lines].text) < 100)
                sprintf(tempSize, "%s%d", sizeDouble, (int) strlen(documentArray[lines].text));
            else if(strlen(documentArray[lines].text) < 1000)
                sprintf(tempSize, "%s%d", sizeSimple, (int) strlen(documentArray[lines].text));

            if((write(fdIn[i], tempSize, strlen(tempSize))) == -1)
                perror("write");

            if((write(fdIn[i], documentArray[lines].text, strlen(documentArray[lines].text))) == -1)
                perror("write");

            lines++;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %r13
movq %rsi, -0x60(%rbp)
movq %rdi, -0x48(%rbp)
leaq -0x34(%rbp), %rax
movl $0x303030, (%rax)       # imm = 0x303030
leaq -0x2e(%rbp), %rax
movb $0x0, 0x2(%rax)
movw $0x3030, (%rax)         # imm = 0x3030
leaq -0x2a(%rbp), %rax
movw $0x30, (%rax)
xorl %eax, %eax
testl %edx, %edx
cmovlel %eax, %edx
movq %rdx, -0x50(%rbp)
xorl %r12d, %r12d
xorl %eax, %eax
cmpq -0x50(%rbp), %r12
je 0x2a5a
cltq
movq %rax, -0x58(%rbp)
movq %rax, %rbx
shlq $0x4, %rbx
addq -0x48(%rbp), %rbx
xorl %ecx, %ecx
movq -0x60(%rbp), %rax
cmpl (%rax,%r12,4), %ecx
jge 0x2a4b
movq %rcx, -0x68(%rbp)
movq %rbx, -0x70(%rbp)
movq (%rbx), %rdi
callq 0x20d0
leaq -0x34(%rbp), %rdx
cmpq $0xa, %rax
jb 0x29b2
leaq -0x2e(%rbp), %rdx
cmpq $0x64, %rax
jb 0x29b2
leaq -0x2a(%rbp), %rdx
cmpq $0x3e7, %rax            # imm = 0x3E7
ja 0x29c6
leaq -0x39(%rbp), %rdi
leaq 0x17ba(%rip), %rsi      # 0x4177
movl %eax, %ecx
xorl %eax, %eax
callq 0x2320
movq %r12, %rbx
movl (%r13,%r12,4), %r14d
leaq -0x39(%rbp), %r15
movq %r15, %rdi
callq 0x20d0
movl %r14d, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2090
cmpq $-0x1, %rax
je 0x2a2f
movq %r13, %r15
movq %rbx, %r12
movl (%r13,%rbx,4), %r14d
movq -0x70(%rbp), %rbx
movq (%rbx), %r13
movq %r13, %rdi
callq 0x20d0
movl %r14d, %edi
movq %r13, %rsi
movq %rax, %rdx
callq 0x2090
cmpq $-0x1, %rax
je 0x2a3d
movq -0x68(%rbp), %rcx
incq %rcx
addq $0x10, %rbx
movq %r15, %r13
jmp 0x2974
leaq 0x1746(%rip), %rdi      # 0x417c
callq 0x22c0
jmp 0x29ee
leaq 0x1738(%rip), %rdi      # 0x417c
callq 0x22c0
jmp 0x2a1c
incq %r12
movq -0x58(%rbp), %rax
addq %rcx, %rax
jmp 0x2957
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq