LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/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, %rbp
movq %rsi, %rbx
movq %rdi, %r13
movq %rcx, %r14
subq %rdx, %r14
leaq 0x2(,%r14,2), %rdi
callq 0x33d0
movq %rax, %r15
andq $0x0, 0x18(%rsp)
andq $0x0, 0x10(%rsp)
leaq 0x4(,%r14,4), %rdi
callq 0x33d0
testq %rax, %rax
je 0x13271
testq %r15, %r15
je 0x13271
movq %rax, %r14
leaq 0x20(%rsp), %rsi
movl $0x8000, %edi           # imm = 0x8000
callq 0x11fa8
movq %rbp, 0x10(%r13)
movq %r12, 0x18(%r13)
leaq 0x6d(%rip), %rax        # 0x13279
leaq 0x18(%rsp), %r8
leaq 0x10(%rsp), %r9
movq %r13, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movq %r8, %rbx
pushq %r14
leaq 0x28(%rsp), %r10
pushq %r10
pushq 0x18(%rsp)
pushq $0x0
pushq %rax
pushq %r15
callq 0x12878
addq $0x30, %rsp
movq %r15, %rdi
callq 0x3050
movq (%rbx), %rdi
callq 0x3050
movq %r14, %rdi
callq 0x3050
leaq 0x20(%rsp), %rdi
callq 0x1209d
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $-0x1
popq %rdi
callq 0x3540
// File: /workspace/github_c_makefile_star2_O2/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 0x132b7
movl %esi, %edi
callq 0x13728
movl %eax, %ebp
movl %ebx, %edi
callq 0x13789
movl %eax, %r14d
movl %ebx, %edi
callq 0x137a5
xorl %ecx, %ecx
cmpl $0x118, %eax            # imm = 0x118
setl %cl
xorl $0xd, %ecx
addl %ebp, %r14d
addl %ecx, %r14d
cvtsi2sd %r14d, %xmm0
jmp 0x132ce
xorl %eax, %eax
cmpl $0x90, %ebx
setb %al
leaq 0x3667(%rip), %rcx      # 0x16930
movsd (%rcx,%rax,8), %xmm0
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
movq %rcx, %r14
movl %edx, %ebp
movq %rsi, %rbx
movslq %r8d, %r13
movq %r13, %rax
shlq $0x4, %rax
movq %rdi, (%rsp)
leaq (%rax,%rdi), %r15
addq $0x8, %r15
leal -0x1(%r13), %r12d
movq (%r15), %rax
movl 0x10(%rax), %eax
testq %r13, %r13
jne 0x13697
cmpl %ebp, %eax
jge 0x13716
movslq %eax, %rdx
movq (%r14), %rcx
leaq 0x18(%rcx), %rsi
movq %rsi, (%r14)
movq (%r15), %rsi
movq %rsi, -0x8(%r15)
movq %rcx, (%r15)
addq $-0x1, %r13
jae 0x136fa
movq -0x18(%r15), %r9
movq -0x10(%r15), %rdi
movq (%rdi), %r8
addq (%r9), %r8
cmpl %ebp, %eax
jge 0x136d3
imulq $0x18, %rdx, %rdx
movq (%rbx,%rdx), %rdx
cmpq %rdx, %r8
ja 0x13706
movq %r8, (%rcx)
movl %eax, 0x10(%rcx)
movq %rdi, 0x8(%rcx)
movq (%rsp), %rdi
movq %rbx, %rsi
movl %ebp, %edx
movq %r14, %rcx
movl %r12d, %r8d
callq 0x1365b
addq $-0x10, %r15
decl %r12d
jmp 0x13688
imulq $0x18, %rdx, %rdx
movq (%rbx,%rdx), %rdx
xorl %esi, %esi
jmp 0x1370a
movq 0x8(%rsi), %rsi
incl %eax
movq %rdx, (%rcx)
movl %eax, 0x10(%rcx)
movq %rsi, 0x8(%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/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
movl %edx, %r14d
movl %esi, %r12d
movq %rdi, %r15
xorl %ebx, %ebx
testl %esi, %esi
cmovlel %ebx, %r12d
pushq $0x1
popq %r13
cmpq %rbx, %r12
je 0x13a1
xorl %edi, %edi
leaq -0x29(%rbp), %rsi
movq %r13, %rdx
callq 0x1110
movb -0x29(%rbp), %al
cmpb %r14b, %al
je 0x139e
movb %al, (%r15,%rbx)
incq %rbx
jmp 0x137a
movl %ebx, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
andw $0x0, (%r14)
callq 0x1030
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
movq %rax, (%rcx)
movq %rcx, 0x8(%rax)
leaq 0x30a0(%rip), %rdi      # 0x4485
callq 0x1060
pushq $0x2
popq %rdx
xorl %edi, %edi
movq %r14, %rsi
callq 0x1110
movswq (%r14), %rbx
movl %ebx, %edi
callq 0x1170
movq %rax, %r14
xorl %edi, %edi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x1110
leaq 0x3076(%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_O2/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 0x1160
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_O2/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 0x6c85(%rip), %eax      # 0x8144
movq 0x6c82(%rip), %rcx      # 0x8148
xorl %r8d, %r8d
xorl %edx, %edx
movq %r8, %rsi
cmpq %r8, %rax
je 0x14f1
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 0x14cb
cmpq %rax, %rsi
setb %r15b
callq 0x292c
movq %rax, %rbx
movq %rax, %rdi
callq 0x295b
movq %rax, %r14
movq %rbx, %rdi
callq 0x2935
testb %al, %al
jne 0x1526
leaq 0x2f28(%rip), %rdi      # 0x4446
callq 0x1060
movb $0x1, %r15b
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1741
movzbl %r15b, %eax
negl %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x172f
movl %ebx, %esi
addq %r15, %rsi
movl %r12d, %edi
callq 0x1110
testl %eax, %eax
js 0x173a
addl %eax, %ebx
cmpl %r14d, %ebx
jne 0x170d
movl %r14d, %ebx
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x11d0
// File: /workspace/github_c_makefile_star2_O2/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, %ecx
xorl %edx, %edx
movb $0x3e, %r8b
leaq 0x271e(%rip), %r9       # 0x4040
cmpq %rdx, %rcx
je 0x193d
movzbl (%rsi,%rdx), %eax
divb %r8b
movzbl %ah, %eax
movb (%rax,%r9), %al
movb %al, (%rdi,%rdx)
incq %rdx
jmp 0x1922
movb $0x0, (%rdi,%rcx)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ww9210[P]xnuca_final_ssp/main.c
// Function: check_patch_attr
int check_patch_attr(struct patch_attr* attr){

    /* check the whether these arguments are valid */

    if(attr->queue_type > BRAINFUCK_EXECUTOR){
        return -2;
    }

    if(attr->value_size > 0x100000){
        return -1;
    }

    if(total_ppl > 3)
    {
        printf("too many:(\n");
        return -3;
    }

    return 0;
}

// Assembly:
cmpl $0x2, (%rdi)
jbe 0x194c
pushq $-0x2
jmp 0x1957
cmpl $0x100000, 0x8(%rdi)    # imm = 0x100000
jbe 0x1959
pushq $-0x1
popq %rax
retq
xorl %eax, %eax
cmpl $0x4, 0x67ee(%rip)      # 0x8150
jb 0x1978
pushq %rbp
movq %rsp, %rbp
leaq 0x2e9a(%rip), %rdi      # 0x4809
callq 0x1060
pushq $-0x3
popq %rax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x67ac(%rip), %eax      # 0x8140
movl %eax, 0xc(%rdi)
andq $0x0, 0x18(%rdi)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
leaq 0x2b0c(%rip), %rdi      # 0x44c3
leaq 0x2b19(%rip), %rsi      # 0x44d7
callq 0x11a0
movq %rax, 0x678e(%rip)      # 0x8158
xorps %xmm0, %xmm0
movaps %xmm0, 0x678c(%rip)     # 0x8160
movaps %xmm0, 0x6795(%rip)     # 0x8170
movaps %xmm0, 0x679e(%rip)     # 0x8180
movaps %xmm0, 0x67a7(%rip)     # 0x8190
xorl %r12d, %r12d
movb %r12b, 0x67ad(%rip)     # 0x81a0
leaq 0x6766(%rip), %rbx      # 0x8160
leaq 0x67af(%rip), %r14      # 0x81b0
pushq $0x4f
popq %r15
pushq $0x1
popq %rdx
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rcx
callq 0x1070
movb %r12b, 0x67e2(%rip)     # 0x81ff
leaq -0x1b0(%rbp), %r12
movq %r12, %rdi
callq 0x22f6
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2368
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2855
movl 0x6715(%rip), %esi      # 0x8160
movl 0x6713(%rip), %edx      # 0x8164
movl 0x6711(%rip), %ecx      # 0x8168
movl 0x670e(%rip), %r8d      # 0x816c
movl 0x670b(%rip), %r9d      # 0x8170
movl 0x6708(%rip), %r10d     # 0x8174
movl 0x6705(%rip), %r11d     # 0x8178
movl 0x6702(%rip), %r14d     # 0x817c
subq $0x8, %rsp
leaq 0x2a55(%rip), %rdi      # 0x44da
xorl %eax, %eax
pushq %r14
pushq %r11
pushq %r10
callq 0x10d0
addq $0x20, %rsp
xorps %xmm0, %xmm0
movaps %xmm0, 0x6710(%rip)     # 0x81b0
movaps %xmm0, 0x6719(%rip)     # 0x81c0
movaps %xmm0, 0x6722(%rip)     # 0x81d0
movaps %xmm0, 0x672b(%rip)     # 0x81e0
movups %xmm0, 0x6733(%rip)     # 0x81ef
movq %rbx, %rax
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x2a16(%rip), %rdi      # 0x4501
callq 0x1060
leaq 0x2a1d(%rip), %rdi      # 0x4514
callq 0x1060
leaq 0x2a1e(%rip), %rdi      # 0x4521
callq 0x1060
leaq 0x2a29(%rip), %rdi      # 0x4538
callq 0x1060
leaq 0x2a2e(%rip), %rdi      # 0x4549
callq 0x1060
leaq 0x2a2b(%rip), %rdi      # 0x4552
callq 0x1060
leaq 0x2a2f(%rip), %rdi      # 0x4562
popq %rbp
jmp 0x1060
// File: /workspace/github_c_makefile_star2_O2/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
andq $0x0, 0x65f9(%rip)      # 0x8148
andq $0x0, 0x66a9(%rip)      # 0x8200
leaq 0x2a1a(%rip), %rdi      # 0x4578
leaq -0xa0(%rbp), %rsi
callq 0x1150
testl %eax, %eax
js 0x1bc5
movq -0x70(%rbp), %r14
movl %r14d, 0x65cb(%rip)     # 0x8144
leaq 0x29f8(%rip), %rdi      # 0x4578
leaq 0x2950(%rip), %rsi      # 0x44d7
callq 0x11a0
movq %rax, %rbx
movslq %r14d, %r14
movq %r14, %rdi
callq 0x1170
movq %rax, 0x65a7(%rip)      # 0x8148
pushq $0x1
popq %rsi
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 0x29c1(%rip), %rdi      # 0x458d
callq 0x1060
xorl %edi, %edi
callq 0x11d0
// File: /workspace/github_c_makefile_star2_O2/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 %rbx
subq $0x18, %rsp
xorps %xmm0, %xmm0
leaq -0x20(%rbp), %rbx
movaps %xmm0, (%rbx)
leaq 0x2828(%rip), %rdi      # 0x45a7
callq 0x1060
leaq 0x2843(%rip), %rdi      # 0x45ce
callq 0x1060
leaq 0x2867(%rip), %rdi      # 0x45fe
callq 0x1060
leaq 0x288e(%rip), %rdi      # 0x4631
callq 0x1060
pushq $0x10
popq %rsi
pushq $0xa
popq %rdx
movq %rbx, %rdi
callq 0x1357
movzbl (%rbx), %eax
cmpl $0x31, %eax
je 0x1e1c
cmpl $0x33, %eax
je 0x1dd1
cmpl $0x32, %eax
jne 0x1e15
leaq 0x2924(%rip), %rdi      # 0x46f3
jmp 0x1e23
movl $0x200, %edi            # imm = 0x200
callq 0x1170
movq %rax, %rbx
movl $0x200, %edx            # imm = 0x200
xorl %edi, %edi
movq %rax, %rsi
callq 0x1110
leaq 0x294e(%rip), %rdi      # 0x4742
callq 0x1060
pushq $0x1
popq %rdi
callq 0x11f0
leaq 0x2977(%rip), %rsi      # 0x477f
movq %rbx, %rdi
callq 0x1220
testq %rax, %rax
jne 0x1e2e
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
leaq 0x2821(%rip), %rdi      # 0x4644
addq $0x18, %rsp
popq %rbx
popq %rbp
jmp 0x1060
leaq 0x294f(%rip), %rdi      # 0x4784
movq %rbx, %rsi
xorl %eax, %eax
callq 0x10d0
movq %rbx, %rdi
callq 0x1030
leaq -0x20(%rbp), %rsi
movl $0x200, %edx            # imm = 0x200
xorl %edi, %edi
callq 0x1110
xorl %edi, %edi
callq 0x11d0
// File: /workspace/github_c_makefile_star2_O2/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 %rbx
pushq %rax
movq %rdi, %rbx
movl 0x4(%rdi), %r15d
movl 0x8(%rdi), %eax
incl %r15d
movq %r15, %rcx
imulq %rax, %rcx
leaq 0x38(%rcx), %rdi
movl %edi, %eax
andl $0xfff, %eax            # imm = 0xFFF
negq %rax
addq %rcx, %rax
addq $-0xfffefc8, %rax       # imm = 0xF0001038
cmpq $-0x10000000, %rax      # imm = 0xF0000000
jae 0x1ea0
xorl %r14d, %r14d
jmp 0x1ec1
callq 0x1170
movq %rax, %r14
leaq 0x5f09(%rip), %rax      # 0x7db8
movq %rax, (%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1979
movl %r15d, 0x20(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x2bb2(%rip), %rdi      # 0x4a8f
callq 0x1060
pushq $0x18
popq %rbx
movq %rbx, %rdi
callq 0x1170
movq %rax, %r14
xorl %edi, %edi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x1110
movq %r14, %rdi
callq 0x1943
movl %eax, %ebx
testl %eax, %eax
js 0x1f4c
movq %r14, %rdi
callq 0x1e5e
testq %rax, %rax
je 0x1f4c
movq %rax, %rcx
addq $0x28, %rcx
leaq 0x62e2(%rip), %rdx      # 0x8208
movq 0x62db(%rip), %rsi      # 0x8208
movq %rcx, 0x62d4(%rip)      # 0x8208
movq %rsi, 0x28(%rax)
movq %rdx, 0x30(%rax)
movq %rcx, 0x8(%rsi)
incl 0x620a(%rip)            # 0x8150
incl 0x61f4(%rip)            # 0x8140
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rbx
pushq %rax
leaq -0xc(%rbp), %rbx
pushq $0x4
popq %rdx
xorl %edi, %edi
movq %rbx, %rsi
callq 0x1110
leaq 0x6297(%rip), %rcx      # 0x8208
movl (%rbx), %edx
pushq $-0x1
popq %rax
movq %rcx, %rbx
movq (%rbx), %rbx
cmpq %rcx, %rbx
je 0x1fa9
cmpl %edx, -0x1c(%rbx)
jne 0x1f79
addq $-0x28, %rbx
movq (%rbx), %rax
movq %rbx, %rdi
callq *(%rax)
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rcx
movq %rax, (%rcx)
movq %rcx, 0x8(%rax)
decl 0x61a9(%rip)            # 0x8150
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 $0x28, %rsp
pushq $-0x1
popq %rbx
cmpl $0x0, 0x6185(%rip)      # 0x8150
je 0x2087
leaq -0x48(%rbp), %r14
pushq $0x18
popq %rdx
xorl %edi, %edi
movq %r14, %rsi
callq 0x1110
movl (%r14), %eax
movl 0x14(%r14), %r13d
leaq 0x6218(%rip), %rcx      # 0x8208
movq %rcx, %rdx
movq (%rdx), %rdx
cmpq %rcx, %rdx
je 0x2087
cmpl %eax, -0x20(%rdx)
jne 0x1ff3
leaq -0x28(%rdx), %r14
cmpl %r13d, 0x18(%r14)
jbe 0x1ff3
cmpl %r13d, 0x1c(%r14)
ja 0x1ff3
movl 0x14(%r14), %r15d
movq %r15, %rdi
callq 0x1170
movq %rax, -0x30(%rbp)
xorl %ebx, %ebx
xorl %edi, %edi
movq %rax, %rsi
movl %r15d, %edx
callq 0x16f7
movq %r15, %rdi
callq 0x1170
movq %rax, %r12
imull %r15d, %r13d
addq %r14, %r13
addq $0x38, %r13
movq %rax, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x1160
movq %r13, %rdi
movq -0x30(%rbp), %r14
movq %r14, %rsi
movq %r15, %rdx
callq 0x1160
pushq $0x1
popq %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x1090
movq %r12, %rdi
callq 0x1030
movq %r14, %rdi
callq 0x1030
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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, 0x60a4(%rip)      # 0x8150
je 0x2112
leaq -0x30(%rbp), %rbx
pushq $0x18
popq %rdx
xorl %edi, %edi
movq %rbx, %rsi
callq 0x1110
leaq 0x6142(%rip), %rax      # 0x8208
movl (%rbx), %ecx
movq %rax, %rbx
movq (%rbx), %rbx
cmpq %rax, %rbx
je 0x2112
cmpl %ecx, -0x20(%rbx)
jne 0x20cb
addq $-0x28, %rbx
movl 0x14(%rbx), %r14d
movq %r14, %rdi
callq 0x1170
movq %rax, %r15
xorl %edi, %edi
movq %rax, %rsi
movl %r14d, %edx
callq 0x16f7
movq (%rbx), %rax
movq %rbx, %rdi
movq %r15, %rsi
callq *0x8(%rax)
movl %eax, %ebx
movq %r15, %rdi
callq 0x1030
movl %ebx, %eax
jmp 0x2115
pushq $-0x1
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq $-0x1
popq %rbx
cmpl $0x0, 0x6017(%rip)      # 0x8150
je 0x21cf
leaq -0x38(%rbp), %r14
pushq $0x18
popq %rdx
xorl %edi, %edi
movq %r14, %rsi
callq 0x1110
movl (%r14), %eax
cmpl $0x2, %eax
ja 0x21cf
leaq 0x60a9(%rip), %rcx      # 0x8208
movl -0x28(%rbp), %r12d
movq %rcx, %rdx
movq (%rdx), %rdx
cmpq %rcx, %rdx
je 0x21c3
cmpl %eax, -0x20(%rdx)
jne 0x2166
leaq -0x28(%rdx), %r14
movl 0x18(%r14), %esi
subl 0x1c(%r14), %esi
cmpl %esi, %r12d
ja 0x2166
movl 0x14(%r14), %esi
pushq $0x1
popq %rdi
callq 0x1130
movq %rax, %r15
subl $0x1, %r12d
jb 0x21de
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 0x21ea
movq (%r14), %rax
movq %r14, %rdi
movq %r15, %rsi
callq *0x28(%rax)
jmp 0x2193
leaq 0x260d(%rip), %rdi      # 0x47d7
callq 0x1060
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x1030
xorl %ebx, %ebx
jmp 0x21cf
leaq 0x25f0(%rip), %rdi      # 0x47e1
xorl %ebx, %ebx
movq %r15, %rsi
xorl %eax, %eax
callq 0x10d0
jmp 0x21cf
// File: /workspace/github_c_makefile_star2_O2/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 0x245f
movq %rdx, %r8
movq %rsi, %r14
movq %rdi, %r12
movl 0x18c(%rdi), %r15d
leaq (%rcx,%rdx), %rax
xorl %edx, %edx
divq %r15
movl %edx, 0x188(%rdi)
testq %rcx, %rcx
je 0x23f6
movq %r15, %rbx
subq %rcx, %rbx
leaq (%r12,%rcx), %rdi
addq $0xc8, %rdi
cmpq %r8, %rbx
movq %r8, %rdx
cmovbq %rbx, %rdx
movq %r14, %rsi
movq %r8, %r13
callq 0x1160
movq %r13, %rax
subq %rbx, %rax
jb 0x245f
leaq 0xc8(%r12), %rsi
movq %r12, %rdi
movq %r15, %rdx
movq %rax, %r13
callq 0x246e
movq %r13, %r8
addq %rbx, %r14
movq %r12, -0x30(%rbp)
leaq 0xc8(%r12), %r13
movq %r14, %rbx
movq %r8, %r12
subq %r15, %r12
jb 0x243e
movq %rbx, %rsi
testb $0x7, %r14b
je 0x2427
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x1160
movq %r13, %rsi
movq -0x30(%rbp), %rdi
movq %r15, %rdx
callq 0x246e
addq %r15, %rbx
addq %r15, %r14
movq %r12, %r8
jmp 0x2408
testq %r8, %r8
je 0x245f
movq %r13, %rdi
movq %rbx, %rsi
movq %r8, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1160
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x64
popq %r15
subl %eax, %r15d
movslq 0x188(%rdi), %rax
testq %rax, %rax
js 0x28d6
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 0x246e
movl $0x80000000, 0x188(%rbx) # imm = 0x80000000
cmpl %r15d, %r12d
jbe 0x290b
testq %r14, %r14
je 0x28fc
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 0x1160
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x204a(%rip), %rdi      # 0x495c
leaq 0x205e(%rip), %rsi      # 0x4977
leaq 0x205e(%rip), %rcx      # 0x497e
movl $0x145, %edx            # imm = 0x145
callq 0x10e0
nop
// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
je 0x2a3b
xorl %ebx, %ebx
jmp 0x2a59
movq %rsi, %r14
movq %rdi, %rbx
callq 0x2a61
movl (%r14), %ecx
testq %rax, %rax
je 0x2a54
addq 0x18(%rax), %rbx
jmp 0x2a56
xorl %ebx, %ebx
addq %rcx, %rbx
movq %rbx, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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, %ebx
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, %rdi
callq 0x2b78
cmpl $0x2, %eax
jne 0x2b5b
movq %r15, %rdi
callq 0x2b9b
cmpl %ebx, %eax
jbe 0x2b5b
testq %r15, %r15
je 0x2b5f
movq 0x38(%r15), %rcx
addq 0x18(%r15), %r14
jmp 0x2b64
xorl %eax, %eax
jmp 0x2b6d
xorl %ecx, %ecx
xorl %r14d, %r14d
movl %ebx, %eax
imulq %rcx, %rax
addq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x2b78
movl %eax, %ecx
xorl %eax, %eax
testq %rbx, %rbx
je 0x2bc9
cmpl $0x2, %ecx
jne 0x2bc9
movq 0x38(%rbx), %rcx
testq %rcx, %rcx
je 0x2bc9
movq 0x20(%rbx), %rax
xorl %edx, %edx
divq %rcx
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
movq %rsp, %rbp
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
testq %rdx, %rdx
sete %al
orb %cl, %al
jne 0x2c35
movl 0x28(%rdx), %eax
movzwl 0x3c(%rdi), %ecx
cmpl %ecx, %eax
jae 0x2c35
movq 0x28(%rdi), %rcx
addq %rdi, %rcx
movzwl 0x3a(%rdi), %edx
imulq %rdx, %rax
movl (%rsi), %edx
addq 0x18(%rax,%rcx), %rdi
cmpb $0x0, (%rdx,%rdi)
leaq (%rdi,%rdx), %rcx
leaq 0x1e51(%rip), %rax      # 0x4a80
cmovneq %rcx, %rax
jmp 0x2c37
xorl %eax, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ww9210[P]xnuca_final_ssp/elf.c
// Function: ELF64_FileGetSectionHeaderEntryWithName
ELF64_SectionHeaderEntryRef ELF64_FileGetSectionHeaderEntryWithName( ELF64_FileRef file, const char * name )
{
    ELF64_Half                  i;
    ELF64_HeaderRef             header;
    ELF64_SectionHeaderEntryRef section;
    const char                * sName;
    
    if( file == NULL )
    {
        return NULL;
    }
    
    header = ELF64_FileGetHeader( file );
    
    if( header == NULL )
    {
        return NULL;
    }
    
    for( i = 0; i < ELF64_HeaderGetSectionHeaderEntryCount( header ); i++ )
    {
        section = ELF64_FileGetSectionHeaderEntry( file, i );
        sName   = ELF64_FileGetNameOfSection( file, section );
        
        if( strcmp( name, sName ) == 0 )
        {
            return section;
        }
    }
    
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x2cc7
movq %rsi, %rbx
movq %rdi, %r14
movzwl 0x3c(%rdi), %r12d
xorl %r13d, %r13d
cmpq %r13, %r12
je 0x2cc7
movzwl 0x3a(%r14), %r15d
movq 0x28(%r14), %rax
addq %r14, %rax
imulq %r13, %r15
addq %rax, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2a20
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1140
incq %r13
testl %eax, %eax
jne 0x2c90
jmp 0x2cca
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ww9210[P]xnuca_final_ssp/elf.c
// Function: ELF64_FileGetSymbolTableEntryWithName
ELF64_SymbolTableEntryRef ELF64_FileGetSymbolTableEntryWithName( ELF64_FileRef file, const char * name )
{
    ELF64_HeaderRef             header;
    ELF64_SectionHeaderEntryRef sHeader;
    ELF64_Half                  i;
    unsigned int                symCount;
    unsigned int                j;
    ELF64_SymbolTableEntryRef   sym;
    const char                * symName;
    
    if( file == NULL )
    {
        return NULL;
    }
    
    header = ELF64_FileGetHeader( file );
    
    if( header == NULL )
    {
        return NULL;
    }
    
    for( i = 0; i < ELF64_HeaderGetSectionHeaderEntryCount( header ); i++ )
    {
        sHeader = ELF64_FileGetSectionHeaderEntry( file, i );
        
        if( ELF64_SectionHeaderEntryGetType( sHeader ) != ELF64_SectionTypeLinkerSymbolTable )
        {
            continue;
        }
        
        symCount = ELF64_SectionHeaderEntryGetSymbolTableEntryCount( sHeader );
            
        for( j = 0; j < symCount; j++ )
        {
            sym     = ELF64_FileGetSymbolTableEntryForSection( file, sHeader, j );
            symName = ELF64_FileGetSymbolTableEntryNameForSection( file, sym, sHeader );
            
            if( strcmp( name, symName ) == 0 )
            {
                return sym;
            }
        }
    }
    
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, -0x40(%rbp)
testq %rdi, %rdi
je 0x2d83
movq %rdi, %r15
movzwl 0x3c(%rdi), %eax
movq %rax, -0x30(%rbp)
xorl %ecx, %ecx
cmpq -0x30(%rbp), %rcx
je 0x2d83
movzwl 0x3a(%r15), %r12d
movq 0x28(%r15), %rax
addq %r15, %rax
movq %rcx, -0x38(%rbp)
imulq %rcx, %r12
addq %rax, %r12
movq %r12, %rdi
callq 0x2b78
cmpl $0x2, %eax
jne 0x2d75
movq %r12, %rdi
callq 0x2b9b
movl %eax, %r13d
xorl %ebx, %ebx
cmpl %ebx, %r13d
je 0x2d75
movq %r15, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0x2b21
movq %rax, %r14
movq %r15, %rdi
movq %rax, %rsi
movq %r12, %rdx
callq 0x2be3
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x1140
incl %ebx
testl %eax, %eax
jne 0x2d3e
jmp 0x2d7e
movq -0x38(%rbp), %rcx
incq %rcx
jmp 0x2d07
movq %r14, %rax
jmp 0x2d85
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/ww9210[P]xnuca_final_ssp/elf.c
// Function: ELF64_FileGetSymbolTableEntryWithAddress
ELF64_SymbolTableEntryRef ELF64_FileGetSymbolTableEntryWithAddress( ELF64_FileRef file, ELF64_Addr address )
{
    ELF64_HeaderRef             header;
    ELF64_SectionHeaderEntryRef sHeader;
    ELF64_Half                  i;
    unsigned int                symCount;
    unsigned int                j;
    ELF64_SymbolTableEntryRef   sym;
    ELF64_Addr                  symAddress;
    
    if( file == NULL )
    {
        return NULL;
    }
    
    header = ELF64_FileGetHeader( file );
    
    if( header == NULL )
    {
        return NULL;
    }
    
    for( i = 0; i < ELF64_HeaderGetSectionHeaderEntryCount( header ); i++ )
    {
        sHeader = ELF64_FileGetSectionHeaderEntry( file, i );
        
        if( ELF64_SectionHeaderEntryGetType( sHeader ) != ELF64_SectionTypeLinkerSymbolTable )
        {
            continue;
        }
        
        symCount = ELF64_SectionHeaderEntryGetSymbolTableEntryCount( sHeader );
            
        for( j = 0; j < symCount; j++ )
        {
            sym         = ELF64_FileGetSymbolTableEntryForSection( file, sHeader, j );
            symAddress  = ELF64_SymbolTableEntryGetSymbolValue( sym );
            
            if( address == symAddress )
            {
                return sym;
            }
        }
    }
    
    return NULL;
}

// Assembly:
testq %rdi, %rdi
je 0x2e29
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movzwl 0x3c(%rdi), %eax
movq %rax, -0x30(%rbp)
xorl %ecx, %ecx
cmpq -0x30(%rbp), %rcx
je 0x2e2c
movzwl 0x3a(%r14), %r15d
movq 0x28(%r14), %rax
addq %r14, %rax
movq %rcx, -0x38(%rbp)
imulq %rcx, %r15
addq %rax, %r15
movq %r15, %rdi
callq 0x2b78
cmpl $0x2, %eax
jne 0x2e20
movq %r15, %rdi
callq 0x2b9b
movl %eax, %r12d
xorl %r13d, %r13d
cmpl %r13d, %r12d
je 0x2e20
movq %r14, %rdi
movq %r15, %rsi
movl %r13d, %edx
callq 0x2b21
testq %rax, %rax
je 0x2e14
movq 0x8(%rax), %rcx
jmp 0x2e16
xorl %ecx, %ecx
incl %r13d
cmpq %rbx, %rcx
jne 0x2df6
jmp 0x2e2e
movq -0x38(%rbp), %rcx
incq %rcx
jmp 0x2dbe
xorl %eax, %eax
retq
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq