// File: /workspace/github_c_makefile_star2_O0/Nico01[P]obj2asm/rec_grpdef.c
// Function: grpdef
void grpdef(size_t length)
{
    NAME_T  name_search;
    NAME_T  *group;
    NAME_T  *segment;
    SEG_T   seg_search;
    SEG_T   *seg;
    int     gcd;
    int     name_idx;
    char    *group_text;
    char    *group_name;

    length -= get_index( &name_search.index );

    name_idx = name_search.index;

    group = (NAME_T *)find( (char *)&name_search, name_tree, TC name_compare,
                                                                        NULL );

    if ( group == NULL ) {
        fmt_error("Undefined name index");
    }

    group_text = "GROUP";
    group_name = group->name;
    grp_operands[0] = '\0';

    --length;                  /* To account for check sum at bottom */
    while ( length ) {
        --length;
        gcd = get_byte();
        switch( gcd ) {
            case GRP_SI:  
                length -= get_index( &seg_search.index );
                seg = (SEG_T *)find( (char *)&seg_search,
                                             segment_tree, TC seg_compare, NULL );
                if ( seg == NULL ) fmt_error("Undefined segment" );
                name_search.index = seg->name;
                segment = (NAME_T *)find( (char *)&name_search,
                                         name_tree, TC name_compare, NULL );
                if ( strlen(grp_operands) + strlen(segment->name) > 50 ) {
                    strcat( grp_operands, "\\" );
                    if ( strcmp(group_name,"FLAT") != 0 ) {
                        out_line( group_name, group_text, grp_operands, "" );
                    }
                    group_name = "";
                    group_text = "";
                    grp_operands[0] = '\0';
                }

                strcat( grp_operands, segment->name );
                if ( length ) {
                    strcat( grp_operands, ", " );
                }
                break;
          case GRP_EI:
                fprintf( stderr, "Group Component: GRP_EI (External Index)\n");
                fmt_error("Un-implemented GROUP operands");
                break;
          case GRP_SCO:
                fprintf( stderr, "Group Component: GRP_SCO (Seg/Class/Ovly Index)\n");
                fmt_error("Un-implemented GROUP operands");
                break;
          case GRP_LTL:
                fprintf( stderr, "Group Component: GRP_LTL (LTL data)\n");
                fmt_error("Un-implemented GROUP operands");
                break;
          case GRP_ABS:
                fprintf( stderr, "Group Component: GRP_ABS (Absolute)\n");
                fmt_error("Un-implemented GROUP operands");
                break;
          default:
                fprintf( stderr, "Group Component: %02X (?)\n", gcd );
                fmt_error("Un-implemented GROUP operands");
                break;
        }
    }
    if ( strcmp(group_name,"FLAT") != 0 ) {
        out_line( group_name, group_text, grp_operands, "" );
        out_newline();          /* Leave a blank line after Group directive */
    }

    grp_insert( name_idx );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x11c80
movswq %ax, %rcx
movq -0x8(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x8(%rbp)
movl -0x38(%rbp), %eax
movl %eax, -0xd8(%rbp)
leaq 0xb119(%rip), %rax      # 0x20160
movq (%rax), %rsi
leaq -0x38(%rbp), %rdi
leaq 0x82b(%rip), %rdx       # 0x15880
xorl %eax, %eax
movl %eax, %ecx
callq 0x16c50
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x15075
leaq 0x39b0(%rip), %rdi      # 0x18a20
callq 0x16e00
leaq 0x39b9(%rip), %rax      # 0x18a35
movq %rax, -0xe0(%rbp)
movq -0x40(%rbp), %rax
addq $0x4, %rax
movq %rax, -0xe8(%rbp)
movb $0x0, 0xc757(%rip)      # 0x217f0
movq -0x8(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x8(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x15324
movq -0x8(%rbp), %rax
decq %rax
movq %rax, -0x8(%rbp)
callq 0x11ad0
movzbl %al, %eax
movl %eax, -0xd4(%rbp)
movl -0xd4(%rbp), %eax
addl $0xffffff06, %eax       # imm = 0xFFFFFF06
movl %eax, %ecx
movq %rcx, -0xf0(%rbp)
subl $0x5, %eax
ja 0x152f5
movq -0xf0(%rbp), %rax
leaq 0x3914(%rip), %rcx      # 0x18a08
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0xc8(%rbp), %rdi
callq 0x11c80
movswq %ax, %rcx
movq -0x8(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x8(%rbp)
leaq 0xb049(%rip), %rax      # 0x20168
movq (%rax), %rsi
leaq -0xc8(%rbp), %rdi
leaq 0xae0(%rip), %rdx       # 0x15c10
xorl %eax, %eax
movl %eax, %ecx
callq 0x16c50
movq %rax, -0xd0(%rbp)
cmpq $0x0, -0xd0(%rbp)
jne 0x15156
leaq 0x38ea(%rip), %rdi      # 0x18a3b
callq 0x16e00
movq -0xd0(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x38(%rbp)
leaq 0xaff6(%rip), %rax      # 0x20160
movq (%rax), %rsi
leaq -0x38(%rbp), %rdi
leaq 0x708(%rip), %rdx       # 0x15880
xorl %eax, %eax
movl %eax, %ecx
callq 0x16c50
movq %rax, -0x48(%rbp)
leaq 0xc664(%rip), %rdi      # 0x217f0
callq 0x90a0
movq %rax, -0xf8(%rbp)
movq -0x48(%rbp), %rdi
addq $0x4, %rdi
callq 0x90a0
movq %rax, %rcx
movq -0xf8(%rbp), %rax
addq %rcx, %rax
cmpq $0x32, %rax
jbe 0x15227
leaq 0xc631(%rip), %rdi      # 0x217f0
leaq 0x3887(%rip), %rsi      # 0x18a4d
callq 0x9180
movq -0xe8(%rbp), %rdi
leaq 0x3876(%rip), %rsi      # 0x18a4f
callq 0x9100
cmpl $0x0, %eax
je 0x15204
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
leaq 0xc5f8(%rip), %rdx      # 0x217f0
leaq 0x2fc1(%rip), %rcx      # 0x181c0
callq 0xe2d0
leaq 0x2fb5(%rip), %rax      # 0x181c0
movq %rax, -0xe8(%rbp)
leaq 0x2fa7(%rip), %rax      # 0x181c0
movq %rax, -0xe0(%rbp)
movb $0x0, 0xc5c9(%rip)      # 0x217f0
movq -0x48(%rbp), %rsi
addq $0x4, %rsi
leaq 0xc5ba(%rip), %rdi      # 0x217f0
callq 0x9180
cmpq $0x0, -0x8(%rbp)
je 0x15255
leaq 0xc5a7(%rip), %rdi      # 0x217f0
leaq 0x365d(%rip), %rsi      # 0x188ad
callq 0x9180
jmp 0x1531f
movq 0x6d97(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
leaq 0x37e9(%rip), %rsi      # 0x18a54
movb $0x0, %al
callq 0x9120
leaq 0x3805(%rip), %rdi      # 0x18a7e
callq 0x16e00
jmp 0x1531f
movq 0x6d6e(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
leaq 0x3808(%rip), %rsi      # 0x18a9c
movb $0x0, %al
callq 0x9120
leaq 0x37dc(%rip), %rdi      # 0x18a7e
callq 0x16e00
jmp 0x1531f
movq 0x6d48(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
leaq 0x3813(%rip), %rsi      # 0x18acd
movb $0x0, %al
callq 0x9120
leaq 0x37b6(%rip), %rdi      # 0x18a7e
callq 0x16e00
jmp 0x1531f
movq 0x6d22(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
leaq 0x3812(%rip), %rsi      # 0x18af2
movb $0x0, %al
callq 0x9120
leaq 0x3790(%rip), %rdi      # 0x18a7e
callq 0x16e00
jmp 0x1531f
movq 0x6cfc(%rip), %rax      # 0x1bff8
movq (%rax), %rdi
movl -0xd4(%rbp), %edx
leaq 0x380b(%rip), %rsi      # 0x18b17
movb $0x0, %al
callq 0x9120
leaq 0x3764(%rip), %rdi      # 0x18a7e
callq 0x16e00
jmp 0x150a5
movq -0xe8(%rbp), %rdi
leaq 0x371d(%rip), %rsi      # 0x18a4f
callq 0x9100
cmpl $0x0, %eax
je 0x15362
movq -0xe8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
leaq 0xc49f(%rip), %rdx      # 0x217f0
leaq 0x2e68(%rip), %rcx      # 0x181c0
callq 0xe2d0
callq 0xe280
movl -0xd8(%rbp), %edi
callq 0x14fb0
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)