// File: /workspace/github_c_makefile_star2_O2/simh[P]simtools/crossassemblers/macro11/dumpobj.c
// Function: main
int main(
    int argc,
    char *argv[])
{
    int             len;
    FILE           *fp;
    char           *cp;

    if (argc < 2) {
        fprintf(stderr, "Usage: dumpobj input.obj [ output.obj ]\n");
        exit(1);
    }

    fp = fopen(argv[1], "rb");
    if (fp == NULL)
        return EXIT_FAILURE;
    if (argc > 2 && argv[2]) {
        bin = fopen(argv[2], "wb");
        if (bin == NULL)
            return EXIT_FAILURE;
    }

    while ((cp = readrec(fp, &len)) != NULL) {
        switch (cp[0] & 0xff) {
        case 1:
            got_gsd(cp, len);
            break;
        case 2:
            got_endgsd(cp, len);
            break;
        case 3:
            got_text(cp, len);
            break;
        case 4:
            got_rld(cp, len);
            break;
        case 5:
            got_isd(cp, len);
            break;
        case 6:
            got_endmod(cp, len);
            break;
        case 7:
            got_libhdr(cp, len);
            break;
        case 8:
            got_libend(cp, len);
            break;
        default:
            printf("Unknown record type %o\n", cp[0] & 0xff);
            break;
        }

        free(cp);
    }

    if (bin) {
        dump_bin(xferad, NULL, 0);
        fclose(bin);
        if (badbin)
            fprintf(stderr, "Probable errors in binary file\n");
    }

    fclose(fp);
    return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x1, %edi
jle 0x2257
movq %rsi, %r14
movl %edi, %r15d
movq 0x8(%rsi), %rdi
leaq 0x1494(%rip), %rsi      # 0x358e
callq 0x1150
pushq $0x1
popq %rbp
testq %rax, %rax
je 0x2228
movq %rax, %rbx
cmpl $0x2, %r15d
je 0x2139
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x2139
leaq 0x146d(%rip), %rsi      # 0x3591
callq 0x1150
movq %rax, 0x3018(%rip)      # 0x5148
testq %rax, %rax
je 0x2228
leaq 0x4(%rsp), %r14
leaq 0xf63(%rip), %r13       # 0x30a8
leaq 0x1497(%rip), %rbp      # 0x35e3
leaq 0x1497(%rip), %r15      # 0x35ea
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12ac
testq %rax, %rax
je 0x21f0
movq %rax, %r12
movzbl (%rax), %esi
leal -0x1(%rsi), %eax
cmpl $0x7, %eax
ja 0x21d5
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movl 0x4(%rsp), %esi
movq %r12, %rdi
callq 0x1772
jmp 0x21e3
movl 0x4(%rsp), %esi
leaq 0x13c1(%rip), %rdi      # 0x3559
jmp 0x21dc
movl 0x4(%rsp), %esi
movq %r12, %rdi
callq 0x1b41
jmp 0x21e3
movl 0x4(%rsp), %esi
movq %r12, %rdi
callq 0x1bd7
jmp 0x21e3
movq %r15, %rdi
jmp 0x21ce
callq 0x1a98
jmp 0x21e3
leaq 0x1413(%rip), %rdi      # 0x35dc
jmp 0x21ce
movq %rbp, %rdi
callq 0x1060
jmp 0x21e3
leaq 0x13b8(%rip), %rdi      # 0x3594
xorl %eax, %eax
callq 0x10c0
movq %r12, %rdi
callq 0x1040
jmp 0x2153
cmpq $0x0, 0x2f50(%rip)      # 0x5148
je 0x221e
movl 0x2ef0(%rip), %edi      # 0x50f0
xorl %esi, %esi
xorl %edx, %edx
callq 0x1586
movq 0x2f38(%rip), %rdi      # 0x5148
callq 0x1090
cmpl $0x0, 0x2f34(%rip)      # 0x5150
jne 0x2239
movq %rbx, %rdi
callq 0x1090
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2db8(%rip), %rax      # 0x4ff8
movq (%rax), %rcx
leaq 0x1362(%rip), %rdi      # 0x35ac
pushq $0x1f
popq %rsi
pushq $0x1
popq %rdx
callq 0x1180
jmp 0x221e
movq 0x2d9a(%rip), %rax      # 0x4ff8
movq (%rax), %rcx
leaq 0x12fd(%rip), %rdi      # 0x3565
pushq $0x28
popq %rsi
pushq $0x1
popq %rdx
callq 0x1180
pushq $0x1
popq %rdi
callq 0x1170
nop