// File: /workspace/github_c_makefile_star2_O0/wtakuo[P]SVM/vmdebug.c
// Function: dump_vm
void dump_vm (long nsteps, Bcode *ip, Bcode code[],
              Value *lv, Value *fp, Value *sp, Value *vs_base,
              Value gv[], size_t gv_size, vm_mode_t mode) {
    long i;
    Value *p;
    if (mode == vm_normal_mode) return;

    /* global variables */
    for (i = 0; i < gv_size; i++) {
        printf("gv[%ld]=0x%08lx ", i, gv[i]);
        if ((i+1) % 4 == 0) printf("\n");
    }
    if (i % 4 != 0) printf("\n");
    /* value stack */
    i = 0;
    for (p = vs_base - 1; p >= sp; p--) {
        printf("vs[%ld]=0x%08lx ", vs_base - 1 - p, *p);
        if ((i+1) % 4 == 0) printf("\n");
        i++;
    }
    if (i % 4 != 0) printf("\n");
    /* machine state */
    printf("lv=%p (%ld), fp=%p (%ld), sp=%p (%ld)\n", 
           lv, vs_base - lv, 
           fp, vs_base - fp,
           sp, vs_base - sp);
    /* next instruction */
    printf("nsteps=%ld, ip=%p, pc=%ld, inst=%s\n",
           nsteps, 
           ip,
           ip - code, 
           instr_name(ip[0]));

    if (mode == vm_step_mode) {
        printf("next? [Y/n]");
        switch (getchar()) {
        case 'n':
        case 'N':
            exit(EXIT_SUCCESS);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl 0x28(%rbp), %eax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
cmpl $0x0, 0x28(%rbp)
jne 0x1cfa
jmp 0x1ee9
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq 0x20(%rbp), %rax
jae 0x1d60
movq -0x38(%rbp), %rsi
movq 0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
leaq 0x14c9(%rip), %rdi      # 0x31ec
movb $0x0, %al
callq 0x1040
movq -0x38(%rbp), %rax
addq $0x1, %rax
movl $0x4, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
jne 0x1d50
leaq 0x14ea(%rip), %rdi      # 0x3233
movb $0x0, %al
callq 0x1040
jmp 0x1d52
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x1d02
movq -0x38(%rbp), %rax
movl $0x4, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
je 0x1d82
leaq 0x14b8(%rip), %rdi      # 0x3233
movb $0x0, %al
callq 0x1040
movq $0x0, -0x38(%rbp)
movq 0x10(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x30(%rbp), %rax
jb 0x1e08
movq 0x10(%rbp), %rsi
addq $-0x8, %rsi
movq -0x40(%rbp), %rax
subq %rax, %rsi
sarq $0x3, %rsi
movq -0x40(%rbp), %rax
movq (%rax), %rdx
leaq 0x143c(%rip), %rdi      # 0x31fd
movb $0x0, %al
callq 0x1040
movq -0x38(%rbp), %rax
addq $0x1, %rax
movl $0x4, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
jne 0x1dee
leaq 0x144c(%rip), %rdi      # 0x3233
movb $0x0, %al
callq 0x1040
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rax
addq $-0x8, %rax
movq %rax, -0x40(%rbp)
jmp 0x1d96
movq -0x38(%rbp), %rax
movl $0x4, %ecx
cqto
idivq %rcx
cmpq $0x0, %rdx
je 0x1e2a
leaq 0x1410(%rip), %rdi      # 0x3233
movb $0x0, %al
callq 0x1040
movq -0x20(%rbp), %rsi
movq 0x10(%rbp), %rdx
movq -0x20(%rbp), %rax
subq %rax, %rdx
sarq $0x3, %rdx
movq -0x28(%rbp), %rcx
movq 0x10(%rbp), %r8
movq -0x28(%rbp), %rax
subq %rax, %r8
sarq $0x3, %r8
movq -0x30(%rbp), %r9
movq 0x10(%rbp), %rax
movq -0x30(%rbp), %rdi
subq %rdi, %rax
sarq $0x3, %rax
leaq 0x13a4(%rip), %rdi      # 0x320e
movq %rax, (%rsp)
movb $0x0, %al
callq 0x1040
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %edi
callq 0x1ef0
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq %rax, %r8
leaq 0x137f(%rip), %rdi      # 0x3235
movb $0x0, %al
callq 0x1040
cmpl $0x2, 0x28(%rbp)
jne 0x1ee9
leaq 0x138f(%rip), %rdi      # 0x3259
xorl %eax, %eax
callq 0x1040
callq 0x1050
orl $0x20, %eax
subl $0x6e, %eax
je 0x1ee0
jmp 0x1ee7
xorl %edi, %edi
callq 0x10a0
jmp 0x1ee9
addq $0x60, %rsp
popq %rbp
retq
nop