LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/assembler.c
// Function: operand_list_cfg
struct operand_node *operand_list_cfg() {
    struct operand_node *root = NULL;
    struct operand_node *current_operand = NULL;

    while(1) {
        switch(cfg_assembler->lookahead) {
            case TOK_REGISTER:
            case TOK_IDENTIFIER:
            case TOK_INTEGER:
            case TOK_STRING:
            case TOK_LPAREN:
                if(current_operand == NULL) {
                    current_operand = operand_cfg();
                    if(root == NULL) root = current_operand;
                }
                else {
                    current_operand->next = operand_cfg();
                    current_operand = current_operand->next;
                }
                if(cfg_assembler->lookahead == TOK_COMMA) {
                    match_cfg(TOK_COMMA);
                    continue;
                }
                else if (cfg_assembler->lookahead == TOK_REGISTER || cfg_assembler->lookahead == TOK_IDENTIFIER 
                            || cfg_assembler->lookahead == TOK_STRING || cfg_assembler->lookahead == TOK_LPAREN
                            || cfg_assembler->lookahead == TOK_INTEGER) continue;
                return root;
            case TOK_EOL:
            case TOK_NULL:
                report_cfg("Expected operand after line %ld, col %ld", cfg_assembler->lineno, cfg_assembler->colno);
                return root;
            default:
                report_cfg("Invalid operand '%s' on line %ld, col %ld", cfg_assembler->tokenizer->lexbuf, cfg_assembler->lineno, cfg_assembler->colno);
                return root;
        }
    }

    return root;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq 0x8ac3(%rip), %rax      # 0xc5b8
xorl %ebx, %ebx
movl $0x638, %r15d           # imm = 0x638
pushq $0x2
popq %rbp
xorl %r12d, %r12d
movl 0x40(%rax), %ecx
cmpl $0xa, %ecx
ja 0x3b84
btl %ecx, %r15d
jae 0x3b5c
callq 0x38f1
movq %rax, %r14
testq %r12, %r12
je 0x3b25
movq %r14, 0x10(%r12)
jmp 0x3b2c
testq %rbx, %rbx
cmoveq %r14, %rbx
movq 0x8a85(%rip), %rax      # 0xc5b8
movl 0x40(%rax), %ecx
cmpl $0xa, %ecx
ja 0x3ba7
btl %ecx, %r15d
movq %r14, %r12
jb 0x3b03
cmpl $0x2, %ecx
jne 0x3ba7
movl %ebp, %edi
callq 0x371d
movq 0x8a61(%rip), %rax      # 0xc5b8
movq %r14, %r12
jmp 0x3b03
movl $0x81, %edx
btl %ecx, %edx
jae 0x3b84
movq 0x98(%rax), %rsi
movq 0xa0(%rax), %rdx
leaq 0x38f1(%rip), %rdi      # 0x746c
xorl %eax, %eax
callq 0x328c
jmp 0x3ba7
movq (%rax), %rcx
movq 0x98(%rax), %rdx
movq 0x10(%rcx), %rsi
movq 0xa0(%rax), %rcx
leaq 0x38f5(%rip), %rdi      # 0x7495
xorl %eax, %eax
callq 0x328c
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/assembler.c
// Function: destroy_instruction
void destroy_instruction(struct instruction_node *instr) {
    /* Free operands */
    struct operand_node *op_node = instr->operand_list;
    while(op_node != NULL) {
        struct operand_node *next_op = op_node->next;
        if(op_node->operand == OPERAND_LABEL || op_node->operand == OPERAND_STRING) free(op_node->identifier);
        free(op_node);
        op_node = next_op;
    }
    free(instr);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rdi), %r14
testq %r14, %r14
je 0x3d7e
movq 0x10(%r14), %r15
movzbl (%r14), %eax
cmpl $0x10, %eax
je 0x3d68
cmpl $0x1, %eax
jne 0x3d71
movq 0x8(%r14), %rdi
callq 0x3030
movq %r14, %rdi
callq 0x3030
movq %r15, %r14
jmp 0x3d51
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x3030
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/assembler.c
// Function: assemble_instruction
int assemble_instruction(struct instruction_node *instr) {
    if(instr == NULL || instr->mnemonic == NULL) return 0;

    if(!verify_operand_list(instr->mnemonic, instr->operand_list)) {
        destroy_instruction(instr);
        return 0;
    }

    int assemble_status;

    /* TO-DO: Assemble (?) instruction */
    if(cfg_assembler->segment == SEGMENT_DATA) {
        fprintf(stderr, "Cannot define instructions in .data segment on line %ld\n", cfg_assembler->lineno);
        cfg_assembler->status = ASSEMBLER_STATUS_FAIL;
        destroy_instruction(instr);
        return 0;
    }

    struct opcode_entry *entry = (struct opcode_entry *)instr->mnemonic->attrptr;

    if(entry->type == OPTYPE_PSUEDO) {
        assemble_status = assemble_psuedo_instruction(instr);
    }
    else if(entry->opcode == 0x00) {
        assemble_status = assemble_funct_instruction(instr);     
    }
    else {
        assemble_status = assemble_opcode_instruction(instr); 
    }

    return assemble_status;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x4c7a
movq %rdi, %rbx
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x4c7a
movq 0x8(%rbx), %rsi
callq 0x3bb3
testl %eax, %eax
je 0x4c72
movq 0x79ba(%rip), %rax      # 0xc5b8
cmpb $0x1, 0x45(%rax)
je 0x4c46
movq (%rbx), %rax
movq 0x10(%rax), %rax
movzwl 0x6(%rax), %ecx
andl $0x3, %ecx
cmpw $0x1, %cx
jne 0x4c26
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x3d8b
cmpb $0x0, (%rax)
je 0x4c39
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x47f0
movq %rbx, %rdi
callq 0x46d5
pushq $0x1
popq %rbp
jmp 0x4c7a
movq 0x63ab(%rip), %rcx      # 0xaff8
movq (%rcx), %rdi
movq 0x98(%rax), %rdx
leaq 0x28dd(%rip), %rsi      # 0x753b
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x30d0
movq 0x794a(%rip), %rax      # 0xc5b8
movb $0x2, 0x44(%rax)
movq %rbx, %rdi
callq 0x3d45
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/assembler.c
// Function: instruction_list_cfg
void instruction_list_cfg() {  
    while(1) {  
        while(cfg_assembler->lookahead == TOK_NULL) {
            /* Free current tokenizer */
            destroy_tokenizer(&cfg_assembler->tokenizer);
            remove_front(cfg_assembler->tokenizer_list, LN_VSTATIC);

            /* No more files to process */
            if(cfg_assembler->tokenizer_list->front == NULL) return;  
            
            /* Setup tokenizer */
            cfg_assembler->tokenizer = (struct tokenizer *)cfg_assembler->tokenizer_list->front->value;

            /* Setup lookahead */
            cfg_assembler->lookahead = get_next_token(cfg_assembler->tokenizer);
        }
    
        if(cfg_assembler->lookahead != TOK_NULL) {
            instruction_cfg();
        }
    }
}

// Assembly:
pushq %rax
movq 0x748c(%rip), %rdi      # 0xc5b8
movl 0x40(%rdi), %eax
testl %eax, %eax
jne 0x517f
callq 0x6620
movq 0x7479(%rip), %rax      # 0xc5b8
movq 0x8(%rax), %rdi
xorl %esi, %esi
callq 0x5513
movq 0x7467(%rip), %rax      # 0xc5b8
movq 0x8(%rax), %rcx
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x5186
movq 0x8(%rcx), %rcx
movq %rcx, (%rax)
movq 0x744d(%rip), %rax      # 0xc5b8
movq (%rax), %rdi
callq 0x654d
movq 0x743e(%rip), %rdi      # 0xc5b8
movl %eax, 0x40(%rdi)
jmp 0x512f
callq 0x4f9d
jmp 0x5125
popq %rax
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/assembler.c
// Function: destroy_tokenizer_list
void destroy_tokenizer_list(struct assembler *assembler) {
    struct list_node *node = assembler->tokenizer_list->front;
    while(node != NULL) {
        destroy_tokenizer((struct tokenizer **)&node->value);
        node = node->next;
    }
    delete_linked_list(&(assembler->tokenizer_list), LN_VSTATIC);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %r14
addq $0x8, %rbx
movq (%r14), %r14
testq %r14, %r14
je 0x527c
leaq 0x8(%r14), %rdi
callq 0x6620
jmp 0x5269
movq %rbx, %rdi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x5588
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/assembler.c
// Function: create_assembler
struct assembler *create_assembler() {
    struct assembler *assembler = (struct assembler *)malloc(sizeof(struct assembler));

    if(assembler == NULL) return NULL;

    assembler->tokenizer = NULL;
    assembler->tokenizer_list = NULL;

    assembler->lookahead = TOK_NULL;
    assembler->decl_symlist = NULL;
    assembler->status = ASSEMBLER_STATUS_NULL;
    assembler->lineno = 1;
    assembler->colno = 1;

    assembler->segment = SEGMENT_TEXT;
    
    for(segment_t segment = 0; segment < MAX_SEGMENTS; ++segment) {
        assembler->segment_offset[segment] = SEGMENT_OFFSET_BASE[segment];
        assembler->segment_memory[segment] = NULL;
        assembler->segment_memory_offset[segment] = 0;
        assembler->segment_memory_size[segment] = 0;
    }

    assembler->auto_align = 1;
    
    return assembler;
}

// Assembly:
pushq %rax
movl $0xa8, %edi
callq 0x30f0
testq %rax, %rax
je 0x52f4
andl $0x0, 0x40(%rax)
andq $0x0, 0x18(%rax)
andw $0x0, 0x44(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
pushq $0x1
popq %rcx
movq %rcx, 0x98(%rax)
movq %rcx, 0xa0(%rax)
xorl %ecx, %ecx
leaq 0x1fb5(%rip), %rdx      # 0x7280
cmpq $0x10, %rcx
je 0x52f0
movl (%rcx,%rdx), %esi
movl %esi, 0x48(%rax,%rcx)
andq $0x0, 0x20(%rax,%rcx,2)
andq $0x0, 0x58(%rax,%rcx,2)
andq $0x0, 0x78(%rax,%rcx,2)
addq $0x4, %rcx
jmp 0x52cb
movb $0x1, 0x46(%rax)
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/assembler.c
// Function: destroy_assembler
void destroy_assembler(struct assembler **assembler) {
    /* Free all segment memory */
    for(segment_t segment = 0; segment < MAX_SEGMENTS; ++segment) {
        free((*assembler)->segment_memory[segment]);
    }

    /* Simple free the data */
    free(*assembler);

    /* Set assembler to NULL */
    *assembler = NULL;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %r14d, %r14d
movq (%rbx), %rdi
cmpq $0x4, %r14
je 0x5450
movq 0x20(%rdi,%r14,8), %rdi
callq 0x3030
incq %r14
jmp 0x5438
callq 0x3030
andq $0x0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/linkedlist.c
// Function: insert_front
void insert_front(struct linked_list *list, void *value)
{
	struct list_node *node = (struct list_node *)malloc(sizeof(struct list_node));
	
	if(node == NULL) { 
        perror("CRITICAL ERROR: Failed to allocate memory for linked list node: ");
        exit(EXIT_FAILURE);
    }
	
	node->next = list->front;
	node->value = value;

	list->front = node;
	
	if(list->rear == NULL)
	{
		list->rear = node;
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
pushq $0x10
popq %rdi
callq 0x30f0
testq %rax, %rax
je 0x54b2
movq (%rbx), %rcx
movq %rcx, (%rax)
movq %r14, 0x8(%rax)
movq %rax, (%rbx)
cmpq $0x0, 0x8(%rbx)
jne 0x54aa
movq %rax, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x21fe(%rip), %rdi      # 0x76b7
callq 0x3130
pushq $0x1
popq %rdi
callq 0x3150
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/linkedlist.c
// Function: insert_rear
void insert_rear(struct linked_list *list, void *value)
{
	struct list_node *node = (struct list_node *)malloc(sizeof(struct list_node));

	if(node == NULL) { 
        perror("CRITICAL ERROR: Failed to allocate memory for linked list node: ");
        exit(EXIT_FAILURE);
    }

	node->value = value;
	node->next = NULL;

	if(list->rear != NULL)
	{
		list->rear->next = node;
		list->rear = node;
	}
	else
	{
		list->rear = list->front = node;
	}
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
pushq $0x10
popq %rdi
callq 0x30f0
testq %rax, %rax
je 0x54ff
movq %r14, 0x8(%rax)
andq $0x0, (%rax)
movq 0x8(%rbx), %rcx
testq %rcx, %rcx
cmoveq %rbx, %rcx
movq %rax, (%rcx)
movq %rax, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x21b1(%rip), %rdi      # 0x76b7
callq 0x3130
pushq $0x1
popq %rdi
callq 0x3150
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/linkedlist.c
// Function: remove_front
void remove_front(struct linked_list *list, short mode) {
	struct list_node *front = list->front;
	
	if(list->front == NULL) return;

	if(list->front == list->rear)
		list->front = list->rear = front->next;
	else 
		list->front = list->front->next;
	
	if(mode == LN_VDYNAMIC)
		free(front->value);
	
	free(front);
}

// Assembly:
pushq %rbx
movq (%rdi), %rbx
testq %rbx, %rbx
je 0x5544
movq (%rbx), %rax
cmpq 0x8(%rdi), %rbx
jne 0x5529
movq %rax, 0x8(%rdi)
movq %rax, (%rdi)
cmpw $0x1, %si
jne 0x553b
movq 0x8(%rbx), %rdi
callq 0x3030
movq %rbx, %rdi
popq %rbx
jmp 0x3030
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/linkedlist.c
// Function: remove_from_list
void remove_from_list(struct linked_list *list, void *value)
{
    struct list_node *curr = list->front;
    struct list_node *prev = NULL;

    while(curr != NULL)
    {
        if(curr->value == value)
        {
            if(prev != NULL)
                prev->next = curr->next;

            if(curr == list->front) list->front = curr->next;
            if(curr == list->rear)  list->rear = prev;
			
			free(curr);

            break;
        }

        prev = curr;
        curr = curr->next;
    }
}

// Assembly:
xorl %edx, %edx
movq %rdi, %rax
movq (%rax), %rax
testq %rax, %rax
je 0x5587
movq %rdx, %rcx
movq %rax, %rdx
cmpq %rsi, 0x8(%rax)
jne 0x554b
testq %rcx, %rcx
je 0x556a
movq (%rax), %rdx
movq %rdx, (%rcx)
cmpq (%rdi), %rax
jne 0x5575
movq (%rax), %rdx
movq %rdx, (%rdi)
cmpq 0x8(%rdi), %rax
jne 0x557f
movq %rcx, 0x8(%rdi)
movq %rax, %rdi
jmp 0x3030
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/linkedlist.c
// Function: delete_linked_list
void delete_linked_list(struct linked_list **lp, short mode)
{
	if(*lp == NULL) return;
    
	delete_list((*lp)->front, mode);
	free(*lp);
	
	*lp = NULL;
}

// Assembly:
movq (%rdi), %rax
testq %rax, %rax
je 0x55ac
pushq %rbx
movq %rdi, %rbx
movq (%rax), %rdi
movswl %si, %esi
callq 0x55ad
movq (%rbx), %rdi
callq 0x3030
andq $0x0, (%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/linkedlist.c
// Function: delete_list
void delete_list(struct list_node *listnode, short mode)
{
	struct list_node *node = listnode;
	struct list_node *temp;
	
	while(node != NULL)
	{
		if(mode == LN_VDYNAMIC)
			free(node->value);
	
		temp = node;
		node = node->next;
		free(temp);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
testq %r14, %r14
je 0x55db
cmpw $0x1, %bx
jne 0x55cb
movq 0x8(%r14), %rdi
callq 0x3030
movq (%r14), %r15
movq %r14, %rdi
callq 0x3030
movq %r15, %r14
jmp 0x55b7
popq %rbx
popq %r14
popq %r15
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/main.c
// Function: display_help_msg
void display_help_msg(char *program) {
    printf("Usage: %s [-a] [-h] [-t output] [-d output] [-o output] file...\n", program);
    printf("A MIPS assembler written in C\n\n");
    printf("The following options may be used:\n");
    printf("  %-20s Only assembles program, does not create object code file\n", "-a");
    printf("  %-20s * Note: This does not disable segment dumps\n", "");
    printf("  %-20s Stores data segment in <output>\n", "-d <output>");
    printf("  %-20s Displays this message\n", "-h");
    printf("  %-20s Stores text segment in <output>\n", "-t <output>");
    printf("  %-20s Stores object code in <output>\n", "-o <output>");
    printf("  %-20s * Note: If this option is not specified, <output> defaults to a.obj\n\n", "");
    printf("Refer to the repository at <https://github.com/tstword/MIPSAssemblerC>\n");
    exit(EXIT_SUCCESS);
}

// Assembly:
pushq %rbx
movq %rdi, %rsi
leaq 0x2109(%rip), %rdi      # 0x76f8
xorl %eax, %eax
callq 0x3070
leaq 0x232e(%rip), %rdi      # 0x792b
callq 0x3040
leaq 0x2341(%rip), %rdi      # 0x794a
callq 0x3040
leaq 0x2124(%rip), %rdi      # 0x7739
leaq 0x215f(%rip), %rsi      # 0x777b
xorl %eax, %eax
callq 0x3070
leaq 0x2154(%rip), %rdi      # 0x777e
leaq 0x228f(%rip), %rbx      # 0x78c0
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3070
leaq 0x2171(%rip), %rdi      # 0x77b3
leaq 0x2193(%rip), %rsi      # 0x77dc
xorl %eax, %eax
callq 0x3070
leaq 0x2191(%rip), %rdi      # 0x77e8
leaq 0x21a9(%rip), %rsi      # 0x7807
xorl %eax, %eax
callq 0x3070
leaq 0x219e(%rip), %rdi      # 0x780a
leaq 0x21c0(%rip), %rsi      # 0x7833
xorl %eax, %eax
callq 0x3070
leaq 0x21be(%rip), %rdi      # 0x783f
leaq 0x21df(%rip), %rsi      # 0x7867
xorl %eax, %eax
callq 0x3070
leaq 0x21dd(%rip), %rdi      # 0x7873
movq %rbx, %rsi
xorl %eax, %eax
callq 0x3070
leaq 0x22c6(%rip), %rdi      # 0x796d
callq 0x3040
xorl %edi, %edi
callq 0x3150
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/mipsfhdr.c
// Function: dump_segment
void dump_segment(struct assembler *assembler, segment_t segment, const char *file) {
    FILE *fp;
    if((fp = fopen_wrap(file, "wb+")) == NULL) {
        fprintf(stderr, "Failed to open output file '%s': Error: ", file);
        perror(NULL);
        destroy_assembler(&assembler);
        exit(EXIT_FAILURE);
    }

    size_t nbytes = fwrite(assembler->segment_memory[segment], 0x1, assembler->segment_memory_offset[segment], fp);
    if(nbytes != assembler->segment_memory_offset[segment]) {
        perror("Segment Dump Error: Failed to write segment to file: ");
        destroy_assembler(&assembler);
        exit(EXIT_FAILURE);
    }

    fclose(fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r15
movl %esi, %ebp
movq %rdi, %rbx
movq %rdi, (%rsp)
leaq 0x1fdf(%rip), %rsi      # 0x79b4
movq %rdx, %rdi
callq 0x5464
testq %rax, %rax
je 0x5a17
movq %rax, %r14
movzbl %bpl, %r15d
movq 0x20(%rbx,%r15,8), %rdi
movq 0x58(%rbx,%r15,8), %rdx
pushq $0x1
popq %rsi
movq %rax, %rcx
callq 0x3160
cmpq 0x58(%rbx,%r15,8), %rax
jne 0x5a36
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3060
movq 0x55da(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x205b(%rip), %rsi      # 0x7a83
movq %r15, %rdx
xorl %eax, %eax
callq 0x30d0
xorl %edi, %edi
jmp 0x5a3d
leaq 0x206f(%rip), %rdi      # 0x7aac
callq 0x3130
movq %rsp, %rdi
callq 0x542e
pushq $0x1
popq %rdi
callq 0x3150
nop
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/symtable.c
// Function: djb2hash
size_t djb2hash(const char *str) {
    const unsigned char *key = (const unsigned char *)str;
    size_t hash = 5381;
    int c;

    while ((c = *key++))
        hash = ((hash << 5) + hash) + c; /* hash * 33 + c */

    return hash;
}

// Assembly:
movl $0x1505, %eax           # imm = 0x1505
movzbl (%rdi), %ecx
testq %rcx, %rcx
je 0x5a6d
incq %rdi
imulq $0x21, %rax, %rax
addq %rcx, %rax
jmp 0x5a59
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/symtable.c
// Function: create_symbol_table
struct symbol_table *create_symbol_table() {
    struct symbol_table *symtab = (struct symbol_table *)malloc(sizeof(struct symbol_table));
    
    symtab->buckets = (struct symbol_table_entry **)calloc(32, sizeof(struct symbol_table_entry));
    symtab->bucket_size = 32;
    symtab->length = 0;

    return symtab;
}

// Assembly:
pushq %rbx
pushq $0x18
popq %rdi
callq 0x30f0
movq %rax, %rbx
pushq $0x20
popq %rdi
pushq $0x28
popq %rsi
callq 0x30a0
movq %rax, (%rbx)
movq $0x20, 0x8(%rbx)
andq $0x0, 0x10(%rbx)
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/symtable.c
// Function: insert_at_index_st
void insert_at_index_st(struct symbol_table *symtab, size_t index, struct symbol_table_entry *entry) {
    struct symbol_table_entry *head = symtab->buckets[index];
    ++symtab->length;
    if(head == NULL) {
        symtab->buckets[index] = entry;
        return;
    }
    while(head->next != NULL) head = head->next;
    head->next = entry;
}

// Assembly:
movq (%rdi), %rax
movq (%rax,%rsi,8), %rcx
incq 0x10(%rdi)
testq %rcx, %rcx
je 0x5abc
movq %rcx, %rax
movq 0x20(%rcx), %rcx
testq %rcx, %rcx
jne 0x5aaa
addq $0x20, %rax
jmp 0x5ac0
leaq (%rax,%rsi,8), %rax
movq %rdx, (%rax)
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/symtable.c
// Function: percolate_symbol_table
void percolate_symbol_table(struct symbol_table *symtab) {
    float symtab_load = ((float)symtab->length) / symtab->bucket_size;
    
    if(symtab_load >= 0.7f) {
        struct symbol_table_entry **prev_buckets = symtab->buckets;
        size_t prev_size = symtab->bucket_size;
        
        symtab->bucket_size <<= 1;
        symtab->length = 0;
        symtab->buckets = (struct symbol_table_entry **)calloc(symtab->bucket_size, 
                                                        sizeof(struct symbol_table_entry));

        for(size_t i = 0; i < prev_size; ++i) {
            struct symbol_table_entry *head = prev_buckets[i], *next_head;
            size_t index;

            while(head != NULL) {
                next_head = head->next;
                head->next = NULL;
                
                index = djb2hash(head->key) % symtab->bucket_size;
                insert_at_index_st(symtab, index, head);
                
                head = next_head;
            }
        }

		free(prev_buckets);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %r12
movq 0x10(%rdi), %rax
testq %rax, %rax
js 0x5ae6
cvtsi2ss %rax, %xmm0
jmp 0x5afb
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
testq %r12, %r12
js 0x5b07
cvtsi2ss %r12, %xmm1
jmp 0x5b1f
movq %r12, %rax
shrq %rax
movl %r12d, %ecx
andl $0x1, %ecx
orq %rax, %rcx
cvtsi2ss %rcx, %xmm1
addss %xmm1, %xmm1
divss %xmm1, %xmm0
ucomiss 0x1fc6(%rip), %xmm0     # 0x7af0
jae 0x5b3b
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%rbx), %r14
leaq (%r12,%r12), %rdi
movq %rdi, 0x8(%rbx)
andq $0x0, 0x10(%rbx)
pushq $0x28
popq %rsi
callq 0x30a0
movq %rax, (%rbx)
xorl %r13d, %r13d
cmpq %r12, %r13
je 0x5b96
movq (%r14,%r13,8), %r15
testq %r15, %r15
je 0x5b91
movq (%r15), %rdi
movq 0x20(%r15), %rbp
andq $0x0, 0x20(%r15)
callq 0x5a54
xorl %edx, %edx
divq 0x8(%rbx)
movq %rbx, %rdi
movq %rdx, %rsi
movq %r15, %rdx
callq 0x5a9a
movq %rbp, %r15
jmp 0x5b62
incq %r13
jmp 0x5b59
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3030
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/symtable.c
// Function: insert_symbol_table
struct symbol_table_entry *insert_symbol_table(struct symbol_table *symtab, const char *key) {
    struct symbol_table_entry *item = (struct symbol_table_entry *)malloc(sizeof(struct symbol_table_entry));
    
    item->key = strdup_wrap(key);
    item->status = SYMBOL_UNDEFINED;
    item->offset = 0x00;
    item->segment = SEGMENT_TEXT; /* Default is SEGMENT_TEXT */
    item->datasize = 0x00;
    item->instr_list = create_list();
    item->next = NULL;

    size_t index = djb2hash(key) % symtab->bucket_size;

    insert_at_index_st(symtab, index, item);
    
    /* Check symbol table load */
    percolate_symbol_table(symtab);

    return item;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r15
movq %rdi, %rbx
pushq $0x28
popq %rdi
callq 0x30f0
movq %rax, %r14
movq %r15, %rdi
callq 0x5469
movq %rax, (%r14)
movb $0x0, 0x8(%r14)
andl $0x0, 0xc(%r14)
andw $0x0, 0x10(%r14)
xorl %eax, %eax
callq 0x5470
movq %rax, 0x18(%r14)
andq $0x0, 0x20(%r14)
movq %r15, %rdi
callq 0x5a54
xorl %edx, %edx
divq 0x8(%rbx)
movq %rbx, %rdi
movq %rdx, %rsi
movq %r14, %rdx
callq 0x5a9a
movq %rbx, %rdi
callq 0x5ac4
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/symtable.c
// Function: get_symbol_table
struct symbol_table_entry *get_symbol_table(struct symbol_table *symtab, const char *key) {
    size_t index = djb2hash(key) % symtab->bucket_size;
    struct symbol_table_entry *head = symtab->buckets[index];

    while(head != NULL) {
        if(strcmp(key, head->key) == 0) return head;
        head = head->next;
    }

    return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r15
movq %rsi, %rdi
callq 0x5a54
xorl %edx, %edx
divq 0x8(%r15)
movq %rdx, %r14
shlq $0x3, %r14
addq (%r15), %r14
movq (%r14), %r14
testq %r14, %r14
je 0x5c5a
movq (%r14), %rsi
movq %rbx, %rdi
callq 0x30b0
testl %eax, %eax
je 0x5c5a
addq $0x20, %r14
jmp 0x5c3d
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/symtable.c
// Function: destroy_symbol_table
void destroy_symbol_table(struct symbol_table **symtabp) {
    struct symbol_table *symtab = *symtabp;

    /* Destory all pairs in the hashtable */
    for(size_t i = 0; i < (symtab)->bucket_size; ++i) {
        struct symbol_table_entry *head = symtab->buckets[i];
        while(head != NULL) {
            struct symbol_table_entry *next_item = head->next;
            delete_linked_list(&head->instr_list, LN_VSTATIC);
            free(head->key);
            free(head);
            head = next_item;
        }
    }

	/* Destroy buckets */
	free(symtab->buckets);

    /* Destory hash table */
    free(symtab);

    /* Set to NULL */
    *symtabp = NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %r14
xorl %r12d, %r12d
movq (%r14), %rdi
cmpq 0x8(%r14), %r12
jae 0x5cb0
movq (%rdi,%r12,8), %r15
testq %r15, %r15
je 0x5cab
movq 0x20(%r15), %r13
leaq 0x18(%r15), %rdi
xorl %esi, %esi
callq 0x5588
movq (%r15), %rdi
callq 0x3030
movq %r15, %rdi
callq 0x3030
movq %r13, %r15
jmp 0x5c82
incq %r12
jmp 0x5c75
callq 0x3030
movq %r14, %rdi
callq 0x3030
andq $0x0, (%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/tokenizer.c
// Function: get_reserved_table
struct reserved_entry* get_reserved_table(const char *key) {
    ssize_t left = 0, right = reserved_table_size - 1;
    ssize_t mid;
    int cmp_result;
    
    while(left <= right) {
        mid = left + ((right - left) / 2);
        cmp_result = strcmp(reserved_table[mid].id, key);
        
        if(cmp_result == 0) return reserved_table + mid;
        if(cmp_result < 0) left = mid + 1;
        if(cmp_result > 0) right = mid - 1;
    }

    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movl $0x90, %r12d
leaq 0x56a9(%rip), %r13      # 0xb390
xorl %ebx, %ebx
movq %r12, %rax
subq %rbx, %rax
jl 0x5d2a
cqto
pushq $0x2
popq %rcx
idivq %rcx
movq %rax, %r15
addq %rbx, %r15
movq %r15, %rbp
shlq $0x5, %rbp
movq (%rbp,%r13), %rdi
movq %r14, %rsi
callq 0x30b0
testl %eax, %eax
je 0x5d2e
leaq 0x1(%r15), %rcx
decq %r15
testl %eax, %eax
cmovsq %rcx, %rbx
cmovgq %r15, %r12
jmp 0x5ce9
xorl %eax, %eax
jmp 0x5d34
addq %rbp, %r13
movq %r13, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/tokenizer.c
// Function: tgetc
int tgetc(struct tokenizer *tokenizer) {
    int ch = fgetc(tokenizer->fstream);

    /* Adjust tokenizer buffer if necessary */
    if(tokenizer->bufpos >= tokenizer->bufsize) {
        char *realloc_ptr = (char *)realloc(tokenizer->lexbuf, tokenizer->bufsize << 1);
        
        if(realloc_ptr == NULL) {
            perror("CRITICAL ERROR: Failed to allocated more memory for tokenizer lexical buffer: ");
            exit(EXIT_FAILURE);
        }
        
        tokenizer->bufsize <<= 1;
        tokenizer->lexbuf = realloc_ptr;
    }

    tokenizer->lexbuf[tokenizer->bufpos++] = ch;
    tokenizer->colno++;

    return ch;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x3090
movl %eax, %ebp
movq 0x10(%rbx), %rax
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rsi
cmpq %rsi, %rcx
jb 0x5d81
addq %rsi, %rsi
movq %rax, %rdi
callq 0x3110
testq %rax, %rax
je 0x5d9a
shlq 0x30(%rbx)
movq %rax, 0x10(%rbx)
movq 0x28(%rbx), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x28(%rbx)
movb %bpl, (%rax,%rcx)
incq 0x40(%rbx)
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0x239a(%rip), %rdi      # 0x813b
callq 0x3130
pushq $0x1
popq %rdi
callq 0x3150
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/tokenizer.c
// Function: report_fsm
void report_fsm(struct tokenizer *tokenizer, const char *fmt, ...) {
    va_list vargs;
    size_t bufsize = 0;

    va_start(vargs, fmt);
    bufsize = vsnprintf(NULL, 0, fmt, vargs) + 1;
    va_end(vargs);

    if(bufsize > tokenizer->errsize) {
        char *realloc_ptr = (char *)realloc(tokenizer->errmsg, bufsize);

        if(realloc_ptr == NULL) {
            perror("CRITICAL ERROR: Failed to allocated more memory for tokenizer error buffer: ");
            exit(EXIT_FAILURE);
        }

        tokenizer->errsize = bufsize;
        tokenizer->errmsg = realloc_ptr;
    }

    va_start(vargs, fmt);
    vsnprintf(tokenizer->errmsg, bufsize, fmt, vargs);
    va_end(vargs);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x20(%rsp), %r12
movq %rdx, 0x10(%r12)
movq %rcx, 0x18(%r12)
movq %r8, 0x20(%r12)
movq %r9, 0x28(%r12)
testb %al, %al
je 0x5e55
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %rcx
movq %r12, 0x10(%rcx)
leaq 0x110(%rsp), %r13
movq %r13, 0x8(%rcx)
movabsq $0x3000000010, %rbp     # imm = 0x3000000010
movq %rbp, (%rcx)
xorl %edi, %edi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x3050
incl %eax
movslq %eax, %r15
cmpq %r15, 0x48(%r14)
jae 0x5ea5
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0x3110
testq %rax, %rax
je 0x5ed4
movq %r15, 0x48(%r14)
movq %rax, 0x18(%r14)
movq %rsp, %rcx
movq %r12, 0x10(%rcx)
movq %r13, 0x8(%rcx)
movq %rbp, (%rcx)
movq 0x18(%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x3050
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22af(%rip), %rdi      # 0x818a
callq 0x3130
pushq $0x1
popq %rdi
callq 0x3150
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/tokenizer.c
// Function: zero_fsm
state_fsm zero_fsm(struct tokenizer *tokenizer) {
    int ch = tgetc(tokenizer);

    switch(ch) {
        case 'x':
        case 'X':
            // Check if next character is digit
            if(isxdigit(tpeekc(tokenizer))) return hex_state;
            tungetc(ch, tokenizer);
            return integer_accept;

        /* To comply with Microsoft's C++ compiler... */
        case '0': case '1': case '2': case '3':
        case '4': case '5': case '6': case '7':
        case '8': case '9':
            return integer_state;

        default:
            tungetc(ch, tokenizer);
            return integer_accept;
    }

    return invalid_state;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x5d43
movl %eax, %r14d
leal -0x30(%r14), %eax
cmpl $0xa, %eax
jae 0x6029
pushq $0x7
popq %rax
popq %rbx
popq %r14
popq %r15
retq
cmpl $0x78, %r14d
je 0x6035
cmpl $0x58, %r14d
jne 0x604f
callq 0x3180
movq (%rax), %r15
movq %rbx, %rdi
callq 0x5dc5
cltq
testb $0x10, 0x1(%r15,%rax,2)
jne 0x605e
movl %r14d, %edi
movq %rbx, %rsi
callq 0x5dae
pushq $0x8
jmp 0x6022
pushq $0x9
jmp 0x6022
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/tokenizer.c
// Function: negative_fsm
state_fsm negative_fsm(struct tokenizer *tokenizer) {
    int ch = tgetc(tokenizer);

    switch(ch) {
        case '0':
            return zero_state;
        /* To comply with Microsoft's C++ compiler... */
        case '1': case '2': case '3':
        case '4': case '5': case '6': case '7':
        case '8': case '9':
            return integer_state;
        default:
            tungetc(ch, tokenizer);
            report_fsm(tokenizer, "Expected integer value to be specified on line %ld, col %ld", tokenizer->lineno, tokenizer->colno);
            return invalid_state;
    }

    return invalid_state;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x5d43
leal -0x30(%rax), %ecx
cmpl $0xa, %ecx
jae 0x60db
movl %ecx, %eax
leaq 0x1dd2(%rip), %rcx      # 0x7ea8
movl (%rcx,%rax,4), %eax
jmp 0x6101
movl %eax, %edi
movq %rbx, %rsi
callq 0x5dae
movq 0x38(%rbx), %rdx
movq 0x40(%rbx), %rcx
leaq 0x2149(%rip), %rsi      # 0x823d
movq %rbx, %rdi
xorl %eax, %eax
callq 0x5dea
pushq $0x16
popq %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/tokenizer.c
// Function: string_fsm
state_fsm string_fsm(struct tokenizer *tokenizer) {
    int ch = tgetc(tokenizer);

    switch(ch) {
        case '"':
            /* Ignore " character */
            --tokenizer->bufpos;
            return string_accept;
        case '\\':
            return string_escape;
        case EOF:
        case '\n':
            tungetc(ch, tokenizer);
            report_fsm(tokenizer, "Non-terminated string, expected '\"' on line %ld, col %ld", tokenizer->lineno, tokenizer->colno);
            return invalid_state;
        default:
            return string_state;
    }

    return invalid_state;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x5d43
cmpl $-0x1, %eax
je 0x6128
cmpl $0xa, %eax
je 0x6128
cmpl $0x5c, %eax
je 0x614f
cmpl $0x22, %eax
jne 0x6153
decq 0x28(%rbx)
pushq $0x12
jmp 0x6155
movl %eax, %edi
movq %rbx, %rsi
callq 0x5dae
movq 0x38(%rbx), %rdx
movq 0x40(%rbx), %rcx
leaq 0x2138(%rip), %rsi      # 0x8279
movq %rbx, %rdi
xorl %eax, %eax
callq 0x5dea
pushq $0x16
jmp 0x6155
pushq $0x17
jmp 0x6155
pushq $0x11
popq %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/tokenizer.c
// Function: character_fsm
state_fsm character_fsm(struct tokenizer *tokenizer) {
    int ch = tgetc(tokenizer);

    switch(ch) {
        case '\\':
            return escape_state;
        default:
            if(isprint(ch)) return quote_state;
            tungetc(ch, tokenizer);
            report_fsm(tokenizer, "Expected C-style character on line %ld, col %ld", tokenizer->lineno, tokenizer->colno);
            return invalid_state;
    }

    return invalid_state;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x5d43
cmpl $0x5c, %eax
jne 0x616c
pushq $0x14
jmp 0x61a9
movl %eax, %ebp
callq 0x3180
movq (%rax), %rax
movslq %ebp, %rcx
testb $0x40, 0x1(%rax,%rcx,2)
jne 0x61a7
movl %ebp, %edi
movq %rbx, %rsi
callq 0x5dae
movq 0x38(%rbx), %rdx
movq 0x40(%rbx), %rcx
leaq 0x2119(%rip), %rsi      # 0x82b2
movq %rbx, %rdi
xorl %eax, %eax
callq 0x5dea
pushq $0x16
jmp 0x61a9
pushq $0x13
popq %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/tokenizer.c
// Function: string_escape_fsm
state_fsm string_escape_fsm(struct tokenizer *tokenizer) {
    int ch = tgetc(tokenizer);

    switch(ch) {
        case 't':
        case 'b':
        case 'n':
        case 'r':
        case '0':
        case 'a':
        case 'f':
        case 'v':
        case '\'':
        case '"':
        case '?':
        case '\\':
            return string_state;
        default:
            tungetc(ch, tokenizer);
            report_fsm(tokenizer, "Unrecognized escape character on line %ld, col %ld", tokenizer->lineno, tokenizer->colno);
            return invalid_state;
    }

    return string_state;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x5d43
movl %eax, %edi
pushq $0x11
popq %rax
leal -0x61(%rdi), %ecx
cmpl $0x15, %ecx
ja 0x61d1
movl $0x2a2023, %edx         # imm = 0x2A2023
btl %ecx, %edx
jb 0x61e9
leal -0x22(%rdi), %ecx
cmpl $0x3a, %ecx
ja 0x61eb
movabsq $0x400000020004021, %rdx # imm = 0x400000020004021
btq %rcx, %rdx
jae 0x61eb
popq %rbx
retq
movq %rbx, %rsi
callq 0x5dae
movq 0x38(%rbx), %rdx
movq 0x40(%rbx), %rcx
leaq 0x20e0(%rip), %rsi      # 0x82e2
movq %rbx, %rdi
xorl %eax, %eax
callq 0x5dea
pushq $0x16
popq %rax
jmp 0x61e9
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/tokenizer.c
// Function: quote_fsm
state_fsm quote_fsm(struct tokenizer *tokenizer) {
    int ch = tgetc(tokenizer);

    switch(ch) {
        case '\'':
            return character_accept;
        default:
            tungetc(ch, tokenizer);
            report_fsm(tokenizer, "Expected end single quote on line %ld, col %ld", tokenizer->lineno, tokenizer->colno);
            return invalid_state;
    }

    return invalid_state;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x5d43
cmpl $0x27, %eax
jne 0x6283
pushq $0xc
jmp 0x62a8
movl %eax, %edi
movq %rbx, %rsi
callq 0x5dae
movq 0x38(%rbx), %rdx
movq 0x40(%rbx), %rcx
leaq 0x2079(%rip), %rsi      # 0x8315
movq %rbx, %rdi
xorl %eax, %eax
callq 0x5dea
pushq $0x16
popq %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/tokenizer.c
// Function: create_tokenizer
struct tokenizer *create_tokenizer(const char *file) {
    /* Create the tokenizer struct */
    struct tokenizer *tokenizer = (struct tokenizer *)malloc(sizeof(struct tokenizer));
    
    /* Failed to allocate space */
    if(tokenizer == NULL) { return NULL; }

    /* Open file for reading */
    tokenizer->fstream = fopen_wrap(file, "r");
    
    /* Failed to open file */
    if(tokenizer->fstream == NULL) { 
        free(tokenizer);
        return NULL; 
    }

    /* Create string buffer */
    tokenizer->lexbuf = (char *)malloc(32);
    
    /* Failed to allocate space */
    if(tokenizer->lexbuf == NULL) { 
        fclose(tokenizer->fstream);
        free(tokenizer);
        return NULL; 
    }

    /* Set the buffer parameters */
    tokenizer->bufsize = 32;
    tokenizer->bufpos = 0;

    /* Set the file parameters */
    tokenizer->colno = 1;
    tokenizer->lineno = 1;

    /* Set the error mesage parameters */
    tokenizer->errmsg = NULL;
    tokenizer->errsize = 0;

    /* Set NULL attribute */
    tokenizer->attrptr = NULL;

    /* Store filename */
    tokenizer->filename = strdup_wrap(file);

    return tokenizer;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r14
pushq $0x50
popq %rdi
callq 0x30f0
testq %rax, %rax
je 0x6542
movq %rax, %rbx
leaq 0x1ed7(%rip), %rsi      # 0x83b3
movq %r14, %rdi
callq 0x5464
movq %rax, 0x8(%rbx)
testq %rax, %rax
je 0x653a
movq %rax, %r15
pushq $0x20
popq %rdi
callq 0x30f0
movq %rax, 0x10(%rbx)
testq %rax, %rax
je 0x6532
movq $0x20, 0x30(%rbx)
andq $0x0, 0x28(%rbx)
pushq $0x1
popq %rax
movq %rax, 0x40(%rbx)
movq %rax, 0x38(%rbx)
andq $0x0, 0x48(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rbx)
movq %r14, %rdi
callq 0x5469
movq %rax, (%rbx)
jmp 0x6544
movq %r15, %rdi
callq 0x3060
movq %rbx, %rdi
callq 0x3030
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/tokenizer.c
// Function: destroy_tokenizer
void destroy_tokenizer(struct tokenizer **tokenizer) {
    if(*tokenizer == NULL) return;

    /* Close reading file stream */
    fclose((*tokenizer)->fstream);
    free((*tokenizer)->filename);

    /* Destory dynamically allocated data */
    free((*tokenizer)->lexbuf);
    free((*tokenizer)->errmsg);
    free(*tokenizer);

    /* Redirect pointer to NULL */
    *tokenizer = NULL;
}

// Assembly:
movq (%rdi), %rax
testq %rax, %rax
je 0x6665
pushq %rbx
movq %rdi, %rbx
movq 0x8(%rax), %rdi
callq 0x3060
movq (%rbx), %rax
movq (%rax), %rdi
callq 0x3030
movq (%rbx), %rax
movq 0x10(%rax), %rdi
callq 0x3030
movq (%rbx), %rax
movq 0x18(%rax), %rdi
callq 0x3030
movq (%rbx), %rdi
callq 0x3030
andq $0x0, (%rbx)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O2/JavieW[P]CSCC69_Ext2_File-System/utilities.c
// Function: getFirstEmptyBitIndex
int getFirstEmptyBitIndex(int bitmapNum) {
    int index, maxLength;
    unsigned char *bitmap;
    if (bitmapNum == INODE_BITMAP) {
        index = EXT2_GOOD_OLD_FIRST_INO;
        maxLength = getSuperblock()->s_inodes_count;
        bitmap = getBitmap(INODE_BITMAP);
    } else {
        index = 0;
        maxLength = getSuperblock()->s_blocks_count;
        bitmap = getBitmap(BLOCK_BITMAP);
    }
    while (index < maxLength) {
        if (getBit(bitmap, index) == 0) {
            return index;
        }
        index++;
    }
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
xorl %edx, %edx
xorl %esi, %esi
cmpl $0x1, %edi
sete %dl
setne %sil
leaq 0x29cc(%rip), %rcx      # 0x40a8
movq (%rcx), %rdi
movl $0xb, %ecx
cmovnel %eax, %ecx
movl 0x800(%rdi,%rdx,4), %edx
shll $0xa, %edx
addq %rdi, %rdx
movl 0x400(%rdi,%rsi,4), %esi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %esi, %ecx
jge 0x1720
movl %ecx, %edi
shrl $0x3, %edi
movzbl (%rdx,%rdi), %edi
movl %ecx, %r8d
andl $0x7, %r8d
btl %r8d, %edi
jae 0x171e
incl %ecx
jmp 0x1700
movl %ecx, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/JavieW[P]CSCC69_Ext2_File-System/utilities.c
// Function: initInode
int initInode(unsigned short mode) {

    // find the first free inode
    int index = getFirstEmptyBitIndex(INODE_BITMAP);
    
    // change its bitmap and update field in gd
    char unsigned *bitmap = getBitmap(INODE_BITMAP);
    changeBitmap(bitmap, index, 'a');
    getGroupDesc()->bg_free_inodes_count--;

    // initialize inode attribute
    struct ext2_inode *inode_table = getInodeTable();
    inode_table[index].i_mode = mode;
    inode_table[index].i_size = 1024;
    inode_table[index].i_links_count = 1;
    inode_table[index].i_blocks = 2;
    for(int i=0; i<15; i++) {
        inode_table[index].i_block[i] = 0;
    }

    // set creation time for this inode
    inode_table[index].i_ctime = time(NULL);
    return index+1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %r14d
pushq $0x1
popq %r15
movl %r15d, %edi
callq 0x16c1
movl %eax, %ebx
leaq 0x28e1(%rip), %rsi      # 0x40a8
movq (%rsi), %rax
movl 0x804(%rax), %edi
shll $0xa, %edi
addq %rax, %rdi
movl %ebx, %ecx
andb $0x7, %cl
shll %cl, %r15d
pushq $0x8
popq %rcx
movl %ebx, %eax
cltd
idivl %ecx
cltq
orb %r15b, (%rax,%rdi)
movq (%rsi), %rax
decw 0x80e(%rax)
movl 0x808(%rax), %ecx
shll $0xa, %ecx
addq %rax, %rcx
movslq %ebx, %rax
shlq $0x7, %rax
leaq (%rcx,%rax), %r15
movw %r14w, (%rax,%rcx)
movl $0x400, 0x4(%rax,%rcx)  # imm = 0x400
movw $0x1, 0x1a(%rax,%rcx)
movl $0x2, 0x1c(%rax,%rcx)
xorl %eax, %eax
cmpq $0xf, %rax
je 0x183c
andl $0x0, 0x28(%r15,%rax,4)
incq %rax
jmp 0x182b
xorl %edi, %edi
callq 0x10c0
movl %eax, 0xc(%r15)
incl %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/JavieW[P]CSCC69_Ext2_File-System/utilities.c
// Function: deleteInode
void deleteInode(int inodeNum) {
    
    char unsigned *inode_bitmap = getBitmap(INODE_BITMAP);
    char unsigned *block_bitmap = getBitmap(BLOCK_BITMAP);
    
    // delete inode
    changeBitmap(inode_bitmap, inodeNum-1, 'd');
    getGroupDesc()->bg_free_inodes_count++;
    struct ext2_inode *inode_table = getInodeTable();
    struct ext2_inode *target = &inode_table[inodeNum-1];
    target->i_dtime = time(NULL);

    // delete block
    int i;
    for(i = 0; i<12;i++) {
        if (target->i_block[i] != 0) {
            changeBitmap(block_bitmap, target->i_block[i]-1, 'd');
            getGroupDesc()->bg_free_blocks_count++;
        }
    }

    // delete single indirect
    int bp = target->i_block[12];
    if (bp != 0)
    {
        // delete blocks in single
        unsigned int *single = (unsigned int*)getBlock(bp);
        for (int i=0; i<EXT2_BLOCK_SIZE/4; i++) {
            if (single[i] != 0) {
                changeBitmap(block_bitmap, single[i]-1, 'd');
                getGroupDesc()->bg_free_blocks_count++;
            }
        }   
        // delte single itself
        changeBitmap(block_bitmap, target->i_block[12]-1, 'd');
        getGroupDesc()->bg_free_blocks_count++;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x283d(%rip), %rax      # 0x40a8
movq (%rax), %rsi
movq %rax, %r10
movl 0x800(%rsi), %r14d
movl 0x804(%rsi), %r8d
leal -0x1(%rdi), %eax
movl %eax, %ecx
andb $0x7, %cl
pushq $0x1
popq %r15
movl %r15d, %r9d
shll %cl, %r9d
shll $0xa, %r8d
addq %rsi, %r8
pushq $0x8
popq %rcx
cltd
idivl %ecx
cltq
notb %r9b
andb %r9b, (%rax,%r8)
movq (%r10), %rbx
incw 0x80e(%rbx)
shll $0xa, %r14d
addq %rsi, %r14
movl 0x808(%rbx), %r12d
shll $0xa, %r12d
leaq (%rbx,%r12), %rax
movslq %edi, %r13
shlq $0x7, %r13
addq %r13, %rax
addq $-0x80, %rax
movq %rax, -0x30(%rbp)
xorl %edi, %edi
callq 0x10c0
movq -0x30(%rbp), %r11
pushq $0x8
popq %r10
leaq 0x27b9(%rip), %r9       # 0x40a8
movl %eax, 0x14(%r11)
addq %rbx, %r13
addq %r12, %r13
pushq $-0x16
popq %rsi
cmpq $-0xa, %rsi
je 0x1933
movl (%r13,%rsi,4), %eax
testl %eax, %eax
je 0x192e
decl %eax
movl %eax, %ecx
andb $0x7, %cl
movl %r15d, %edi
shll %cl, %edi
cltd
idivl %r10d
cltq
notb %dil
andb %dil, (%r14,%rax)
movq (%r9), %rax
incw 0x80c(%rax)
incq %rsi
jmp 0x18fc
movl 0x58(%r11), %eax
testl %eax, %eax
je 0x19a4
shll $0xa, %eax
movslq %eax, %rsi
addq (%r9), %rsi
xorl %edi, %edi
cmpq $0x100, %rdi            # imm = 0x100
je 0x197f
movl (%rsi,%rdi,4), %eax
testl %eax, %eax
je 0x197a
decl %eax
movl %eax, %ecx
andb $0x7, %cl
movl %r15d, %r8d
shll %cl, %r8d
cltd
idivl %r10d
cltq
notb %r8b
andb %r8b, (%r14,%rax)
movq (%r9), %rax
incw 0x80c(%rax)
incq %rdi
jmp 0x1946
movl 0x58(%r11), %eax
decl %eax
movl %eax, %ecx
andb $0x7, %cl
shll %cl, %r15d
cltd
idivl %r10d
cltq
notb %r15b
andb %r15b, (%r14,%rax)
movq (%r9), %rax
incw 0x80c(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/JavieW[P]CSCC69_Ext2_File-System/utilities.c
// Function: allocateNewBlock
int allocateNewBlock() {
    int index = getFirstEmptyBitIndex(BLOCK_BITMAP);
    changeBitmap(getBitmap(BLOCK_BITMAP), index, 'a');
    getGroupDesc()->bg_free_blocks_count--;
    return index+1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %edi, %edi
callq 0x16c1
movl %eax, %esi
leaq 0x26cb(%rip), %rdi      # 0x40a8
movq (%rdi), %rax
movl 0x800(%rax), %r8d
shll $0xa, %r8d
addq %rax, %r8
movl %esi, %ecx
andb $0x7, %cl
pushq $0x1
popq %r9
shll %cl, %r9d
pushq $0x8
popq %rcx
movl %esi, %eax
cltd
idivl %ecx
cltq
orb %r9b, (%rax,%r8)
movq (%rdi), %rax
decw 0x80c(%rax)
incl %esi
movl %esi, %eax
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/JavieW[P]CSCC69_Ext2_File-System/utilities.c
// Function: searchFileInDir
int searchFileInDir(struct ext2_inode *parentInode, char *childFileName) {
    /**
     * return inode num if childFile is found, o/w 0
     */
    struct ext2_dir_entry_2 *cur_dir_entry = NULL;
    struct ext2_dir_entry_2 *pre_dir_entry = getPreDirent(parentInode, childFileName);
    if (strcmp(childFileName, ".") == 0) {
        return ((struct ext2_dir_entry_2 *)getBlock(parentInode->i_block[0]))->inode;
    }
    else if (pre_dir_entry != NULL) {
        cur_dir_entry = (void *)pre_dir_entry + pre_dir_entry->rec_len;
        return cur_dir_entry->inode;
    } 
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
callq 0x1a62
cmpb $0x2e, (%r14)
jne 0x1a37
cmpb $0x0, 0x1(%r14)
je 0x1a49
testq %rax, %rax
je 0x1a45
movzwl 0x4(%rax), %ecx
addq %rax, %rcx
jmp 0x1a5b
xorl %eax, %eax
jmp 0x1a5d
movslq 0x28(%rbx), %rcx
leaq 0x2654(%rip), %rax      # 0x40a8
shlq $0xa, %rcx
addq (%rax), %rcx
movl (%rcx), %eax
popq %rbx
popq %r14
popq %rbp
retq