// File: /workspace/github_c_makefile_star2_O3/simh[P]simtools/crossassemblers/macro11/dumpobj.c
// Function: got_gsd
void got_gsd(
    char *cp,
    int len)
{
    int             i;
    char           *gsdline;

    for (i = 2; i < len; i += 8) {
        char            name[8];
        unsigned        value;
        unsigned        flags;

        gsdline = malloc(256);
        if (gsdline == NULL) {
            fprintf(stderr, "Out of memory\n");
            exit(EXIT_FAILURE);
        }

        unrad50(WORD(cp + i), name);
        unrad50(WORD(cp + i + 2), name + 3);
        name[6] = 0;

        value = WORD(cp + i + 6);
        flags = cp[i + 4] & 0xff;

        switch (cp[i + 5] & 0xff) {
        case 0:
            sprintf(gsdline, "\tMODNAME %s=%o flags=%o\n", name, value, flags);
            break;
        case 1:
            sprintf(gsdline, "\tCSECT %s=%o flags=%o\n", name, value, flags);
            break;
        case 2:
            sprintf(gsdline, "\tISD %s=%o flags=%o\n", name, value, flags);
            break;
        case 3:
            sprintf(gsdline, "\tXFER %s=%o flags=%o\n", name, value, flags);
            xferad = value;
            break;
        case 4:
            sprintf(gsdline, "\tGLOBAL %s=%o %s%s%s %s flags=%o\n", name, value,
                    flags &   01 ? "WEAK " : "",
                    flags &   04 ? "LIB "  : "",
                    flags &  010 ? "DEF"   : "REF",
                    flags &  040 ? "REL"   : "ABS",
                    flags);
            break;
        case 5:
            sprintf(gsdline, "\tPSECT %s=%o %s%s %s %s %s %s %s flags=%o\n", name, value,
                    flags &   01 ? "SAV " : "",
                    flags &   02 ? "LIB " : "",
                    flags &   04 ? "OVR"  : "CON",
                    flags &  020 ? "RO"   : "RW",
                    flags &  040 ? "REL"  : "ABS",
                    flags & 0100 ? "GBL"  : "LCL",
                    flags & 0200 ? "D"    : "I",
                    flags);
            psects[psectid] = strdup(name);
            trim(psects[psectid++]);
            psectid %= NPSECTS;
            break;
        case 6:
            sprintf(gsdline, "\tIDENT %s=%o flags=%o\n", name, value, flags);
            break;
        case 7:
            sprintf(gsdline, "\tVSECT %s=%o flags=%o\n", name, value, flags);
            break;
        case 010:
            sprintf(gsdline, "\tCompletion Routine Name %s=%o flags=%o\n", name, value, flags);
            break;
        default:
            sprintf(gsdline, "\t***Unknown GSD entry type %d flags=%o\n", cp[i + 5] & 0xff, flags);
            break;
        }

        gsdline = realloc(gsdline, strlen(gsdline) + 1);
        add_gsdline(gsdline);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpl $0x3, %esi
jl 0x1b73
movl %esi, %ebx
movq %rdi, %r14
movl $0x2, %r15d
leaq 0xf(%rsp), %r12
movl %esi, 0x14(%rsp)
movl $0x100, %edi            # imm = 0x100
callq 0x1130
testq %rax, %rax
je 0x1b82
movq %rax, %r13
movzwl (%r14,%r15), %edi
leaq 0xc(%rsp), %rsi
callq 0x24a8
movzwl 0x2(%r14,%r15), %edi
movq %r12, %rsi
callq 0x24a8
movb $0x0, 0x12(%rsp)
movzbl 0x4(%r14,%r15), %r10d
movzbl 0x5(%r14,%r15), %edx
cmpq $0x8, %rdx
ja 0x1b5d
movzwl 0x6(%r14,%r15), %ebp
leaq 0x1718(%rip), %rcx      # 0x3004
movslq (%rcx,%rdx,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r13, %rdi
leaq 0x18b4(%rip), %rsi      # 0x31b3
jmp 0x1b21
testb $0x1, %r10b
leaq 0x1921(%rip), %r8       # 0x3230
leaq 0x17d4(%rip), %rax      # 0x30ea
cmoveq %rax, %r8
testb $0x4, %r10b
leaq 0x1911(%rip), %r9       # 0x3236
cmoveq %rax, %r9
testb $0x8, %r10b
leaq 0x1907(%rip), %r11      # 0x323b
leaq 0x1904(%rip), %rax      # 0x323f
cmoveq %rax, %r11
testb $0x20, %r10b
leaq 0x18f9(%rip), %r12      # 0x3243
leaq 0x18f6(%rip), %rax      # 0x3247
cmoveq %rax, %r12
subq $0x8, %rsp
movq %r13, %rdi
leaq 0x18ab(%rip), %rsi      # 0x320e
leaq 0x14(%rsp), %rdx
movl %ebp, %ecx
xorl %eax, %eax
pushq %r10
pushq %r12
leaq 0x27(%rsp), %r12
pushq %r11
callq 0x1160
addq $0x20, %rsp
jmp 0x1b32
movq %r13, %rdi
leaq 0x1854(%rip), %rsi      # 0x31e3
jmp 0x1b21
movq %r13, %rdi
leaq 0x185a(%rip), %rsi      # 0x31f8
leaq 0xc(%rsp), %rdx
movl %ebp, %ecx
movl %r10d, %r8d
xorl %eax, %eax
callq 0x1160
movl %ebp, 0x373b(%rip)      # 0x50f0
jmp 0x1b32
movq %r13, %rdi
leaq 0x18e6(%rip), %rsi      # 0x32aa
jmp 0x1b21
movq %r13, %rdi
leaq 0x17f9(%rip), %rsi      # 0x31cc
jmp 0x1b21
testb $0x1, %r10b
leaq 0x1893(%rip), %r8       # 0x3276
leaq 0x1700(%rip), %rax      # 0x30ea
cmoveq %rax, %r8
testb $0x2, %r10b
leaq 0x183d(%rip), %r9       # 0x3236
cmoveq %rax, %r9
testb $0x4, %r10b
leaq 0x1873(%rip), %rcx      # 0x327b
leaq 0x1870(%rip), %rax      # 0x327f
cmoveq %rax, %rcx
movq %rcx, 0x20(%rsp)
testb $0x10, %r10b
leaq 0x1860(%rip), %rcx      # 0x3283
leaq 0x185c(%rip), %rax      # 0x3286
cmoveq %rax, %rcx
movq %rcx, 0x18(%rsp)
testb $0x20, %r10b
leaq 0x1805(%rip), %rbx      # 0x3243
leaq 0x1802(%rip), %rax      # 0x3247
cmoveq %rax, %rbx
testb $0x40, %r10b
leaq 0x1835(%rip), %r11      # 0x3289
leaq 0x1832(%rip), %rax      # 0x328d
cmoveq %rax, %r11
testb %r10b, %r10b
leaq 0x1b71(%rip), %r12      # 0x35da
leaq 0x1821(%rip), %rax      # 0x3291
cmovnsq %rax, %r12
movq %r13, %rdi
leaq 0x17cd(%rip), %rsi      # 0x324b
leaq 0xc(%rsp), %rdx
movl %ebp, %ecx
xorl %eax, %eax
pushq %r10
pushq %r12
pushq %r11
pushq %rbx
pushq 0x38(%rsp)
pushq 0x48(%rsp)
callq 0x1160
addq $0x30, %rsp
leaq 0xc(%rsp), %rdi
callq 0x1190
movq %rax, %rbp
movslq 0x368d(%rip), %rax      # 0x5140
leaq 0x36b6(%rip), %rcx      # 0x5170
movq %rbp, (%rcx,%rax,8)
leal 0x1(%rax), %r12d
movq %rbp, %rdi
callq 0x10a0
addq %rbp, %rax
movq %rax, %rcx
cmpq %rbp, %rax
jbe 0x1adf
leaq -0x1(%rcx), %rax
cmpb $0x20, -0x1(%rcx)
je 0x1acd
leal 0xff(%r12), %eax
testl %r12d, %r12d
cmovnsl %r12d, %eax
movb $0x0, (%rcx)
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
subl %eax, %r12d
movl %r12d, 0x3640(%rip)     # 0x5140
movl 0x14(%rsp), %ebx
leaq 0xf(%rsp), %r12
jmp 0x1b32
movq %r13, %rdi
leaq 0x177e(%rip), %rsi      # 0x3293
jmp 0x1b21
movq %r13, %rdi
leaq 0x17a0(%rip), %rsi      # 0x32c1
leaq 0xc(%rsp), %rdx
movl %ebp, %ecx
movl %r10d, %r8d
xorl %eax, %eax
callq 0x1160
movq %r13, %rdi
callq 0x10a0
leaq 0x1(%rax), %rsi
movq %r13, %rdi
callq 0x1140
movq %rax, %rdi
callq 0x17f2
addq $0x8, %r15
cmpl %ebx, %r15d
jl 0x1891
jmp 0x1b73
movq %r13, %rdi
leaq 0x1783(%rip), %rsi      # 0x32ea
movl %r10d, %ecx
xorl %eax, %eax
callq 0x1160
jmp 0x1b32
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1263