// File: /workspace/github_c_makefile_star2_O3/c0stya[P]fslib/src/print.c
// Function: fst_print_sym
void fst_print_sym(
                    const struct _fst * fst,
                    struct _symt * ist,
                    struct _symt * ost,
                    struct _symt * sst) 
{
    struct _state state;
    struct _arc arc;

    token_t sa, sb, li, lo;

    rtrans_f strans, itrans, otrans; 

    state_t s;
    arc_t   a;

    itrans = (ist == NULL ? trn:trt);
    otrans = (ost == NULL ? trn:trt);
    strans = (sst == NULL ? trn:trt);

    struct _queue *finals = queue_create(sizeof(state_t));
    
    for(s=0; s < fst->n_states; ++s) {
        state = fst->states[s];
        for(a=0; a < state.n_arcs; ++a) {
            arc = state.arcs[a];

            strans(sst, s, sa);
            strans(sst, arc.state, sb); 
            itrans(ist, arc.ilabel, li);
            otrans(ost, arc.olabel, lo);

            if (sa == NULL || sb == NULL || li == NULL || lo == NULL) {
                fprintf(stderr, "Invalid symbol\n");
                exit(EXIT_FAILURE);
            }

            printf("%s\t%s\t%s\t%s\t%.5f\n",
                sa,
                sb,
                li,
                lo,
                arc.weight);
        }

        if(state.final == 1) {
            queue_enque(finals, &s);
        }
    }

    while(queue_deque(finals, &s) != NULL) {
        state = fst->states[s];

        strans(sst, s, sa);

        if (sa == NULL) {
            fprintf(stderr, "Invalid symbol\n");
            exit(EXIT_FAILURE);
        }

        printf("%s\t%f\n", sa, state.weight);
    }

    queue_remove(finals);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1078, %rsp           # imm = 0x1078
movq %rsi, -0x78(%rbp)
testq %rsi, %rsi
leaq 0x200(%rip), %rax       # 0x3492
leaq 0x220(%rip), %r8        # 0x34b9
movq %r8, %rsi
cmoveq %rax, %rsi
movq %rsi, -0x88(%rbp)
movq %rdx, -0x70(%rbp)
testq %rdx, %rdx
movq %r8, %rsi
cmoveq %rax, %rsi
movq %rsi, -0x80(%rbp)
movq %rdi, %r15
movq %rcx, -0x50(%rbp)
testq %rcx, %rcx
cmoveq %rax, %r8
movq %r8, -0x48(%rbp)
movl $0x4, %edi
callq 0x2df0
movq %rax, %r14
movl $0x0, -0x2c(%rbp)
cmpl $0x0, 0x4(%r15)
je 0x340f
xorl %eax, %eax
movq %r15, -0x68(%rbp)
movq %r14, -0x60(%rbp)
movq -0x48(%rbp), %r12
movq 0x10(%r15), %rcx
movl %eax, %eax
leaq (%rax,%rax,2), %rax
movl (%rcx,%rax,8), %esi
movl 0xc(%rcx,%rax,8), %edx
movl %edx, -0x3c(%rbp)
movq %rsi, -0x58(%rbp)
testq %rsi, %rsi
movq -0x50(%rbp), %r14
je 0x33e3
movq 0x10(%rcx,%rax,8), %r13
shlq $0x4, -0x58(%rbp)
xorl %ebx, %ebx
movl (%r13,%rbx), %r15d
movl 0x8(%r13,%rbx), %eax
movq %rax, -0x90(%rbp)
movl 0xc(%r13,%rbx), %eax
movq %rax, -0x98(%rbp)
movl -0x2c(%rbp), %esi
xorps %xmm0, %xmm0
cvtss2sd 0x4(%r13,%rbx), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %r14, %rdi
leaq -0x4a0(%rbp), %rdx
callq *%r12
movq %r14, %rdi
movq %r15, %rsi
movq -0x88(%rbp), %r15
leaq -0x10a0(%rbp), %rdx
callq *%r12
movq -0x78(%rbp), %rdi
movq -0x90(%rbp), %rsi
leaq -0xca0(%rbp), %rdx
callq *%r15
movq -0x70(%rbp), %rdi
movq -0x98(%rbp), %rsi
leaq -0x8a0(%rbp), %rdx
callq *-0x80(%rbp)
leaq 0x2eeb(%rip), %rdi      # 0x6298
leaq -0x4a0(%rbp), %rsi
leaq -0x10a0(%rbp), %rdx
leaq -0xca0(%rbp), %rcx
leaq -0x8a0(%rbp), %r8
movsd -0x38(%rbp), %xmm0
movb $0x1, %al
callq 0x10b0
addq $0x10, %rbx
cmpq %rbx, -0x58(%rbp)
jne 0x3329
cmpl $0x1, -0x3c(%rbp)
movq -0x60(%rbp), %r14
jne 0x33f9
movq %r14, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x2e1c
movl -0x2c(%rbp), %eax
incl %eax
movl %eax, -0x2c(%rbp)
movq -0x68(%rbp), %r15
cmpl 0x4(%r15), %eax
jb 0x32f8
leaq -0x2c(%rbp), %rsi
movq %r14, %rdi
callq 0x2ea0
testq %rax, %rax
movq -0x50(%rbp), %rbx
movq -0x48(%rbp), %r13
je 0x3478
leaq -0x4a0(%rbp), %r12
movq 0x10(%r15), %rax
movl -0x2c(%rbp), %esi
leaq (%rsi,%rsi,2), %rcx
xorps %xmm0, %xmm0
cvtss2sd 0x8(%rax,%rcx,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movq %rbx, %rdi
movq %r12, %rdx
callq *%r13
leaq 0x2e52(%rip), %rdi      # 0x62aa
movq %r12, %rsi
movsd -0x38(%rbp), %xmm0
movb $0x1, %al
callq 0x10b0
movq %r14, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x2ea0
testq %rax, %rax
jne 0x342f
movq %r14, %rdi
callq 0x2f4a
addq $0x1078, %rsp           # imm = 0x1078
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq