// File: /workspace/github_c_makefile_star2_O2/afi-lambda[P]a_little_smalltalk/src/primitive.c
// Function: unaryPrims
static int unaryPrims(int number, object firstarg)
{
    int i, j, saveLinkPointer;
    object returnedObject, saveProcessStack;

    returnedObject = firstarg;
    switch (number)
    {
    case 1: /* class of object */
        returnedObject = getClass(firstarg);
        break;

    case 2: /* basic size of object */
        if (isInteger(firstarg))
            i = 0;
        else
        {
            i = sizeField(firstarg);
            /* byte objects have negative size */
            if (i < 0)
                i = (-i);
        }
        returnedObject = newInteger(i);
        break;

    case 3: /* hash value of object */
        if (isInteger(firstarg))
            returnedObject = firstarg;
        else
            returnedObject = newInteger(firstarg);
        break;

    case 4: /* debugging print */
        fprintf(stderr, "primitive 14 %d\n", firstarg);
        break;

    case 8: /* change return point - block return */
        /* first get previous link pointer */
        i = intValue(basicAt(processStack, linkPointer));
        /* then creating context pointer */
        j = intValue(basicAt(firstarg, 1));
        if (basicAt(processStack, j+1) != firstarg)
        {
            returnedObject = falseobj;
            break;
        }
        /* first change link pointer to that of creator */
        fieldAtPut(processStack, i,
                   basicAt(processStack, j))
        ;
        /* then change return point to that of creator */
        fieldAtPut(processStack, i+2,
                   basicAt(processStack, j+2))
        ;
        returnedObject = trueobj;
        break;

    case 9: /* process execute */
        /* first save the values we are about to clobber */
        saveProcessStack = processStack;
        saveLinkPointer = linkPointer;
        /* trap control-C */
        signal(SIGINT, brkfun);
        if (setjmp(jb))
        {
            returnedObject = falseobj;
        }
        else if (execute(firstarg, 5000))
            returnedObject = trueobj;
        else
            returnedObject = falseobj;
        /* then restore previous environment */
        processStack = saveProcessStack;
        linkPointer = saveLinkPointer;
        signal(SIGINT, brkdum);
        break;

    default: /* unknown primitive */
        sysError("unknown primitive", "unaryPrims");
        break;
    }
    return (returnedObject);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
decl %edi
cmpl $0x8, %edi
ja 0x567e
movl %edi, %eax
leaq 0x3ff8(%rip), %rcx      # 0x9660
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movswl %bp, %edi
callq 0x313c
jmp 0x5859
leaq 0x3e3e(%rip), %rdi      # 0x94c3
leaq 0x405d(%rip), %rsi      # 0x96e9
callq 0x4938
jmp 0x5867
movswl %bp, %ebx
movl %ebx, %edi
callq 0x2b28
testl %eax, %eax
jne 0x5867
movl %ebx, %edi
jmp 0x5854
leaq 0x22902(%rip), %r14     # 0x27fb8
movswl (%r14), %eax
shrl %eax
movswq %ax, %rax
shlq $0x4, %rax
leaq 0x8b65(%rip), %r15      # 0xe230
movq 0x8(%r15,%rax), %rax
leaq 0x228e5(%rip), %rcx     # 0x27fbc
movslq (%rcx), %rcx
movswl -0x2(%rax,%rcx,2), %edi
callq 0x2d90
movl %eax, %ebx
movswl %bp, %eax
shrl %eax
movswq %ax, %rax
shlq $0x4, %rax
movq 0x8(%r15,%rax), %rax
movswl (%rax), %edi
callq 0x2d90
movswl (%r14), %ecx
shrl %ecx
movswq %cx, %rcx
shlq $0x4, %rcx
movq 0x8(%r15,%rcx), %rcx
movslq %eax, %r12
cmpw %bp, (%rcx,%r12,2)
jne 0x585d
leaq 0x22160(%rip), %r13     # 0x27888
movl %ebx, (%r13)
movslq %ebx, %rbx
movswl -0x2(%rcx,%rbx,2), %edi
callq 0x2b55
movswl (%r14), %eax
shrl %eax
movswq %ax, %rax
shlq $0x4, %rax
movq 0x8(%r15,%rax), %rax
movswl -0x2(%rax,%r12,2), %edi
movslq (%r13), %rdx
movw %di, -0x2(%rax,%rdx,2)
callq 0x2b30
movl %ebx, %eax
addl $0x2, %eax
movl %eax, (%r13)
movswl (%r14), %eax
shrl %eax
movswq %ax, %rax
shlq $0x4, %rax
movq 0x8(%r15,%rax), %rax
movswl 0x2(%rax,%rbx,2), %edi
callq 0x2b55
movswl (%r14), %eax
shrl %eax
movswq %ax, %rax
shlq $0x4, %rax
movq 0x8(%r15,%rax), %rax
movswl 0x2(%rax,%r12,2), %edi
movslq (%r13), %rdx
movw %di, -0x2(%rax,%rdx,2)
callq 0x2b30
leaq 0x2280e(%rip), %rax     # 0x27fc2
jmp 0x5864
leaq 0x227f8(%rip), %rbx     # 0x27fb8
movzwl (%rbx), %r14d
leaq 0x227f1(%rip), %r15     # 0x27fbc
movl (%r15), %r12d
leaq -0xd7d(%rip), %rsi      # 0x4a58
pushq $0x2
popq %rdi
callq 0x2160
leaq 0x227ec(%rip), %rdi     # 0x27fd0
callq 0x2130
testl %eax, %eax
jne 0x57fe
movswl %bp, %edi
movl $0x1388, %esi           # imm = 0x1388
callq 0x37be
testl %eax, %eax
jne 0x5879
leaq 0x227bf(%rip), %rax     # 0x27fc4
movzwl (%rax), %ebp
movw %r14w, (%rbx)
movl %r12d, (%r15)
leaq -0xdae(%rip), %rsi      # 0x4a68
pushq $0x2
popq %rdi
callq 0x2160
jmp 0x5867
movswl %bp, %ebx
movl %ebx, %edi
callq 0x2b28
xorl %edi, %edi
testl %eax, %eax
jne 0x5854
shrl %ebx
movl %ebx, %eax
movswq %ax, %rax
shlq $0x4, %rax
leaq 0x89ed(%rip), %rcx      # 0xe230
movzwl 0x4(%rcx,%rax), %eax
movl %eax, %ecx
negw %cx
cmovsw %ax, %cx
movzwl %cx, %edi
callq 0x2d9b
movl %eax, %ebp
jmp 0x5867
leaq 0x22760(%rip), %rax     # 0x27fc4
movzwl (%rax), %ebp
movswl %bp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22742(%rip), %rax     # 0x27fc2
jmp 0x5805
movq 0x7767(%rip), %rax      # 0xcff0
movq (%rax), %rdi
movswl %bp, %edx
leaq 0x3e42(%rip), %rsi      # 0x96d8
xorl %eax, %eax
callq 0x2170
jmp 0x5867
nop