// File: /workspace/github_c_makefile_star2_O2/tstword[P]MIPSAssemblerC/src/assembler.c
// Function: report_cfg
void report_cfg(const char *fmt, ...) {
    /* Routine to allow formatted printing similar to printf */
    va_list vargs;
    size_t bufsize = 0;
    char *buffer = NULL;

    if(fmt != NULL) {
        va_start(vargs, fmt);
        bufsize = vsnprintf(NULL, 0, fmt, vargs) + 1;
        va_end(vargs);

        buffer = (char *)malloc(bufsize * sizeof(char));

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

        va_start(vargs, fmt);
        vsnprintf(buffer, bufsize, fmt, vargs);
        va_end(vargs);
    }
    /* End routine */

    cfg_assembler->status = ASSEMBLER_STATUS_FAIL;

    /* Check if tokenizer failed, otherwise CFG failed */
    if(cfg_assembler->lookahead == TOK_INVALID) fprintf(stderr, "%s: Error: %s\n", cfg_assembler->tokenizer->filename, cfg_assembler->tokenizer->errmsg);
    else if(buffer != NULL) fprintf(stderr, "%s: Error: %s\n", cfg_assembler->tokenizer->filename, buffer);

    /* Recover and skip to next line to retrieve extra data */
    while(cfg_assembler->lookahead != TOK_EOL && cfg_assembler->lookahead != TOK_NULL) {
        cfg_assembler->lookahead = get_next_token(cfg_assembler->tokenizer);
    }

    /* Free buffer */
    free(buffer);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rsi, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x32f1
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)
testq %rdi, %rdi
je 0x3361
movq %rdi, %r14
leaq 0x20(%rsp), %r12
movq %rsp, %rcx
movq %r12, 0x10(%rcx)
leaq 0x110(%rsp), %r13
movq %r13, 0x8(%rcx)
movabsq $0x3000000008, %rbp     # imm = 0x3000000008
movq %rbp, (%rcx)
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
callq 0x3050
incl %eax
movslq %eax, %r15
movq %r15, %rdi
callq 0x30f0
testq %rax, %rax
je 0x33fd
movq %rax, %rbx
movq %rsp, %rcx
movq %r12, 0x10(%rcx)
movq %r13, 0x8(%rcx)
movq %rbp, (%rcx)
movq %rax, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x3050
jmp 0x3363
xorl %ebx, %ebx
movq 0x924e(%rip), %rax      # 0xc5b8
movb $0x2, 0x44(%rax)
cmpl $0xb, 0x40(%rax)
je 0x33ba
testq %rbx, %rbx
jne 0x33d7
movq 0x9238(%rip), %rcx      # 0xc5b8
movl 0x40(%rcx), %eax
testl %eax, %eax
je 0x33a0
cmpl $0x7, %eax
je 0x33a0
movq (%rcx), %rdi
callq 0x654d
movq 0x921d(%rip), %rcx      # 0xc5b8
movl %eax, 0x40(%rcx)
jmp 0x3383
movq %rbx, %rdi
callq 0x3030
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7c37(%rip), %rcx      # 0xaff8
movq (%rcx), %rdi
movq (%rax), %rax
movq (%rax), %rdx
movq 0x18(%rax), %rcx
leaq 0x3f0d(%rip), %rsi      # 0x72e2
jmp 0x33f1
movq 0x7c1a(%rip), %rcx      # 0xaff8
movq (%rcx), %rdi
movq (%rax), %rax
movq (%rax), %rdx
leaq 0x3ef4(%rip), %rsi      # 0x72e2
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30d0
jmp 0x3379
leaq 0x3e9c(%rip), %rdi      # 0x72a0
callq 0x3130
pushq $0x1
popq %rdi
callq 0x3150