// File: /workspace/github_c_makefile_star2_O0/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
subq $0x1060, %rsp           # imm = 0x1060
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x18(%rbp), %rdx
leaq 0x286(%rip), %rax       # 0x4950
leaq 0x23f(%rip), %rcx       # 0x4910
cmpq $0x0, %rdx
cmoveq %rcx, %rax
movq %rax, -0x1050(%rbp)
movq -0x20(%rbp), %rdx
leaq 0x265(%rip), %rax       # 0x4950
leaq 0x21e(%rip), %rcx       # 0x4910
cmpq $0x0, %rdx
cmoveq %rcx, %rax
movq %rax, -0x1058(%rbp)
movq -0x28(%rbp), %rdx
leaq 0x244(%rip), %rax       # 0x4950
leaq 0x1fd(%rip), %rcx       # 0x4910
cmpq $0x0, %rdx
cmoveq %rcx, %rax
movq %rax, -0x1048(%rbp)
movq -0x10(%rbp), %rdi
movq 0x69b3(%rip), %rdx      # 0xb0e0
leaq 0x392b(%rip), %rsi      # 0x805f
movb $0x0, %al
callq 0x10f0
movl $0x0, -0x105c(%rbp)
movl -0x105c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x4(%rcx), %eax
jae 0x48eb
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x105c(%rbp), %ecx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x1048(%rbp), %rax
movq -0x28(%rbp), %rdi
movl -0x105c(%rbp), %ecx
movl %ecx, %esi
leaq -0x440(%rbp), %rdx
callq *%rax
movq -0x30(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x47db
movq -0x10(%rbp), %rdi
leaq -0x440(%rbp), %rdx
leaq -0x440(%rbp), %rcx
movl -0x105c(%rbp), %esi
movq -0x8(%rbp), %rax
movl (%rax), %r9d
leaq 0x3b36(%rip), %r8       # 0x82f3
leaq 0x3b28(%rip), %rax      # 0x82ec
cmpl %r9d, %esi
cmoveq %rax, %r8
leaq 0x3b87(%rip), %rsi      # 0x8359
movb $0x0, %al
callq 0x10f0
jmp 0x47fb
movq -0x10(%rbp), %rdi
leaq -0x440(%rbp), %rdx
leaq -0x440(%rbp), %rcx
leaq 0x3b97(%rip), %rsi      # 0x838b
movb $0x0, %al
callq 0x10f0
movl $0x0, -0x1060(%rbp)
movl -0x1060(%rbp), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
jae 0x48d5
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x1060(%rbp), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x1048(%rbp), %rax
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, %esi
leaq -0x840(%rbp), %rdx
callq *%rax
movq -0x1050(%rbp), %rax
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rcx
movl 0x8(%rcx), %ecx
movl %ecx, %esi
leaq -0xc40(%rbp), %rdx
callq *%rax
movq -0x1058(%rbp), %rax
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rcx
movl 0xc(%rcx), %ecx
movl %ecx, %esi
leaq -0x1040(%rbp), %rdx
callq *%rax
movq -0x10(%rbp), %rdi
leaq -0x440(%rbp), %rdx
leaq -0x840(%rbp), %rcx
leaq -0xc40(%rbp), %r8
leaq -0x1040(%rbp), %r9
movq -0x38(%rbp), %rax
movss 0x4(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x3b0d(%rip), %rsi      # 0x83c7
movb $0x1, %al
callq 0x10f0
movl -0x1060(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1060(%rbp)
jmp 0x4805
jmp 0x48d7
movl -0x105c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x105c(%rbp)
jmp 0x4745
movq -0x10(%rbp), %rdi
movq 0x67f2(%rip), %rdx      # 0xb0e8
leaq 0x3762(%rip), %rsi      # 0x805f
movb $0x0, %al
callq 0x10f0
xorl %eax, %eax
addq $0x1060, %rsp           # imm = 0x1060
popq %rbp
retq
nop