// File: /workspace/github_c_makefile_star2_O2/bluecmd[P]fst-example/gtkwave/fstapi.c
// Function: fstReaderIterateHier
struct fstHier *fstReaderIterateHier(void *ctx)
{
struct fstReaderContext *xc = (struct fstReaderContext *)ctx;
int isfeof;
fstHandle alias;
char *pnt;
int ch;

if(!xc) return(NULL);

if(!xc->fh)
        {
        if(!fstReaderRecreateHierFile(xc))
                {
                return(NULL);
                }
        }

if(xc->do_rewind)
        {
        xc->do_rewind = 0;
        xc->current_handle = 0;
        fstReaderFseeko(xc, xc->fh, 0, SEEK_SET);
        clearerr(xc->fh);
        }

if(!(isfeof=feof(xc->fh)))
        {
        int tag = fgetc(xc->fh);
        switch(tag)
                {
                case FST_ST_VCD_SCOPE:
                        xc->hier.htyp = FST_HT_SCOPE;
                        xc->hier.u.scope.typ = fgetc(xc->fh);
                        xc->hier.u.scope.name = pnt = xc->str_scope_nam;
                        while((ch = fgetc(xc->fh)))
                                {
                                *(pnt++) = ch;
                                }; /* scopename */
                        *pnt = 0;
                        xc->hier.u.scope.name_length = pnt - xc->hier.u.scope.name;

                        xc->hier.u.scope.component = pnt = xc->str_scope_comp;
                        while((ch = fgetc(xc->fh)))
                                {
                                *(pnt++) = ch;
                                }; /* scopecomp */
                        *pnt = 0;
                        xc->hier.u.scope.component_length = pnt - xc->hier.u.scope.component;
                        break;

                case FST_ST_VCD_UPSCOPE:
                        xc->hier.htyp = FST_HT_UPSCOPE;
                        break;

                case FST_ST_GEN_ATTRBEGIN:
                        xc->hier.htyp = FST_HT_ATTRBEGIN;
                        xc->hier.u.attr.typ = fgetc(xc->fh);
                        xc->hier.u.attr.subtype = fgetc(xc->fh);
                        xc->hier.u.attr.name = pnt = xc->str_scope_nam;
                        while((ch = fgetc(xc->fh)))
                                {
                                *(pnt++) = ch;
                                }; /* scopename */
                        *pnt = 0;
                        xc->hier.u.attr.name_length = pnt - xc->hier.u.scope.name;

                        xc->hier.u.attr.arg = fstReaderVarint64(xc->fh);

                        if(xc->hier.u.attr.typ == FST_AT_MISC)
                                {
                                if((xc->hier.u.attr.subtype == FST_MT_SOURCESTEM)||(xc->hier.u.attr.subtype == FST_MT_SOURCEISTEM))
                                        {
                                        int sidx_skiplen_dummy = 0;
                                        xc->hier.u.attr.arg_from_name = fstGetVarint64((unsigned char *)xc->str_scope_nam, &sidx_skiplen_dummy);
                                        }
                                }
                        break;

                case FST_ST_GEN_ATTREND:
                        xc->hier.htyp = FST_HT_ATTREND;
                        break;

                case FST_VT_VCD_EVENT:
                case FST_VT_VCD_INTEGER:
                case FST_VT_VCD_PARAMETER:
                case FST_VT_VCD_REAL:
                case FST_VT_VCD_REAL_PARAMETER:
                case FST_VT_VCD_REG:
                case FST_VT_VCD_SUPPLY0:
                case FST_VT_VCD_SUPPLY1:
                case FST_VT_VCD_TIME:
                case FST_VT_VCD_TRI:
                case FST_VT_VCD_TRIAND:
                case FST_VT_VCD_TRIOR:
                case FST_VT_VCD_TRIREG:
                case FST_VT_VCD_TRI0:
                case FST_VT_VCD_TRI1:
                case FST_VT_VCD_WAND:
                case FST_VT_VCD_WIRE:
                case FST_VT_VCD_WOR:
                case FST_VT_VCD_PORT:
                case FST_VT_VCD_SPARRAY:
                case FST_VT_VCD_REALTIME:
                case FST_VT_GEN_STRING:
                case FST_VT_SV_BIT:
                case FST_VT_SV_LOGIC:
                case FST_VT_SV_INT:
                case FST_VT_SV_SHORTINT:
                case FST_VT_SV_LONGINT:
                case FST_VT_SV_BYTE:
                case FST_VT_SV_ENUM:
                case FST_VT_SV_SHORTREAL:
                        xc->hier.htyp = FST_HT_VAR;
                        xc->hier.u.var.svt_workspace = FST_SVT_NONE;
                        xc->hier.u.var.sdt_workspace = FST_SDT_NONE;
                        xc->hier.u.var.sxt_workspace = 0;
                        xc->hier.u.var.typ = tag;
                        xc->hier.u.var.direction = fgetc(xc->fh);
                        xc->hier.u.var.name = pnt = xc->str_scope_nam;
                        while((ch = fgetc(xc->fh)))
                                {
                                *(pnt++) = ch;
                                }; /* varname */
                        *pnt = 0;
                        xc->hier.u.var.name_length = pnt - xc->hier.u.var.name;
                        xc->hier.u.var.length = fstReaderVarint32(xc->fh);
                        if(tag == FST_VT_VCD_PORT)
                                {
                                xc->hier.u.var.length -= 2; /* removal of delimiting spaces */
                                xc->hier.u.var.length /= 3; /* port -> signal size adjust */
                                }

                        alias = fstReaderVarint32(xc->fh);

                        if(!alias)
                                {
                                xc->current_handle++;
                                xc->hier.u.var.handle = xc->current_handle;
                                xc->hier.u.var.is_alias = 0;
                                }
                                else
                                {
                                xc->hier.u.var.handle = alias;
                                xc->hier.u.var.is_alias = 1;
                                }

                        break;

                default:
                        isfeof = 1;
                        break;
                }
        }

return(!isfeof ? &xc->hier : NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
je 0x71a3
movq %rdi, %rbx
movq 0x8(%rdi), %rsi
testq %rsi, %rsi
jne 0x7165
movq %rbx, %rdi
callq 0x6c6d
testl %eax, %eax
je 0x71a3
movq 0x8(%rbx), %rsi
movb 0x294(%rbx), %al
testb $0x1, %al
je 0x7197
andb $-0x2, %al
movb %al, 0x294(%rbx)
andl $0x0, 0x280(%rbx)
movq %rbx, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x6776
movq 0x8(%rbx), %rdi
callq 0x2230
movq 0x8(%rbx), %rsi
movq %rsi, %rdi
callq 0x2220
testl %eax, %eax
je 0x71b5
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rbx), %rdi
callq 0x21a0
movl %eax, %r14d
cmpl $0x1e, %eax
jae 0x7297
movb $0x2, 0x248(%rbx)
andw $0x0, 0x252(%rbx)
andl $0x0, 0x254(%rbx)
movb %r14b, 0x250(%rbx)
movq 0x8(%rbx), %rdi
callq 0x21a0
movb %al, 0x251(%rbx)
leaq 0x295(%rbx), %r15
movq %r15, 0x258(%rbx)
leal 0x295(%rbx), %r12d
movq 0x8(%rbx), %rdi
callq 0x21a0
testl %eax, %eax
je 0x7223
movb %al, (%r15)
incq %r15
incl %r12d
jmp 0x720b
movb $0x0, (%r15)
subl 0x258(%rbx), %r12d
movl %r12d, 0x268(%rbx)
movq 0x8(%rbx), %rdi
callq 0x7490
cmpl $0x12, %r14d
jne 0x724e
addl $-0x2, %eax
pushq $0x3
popq %rcx
xorl %edx, %edx
divl %ecx
movl %eax, 0x260(%rbx)
movq 0x8(%rbx), %rdi
callq 0x7490
testl %eax, %eax
je 0x7270
movl %eax, 0x264(%rbx)
orb $0x1, 0x26c(%rbx)
jmp 0x728b
movl 0x280(%rbx), %eax
incl %eax
movl %eax, 0x280(%rbx)
movl %eax, 0x264(%rbx)
andb $-0x2, 0x26c(%rbx)
addq $0x248, %rbx            # imm = 0x248
jmp 0x71a5
addl $0xffffff04, %r14d      # imm = 0xFFFFFF04
cmpl $0x3, %r14d
ja 0x71a3
leaq 0xaead(%rip), %rax      # 0x1215c
movslq (%rax,%r14,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movb $0x3, 0x248(%rbx)
movq 0x8(%rbx), %rdi
callq 0x21a0
movb %al, 0x250(%rbx)
movq 0x8(%rbx), %rdi
callq 0x21a0
movb %al, 0x251(%rbx)
leaq 0x295(%rbx), %r14
movq %r14, 0x258(%rbx)
leal 0x295(%rbx), %r15d
movq %r14, %r12
movq 0x8(%rbx), %rdi
callq 0x21a0
testl %eax, %eax
je 0x73c3
movb %al, (%r12)
incq %r12
incl %r15d
jmp 0x72f5
movb $0x0, 0x248(%rbx)
movq 0x8(%rbx), %rdi
callq 0x21a0
movb %al, 0x250(%rbx)
leaq 0x295(%rbx), %r14
movq %r14, 0x258(%rbx)
leal 0x295(%rbx), %r15d
movq 0x8(%rbx), %rdi
callq 0x21a0
testl %eax, %eax
je 0x7355
movb %al, (%r14)
incq %r14
incl %r15d
jmp 0x733d
movb $0x0, (%r14)
subl 0x258(%rbx), %r15d
movl %r15d, 0x268(%rbx)
leaq 0x496(%rbx), %r14
movq %r14, 0x260(%rbx)
leal 0x496(%rbx), %r15d
movq 0x8(%rbx), %rdi
callq 0x21a0
testl %eax, %eax
je 0x7394
movb %al, (%r14)
incq %r14
incl %r15d
jmp 0x737c
movb $0x0, (%r14)
subl 0x260(%rbx), %r15d
movl %r15d, 0x26c(%rbx)
jmp 0x728b
movb $0x1, 0x248(%rbx)
jmp 0x728b
movb $0x4, 0x248(%rbx)
jmp 0x728b
movb $0x0, (%r12)
subl 0x258(%rbx), %r15d
movl %r15d, 0x270(%rbx)
movq 0x8(%rbx), %rdi
callq 0x741b
movq %rax, 0x260(%rbx)
cmpb $0x0, 0x250(%rbx)
jne 0x728b
movb 0x251(%rbx), %al
andb $-0x2, %al
cmpb $0x4, %al
jne 0x728b
leaq -0x24(%rbp), %rsi
movq %r14, %rdi
callq 0x7463
movq %rax, 0x268(%rbx)
jmp 0x728b