LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/madler[P]pigz/zopfli/src/zopfli/hash.c
// Function: ZopfliAllocHash
void ZopfliAllocHash(size_t window_size, ZopfliHash* h) {
  h->head = (int*)malloc(sizeof(*h->head) * 65536);
  h->prev = (unsigned short*)malloc(sizeof(*h->prev) * window_size);
  h->hashval = (int*)malloc(sizeof(*h->hashval) * window_size);

#ifdef ZOPFLI_HASH_SAME
  h->same = (unsigned short*)malloc(sizeof(*h->same) * window_size);
#endif

#ifdef ZOPFLI_HASH_SAME_HASH
  h->head2 = (int*)malloc(sizeof(*h->head2) * 65536);
  h->prev2 = (unsigned short*)malloc(sizeof(*h->prev2) * window_size);
  h->hashval2 = (int*)malloc(sizeof(*h->hashval2) * window_size);
#endif
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movl $0x40000, %edi          # imm = 0x40000
callq 0x33d0
movq %rax, (%rbx)
leaq (%r14,%r14), %r15
movq %r15, %rdi
callq 0x33d0
movq %rax, 0x8(%rbx)
shlq $0x2, %r14
movq %r14, %rdi
callq 0x33d0
movq %rax, 0x10(%rbx)
movq %r15, %rdi
callq 0x33d0
movq %rax, 0x40(%rbx)
movl $0x40000, %edi          # imm = 0x40000
callq 0x33d0
movq %rax, 0x20(%rbx)
movq %r15, %rdi
callq 0x33d0
movq %rax, 0x28(%rbx)
movq %r14, %rdi
callq 0x33d0
movq %rax, 0x30(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/madler[P]pigz/zopfli/src/zopfli/hash.c
// Function: ZopfliResetHash
void ZopfliResetHash(size_t window_size, ZopfliHash* h) {
  size_t i;

  h->val = 0;
  for (i = 0; i < 65536; i++) {
    h->head[i] = -1;  /* -1 indicates no head so far. */
  }
  for (i = 0; i < window_size; i++) {
    h->prev[i] = i;  /* If prev[j] == j, then prev[j] is uninitialized. */
    h->hashval[i] = -1;
  }

#ifdef ZOPFLI_HASH_SAME
  for (i = 0; i < window_size; i++) {
    h->same[i] = 0;
  }
#endif

#ifdef ZOPFLI_HASH_SAME_HASH
  h->val2 = 0;
  for (i = 0; i < 65536; i++) {
    h->head2[i] = -1;
  }
  for (i = 0; i < window_size; i++) {
    h->prev2[i] = i;
    h->hashval2[i] = -1;
  }
#endif
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movl $0x0, 0x18(%rsi)
movq (%rsi), %rdi
movl $0x40000, %edx          # imm = 0x40000
movl $0xff, %esi
callq 0x3260
testq %rbx, %rbx
je 0x129fc
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
xorl %edx, %edx
movw %dx, (%rax,%rdx,2)
movl $0xffffffff, (%rcx,%rdx,4) # imm = 0xFFFFFFFF
incq %rdx
cmpq %rdx, %rbx
jne 0x129da
movq 0x40(%r14), %rdi
leaq (%rbx,%rbx), %rdx
xorl %esi, %esi
callq 0x3260
movl $0x0, 0x38(%r14)
movq 0x20(%r14), %rdi
movl $0x40000, %edx          # imm = 0x40000
movl $0xff, %esi
callq 0x3260
testq %rbx, %rbx
je 0x12a39
movq 0x28(%r14), %rax
movq 0x30(%r14), %rcx
xorl %edx, %edx
movw %dx, (%rax,%rdx,2)
movl $0xffffffff, (%rcx,%rdx,4) # imm = 0xFFFFFFFF
incq %rdx
cmpq %rdx, %rbx
jne 0x12a26
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/madler[P]pigz/zopfli/src/zopfli/squeeze.c
// Function: GetCostStat
static double GetCostStat(unsigned litlen, unsigned dist, void* context) {
  SymbolStats* stats = (SymbolStats*)context;
  if (dist == 0) {
    return stats->ll_symbols[litlen];
  } else {
    int lsym = ZopfliGetLengthSymbol(litlen);
    int lbits = ZopfliGetLengthExtraBits(litlen);
    int dsym = ZopfliGetDistSymbol(dist);
    int dbits = ZopfliGetDistExtraBits(dist);
    return lbits + dbits + stats->ll_symbols[lsym] + stats->d_symbols[dsym];
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
movl %edi, %r14d
testl %esi, %esi
je 0x13bc7
movl %esi, %ebp
movl %r14d, %edi
callq 0x14249
movl %eax, %r15d
movl %r14d, %edi
callq 0x1422d
movl %eax, %r14d
movl %ebp, %edi
callq 0x14208
movl %eax, %r12d
movl %ebp, %edi
callq 0x141c8
addl %r14d, %eax
cvtsi2sd %eax, %xmm0
movslq %r15d, %rax
addsd 0xa00(%rbx,%rax,8), %xmm0
movslq %r12d, %rax
addsd 0x1300(%rbx,%rax,8), %xmm0
jmp 0x13bd3
movl %r14d, %eax
movsd 0xa00(%rbx,%rax,8), %xmm0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/madler[P]pigz/zopfli/src/zopfli/squeeze.c
// Function: ZopfliLZ77OptimalFixed
void ZopfliLZ77OptimalFixed(ZopfliBlockState *s,
                            const unsigned char* in,
                            size_t instart, size_t inend,
                            ZopfliLZ77Store* store)
{
  /* Dist to get to here with smallest cost. */
  size_t blocksize = inend - instart;
  unsigned short* length_array =
      (unsigned short*)malloc(sizeof(unsigned short) * (blocksize + 1));
  unsigned short* path = 0;
  size_t pathsize = 0;
  ZopfliHash hash;
  ZopfliHash* h = &hash;
  float* costs = (float*)malloc(sizeof(float) * (blocksize + 1));

  if (!costs) exit(-1); /* Allocation failed. */
  if (!length_array) exit(-1); /* Allocation failed. */

  ZopfliAllocHash(ZOPFLI_WINDOW_SIZE, h);

  s->blockstart = instart;
  s->blockend = inend;

  /* Shortest path for fixed tree This one should give the shortest possible
  result for fixed tree, no repeated runs are needed since the tree is known. */
  LZ77OptimalRun(s, in, instart, inend, &path, &pathsize,
                 length_array, GetCostFixed, 0, store, h, costs);

  free(length_array);
  free(path);
  free(costs);
  ZopfliCleanHash(h);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, 0x8(%rsp)
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %rbx
movq %rdi, %rbp
movq %rcx, %r15
subq %rdx, %r15
leaq 0x2(,%r15,2), %rdi
callq 0x33d0
movq %rax, %r14
xorl %eax, %eax
movq %rax, 0x18(%rsp)
movq %rax, 0x10(%rsp)
leaq 0x4(,%r15,4), %rdi
callq 0x33d0
testq %rax, %rax
je 0x13cc2
testq %r14, %r14
je 0x13cc2
movq %rax, %r15
leaq 0x20(%rsp), %rsi
movl $0x8000, %edi           # imm = 0x8000
callq 0x12938
movq %r13, 0x10(%rbp)
movq %r12, 0x18(%rbp)
leaq 0x6f(%rip), %rax        # 0x13ccc
leaq 0x18(%rsp), %r8
leaq 0x10(%rsp), %r9
movq %rbp, %rdi
movq %rbx, %rsi
movq %r13, %rdx
movq %r12, %rcx
movq %r8, %rbx
pushq %r15
leaq 0x28(%rsp), %r10
pushq %r10
pushq 0x18(%rsp)
pushq $0x0
pushq %rax
pushq %r14
callq 0x1327b
addq $0x30, %rsp
movq %r14, %rdi
callq 0x3050
movq (%rbx), %rdi
callq 0x3050
movq %r15, %rdi
callq 0x3050
leaq 0x20(%rsp), %rdi
callq 0x12a41
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x3540
// File: /workspace/github_c_makefile_star2_O1/madler[P]pigz/zopfli/src/zopfli/squeeze.c
// Function: GetCostFixed
static double GetCostFixed(unsigned litlen, unsigned dist, void* unused) {
  (void)unused;
  if (dist == 0) {
    if (litlen <= 143) return 8;
    else return 9;
  } else {
    int dbits = ZopfliGetDistExtraBits(dist);
    int lbits = ZopfliGetLengthExtraBits(litlen);
    int lsym = ZopfliGetLengthSymbol(litlen);
    int cost = 0;
    if (lsym <= 279) cost += 7;
    else cost += 8;
    cost += 5;  /* Every dist symbol has length 5. */
    return cost + dbits + lbits;
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edi, %ebx
testl %esi, %esi
je 0x13d0a
movl %esi, %edi
callq 0x141c8
movl %eax, %ebp
movl %ebx, %edi
callq 0x1422d
movl %eax, %r14d
movl %ebx, %edi
callq 0x14249
xorl %ecx, %ecx
cmpl $0x118, %eax            # imm = 0x118
setl %cl
xorl $0xd, %ecx
addl %ebp, %r14d
addl %ecx, %r14d
cvtsi2sd %r14d, %xmm0
jmp 0x13d21
xorl %eax, %eax
cmpl $0x90, %ebx
setb %al
leaq 0x3bd4(%rip), %rcx      # 0x178f0
movsd (%rcx,%rax,8), %xmm0
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/madler[P]pigz/zopfli/src/zopfli/katajainen.c
// Function: BoundaryPM
static void BoundaryPM(Node* (*lists)[2], Node* leaves, int numsymbols,
                       NodePool* pool, int index) {
  Node* newchain;
  Node* oldchain;
  int lastcount = lists[index][1]->count;  /* Count of last chain of list. */

  if (index == 0 && lastcount >= numsymbols) return;

  newchain = pool->next++;
  oldchain = lists[index][1];

  /* These are set up before the recursive calls below, so that there is a list
  pointing to the new node, to let the garbage collection know it's in use. */
  lists[index][0] = oldchain;
  lists[index][1] = newchain;

  if (index == 0) {
    /* New leaf node in list 0. */
    InitNode(leaves[lastcount].weight, lastcount + 1, 0, newchain);
  } else {
    size_t sum = lists[index - 1][0]->weight + lists[index - 1][1]->weight;
    if (lastcount < numsymbols && sum > leaves[lastcount].weight) {
      /* New leaf inserted in list, so count is incremented. */
      InitNode(leaves[lastcount].weight, lastcount + 1, oldchain->tail,
          newchain);
    } else {
      InitNode(sum, lastcount, lists[index - 1][1], newchain);
      /* Two lookahead chains of previous list used up, create new ones. */
      BoundaryPM(lists, leaves, numsymbols, pool, index - 1);
      BoundaryPM(lists, leaves, numsymbols, pool, index - 1);
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %ebx
movq %rcx, %r15
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r12
movslq %r8d, %rax
decl %ebx
shlq $0x4, %rax
leaq (%rax,%rdi), %r13
addq $0x8, %r13
movq (%r13), %rax
movl 0x10(%rax), %eax
cmpl $-0x1, %ebx
jne 0x14125
cmpl %ebp, %eax
jge 0x141b9
movslq %eax, %rsi
movq (%r15), %rcx
leaq 0x18(%rcx), %rdx
movq %rdx, (%r15)
movq (%r13), %rdx
movq %rdx, -0x8(%r13)
movq %rcx, (%r13)
cmpl $-0x1, %ebx
je 0x1418f
movslq %ebx, %rdi
shlq $0x4, %rdi
movq (%r12,%rdi), %r9
movq 0x8(%r12,%rdi), %rdi
movq (%rdi), %r8
addq (%r9), %r8
cmpl %ebp, %eax
jge 0x1416a
leaq (%rsi,%rsi,2), %rsi
movq (%r14,%rsi,8), %rsi
cmpq %rsi, %r8
ja 0x141a9
movq %r8, (%rcx)
movl %eax, 0x10(%rcx)
movq %rdi, 0x8(%rcx)
movq %r12, %rdi
movq %r14, %rsi
movl %ebp, %edx
movq %r15, %rcx
movl %ebx, %r8d
callq 0x140e7
decl %ebx
addq $-0x10, %r13
jmp 0x14111
leaq (%rsi,%rsi,2), %rdx
movq (%r14,%rdx,8), %rdx
incl %eax
movq %rdx, (%rcx)
movl %eax, 0x10(%rcx)
movq $0x0, 0x8(%rcx)
jmp 0x141b9
incl %eax
movq 0x8(%rdx), %rdx
movq %rsi, (%rcx)
movl %eax, 0x10(%rcx)
movq %rdx, 0x8(%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/./utils.h
// Function: ppl_node_unlink
void ppl_node_unlink(struct ppl_list_node * node){
    struct ppl_list_node * FD = node->fd;
    struct ppl_list_node * BK = node->bk;
    BK->fd = FD;
    FD->bk = BK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
movq %rax, (%rcx)
movq %rcx, 0x8(%rax)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/./utils.h
// Function: list_insert
void list_insert(struct ppl_list_node * head,  struct ppl_list_node * node){
    struct ppl_list_node * FD = head->fd;
    //struct ppl_list_node * BK = head->bk;
    head->fd = node;
    node->fd = FD;
    node->bk = head;
    FD->bk = node;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %rax
movq %rsi, (%rdi)
movq %rax, (%rsi)
movq %rdi, 0x8(%rsi)
movq %rsi, 0x8(%rax)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/./utils.h
// Function: recv_until
int recv_until(char* buf,int size,char end){
    char tmp;
    int i;
    for(i=0;i<size;i++){
        read(0,&tmp,1);
        if(tmp==end){
            break;
        }
        buf[i]=tmp;
    }
    buf[i+1]=='\x00';
    return i;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testl %esi, %esi
jle 0x13df
movl %edx, %ebx
movq %rdi, %r15
movl %esi, %r13d
xorl %r14d, %r14d
leaq -0x29(%rbp), %r12
movl $0x1, %edx
xorl %edi, %edi
movq %r12, %rsi
callq 0x1110
movb -0x29(%rbp), %al
cmpb %bl, %al
je 0x13e2
movb %al, (%r15,%r14)
incq %r14
cmpq %r14, %r13
jne 0x13b8
movl %r13d, %r14d
jmp 0x13e2
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: elf_executor_free
void elf_executor_free(struct executor_queue* eq){
    short buffer_size=0;
    free(eq);
    ppl_node_unlink(&eq->list);
    puts("feedback?");
    read(0, &buffer_size, 2);
    char *buffer = malloc((unsigned int)buffer_size);
    read(0, buffer, buffer_size);
    puts("thanks for the feedback, we will definitely read it");
    free(buffer);
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq -0x12(%rbp), %r14
movw $0x0, (%r14)
callq 0x1030
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
movq %rax, (%rcx)
movq %rcx, 0x8(%rax)
leaq 0x305e(%rip), %rdi      # 0x4485
callq 0x1060
movl $0x2, %edx
xorl %edi, %edi
movq %r14, %rsi
callq 0x1110
movswq (%r14), %rbx
movl %ebx, %edi
callq 0x1160
movq %rax, %r14
xorl %edi, %edi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x1110
leaq 0x3032(%rip), %rdi      # 0x448f
callq 0x1060
movq %r14, %rdi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x1030
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: elf_push_elem
int elf_push_elem(struct executor_queue* eq, void* value){
    void * dst;
    dst = &eq->elements[eq->head * eq->value_size];
    memcpy(dst, value, eq->value_size);
    if(++eq->head > eq->max_queue_entries){
        eq->head = 0;
    }
#ifdef DEBUG
    printf("succesfully pushed new element of %d bytes to: %p \n", eq->value_size, dst);
#endif
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x14(%rdi), %edx
movl 0x18(%rdi), %eax
imull %edx, %eax
addq %rax, %rdi
addq $0x38, %rdi
callq 0x1150
movl 0x18(%rbx), %eax
incl %eax
xorl %ecx, %ecx
cmpl 0x10(%rbx), %eax
cmoval %ecx, %eax
movl %eax, 0x18(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: elf_check_patch
int elf_check_patch(struct executor_queue* eq, void* value){
    // get different size
    int i;
    int diff = 0;
    int fail = 0;
    char* pv = (char*)value; // patched version

    for(i = 0; i < elf_unpatched_size; i++){
        if(pv[i] != elf_unpatched[i]){
            diff++;
        }
        if(diff > 0x100){
            break;
        }
    }

#ifdef DEBUG
    printf("diff: %d\n",diff);
#endif
    if(diff > 0x100){
        fail = 1;
    }

    // check elf header        
    // todo
    ELF64_FileRef file;
    ELF64_HeaderRef header;
    file = ELF64_ReadFromData(pv);
    header = ELF64_FileGetHeader(file);
    if( ELF64_FileIsValid(file) == false){
        puts("bad elf :(");
        fail = 1;
    }
    dump_program_header_entry(file, header);
    if(fail){
        return -1;
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rdi
movl 0x6c2f(%rip), %eax      # 0x8134
testq %rax, %rax
setne %r15b
je 0x1553
movq 0x6c23(%rip), %rcx      # 0x8138
movb (%rdi), %sil
xorl %edx, %edx
cmpb (%rcx), %sil
setne %dl
movl $0x1, %r8d
movq %r8, %rsi
cmpq %r8, %rax
je 0x154c
movb (%rdi,%rsi), %r8b
xorl %r9d, %r9d
cmpb (%rcx,%rsi), %r8b
setne %r9b
addl %r9d, %edx
leaq 0x1(%rsi), %r8
cmpl $0x101, %edx            # imm = 0x101
jb 0x1526
cmpq %rax, %rsi
setb %r15b
callq 0x2b7c
movq %rax, %rbx
movq %rax, %rdi
callq 0x2bab
movq %rax, %r14
movq %rbx, %rdi
callq 0x2b85
testb %al, %al
jne 0x1581
leaq 0x2ecd(%rip), %rdi      # 0x4446
callq 0x1060
movb $0x1, %r15b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x17af
movzbl %r15b, %eax
negl %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: safe_read
int safe_read(int fd, char* buffer, unsigned int size){
    int total, tmp;
    total = 0;
    tmp = 0;
    while(total < size){
        tmp = read(fd, buffer+total,size-total);
        if(tmp<0){
            exit(0);
        }
        total+=tmp;
        if(total==size){
            break;
        }
    }
    return total;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %r14d
movq %rsi, %r15
movl %edi, %r12d
xorl %ebx, %ebx
movl %r14d, %edx
subl %ebx, %edx
jbe 0x179d
movl %ebx, %esi
addq %r15, %rsi
movl %r12d, %edi
callq 0x1110
testl %eax, %eax
js 0x17a8
addl %eax, %ebx
cmpl %r14d, %ebx
jne 0x177e
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x11c0
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: rand_str
void rand_str(char *dest, unsigned char* seed, unsigned int size){
    int i;
    unsigned char index;
    for(i=0; i < size; i++){
        index = seed[i] % 62;
#ifdef DEBUG
        //printf("%d,%c ",index, charset[index]);
#endif
        dest[i] = charset[index];
    }
    dest[size]='\x00';
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %edx, %eax
testl %edx, %edx
je 0x19f0
xorl %ecx, %ecx
leaq 0x268b(%rip), %rdx      # 0x4040
movb (%rsi,%rcx), %r8b
movl %r8d, %r9d
shrb %r9b
movzbl %r9b, %r9d
imull $0x85, %r9d, %r9d
shrl $0xc, %r9d
leal (%r9,%r9), %r10d
shll $0x6, %r9d
subl %r10d, %r9d
subb %r9b, %r8b
movzbl %r8b, %r8d
movb (%r8,%rdx), %r8b
movb %r8b, (%rdi,%rcx)
incq %rcx
cmpq %rcx, %rax
jne 0x19b5
movb $0x0, (%rdi,%rax)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: init_executor_queue
void init_executor_queue(struct executor_queue* eq, struct patch_attr *attr){
    eq->queue_type = attr->queue_type;
    eq->max_queue_entries = attr->max_queue_entries;
    eq->value_size = attr->value_size;
    eq->executor_idx = global_executor_idx;
    eq->head = 0;
    eq->tail = 0;
    return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl (%rsi), %eax
movl %eax, 0x8(%rdi)
movl 0x4(%rsi), %eax
movl %eax, 0x10(%rdi)
movl 0x8(%rsi), %eax
movl %eax, 0x14(%rdi)
movl 0x66e5(%rip), %eax      # 0x8130
movl %eax, 0xc(%rdi)
movq $0x0, 0x18(%rdi)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: safe_read_flag
unsigned int* safe_read_flag()
{
    flag_fp = fopen(FLAGPATH,"rb");
	if(flag_fp<0){
		perror("fopen");
		exit(1);
	}
	unsigned int *p = (unsigned int *)sha3_hash;
	sha3_ctx ctx;
	memset(sha3_hash,0,65);
	fread(flag, FLAGLENGTH, 1, flag_fp);
	flag[FLAGLENGTH]='\x00';
#ifdef DEBUG
	printf("%s\n",flag);
#endif
	rhash_sha3_256_init(&ctx);
	rhash_sha3_update(&ctx, (const unsigned char*)flag, FLAGLENGTH);
	rhash_sha3_final(&ctx,(unsigned char*)sha3_hash);
	printf("sha3 of flag: %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);

	memset(flag,0,FLAGLENGTH);
    return p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
leaq 0x2a54(%rip), %rdi      # 0x44c3
leaq 0x2a61(%rip), %rsi      # 0x44d7
callq 0x1190
movq %rax, 0x66c6(%rip)      # 0x8148
xorps %xmm0, %xmm0
movaps %xmm0, 0x66c4(%rip)     # 0x8150
movaps %xmm0, 0x66cd(%rip)     # 0x8160
movaps %xmm0, 0x66d6(%rip)     # 0x8170
movaps %xmm0, 0x66df(%rip)     # 0x8180
xorl %r15d, %r15d
movb %r15b, 0x66e5(%rip)     # 0x8190
leaq 0x669e(%rip), %rbx      # 0x8150
leaq 0x66e7(%rip), %r14      # 0x81a0
movl $0x4f, %esi
movl $0x1, %edx
movq %r14, %rdi
movq %rax, %rcx
callq 0x1070
movb %r15b, 0x671a(%rip)     # 0x81ef
leaq -0x1a8(%rbp), %r15
movq %r15, %rdi
callq 0x24ba
movl $0x4f, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x252c
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2aa5
movl 0x664b(%rip), %esi      # 0x8150
movl 0x6649(%rip), %edx      # 0x8154
movl 0x6647(%rip), %ecx      # 0x8158
movl 0x6644(%rip), %r8d      # 0x815c
movl 0x6641(%rip), %r9d      # 0x8160
movl 0x663e(%rip), %r10d     # 0x8164
movl 0x663b(%rip), %r11d     # 0x8168
movl 0x6638(%rip), %r14d     # 0x816c
subq $0x8, %rsp
leaq 0x299b(%rip), %rdi      # 0x44da
xorl %eax, %eax
pushq %r14
pushq %r11
pushq %r10
callq 0x10d0
addq $0x20, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, 0x6646(%rip)     # 0x81a0
movaps %xmm0, 0x664f(%rip)     # 0x81b0
movaps %xmm0, 0x6658(%rip)     # 0x81c0
movaps %xmm0, 0x6661(%rip)     # 0x81d0
movups %xmm0, 0x6669(%rip)     # 0x81df
movq %rbx, %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: print_options
void print_options(){
    puts("[u] upload patches");
    puts("[c] complain");
    puts("[a] add patch pipeline");
    puts("[s] swap a patch");
    puts("[e] exit");
    puts("[r] run patches");
    puts("[d] remove a pipeline");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x295e(%rip), %rdi      # 0x4501
callq 0x1060
leaq 0x2965(%rip), %rdi      # 0x4514
callq 0x1060
leaq 0x2966(%rip), %rdi      # 0x4521
callq 0x1060
leaq 0x2971(%rip), %rdi      # 0x4538
callq 0x1060
leaq 0x2976(%rip), %rdi      # 0x4549
callq 0x1060
leaq 0x2973(%rip), %rdi      # 0x4552
callq 0x1060
leaq 0x2977(%rip), %rdi      # 0x4562
popq %rbp
jmp 0x1060
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: read_original_program
void read_original_program(){
    struct stat st;
    elf_unpatched=NULL;
    py_unpatched=NULL;
    int elfsize = 0;
    int ret = stat(ELF_PROGRAM_NAME, &st);
    if(ret<0){
        puts("elf file not exist");
        exit(0);
    }

    elfsize = st.st_size; 
    elf_unpatched_size = elfsize;
    FILE *fp = fopen(ELF_PROGRAM_NAME, "rb");
    elf_unpatched = malloc(elfsize);
    fread(elf_unpatched, 1, elfsize , fp);
    fclose(fp);
#ifdef DEBUG
    printf("%d, %s\n",elfsize, elf_unpatched);
#endif
    return; 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
xorl %eax, %eax
movq %rax, 0x6530(%rip)      # 0x8138
movq %rax, 0x65e1(%rip)      # 0x81f0
leaq 0x2962(%rip), %rdi      # 0x4578
leaq -0xa0(%rbp), %rsi
callq 0x1140
testl %eax, %eax
js 0x1c7f
movq -0x70(%rbp), %r14
movl %r14d, 0x6503(%rip)     # 0x8134
leaq 0x2940(%rip), %rdi      # 0x4578
leaq 0x2898(%rip), %rsi      # 0x44d7
callq 0x1190
movq %rax, %rbx
movslq %r14d, %r14
movq %r14, %rdi
callq 0x1160
movq %rax, 0x64df(%rip)      # 0x8138
movl $0x1, %esi
movq %rax, %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x1070
movq %rbx, %rdi
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x10a0
leaq 0x2907(%rip), %rdi      # 0x458d
callq 0x1060
xorl %edi, %edi
callq 0x11c0
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: add_complain
int add_complain(){
    char option_buffer[16];
    char *message;
    memset(option_buffer, 0, 16);
    puts("Anything to complain about your patch?");
    puts("1. My patch is checked down but it should work.");
    puts("2. My patch seems not effective against some team.") ;
    puts("3. other complains");
    recv_until(option_buffer, 16, '\n');
    switch(option_buffer[0]){
        case '1':
            puts("We have a checker to check the function of the target program, your patch should not change those basic behaviors, also we disallow too many change over the original program.");
            break;
        case '2':
            puts("Maybe they are attacking your service with a deeper vulnerability, come on bro");
            break;
        case '3':
            message = malloc(0x200);
            read(0,message,0x200);
            puts("thanks for the complain, we will get back to you in a second");
            sleep(1);
            if(strstr(message,"flag") > 0){
                printf("%s, Your complain looks reasonable, let us give you a stack overflow as reward :n\n",message);
                free(message);
                read(0, option_buffer, 0x200);
                exit(0);
            }
            break;
        default:
            break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, -0x30(%rbp)
leaq 0x2745(%rip), %rdi      # 0x45a7
callq 0x1060
leaq 0x2760(%rip), %rdi      # 0x45ce
callq 0x1060
leaq 0x2784(%rip), %rdi      # 0x45fe
callq 0x1060
leaq 0x27ab(%rip), %rdi      # 0x4631
callq 0x1060
xorl %r14d, %r14d
leaq -0x11(%rbp), %rbx
movl $0x1, %edx
xorl %edi, %edi
movq %rbx, %rsi
callq 0x1110
movb -0x11(%rbp), %al
cmpb $0xa, %al
je 0x1eb6
movb %al, -0x30(%rbp,%r14)
incq %r14
cmpq $0x10, %r14
jne 0x1e92
movzbl -0x30(%rbp), %eax
cmpl $0x31, %eax
je 0x1f21
cmpl $0x33, %eax
je 0x1ed2
cmpl $0x32, %eax
jne 0x1f18
leaq 0x2823(%rip), %rdi      # 0x46f3
jmp 0x1f28
movl $0x200, %edi            # imm = 0x200
callq 0x1160
movq %rax, %rbx
movl $0x200, %edx            # imm = 0x200
xorl %edi, %edi
movq %rax, %rsi
callq 0x1110
leaq 0x284d(%rip), %rdi      # 0x4742
callq 0x1060
movl $0x1, %edi
callq 0x11e0
leaq 0x2874(%rip), %rsi      # 0x477f
movq %rbx, %rdi
callq 0x1210
testq %rax, %rax
jne 0x1f35
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x271c(%rip), %rdi      # 0x4644
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x1060
leaq 0x2848(%rip), %rdi      # 0x4784
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10d0
movq %rbx, %rdi
callq 0x1030
leaq -0x30(%rbp), %rsi
movl $0x200, %edx            # imm = 0x200
xorl %edi, %edi
callq 0x1110
xorl %edi, %edi
callq 0x11c0
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: do_patch_pipeline_alloc
struct executor_queue * do_patch_pipeline_alloc(struct patch_attr* attr){
    unsigned int size, value_size; 
    unsigned long queue_size, cost;

    struct executor_queue * eq;
    size = attr->max_queue_entries + 1;
    value_size = attr->value_size;
    queue_size = sizeof(*eq) + (unsigned long) value_size * size;
    cost = queue_size + (0x1000 - (queue_size % 0x1000));
    if (cost >= 0x10000000){
        return NULL;
    }
    eq = malloc(queue_size);
    if(eq<0){
        return NULL;
    }
    eq->ops = &elf_executor_ops;
    init_executor_queue(eq, attr);
    eq->size = size;
    return eq;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
movl 0x4(%rdi), %r12d
movl 0x8(%rdi), %r15d
leal 0x1(%r12), %r14d
movq %r14, %rax
imulq %r15, %rax
leaq 0x38(%rax), %rdi
movl %edi, %ecx
andl $0xfff, %ecx            # imm = 0xFFF
negq %rcx
addq %rcx, %rax
addq $-0xfffefc8, %rax       # imm = 0xF0001038
cmpq $-0x10000000, %rax      # imm = 0xF0000000
jae 0x1fab
xorl %eax, %eax
jmp 0x1fdc
callq 0x1160
leaq 0x5e01(%rip), %rcx      # 0x7db8
movq %rcx, (%rax)
movl (%rbx), %ecx
movl %ecx, 0x8(%rax)
movl %r12d, 0x10(%rax)
movl %r15d, 0x14(%rax)
movl 0x6163(%rip), %ecx      # 0x8130
movl %ecx, 0xc(%rax)
movq $0x0, 0x18(%rax)
movl %r14d, 0x20(%rax)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: add_patch_pipeline
int add_patch_pipeline(){
    struct patch_attr* attr; int res = 0;
    struct executor_queue *eq;
    puts(">");
    attr = malloc(sizeof(struct patch_attr));
    read(0, attr, sizeof(struct patch_attr));
#ifdef DEBUG
    puts("o");
#endif

    res=check_patch_attr(attr);
    if(res<0){
#ifdef DEBUG
        printf("check patach attr error code: %d\n",res);
#endif
        return res;
    }

    eq = do_patch_pipeline_alloc(attr);
    if(!eq){
#ifdef DEBUG
        printf("pipeline alloc error\n");
#endif
        return res;
    }

    list_insert(&head, &eq->list);
    total_ppl+=1;
    global_executor_idx+=1;
#ifdef DEBUG
    printf("successfully added pipeline\n");
#endif

    return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
leaq 0x2a9c(%rip), %rdi      # 0x4a8f
callq 0x1060
movl $0x18, %edi
callq 0x1160
movq %rax, %rbx
movl $0x18, %edx
xorl %edi, %edi
movq %rax, %rsi
callq 0x1110
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
movb $0x1, %al
cmpl $0x2, (%rbx)
ja 0x2055
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpl $0x100000, 0x8(%rbx)    # imm = 0x100000
ja 0x2055
xorl %eax, %eax
cmpl $0x4, 0x6107(%rip)      # 0x8140
movl $0x0, %r14d
jb 0x2055
leaq 0x27c1(%rip), %rdi      # 0x4809
callq 0x1060
movl $0xfffffffd, %r14d      # imm = 0xFFFFFFFD
movb $0x1, %al
testb %al, %al
jne 0x209a
movq %rbx, %rdi
callq 0x1f65
testq %rax, %rax
je 0x209a
movq %rax, %rcx
addq $0x28, %rcx
leaq 0x6184(%rip), %rdx      # 0x81f8
movq 0x617d(%rip), %rsi      # 0x81f8
movq %rcx, 0x6176(%rip)      # 0x81f8
movq %rsi, 0x28(%rax)
movq %rdx, 0x30(%rax)
movq %rcx, 0x8(%rsi)
incl 0x60ac(%rip)            # 0x8140
incl 0x6096(%rip)            # 0x8130
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: remove_pipeline
int remove_pipeline(){
    struct executor_queue *eq = NULL;
    struct ppl_list_node * cur; 
    unsigned int idx;
    read(0, &idx, 4);
    cur = &head;
    for(cur=cur->fd; cur!=&head; cur=cur->fd){
        eq = (struct executor_queue *)((unsigned long)cur - (unsigned long)&((struct executor_queue*)0)->list);
#ifdef DEBUG
        printf("found executor at: %p\n", eq);
#endif
        if (eq->executor_idx == idx){
            break;
        }
        eq = NULL;
    }
    if(eq != NULL){
#ifdef DEBUG
        printf("goint to remove pipeline %d\n",idx);
#endif  
        eq->ops->executor_free(eq);
        ppl_node_unlink(&eq->list);
        total_ppl-=1;
    }
    else{
        return -1;
    }
    return 0; 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
xorl %ebx, %ebx
leaq -0x14(%rbp), %r14
movl $0x4, %edx
xorl %edi, %edi
movq %r14, %rsi
callq 0x1110
leaq 0x612f(%rip), %rcx      # 0x81f8
movl (%r14), %edx
movq %rcx, %rax
movq (%rax), %rax
cmpq %rcx, %rax
je 0x20e3
cmpl %edx, -0x1c(%rax)
jne 0x20cf
addq $-0x28, %rax
movq %rax, %rbx
testq %rbx, %rbx
je 0x2109
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
movq %rax, (%rcx)
movq %rcx, 0x8(%rax)
decl 0x603b(%rip)            # 0x8140
xorl %eax, %eax
jmp 0x210e
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: swap_a_patch
int swap_a_patch(){
    struct patch_attr attr;
    unsigned int value_size;
    struct executor_queue * eq;
    unsigned int queue_type, idx_to_swap;
    unsigned char * value, * tmp_buffer;
    struct ppl_list_node * cur;
    int found_queue = 0;
    void *dst;
    if(!total_ppl){
        return -1;
    }
    read(0, &attr, sizeof(struct patch_attr));
    queue_type = attr.queue_type;
    idx_to_swap  = attr.idx_to_swap;
#ifdef DEBUG
    printf("type:%d\t idx to swap: %d\n", queue_type, idx_to_swap);
#endif
    
    cur = &head;
    for(cur=cur->fd; cur!=&head; cur=cur->fd)
    {
        eq = (struct executor_queue *)((unsigned long)cur - (unsigned long)&((struct executor_queue*)0)->list);
#ifdef DEBUG
        printf("found executor at: %p\n", eq);
#endif
        if(eq->queue_type == queue_type && eq->head > idx_to_swap && eq->tail<=idx_to_swap){
            found_queue = 1;
            break;
        }
    }
    if (!found_queue){
#ifdef DEBUG
        printf("executor not found for type %d\n", queue_type);
        printf("head: %d, tail: %d\n", eq->head, eq->tail);
#endif
        return -1;
    }
    value_size = eq->value_size;
    value = malloc(value_size);
#ifdef DEBUG
    puts("xD");
#endif
    // read new patch to buffer just allocated
    //read(0, value, value_size);
    safe_read(0, value, value_size);

    tmp_buffer = (char*)malloc(value_size);
    dst = &eq->elements[idx_to_swap * value_size];
    memcpy(tmp_buffer, dst, value_size);
    memcpy(dst, value, value_size);

    write(1, tmp_buffer, value_size);

    free(tmp_buffer);
    free(value);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $0x0, 0x600b(%rip)      # 0x8140
je 0x2202
leaq -0x40(%rbp), %r14
movl $0x18, %edx
xorl %edi, %edi
movq %r14, %rsi
callq 0x1110
movl 0x14(%r14), %r13d
movq 0x609f(%rip), %rcx      # 0x81f8
leaq 0x6098(%rip), %rdx      # 0x81f8
cmpq %rdx, %rcx
sete %al
je 0x218d
movl -0x40(%rbp), %esi
leaq -0x28(%rcx), %rbx
cmpl %esi, -0x20(%rcx)
jne 0x2180
cmpl %r13d, 0x18(%rbx)
jbe 0x2180
cmpl %r13d, 0x1c(%rbx)
jbe 0x218d
movq (%rcx), %rcx
cmpq %rdx, %rcx
sete %al
jne 0x216b
jmp 0x218d
testb $0x1, %al
jne 0x2202
movl 0x14(%rbx), %r15d
movq %r15, %rdi
callq 0x1160
movq %rax, %r14
xorl %edi, %edi
movq %rax, %rsi
movl %r15d, %edx
callq 0x1768
movq %r15, %rdi
callq 0x1160
movq %rax, %r12
imull %r15d, %r13d
addq %rbx, %r13
addq $0x38, %r13
movq %rax, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x1150
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x1150
movl $0x1, %edi
movq %r12, %rsi
movq %r15, %rdx
xorl %r15d, %r15d
callq 0x1090
movq %r12, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: upload_patches
int upload_patches(){
    struct patch_attr attr;
    unsigned int value_size, queue_type;
    struct executor_queue * eq;
    int found_queue = 0;
    unsigned char *value;
    struct ppl_list_node * cur;
    int ret=0;
    if(!total_ppl){
        return -1;
    }
    read(0, &attr, sizeof(struct patch_attr));
    queue_type = attr.queue_type; 

    // iterate over the linked list
    cur = &head;
    for(cur=cur->fd; cur!=&head; cur=cur->fd)
    {
        eq = (struct executor_queue *)((unsigned long)cur - (unsigned long)&((struct executor_queue*)0)->list);
#ifdef DEBUG
        printf("found executor at: %p\n", eq);
#endif
        if(eq->queue_type == queue_type){
            found_queue=1;
            break;
        }
    }

    if(!found_queue){
#ifdef DEBUG
        printf("executor not found for type %d\n", queue_type);
#endif
        return -1;
    }
    value_size = eq->value_size;
    value = malloc(value_size);
#ifdef DEBUG
    puts("p:");
#endif
    //read(0, value, value_size);
    safe_read(0, value, value_size);

    // invoke push_elem
    ret = eq->ops->push_elem(eq, value);

    free(value);
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
cmpl $0x0, 0x5f18(%rip)      # 0x8140
je 0x226d
leaq -0x30(%rbp), %rsi
movl $0x18, %edx
xorl %edi, %edi
callq 0x1110
movq 0x5fb7(%rip), %rcx      # 0x81f8
leaq 0x5fb0(%rip), %rdx      # 0x81f8
cmpq %rdx, %rcx
sete %al
je 0x2269
movl -0x30(%rbp), %esi
leaq -0x28(%rcx), %rbx
cmpl %esi, -0x20(%rcx)
je 0x2269
movq (%rcx), %rcx
cmpq %rdx, %rcx
sete %al
jne 0x2253
jmp 0x2269
testb %al, %al
je 0x2274
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x22a8
movl 0x14(%rbx), %r14d
movq %r14, %rdi
callq 0x1160
movq %rax, %r15
xorl %edi, %edi
movq %rax, %rsi
movl %r14d, %edx
callq 0x1768
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0x8(%rax)
movl %eax, %ebx
movq %r15, %rdi
callq 0x1030
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/main.c
// Function: run_patches
int run_patches(){
    struct patch_attr attr;
    struct ppl_list_node * cur;
    unsigned int queue_type;
    int found_queue = 0;
    int cur_run;
    unsigned int value_size;
    void* value;
    int ret;
    struct executor_queue* eq;
    if(!total_ppl){
        return -1;
    }
    read(0, &attr, sizeof(struct patch_attr));
    if(attr.queue_type > BRAINFUCK_EXECUTOR){
        return -1; 
    }
    queue_type = attr.queue_type;
    // iterate over the linked list
    cur = &head;
    for(cur=cur->fd; cur!=&head; cur=cur->fd)
    {
        eq = (struct executor_queue *)((unsigned long)cur - (unsigned long)&((struct executor_queue*)0)->list);
#ifdef DEBUG
        printf("%p\n", eq);
#endif
        if(eq->queue_type == queue_type && attr.number_of_patch <= eq->head - eq->tail){
            found_queue=1;
            break;
        }
    }
    if(!found_queue){
        puts("not found");
        return -1; 
    }
    value_size = eq->value_size;
    value = malloc(eq->value_size);
    memset(value, 0, value_size);
    for(cur_run=0; cur_run<attr.number_of_patch; cur_run++){
        // get_the element 
        eq->ops->get_elem(eq, value);
        ret=eq->ops->check_patch(eq, value);
        if(ret < 0){
            printf("%s... is not a valid patch\n", (char*)value);
            return 0;
        }
        eq->ops->run_patch(eq, value);
    }
    free(value);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $0x0, 0x5e72(%rip)      # 0x8140
je 0x23b6
leaq -0x38(%rbp), %r14
movl $0x18, %edx
xorl %edi, %edi
movq %r14, %rsi
callq 0x1110
movl (%r14), %ecx
cmpl $0x2, %ecx
ja 0x23b6
movq 0x5efe(%rip), %rdx      # 0x81f8
leaq 0x5ef7(%rip), %rsi      # 0x81f8
cmpq %rsi, %rdx
sete %al
je 0x232f
movl -0x28(%rbp), %edi
leaq -0x28(%rdx), %r14
cmpl %ecx, -0x20(%rdx)
jne 0x2322
movl 0x18(%r14), %r8d
subl 0x1c(%r14), %r8d
cmpl %r8d, %edi
jbe 0x232f
movq (%rdx), %rdx
cmpq %rsi, %rdx
sete %al
jne 0x230c
jmp 0x232f
testb $0x1, %al
je 0x2341
leaq 0x249d(%rip), %rdi      # 0x47d7
callq 0x1060
jmp 0x23b6
movl 0x14(%r14), %ebx
movq %rbx, %rdi
callq 0x1160
movq %rax, %r15
xorl %r12d, %r12d
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x10f0
cmpl $0x0, -0x28(%rbp)
je 0x2397
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0x18(%rax)
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0x20(%rax)
testl %eax, %eax
js 0x23a3
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0x28(%rax)
incl %r12d
cmpl -0x28(%rbp), %r12d
jb 0x2366
movq %r15, %rdi
callq 0x1030
xorl %ebx, %ebx
jmp 0x23b6
leaq 0x2437(%rip), %rdi      # 0x47e1
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/sha3.c
// Function: rhash_sha3_update
void rhash_sha3_update(sha3_ctx *ctx, const unsigned char *msg, size_t size)
{
	size_t index = (size_t)ctx->rest;
	size_t block_size = (size_t)ctx->block_size;

	if (ctx->rest & SHA3_FINALIZED) return; /* too late for additional input */
	ctx->rest = (unsigned)((ctx->rest + size) % block_size);

	/* fill partial block */
	if (index) {
		size_t left = block_size - index;
		memcpy((char*)ctx->message + index, msg, (size < left ? size : left));
		if (size < left) return;

		/* process partial block */
		rhash_sha3_process_block(ctx->hash, ctx->message, block_size);
		msg  += left;
		size -= left;
	}
	while (size >= block_size) {
		uint64_t* aligned_message_block;
		if (IS_ALIGNED_64(msg)) {
			/* the most common case is processing of an already aligned message
			without copying it */
			aligned_message_block = (uint64_t*)msg;
		} else {
			memcpy(ctx->message, msg, block_size);
			aligned_message_block = ctx->message;
		}

		rhash_sha3_process_block(ctx->hash, aligned_message_block, block_size);
		msg  += block_size;
		size -= block_size;
	}
	if (size) {
		memcpy(ctx->message, msg, size); /* save leftovers */
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl 0x188(%rdi), %ecx
testl %ecx, %ecx
js 0x262a
movq %rdx, %rbx
movq %rsi, %r15
movl 0x18c(%rdi), %r12d
leaq (%rcx,%rdx), %rax
xorl %edx, %edx
divq %r12
movl %edx, 0x188(%rdi)
testq %rcx, %rcx
movq %rdi, -0x30(%rbp)
je 0x25be
movq %r12, %r14
subq %rcx, %r14
addq %rcx, %rdi
addq $0xc8, %rdi
cmpq %rbx, %r14
movq %rbx, %rdx
cmovbq %r14, %rdx
movq %r15, %rsi
callq 0x1150
movq %rbx, %r13
subq %r14, %r13
jae 0x259c
movq %rbx, %r13
jmp 0x25b2
movq -0x30(%rbp), %rdi
leaq 0xc8(%rdi), %rsi
movq %r12, %rdx
callq 0x2639
addq %r14, %r15
cmpq %r14, %rbx
movq %r13, %rbx
movq -0x30(%rbp), %rdi
jb 0x262a
cmpq %r12, %rbx
jb 0x2601
leaq 0xc8(%rdi), %r13
movq %r15, %r14
movq %r15, %rsi
testb $0x7, %r14b
je 0x25e7
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1150
movq %r13, %rsi
movq -0x30(%rbp), %rdi
movq %r12, %rdx
callq 0x2639
addq %r12, %r15
subq %r12, %rbx
addq %r12, %r14
cmpq %r12, %rbx
jae 0x25cd
testq %rbx, %rbx
movq -0x30(%rbp), %rdi
je 0x262a
addq $0xc8, %rdi
movq %r15, %rsi
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1150
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/sha3.c
// Function: rhash_sha3_final
void rhash_sha3_final(sha3_ctx *ctx, unsigned char* result)
{
	size_t digest_length = 100 - ctx->block_size / 2;
	const size_t block_size = ctx->block_size;

	if (!(ctx->rest & SHA3_FINALIZED))
	{
		/* clear the rest of the data queue */
		memset((char*)ctx->message + ctx->rest, 0, block_size - ctx->rest);
		((char*)ctx->message)[ctx->rest] |= 0x06;
		((char*)ctx->message)[block_size - 1] |= 0x80;

		/* process final block */
		rhash_sha3_process_block(ctx->hash, ctx->message, block_size);
		ctx->rest = SHA3_FINALIZED; /* mark context as finalized */
	}

	assert(block_size > digest_length);
	if (result) me64_to_le_str(result, ctx->hash, digest_length);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movl 0x18c(%rdi), %r12d
movl %r12d, %eax
shrl %eax
movl $0x64, %r15d
subl %eax, %r15d
movslq 0x188(%rdi), %rax
testq %rax, %rax
js 0x2b28
leaq 0xc8(%rbx), %r13
leaq (%rbx,%rax), %rdi
addq $0xc8, %rdi
movq %r12, %rdx
subq %rax, %rdx
xorl %esi, %esi
callq 0x10f0
movl 0x188(%rbx), %eax
orb $0x6, 0xc8(%rbx,%rax)
orb $-0x80, 0xc7(%rbx,%r12)
movq %rbx, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x2639
movl $0x80000000, 0x188(%rbx) # imm = 0x80000000
cmpl %r15d, %r12d
jbe 0x2b5d
testq %r14, %r14
je 0x2b4e
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1150
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1df8(%rip), %rdi      # 0x495c
leaq 0x1e0c(%rip), %rsi      # 0x4977
leaq 0x1e0c(%rip), %rcx      # 0x497e
movl $0x145, %edx            # imm = 0x145
callq 0x10e0
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/elf.c
// Function: ELF64_FileGetNameOfSection
const char * ELF64_FileGetNameOfSection( ELF64_FileRef file, ELF64_SectionHeaderEntryRef section )
{
    ELF64_HeaderRef             header;
    ELF64_SectionHeaderEntryRef stringTable;
    ELF64_Word                  nameOffset;
    
    if( file == NULL || section == NULL )
    {
        return NULL;
    }
    
    header = ELF64_FileGetHeader( file );
    
    if( header == NULL )
    {
        return NULL;
    }
    
    stringTable = ELF64_FileGetStringTableHeaderEntry( file );
    nameOffset  = ELF64_SectionHeaderEntryGetNameOffset( section );
    
    return ( const char * )( ELF64_FileGetDataForSection( file, stringTable ) + nameOffset );
}

// Assembly:
testq %rdi, %rdi
sete %cl
testq %rsi, %rsi
sete %dl
orb %cl, %dl
je 0x2c83
xorl %eax, %eax
retq
movq %rdi, %rax
movzwl 0x3e(%rdi), %edx
cmpw %dx, 0x3c(%rdi)
jbe 0x2ca4
movzwl 0x3a(%rax), %ecx
movq 0x28(%rax), %rdi
addq %rax, %rdi
imulq %rdx, %rcx
addq %rdi, %rcx
jmp 0x2ca6
xorl %ecx, %ecx
pushq %rbp
movq %rsp, %rbp
movl (%rsi), %edx
testq %rcx, %rcx
je 0x2cb7
addq 0x18(%rcx), %rax
jmp 0x2cb9
xorl %eax, %eax
addq %rdx, %rax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/elf.c
// Function: ELF64_FileGetNameOfSectionAtIndex
ELF64_SectionHeaderEntryRef ELF64_FileGetSectionHeaderEntry( ELF64_FileRef file, unsigned int index )
{
    ELF64_HeaderRef header;
    ELF64_Off       offset;
    ELF64_Half      entrySize;
    
    if( file == NULL )
    {
        return NULL;
    }
    
    header = ELF64_FileGetHeader( file );
    
    if( header == NULL || index >= ELF64_HeaderGetSectionHeaderEntryCount( header ) )
    {
        return NULL;
    }
    
    offset      = ELF64_HeaderGetSectionHeaderOffset( header );
    entrySize   = ELF64_HeaderGetSectionHeaderEntrySize( header );
    
    return ( ELF64_SectionHeaderEntryRef )( ( void * )( ( char * )file + offset + ( entrySize * index ) ) );
}

// Assembly:
testq %rdi, %rdi
je 0x2d2d
movzwl 0x3c(%rdi), %eax
cmpl %esi, %eax
jbe 0x2d2d
movzwl 0x3a(%rdi), %ecx
movq 0x28(%rdi), %rax
addq %rdi, %rax
imull %esi, %ecx
addq %rax, %rcx
jmp 0x2d2f
xorl %ecx, %ecx
xorl %eax, %eax
testq %rdi, %rdi
je 0x2d75
testq %rcx, %rcx
je 0x2d75
movzwl 0x3e(%rdi), %edx
cmpw %dx, 0x3c(%rdi)
jbe 0x2d59
movzwl 0x3a(%rdi), %eax
movq 0x28(%rdi), %rsi
addq %rdi, %rsi
imulq %rdx, %rax
addq %rsi, %rax
jmp 0x2d5b
xorl %eax, %eax
pushq %rbp
movq %rsp, %rbp
movl (%rcx), %ecx
testq %rax, %rax
je 0x2d6f
addq 0x18(%rax), %rdi
movq %rdi, %rax
jmp 0x2d71
xorl %eax, %eax
addq %rcx, %rax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/elf.c
// Function: ELF64_FileGetSymbolTableEntryForSection
ELF64_SymbolTableEntryRef ELF64_FileGetSymbolTableEntryForSection( ELF64_FileRef file, ELF64_SectionHeaderEntryRef section, unsigned int index )
{
    ELF64_XWord entrySize;
    
    if( ELF64_SectionHeaderEntryGetType( section ) != ELF64_SectionTypeLinkerSymbolTable )
    {
        return NULL;
    }
    
    if( index >= ELF64_SectionHeaderEntryGetSymbolTableEntryCount( section ) )
    {
        return NULL;
    }
    
    entrySize = ELF64_SectionHeaderEntryGetEntrySize( section );
    
    return ( ELF64_SymbolTableEntryRef )( ( void * )( ELF64_FileGetDataForSection( file, section ) + ( index * entrySize ) ) );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x2e20
cmpl $0x2, %eax
jne 0x2df8
movq %r15, %rdi
callq 0x2e43
cmpl %r14d, %eax
jbe 0x2df8
testq %r15, %r15
je 0x2dfc
movq 0x38(%r15), %rax
jmp 0x2dfe
xorl %eax, %eax
jmp 0x2e15
xorl %eax, %eax
testq %r15, %r15
je 0x2e09
addq 0x18(%r15), %rbx
jmp 0x2e0b
xorl %ebx, %ebx
movl %r14d, %ecx
imulq %rcx, %rax
addq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/elf.c
// Function: ELF64_SectionHeaderEntryGetSymbolTableEntryCount
unsigned int ELF64_SectionHeaderEntryGetSymbolTableEntryCount( ELF64_SectionHeaderEntryRef section )
{
    ELF64_XWord entrySize;
    ELF64_XWord sectionSize;
    
    if( ELF64_SectionHeaderEntryGetType( section ) != ELF64_SectionTypeLinkerSymbolTable )
    {
        return 0;
    }
    
    entrySize   = ELF64_SectionHeaderEntryGetEntrySize( section );
    sectionSize = ELF64_SectionHeaderEntryGetSectionSize( section );
    
    if( entrySize == 0 )
    {
        return 0;
    }
    
    return ( unsigned int )( sectionSize / entrySize );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x2e20
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x2, %ecx
jne 0x2e83
testq %rbx, %rbx
je 0x2e65
movq 0x38(%rbx), %rsi
jmp 0x2e67
xorl %esi, %esi
xorl %eax, %eax
testq %rbx, %rbx
je 0x2e74
movq 0x20(%rbx), %rcx
jmp 0x2e76
xorl %ecx, %ecx
testq %rsi, %rsi
je 0x2e83
movq %rcx, %rax
xorl %edx, %edx
divq %rsi
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/ww9210[P]xnuca_final_ssp/elf.c
// Function: ELF64_FileGetSymbolTableEntryNameForSection
const char * ELF64_FileGetSymbolTableEntryNameForSection( ELF64_FileRef file, ELF64_SymbolTableEntryRef sym, ELF64_SectionHeaderEntryRef section )
{
    ELF64_Word                  stringTableIndex;
    ELF64_SectionHeaderEntryRef stringTable;
    ELF64_Word                  nameOffset;
    const char                * name;
    
    if( file == NULL || sym == NULL || section == NULL )
    {
        return NULL;
    }
    
    stringTableIndex = ELF64_SectionHeaderEntryGetLinkedSectionIndex( section );
    stringTable      = ELF64_FileGetSectionHeaderEntry( file, stringTableIndex );
    
    if( stringTable == NULL )
    {
        return NULL;
    }
    
    nameOffset = ELF64_SymbolTableEntryGetNameOffset( sym );
    name       = ( const char * )( ELF64_FileGetDataForSection( file, stringTable ) + nameOffset );
    
    if( strlen( name ) == 0 )
    {
        return "<unnamed-symbol>";
    }
    
    return name;
}

// Assembly:
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
testq %rdx, %rdx
sete %al
orb %cl, %al
jne 0x2ef9
movl 0x28(%rdx), %eax
movzwl 0x3c(%rdi), %ecx
cmpl %ecx, %eax
jae 0x2ed3
movzwl 0x3a(%rdi), %ecx
movq 0x28(%rdi), %rdx
addq %rdi, %rdx
imull %ecx, %eax
addq %rdx, %rax
jmp 0x2ed5
xorl %eax, %eax
testq %rax, %rax
je 0x2ef9
pushq %rbp
movq %rsp, %rbp
movl (%rsi), %ecx
addq 0x18(%rax), %rdi
cmpb $0x0, (%rcx,%rdi)
leaq (%rdi,%rcx), %rcx
leaq 0x1b8d(%rip), %rax      # 0x4a80
cmovneq %rcx, %rax
popq %rbp
retq
xorl %eax, %eax
retq