// File: /workspace/github_c_makefile_star2_O2/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 %rdx, -0x68(%rbp)
testq %rdx, %rdx
leaq 0x1a1(%rip), %rax       # 0x352f
leaq 0x1c1(%rip), %rdx       # 0x3556
movq %rdx, %r9
cmoveq %rax, %r9
movq %r9, -0x60(%rbp)
movq %rcx, -0x70(%rbp)
testq %rcx, %rcx
movq %rdx, %rcx
cmoveq %rax, %rcx
movq %rcx, -0x58(%rbp)
movq %rdi, %r15
movq %r8, -0x40(%rbp)
testq %r8, %r8
cmoveq %rax, %rdx
movq %rdx, -0x38(%rbp)
leaq 0x3017(%rip), %rdi      # 0x63e2
movq %rsi, -0x30(%rbp)
callq 0x10d0
leaq -0x480(%rbp), %r13
xorl %r14d, %r14d
movq %r15, -0x48(%rbp)
movl 0x4(%r15), %eax
cmpq %rax, %r14
jae 0x350b
movq 0x10(%r15), %r12
imulq $0x18, %r14, %rbx
movq -0x40(%rbp), %rdi
movq %r14, %rsi
movq %r13, %rdx
callq *-0x38(%rbp)
cmpl $0x0, 0xc(%r12,%rbx)
movq %r14, -0x50(%rbp)
je 0x342a
movq -0x30(%rbp), %rdi
leaq 0x2f67(%rip), %rsi      # 0x6382
movq %r13, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x1120
jmp 0x345a
movl (%r15), %eax
cmpq %rax, %r14
leaq 0x2eb3(%rip), %r8       # 0x62ea
leaq 0x2ea5(%rip), %rax      # 0x62e3
cmoveq %rax, %r8
movq -0x30(%rbp), %rdi
leaq 0x2f03(%rip), %rsi      # 0x6350
movq %r13, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x1120
addq %rbx, %r12
pushq $0xc
popq %rbx
xorl %r13d, %r13d
movq %r12, -0x78(%rbp)
movl (%r12), %eax
cmpq %rax, %r13
jae 0x34f4
movq 0x10(%r12), %r15
movl -0xc(%r15,%rbx), %esi
movq -0x40(%rbp), %rdi
leaq -0x880(%rbp), %rdx
callq *-0x38(%rbp)
movl -0x4(%r15,%rbx), %esi
movq -0x68(%rbp), %rdi
leaq -0x1080(%rbp), %r14
movq %r14, %rdx
callq *-0x60(%rbp)
movl (%r15,%rbx), %esi
movq -0x70(%rbp), %rdi
leaq -0xc80(%rbp), %r12
movq %r12, %rdx
callq *-0x58(%rbp)
cvtss2sd -0x8(%r15,%rbx), %xmm0
movq -0x30(%rbp), %rdi
leaq 0x2ef5(%rip), %rsi      # 0x63be
leaq -0x480(%rbp), %rdx
leaq -0x880(%rbp), %rcx
movq %r14, %r8
movq %r12, %r9
movq -0x78(%rbp), %r12
movb $0x1, %al
callq 0x1120
incq %r13
addq $0x10, %rbx
jmp 0x3467
movq -0x50(%rbp), %r14
incq %r14
movq -0x48(%rbp), %r15
leaq -0x480(%rbp), %r13
jmp 0x33e2
leaq 0x2f06(%rip), %rdi      # 0x6418
movq -0x30(%rbp), %rsi
callq 0x10d0
xorl %eax, %eax
addq $0x1058, %rsp           # imm = 0x1058
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq