// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x68, %rsp
movq %rdi, -0x20(%rbp)
movl %esi, -0x24(%rbp)
movl $0x2, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x1ec0
movl $0x100, %edi            # imm = 0x100
callq 0x1120
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x1afe
movq 0x3515(%rip), %rax      # 0x4ff8
movq (%rax), %rdi
leaq 0x16b7(%rip), %rsi      # 0x31a4
movb $0x0, %al
callq 0x1110
movl $0x1, %edi
callq 0x1160
movq -0x20(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzwl (%rax,%rcx), %edi
leaq -0x38(%rbp), %rsi
callq 0x2e40
movq -0x20(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzwl 0x2(%rax,%rcx), %edi
leaq -0x35(%rbp), %rsi
callq 0x2e40
movb $0x0, -0x32(%rbp)
movq -0x20(%rbp), %rax
movslq -0x28(%rbp), %rcx
movzwl 0x6(%rax,%rcx), %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rcx
movslq -0x28(%rbp), %rax
movzbl 0x4(%rax,%rcx), %eax
movl %eax, -0x40(%rbp)
movq -0x20(%rbp), %rcx
movslq -0x28(%rbp), %rax
movzbl 0x5(%rax,%rcx), %eax
movl %eax, %ecx
movq %rcx, -0x48(%rbp)
subl $0x8, %eax
ja 0x1e58
movq -0x48(%rbp), %rax
leaq 0x1490(%rip), %rcx      # 0x3004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rdx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %r8d
leaq 0x1620(%rip), %rsi      # 0x31b3
movb $0x0, %al
callq 0x1150
jmp 0x1e84
movq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rdx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %r8d
leaq 0x1617(%rip), %rsi      # 0x31cc
movb $0x0, %al
callq 0x1150
jmp 0x1e84
movq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rdx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %r8d
leaq 0x160c(%rip), %rsi      # 0x31e3
movb $0x0, %al
callq 0x1150
jmp 0x1e84
movq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rdx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %r8d
leaq 0x15ff(%rip), %rsi      # 0x31f8
movb $0x0, %al
callq 0x1150
movl -0x3c(%rbp), %eax
movl %eax, 0x34d7(%rip)      # 0x50e0
jmp 0x1e84
movq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rdx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %esi
andl $0x1, %esi
leaq 0x14c4(%rip), %r8       # 0x30ea
leaq 0x1603(%rip), %rax      # 0x3230
cmpl $0x0, %esi
cmovneq %rax, %r8
movl -0x40(%rbp), %esi
andl $0x4, %esi
leaq 0x14a9(%rip), %r9       # 0x30ea
leaq 0x15ee(%rip), %rax      # 0x3236
cmpl $0x0, %esi
cmovneq %rax, %r9
movl -0x40(%rbp), %esi
andl $0x8, %esi
leaq 0x15e3(%rip), %r11      # 0x323f
leaq 0x15d8(%rip), %rax      # 0x323b
cmpl $0x0, %esi
cmovneq %rax, %r11
movl -0x40(%rbp), %esi
andl $0x20, %esi
leaq 0x15d0(%rip), %r10      # 0x3247
leaq 0x15c5(%rip), %rax      # 0x3243
cmpl $0x0, %esi
cmovneq %rax, %r10
movl -0x40(%rbp), %eax
leaq 0x157f(%rip), %rsi      # 0x320e
movq %r11, (%rsp)
movq %r10, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x1150
jmp 0x1e84
movq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rdx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %esi
andl $0x1, %esi
leaq 0x142a(%rip), %r8       # 0x30ea
leaq 0x15af(%rip), %rax      # 0x3276
cmpl $0x0, %esi
cmovneq %rax, %r8
movl -0x40(%rbp), %esi
andl $0x2, %esi
leaq 0x140f(%rip), %r9       # 0x30ea
leaq 0x1554(%rip), %rax      # 0x3236
cmpl $0x0, %esi
cmovneq %rax, %r9
movl -0x40(%rbp), %esi
andl $0x4, %esi
leaq 0x1589(%rip), %r15      # 0x327f
leaq 0x157e(%rip), %rax      # 0x327b
cmpl $0x0, %esi
cmovneq %rax, %r15
movl -0x40(%rbp), %esi
andl $0x10, %esi
leaq 0x1575(%rip), %r14      # 0x3286
leaq 0x156b(%rip), %rax      # 0x3283
cmpl $0x0, %esi
cmovneq %rax, %r14
movl -0x40(%rbp), %esi
andl $0x20, %esi
leaq 0x151b(%rip), %rbx      # 0x3247
leaq 0x1510(%rip), %rax      # 0x3243
cmpl $0x0, %esi
cmovneq %rax, %rbx
movl -0x40(%rbp), %esi
andl $0x40, %esi
leaq 0x1546(%rip), %r11      # 0x328d
leaq 0x153b(%rip), %rax      # 0x3289
cmpl $0x0, %esi
cmovneq %rax, %r11
movl -0x40(%rbp), %esi
andl $0x80, %esi
leaq 0x152e(%rip), %r10      # 0x3293
leaq 0x1525(%rip), %rax      # 0x3291
cmpl $0x0, %esi
cmovneq %rax, %r10
movl -0x40(%rbp), %eax
leaq 0x14ce(%rip), %rsi      # 0x324b
movq %r15, (%rsp)
movq %r14, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
movq %r11, 0x18(%rsp)
movq %r10, 0x20(%rsp)
movl %eax, 0x28(%rsp)
movb $0x0, %al
callq 0x1150
leaq -0x38(%rbp), %rdi
callq 0x1180
movq %rax, %rdx
movslq 0x337d(%rip), %rcx      # 0x5130
leaq 0x33a6(%rip), %rax      # 0x5160
movq %rdx, (%rax,%rcx,8)
movl 0x336c(%rip), %eax      # 0x5130
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x3361(%rip)      # 0x5130
movslq %eax, %rcx
leaq 0x3387(%rip), %rax      # 0x5160
movq (%rax,%rcx,8), %rdi
callq 0x1980
movl 0x3348(%rip), %eax      # 0x5130
movl $0x100, %ecx            # imm = 0x100
cltd
idivl %ecx
movl %edx, 0x333a(%rip)      # 0x5130
jmp 0x1e84
movq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rdx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %r8d
leaq 0x1484(%rip), %rsi      # 0x3295
movb $0x0, %al
callq 0x1150
jmp 0x1e84
movq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rdx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %r8d
leaq 0x147c(%rip), %rsi      # 0x32ac
movb $0x0, %al
callq 0x1150
jmp 0x1e84
movq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rdx
movl -0x3c(%rbp), %ecx
movl -0x40(%rbp), %r8d
leaq 0x1474(%rip), %rsi      # 0x32c3
movb $0x0, %al
callq 0x1150
jmp 0x1e84
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
addl $0x5, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %edx
andl $0xff, %edx
movl -0x40(%rbp), %ecx
leaq 0x146f(%rip), %rsi      # 0x32ec
movb $0x0, %al
callq 0x1150
movq -0x30(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x30(%rbp), %rdi
callq 0x1090
movq -0x50(%rbp), %rdi
movq %rax, %rsi
addq $0x1, %rsi
callq 0x1130
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x19f0
movl -0x28(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x28(%rbp)
jmp 0x1abb
addq $0x68, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax,%rax)