// File: /workspace/github_c_makefile_star2_O0/afi-lambda[P]a_little_smalltalk/src/primitive.c
// Function: floatUnary
static int floatUnary(int number, double firstarg)
{
    char buffer[20];
    double temp;
    int i, j;
    object returnedObject;

    switch (number)
    {
    case 1: /* floating value asString */
        sprintf(buffer, "%g", firstarg);
        returnedObject = newStString(buffer);
        break;

    case 2: /* log */
        returnedObject = newFloat(log(firstarg));
        break;

    case 3: /* exp */
        returnedObject = newFloat(exp(firstarg));
        break;

    case 6: /* integer part */
        /* return two integers n and m such that */
        /* number can be written as n * 2** m */
# define ndif 12
        temp = frexp(firstarg, &i);
        if ((i >= 0) && (i <= ndif))
        {
            temp = ldexp(temp, i);
            i = 0;
        }
        else
        {
            i -= ndif;
            temp = ldexp(temp, ndif);
        }
        j = (int) temp;
        returnedObject = newArray(2);
        basicAtPut(returnedObject, 1, newInteger(j));
        basicAtPut(returnedObject, 2, newInteger(i));
# ifdef trynew
        /* if number is too big it can't be integer anyway */
        if (firstarg > 2e9)
            returnedObject = nilobj;
        else
        {
            modf(firstarg, &temp);
            ltemp = (long) temp;
            if (longCanBeInt(ltemp))
                returnedObject = newInteger((int) temp);
            else
                returnedObject = newFloat(temp);
        }
# endif
        break;

    default:
        sysError("unknown primitive", "floatUnary");
        break;
    }

    return (returnedObject);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movsd %xmm0, -0x10(%rbp)
movl -0x4(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x50(%rbp)
subl $0x5, %eax
ja 0x7e6d
movq -0x50(%rbp), %rax
leaq 0x4901(%rip), %rcx      # 0xc640
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x30(%rbp), %rdi
movsd -0x10(%rbp), %xmm0
leaq 0x4a63(%rip), %rsi      # 0xc7bb
movb $0x1, %al
callq 0x21d0
leaq -0x30(%rbp), %rdi
callq 0x45d0
movw %ax, -0x42(%rbp)
jmp 0x7e80
movsd -0x10(%rbp), %xmm0
callq 0x20d0
callq 0x4330
movw %ax, -0x42(%rbp)
jmp 0x7e80
movsd -0x10(%rbp), %xmm0
callq 0x2200
callq 0x4330
movw %ax, -0x42(%rbp)
jmp 0x7e80
movsd -0x10(%rbp), %xmm0
leaq -0x3c(%rbp), %rdi
callq 0x2120
movsd %xmm0, -0x38(%rbp)
cmpl $0x0, -0x3c(%rbp)
jl 0x7ddb
cmpl $0xc, -0x3c(%rbp)
jg 0x7ddb
movsd -0x38(%rbp), %xmm0
movl -0x3c(%rbp), %edi
callq 0x2040
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
jmp 0x7df8
movl -0x3c(%rbp), %eax
subl $0xc, %eax
movl %eax, -0x3c(%rbp)
movsd -0x38(%rbp), %xmm0
movl $0xc, %edi
callq 0x2040
movsd %xmm0, -0x38(%rbp)
cvttsd2si -0x38(%rbp), %eax
movl %eax, -0x40(%rbp)
movl $0x2, %edi
callq 0x3d60
movw %ax, -0x42(%rbp)
movl -0x40(%rbp), %edi
callq 0x34a0
movswl -0x42(%rbp), %ecx
sarl %ecx
movslq %ecx, %rdx
leaq 0x843a(%rip), %rcx      # 0x10260
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movw %ax, (%rcx)
movswl %ax, %edi
callq 0x2fd0
movl -0x3c(%rbp), %edi
callq 0x34a0
movswl -0x42(%rbp), %ecx
sarl %ecx
movslq %ecx, %rdx
leaq 0x840c(%rip), %rcx      # 0x10260
shlq $0x4, %rdx
addq %rdx, %rcx
movq 0x8(%rcx), %rcx
movw %ax, 0x2(%rcx)
movswl %ax, %edi
callq 0x2fd0
jmp 0x7e80
leaq 0x464b(%rip), %rdi      # 0xc4bf
leaq 0x4943(%rip), %rsi      # 0xc7be
callq 0x63f0
movswl -0x42(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)