// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
testb %al, %al
je 0x32b8
movaps %xmm0, -0xb0(%rbp)
movaps %xmm1, -0xa0(%rbp)
movaps %xmm2, -0x90(%rbp)
movaps %xmm3, -0x80(%rbp)
movaps %xmm4, -0x70(%rbp)
movaps %xmm5, -0x60(%rbp)
movaps %xmm6, -0x50(%rbp)
movaps %xmm7, -0x40(%rbp)
movq %r9, -0xb8(%rbp)
movq %r8, -0xc0(%rbp)
movq %rcx, -0xc8(%rbp)
movq %rdx, -0xd0(%rbp)
movq %rsi, -0xd8(%rbp)
movq %rdi, -0x8(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x33aa
leaq -0x20(%rbp), %rax
leaq -0xe0(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x8, (%rax)
movq -0x8(%rbp), %rdx
leaq -0x20(%rbp), %rcx
xorl %eax, %eax
movl %eax, %esi
movq %rsi, %rdi
callq 0x3040
addl $0x1, %eax
cltq
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rax
movq -0x28(%rbp), %rdi
shlq $0x0, %rdi
callq 0x30e0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x336d
leaq 0x7122(%rip), %rdi      # 0xa480
callq 0x3120
movl $0x1, %edi
callq 0x3140
leaq -0x20(%rbp), %rax
leaq -0xe0(%rbp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x10(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl $0x30, 0x4(%rax)
movl $0x8, (%rax)
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x8(%rbp), %rdx
leaq -0x20(%rbp), %rcx
callq 0x3040
leaq -0x20(%rbp), %rax
movq 0xc1f7(%rip), %rax      # 0xf5a8
movb $0x2, 0x44(%rax)
movq 0xc1ec(%rip), %rax      # 0xf5a8
cmpl $0xb, 0x40(%rax)
jne 0x33f7
movq 0xac2f(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xc1d5(%rip), %rax      # 0xf5a8
movq (%rax), %rax
movq (%rax), %rdx
movq 0xc1c8(%rip), %rax      # 0xf5a8
movq (%rax), %rax
movq 0x18(%rax), %rcx
leaq 0x70d4(%rip), %rsi      # 0xa4c2
movb $0x0, %al
callq 0x30c0
jmp 0x3429
cmpq $0x0, -0x30(%rbp)
je 0x3427
movq 0xabf3(%rip), %rax      # 0xdff8
movq (%rax), %rdi
movq 0xc199(%rip), %rax      # 0xf5a8
movq (%rax), %rax
movq (%rax), %rdx
movq -0x30(%rbp), %rcx
leaq 0x70a2(%rip), %rsi      # 0xa4c2
movb $0x0, %al
callq 0x30c0
jmp 0x3429
jmp 0x342b
movq 0xc176(%rip), %rcx      # 0xf5a8
xorl %eax, %eax
cmpl $0x7, 0x40(%rcx)
movb %al, -0xe1(%rbp)
je 0x3454
movq 0xc161(%rip), %rax      # 0xf5a8
cmpl $0x0, 0x40(%rax)
setne %al
movb %al, -0xe1(%rbp)
movb -0xe1(%rbp), %al
testb $0x1, %al
jne 0x3460
jmp 0x347d
movq 0xc141(%rip), %rax      # 0xf5a8
movq (%rax), %rdi
callq 0x8f90
movl %eax, %ecx
movq 0xc130(%rip), %rax      # 0xf5a8
movl %ecx, 0x40(%rax)
jmp 0x342b
movq -0x30(%rbp), %rdi
callq 0x3030
addq $0xf0, %rsp
popq %rbp
retq
nop