// File: /workspace/github_c_makefile_star2_O0/afi-lambda[P]a_little_smalltalk/src/primitive.c
// Function: intBinary
static object intBinary(int number, register int firstarg, register int secondarg)
{
    boolean binresult;
    long longresult;
    object returnedObject;

    switch (number)
    {
    case 0: /* addition */
        longresult = firstarg;
        longresult += secondarg;
        if (longCanBeInt(longresult))
            firstarg = longresult;
        else
            goto overflow;
        break;
    case 1: /* subtraction */
        longresult = firstarg;
        longresult -= secondarg;
        if (longCanBeInt(longresult))
            firstarg = longresult;
        else
            goto overflow;
        break;

    case 2: /* relationals */
        binresult = firstarg < secondarg;
        break;
    case 3:
        binresult = firstarg > secondarg;
        break;
    case 4:
        binresult = firstarg <= secondarg;
        break;
    case 5:
        binresult = firstarg >= secondarg;
        break;
    case 6:
    case 13:
        binresult = firstarg == secondarg;
        break;
    case 7:
        binresult = firstarg != secondarg;
        break;

    case 8: /* multiplication */
        longresult = firstarg;
        longresult *= secondarg;
        if (longCanBeInt(longresult))
            firstarg = longresult;
        else
            goto overflow;
        break;

    case 9: /* quo: */
        if (secondarg == 0)
            goto overflow;
        firstarg /= secondarg;
        break;

    case 10: /* rem: */
        if (secondarg == 0)
            goto overflow;
        firstarg %= secondarg;
        break;

    case 11: /* bit operations */
        firstarg &= secondarg;
        break;

    case 12:
        firstarg ^= secondarg;
        break;

    case 19: /* shifts */
        if (secondarg < 0)
            firstarg >>= (-secondarg);
        else
            firstarg <<= secondarg;
        break;
    }
    if ((number >= 2) && (number <= 7))
        if (binresult)
            returnedObject = trueobj;
        else
            returnedObject = falseobj;
    else
        returnedObject = newInteger(firstarg);
    return (returnedObject);

    /* on overflow, return nil and let smalltalk code */
    /* figure out what to do */
overflow:
    returnedObject = nilobj;
    return (returnedObject);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl -0x8(%rbp), %eax
movq %rax, -0x30(%rbp)
subq $0x13, %rax
ja 0x7bc6
movq -0x30(%rbp), %rax
leaq 0x4baf(%rip), %rcx      # 0xc5cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movslq -0xc(%rbp), %rax
movq %rax, -0x20(%rbp)
movslq -0x10(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $-0x3fff, -0x20(%rbp)   # imm = 0xC001
jl 0x7a57
cmpq $0x3fff, -0x20(%rbp)    # imm = 0x3FFF
jg 0x7a57
movq -0x20(%rbp), %rax
movl %eax, -0xc(%rbp)
jmp 0x7a5c
jmp 0x7c0e
jmp 0x7bc6
movslq -0xc(%rbp), %rax
movq %rax, -0x20(%rbp)
movslq -0x10(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
cmpq $-0x3fff, -0x20(%rbp)   # imm = 0xC001
jl 0x7a95
cmpq $0x3fff, -0x20(%rbp)    # imm = 0x3FFF
jg 0x7a95
movq -0x20(%rbp), %rax
movl %eax, -0xc(%rbp)
jmp 0x7a9a
jmp 0x7c0e
jmp 0x7bc6
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
jmp 0x7bc6
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
setg %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
jmp 0x7bc6
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
setle %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
jmp 0x7bc6
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
setge %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
jmp 0x7bc6
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
jmp 0x7bc6
movl -0xc(%rbp), %eax
cmpl -0x10(%rbp), %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
jmp 0x7bc6
movslq -0xc(%rbp), %rax
movq %rax, -0x20(%rbp)
movslq -0x10(%rbp), %rax
imulq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $-0x3fff, -0x20(%rbp)   # imm = 0xC001
jl 0x7b55
cmpq $0x3fff, -0x20(%rbp)    # imm = 0x3FFF
jg 0x7b55
movq -0x20(%rbp), %rax
movl %eax, -0xc(%rbp)
jmp 0x7b5a
jmp 0x7c0e
jmp 0x7bc6
cmpl $0x0, -0x10(%rbp)
jne 0x7b67
jmp 0x7c0e
movl -0x10(%rbp), %ecx
movl -0xc(%rbp), %eax
cltd
idivl %ecx
movl %eax, -0xc(%rbp)
jmp 0x7bc6
cmpl $0x0, -0x10(%rbp)
jne 0x7b80
jmp 0x7c0e
movl -0x10(%rbp), %ecx
movl -0xc(%rbp), %eax
cltd
idivl %ecx
movl %edx, -0xc(%rbp)
jmp 0x7bc6
movl -0x10(%rbp), %eax
andl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0x7bc6
movl -0x10(%rbp), %eax
xorl -0xc(%rbp), %eax
movl %eax, -0xc(%rbp)
jmp 0x7bc6
cmpl $0x0, -0x10(%rbp)
jge 0x7bb9
xorl %ecx, %ecx
subl -0x10(%rbp), %ecx
movl -0xc(%rbp), %eax
sarl %cl, %eax
movl %eax, -0xc(%rbp)
jmp 0x7bc4
movl -0x10(%rbp), %ecx
movl -0xc(%rbp), %eax
shll %cl, %eax
movl %eax, -0xc(%rbp)
jmp 0x7bc6
cmpl $0x2, -0x8(%rbp)
jl 0x7bf8
cmpl $0x7, -0x8(%rbp)
jg 0x7bf8
cmpl $0x0, -0x14(%rbp)
je 0x7be8
leaq 0x22413(%rip), %rax     # 0x29ff2
movw (%rax), %ax
movw %ax, -0x22(%rbp)
jmp 0x7bf6
leaq 0x22405(%rip), %rax     # 0x29ff4
movw (%rax), %ax
movw %ax, -0x22(%rbp)
jmp 0x7c04
movl -0xc(%rbp), %edi
callq 0x34a0
movw %ax, -0x22(%rbp)
movw -0x22(%rbp), %ax
movw %ax, -0x2(%rbp)
jmp 0x7c1c
movw $0x0, -0x22(%rbp)
movw -0x22(%rbp), %ax
movw %ax, -0x2(%rbp)
movw -0x2(%rbp), %ax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)