// File: /workspace/github_c_makefile_star2_O1/c0stya[P]fslib/src/draw.c
// Function: fst_draw_sym
int fst_draw_sym(   const struct _fst * fst, 
                    FILE * fout,
                    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; 

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


    fprintf(fout, "%s", header);

    for(state_t s=0; s < fst->n_states; ++s) {
        state = &fst->states[s];

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

        if (!state->final) {
            fprintf(fout, "\t%s [label = \"%s\", shape = circle, style = %s ];\n", 
                sa, sa, s == fst->start ? "filled" : "solid");
        } else { 
            fprintf(fout, "\t%s [label = \"%s\", shape = doublecircle, style = filled ];\n", 
                sa, sa);
        }

        for(arc_t a=0; a < state->n_arcs; ++a) {
            arc = &state->arcs[a];

            strans(sst, arc->state, sb); 
            itrans(ist, arc->ilabel, li);
            otrans(ost, arc->olabel, lo);

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

            fprintf(fout,
                "\t\t%s -> %s [ label = \"%s:%s/%g\" ];\n",
                sa, sb, li, lo, arc->weight);
        } 
    }

    fprintf(fout, "%s", footer);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1058, %rsp           # imm = 0x1058
movq %r8, %r12
movq %rdx, %r13
movq %rsi, %r15
testq %rdx, %rdx
leaq 0x1ca(%rip), %rax       # 0x37e0
leaq 0x1ea(%rip), %r14       # 0x3807
movq %r14, %rdx
cmoveq %rax, %rdx
movq %rdx, -0x68(%rbp)
movq %rcx, -0x70(%rbp)
testq %rcx, %rcx
movq %r14, %rcx
cmoveq %rax, %rcx
movq %rcx, -0x60(%rbp)
movq %rdi, %rbx
testq %r8, %r8
cmoveq %rax, %r14
leaq 0x2d97(%rip), %rdi      # 0x63e2
callq 0x10d0
cmpl $0x0, 0x4(%rbx)
je 0x37bd
movq %rbx, %rcx
xorl %ebx, %ebx
movq %r12, -0x40(%rbp)
movq %r13, -0x58(%rbp)
movq %r14, -0x38(%rbp)
movq %rcx, -0x30(%rbp)
movq %r15, -0x50(%rbp)
movq 0x10(%rcx), %rax
leaq (%rbx,%rbx,2), %r13
movq %r12, %rdi
movq %rbx, %rsi
leaq -0x480(%rbp), %rdx
movq %rax, %r12
callq *%r14
cmpl $0x0, 0xc(%r12,%r13,8)
movq %rbx, -0x48(%rbp)
je 0x36b7
movq %r15, %rdi
leaq 0x2cde(%rip), %rsi      # 0x6382
leaq -0x480(%rbp), %rcx
movq %rcx, %rdx
xorl %eax, %eax
callq 0x1120
jmp 0x36ed
movq -0x30(%rbp), %rax
movl (%rax), %eax
cmpq %rax, %rbx
leaq 0x2c23(%rip), %r8       # 0x62ea
leaq 0x2c15(%rip), %rax      # 0x62e3
cmoveq %rax, %r8
movq %r15, %rdi
leaq 0x2c74(%rip), %rsi      # 0x6350
leaq -0x480(%rbp), %rcx
movq %rcx, %rdx
xorl %eax, %eax
callq 0x1120
leaq (%r12,%r13,8), %rcx
cmpl $0x0, (%rcx)
movq -0x40(%rbp), %r14
movq -0x38(%rbp), %r8
je 0x37a0
movl $0xc, %ebx
xorl %r13d, %r13d
movq %rcx, -0x78(%rbp)
movq 0x10(%rcx), %r15
movl -0xc(%r15,%rbx), %esi
movq %r14, %rdi
leaq -0x1080(%rbp), %rdx
movq %r8, %r12
callq *%r8
movl -0x4(%r15,%rbx), %esi
movq -0x58(%rbp), %rdi
leaq -0xc80(%rbp), %rdx
callq *-0x68(%rbp)
movl (%r15,%rbx), %esi
movq -0x70(%rbp), %rdi
leaq -0x880(%rbp), %rdx
callq *-0x60(%rbp)
xorps %xmm0, %xmm0
cvtss2sd -0x8(%r15,%rbx), %xmm0
movq -0x50(%rbp), %r15
movq %r15, %rdi
leaq 0x2c5a(%rip), %rsi      # 0x63be
leaq -0x480(%rbp), %rdx
leaq -0x1080(%rbp), %rcx
leaq -0xc80(%rbp), %r8
leaq -0x880(%rbp), %r9
movb $0x1, %al
callq 0x1120
movq -0x78(%rbp), %rcx
movq %r12, %r8
incq %r13
movl (%rcx), %eax
addq $0x10, %rbx
cmpq %rax, %r13
jb 0x370e
movq -0x48(%rbp), %rbx
incq %rbx
movq -0x30(%rbp), %rcx
movl 0x4(%rcx), %eax
cmpq %rax, %rbx
movq %r14, %r12
movq %r8, %r14
jb 0x3673
leaq 0x2c54(%rip), %rdi      # 0x6418
movq %r15, %rsi
callq 0x10d0
xorl %eax, %eax
addq $0x1058, %rsp           # imm = 0x1058
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq