// File: /workspace/github_c_makefile_star2_O1/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 0x1b7e
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 0x1b8d
movq %rax, %r13
movzwl (%r14,%r15), %edi
leaq 0xc(%rsp), %rsi
callq 0x2454
movzwl 0x2(%r14,%r15), %edi
movq %r12, %rsi
callq 0x2454
movb $0x0, 0x12(%rsp)
movzbl 0x4(%r14,%r15), %r10d
movzbl 0x5(%r14,%r15), %edx
cmpq $0x8, %rdx
ja 0x1b68
movzwl 0x6(%r14,%r15), %ebp
leaq 0x1714(%rip), %rcx      # 0x3004
movslq (%rcx,%rdx,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r13, %rdi
leaq 0x18b0(%rip), %rsi      # 0x31b3
jmp 0x1b2c
testb $0x1, %r10b
leaq 0x191d(%rip), %r8       # 0x3230
leaq 0x17d0(%rip), %rax      # 0x30ea
cmoveq %rax, %r8
testb $0x4, %r10b
leaq 0x190d(%rip), %r9       # 0x3236
cmoveq %rax, %r9
testb $0x8, %r10b
leaq 0x1903(%rip), %r11      # 0x323b
leaq 0x1900(%rip), %rax      # 0x323f
cmoveq %rax, %r11
testb $0x20, %r10b
leaq 0x18f5(%rip), %r12      # 0x3243
leaq 0x18f2(%rip), %rax      # 0x3247
cmoveq %rax, %r12
subq $0x8, %rsp
movq %r13, %rdi
leaq 0x18a7(%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 0x1b3d
movq %r13, %rdi
leaq 0x1850(%rip), %rsi      # 0x31e3
jmp 0x1b2c
movq %r13, %rdi
leaq 0x1856(%rip), %rsi      # 0x31f8
leaq 0xc(%rsp), %rdx
movl %ebp, %ecx
movl %r10d, %r8d
xorl %eax, %eax
callq 0x1160
movl %ebp, 0x3737(%rip)      # 0x50f0
jmp 0x1b3d
movq %r13, %rdi
leaq 0x18e2(%rip), %rsi      # 0x32aa
jmp 0x1b2c
movq %r13, %rdi
leaq 0x17f5(%rip), %rsi      # 0x31cc
jmp 0x1b2c
testb $0x1, %r10b
leaq 0x188f(%rip), %r8       # 0x3276
leaq 0x16fc(%rip), %rax      # 0x30ea
cmoveq %rax, %r8
testb $0x2, %r10b
leaq 0x1839(%rip), %r9       # 0x3236
cmoveq %rax, %r9
testb $0x4, %r10b
leaq 0x186f(%rip), %rcx      # 0x327b
leaq 0x186c(%rip), %rax      # 0x327f
cmoveq %rax, %rcx
movq %rcx, 0x20(%rsp)
testb $0x10, %r10b
leaq 0x185c(%rip), %rcx      # 0x3283
leaq 0x1858(%rip), %rax      # 0x3286
cmoveq %rax, %rcx
movq %rcx, 0x18(%rsp)
testb $0x20, %r10b
leaq 0x1801(%rip), %rbx      # 0x3243
leaq 0x17fe(%rip), %rax      # 0x3247
cmoveq %rax, %rbx
testb $0x40, %r10b
leaq 0x1831(%rip), %r11      # 0x3289
leaq 0x182e(%rip), %rax      # 0x328d
cmoveq %rax, %r11
testb %r10b, %r10b
leaq 0x1b6d(%rip), %r12      # 0x35da
leaq 0x181d(%rip), %rax      # 0x3291
cmovnsq %rax, %r12
movq %r13, %rdi
leaq 0x17c9(%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 0x3689(%rip), %rax      # 0x5140
leaq 0x36b2(%rip), %rcx      # 0x5170
movq %rbp, (%rcx,%rax,8)
leal 0x1(%rax), %r12d
movl %r12d, 0x3673(%rip)     # 0x5140
movq %rbp, %rdi
callq 0x10a0
addq %rbp, %rax
movq %rax, %rcx
cmpq %rbp, %rax
jbe 0x1aea
leaq -0x1(%rcx), %rax
cmpb $0x20, -0x1(%rcx)
je 0x1ad8
leal 0xff(%r12), %eax
testl %r12d, %r12d
cmovnsl %r12d, %eax
movb $0x0, (%rcx)
andl $0xffffff00, %eax       # imm = 0xFFFFFF00
subl %eax, %r12d
movl %r12d, 0x3635(%rip)     # 0x5140
movl 0x14(%rsp), %ebx
leaq 0xf(%rsp), %r12
jmp 0x1b3d
movq %r13, %rdi
leaq 0x1773(%rip), %rsi      # 0x3293
jmp 0x1b2c
movq %r13, %rdi
leaq 0x1795(%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 0x17fa
addq $0x8, %r15
cmpl %ebx, %r15d
jl 0x1895
jmp 0x1b7e
movq %r13, %rdi
leaq 0x1778(%rip), %rsi      # 0x32ea
movl %r10d, %ecx
xorl %eax, %eax
callq 0x1160
jmp 0x1b3d
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1263