// File: /workspace/github_c_makefile_star2_O3/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 0x36c1
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
jne 0x371e
movq 0x8eeb(%rip), %rax      # 0xc5b8
movb $0x2, 0x44(%rax)
xorl %ebx, %ebx
cmpl $0xb, 0x40(%rax)
je 0x3794
movq 0x8ed4(%rip), %rcx      # 0xc5b8
movl 0x40(%rcx), %eax
testl %eax, %eax
je 0x3704
cmpl $0x7, %eax
je 0x3704
movq (%rcx), %rdi
callq 0x6bfa
movq 0x8eb9(%rip), %rcx      # 0xc5b8
movl %eax, 0x40(%rcx)
jmp 0x36e7
movq %rbx, %rdi
callq 0x3030
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
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 0x37d7
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
movq 0x8e2e(%rip), %rax      # 0xc5b8
movb $0x2, 0x44(%rax)
cmpl $0xb, 0x40(%rax)
jne 0x37b1
movq 0x785d(%rip), %rcx      # 0xaff8
movq (%rcx), %rdi
movq (%rax), %rax
movq (%rax), %rdx
movq 0x18(%rax), %rcx
leaq 0x3b33(%rip), %rsi      # 0x72e2
jmp 0x37cb
movq 0x7840(%rip), %rcx      # 0xaff8
movq (%rcx), %rdi
movq (%rax), %rax
movq (%rax), %rdx
leaq 0x3b1a(%rip), %rsi      # 0x72e2
movq %rbx, %rcx
xorl %eax, %eax
callq 0x30d0
jmp 0x36dd
callq 0x31a0