To generate the assembly that I use as the basis of the
INPUT subsystem code I do this:

gcc -Os -m64 -march=x86-64 -mtune=core2 -mcmodel=large -mfpmath=sse -mssse3 \
    -mno-sse4 -fno-reciprocal-math -fno-associative-math -fno-unwind-tables \
    -mno-red-zone -fverbose-asm -fno-stack-protector \
    -fno-asynchronous-unwind-tables -fno-common -fno-ident \
    -fno-omit-frame-pointer -fmerge-constants -mno-omit-leaf-frame-pointer \
    -fno-delete-null-pointer-checks -fno-inline -fno-builtin -fno-jump-tables \
    -fno-optimize-sibling-calls -fno-zero-initialized-in-bss \
    -fno-delayed-branch -fno-schedule-insns -fno-shrink-wrap \
    -fno-combine-stack-adjustments -fno-guess-branch-probability \
    -fno-reorder-blocks-and-partition -fno-reorder-blocks \
    -fno-align-labels -fno-align-jumps -fno-align-functions \
    -S parseinput.c -o parseinput.s

Then use vim to expand the tabs.

Then update the sections for read-only strings:

        .section .rodata.str1.1,"aMS",@progbits,1

Then update the sections for executable code:

        .section .text,"ax",@progbits

Then update the sections for read-only non-string data:

        .section .rodata,"a",@progbits

Then update the sections for uninitialized writable data:

        .section .bss,"aw",@nobits

Then if any writable initialized data exists, update the sections for that:

        .section .data,"aw",@progbits

Verify you have this at the end of the file:

        .section .note.GNU-stack,"",@progbits

Change ret to retq

Then add these at the top:

        .att_syntax
        .att_mnemonic
        .arch core2,nojumps
        .code64

Then use vim to rename .LC* to .LfuncnameC*, and to rename labels to
.Lfuncname*

Now begin assembling and finding the places where 32 bit jumps are needed, and
add .d32 to fix it.

Lu, Hongjiu sent a helpful reply to my query about that, and the .d32 suffix
goes on the instruction, not the label.  GNU gas, as always, has the features,
they just aren't properly documented with any examples so actually learning
how to use is quite difficult.

Finally, if you wish, convert the .Lwhatever labels to local labels.  This
should only be done after you have fixed any 32bit jumps.

Remove all .globl except the one for main.

Use vim and rename things as shown in this table:

   original name                   new name

rt_nput_stack                  .Lrt_nput_stack
rt_nput_stack_top              .Lrt_nput_stack_top
informat                       .Linformat
character_class                .Lcharacter_class
states                         .Lstates

Now look for ways to improve readability.  Check if functions really have
locals - if not, you can remove the rbp stuff.
