// File: tomfunkhouser[P]gaps/pkgs/fglut/freeglut_joystick.c
// Function: fghJoystickFudgeAxis
static float fghJoystickFudgeAxis( SFG_Joystick* joy, float value, int axis )
{
    if( value < joy->center[ axis ] )
    {
        float xx = ( value - joy->center[ axis ] ) / ( joy->center[ axis ] -
                                                       joy->min[ axis ] );

        if( xx < -joy->saturate[ axis ] )
            return -1.0f;

        if( xx > -joy->dead_band [ axis ] )
            return 0.0f;

        xx = ( xx + joy->dead_band[ axis ] ) / ( joy->saturate[ axis ] -
                                                 joy->dead_band[ axis ] );

        return ( xx < -1.0f ) ? -1.0f : xx;
    }
    else
    {
        float xx = ( value - joy->center [ axis ] ) / ( joy->max[ axis ] -
                                                        joy->center[ axis ] );

        if( xx > joy->saturate[ axis ] )
            return 1.0f;

        if( xx < joy->dead_band[ axis ] )
            return 0.0f;

        xx = ( xx - joy->dead_band[ axis ] ) / ( joy->saturate[ axis ] -
                                                 joy->dead_band[ axis ] );

        return ( xx > 1.0f ) ? 1.0f : xx;
    }
}

// Assembly:
movq %rdi, -0x10(%rsp)
movss %xmm0, -0x14(%rsp)
movl %esi, -0x18(%rsp)
movss -0x14(%rsp), %xmm1
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
movss 0x1e0(%rax,%rcx,4), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x17dcd6
movss -0x14(%rsp), %xmm0
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
subss 0x1e0(%rax,%rcx,4), %xmm0
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
movss 0x1e0(%rax,%rcx,4), %xmm1
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
subss 0x260(%rax,%rcx,4), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x1c(%rsp)
movss -0x1c(%rsp), %xmm1
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
movss 0x1a0(%rax,%rcx,4), %xmm0
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x17dc18
movss 0x122ab(%rip), %xmm0    # 0x18feb8
movss %xmm0, -0x4(%rsp)
jmp 0x17ddfc
movss -0x1c(%rsp), %xmm0
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
movss 0x160(%rax,%rcx,4), %xmm1
movd %xmm1, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x17dc51
xorps %xmm0, %xmm0
movss %xmm0, -0x4(%rsp)
jmp 0x17ddfc
movss -0x1c(%rsp), %xmm0
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
addss 0x160(%rax,%rcx,4), %xmm0
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
movss 0x1a0(%rax,%rcx,4), %xmm1
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
subss 0x160(%rax,%rcx,4), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x1c(%rsp)
movss 0x12216(%rip), %xmm0    # 0x18feb8
ucomiss -0x1c(%rsp), %xmm0
jbe 0x17dcb9
movss 0x12207(%rip), %xmm0    # 0x18feb8
movss %xmm0, -0x24(%rsp)
jmp 0x17dcc5
movss -0x1c(%rsp), %xmm0
movss %xmm0, -0x24(%rsp)
movss -0x24(%rsp), %xmm0
movss %xmm0, -0x4(%rsp)
jmp 0x17ddfc
movss -0x14(%rsp), %xmm0
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
subss 0x1e0(%rax,%rcx,4), %xmm0
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
movss 0x220(%rax,%rcx,4), %xmm1
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
subss 0x1e0(%rax,%rcx,4), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x20(%rsp)
movss -0x20(%rsp), %xmm0
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
ucomiss 0x1a0(%rax,%rcx,4), %xmm0
jbe 0x17dd4c
movss 0x10347(%rip), %xmm0    # 0x18e088
movss %xmm0, -0x4(%rsp)
jmp 0x17ddfc
movss -0x20(%rsp), %xmm1
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
movss 0x160(%rax,%rcx,4), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x17dd78
xorps %xmm0, %xmm0
movss %xmm0, -0x4(%rsp)
jmp 0x17ddfc
movss -0x20(%rsp), %xmm0
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
subss 0x160(%rax,%rcx,4), %xmm0
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
movss 0x1a0(%rax,%rcx,4), %xmm1
movq -0x10(%rsp), %rax
movslq -0x18(%rsp), %rcx
subss 0x160(%rax,%rcx,4), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x20(%rsp)
movss -0x20(%rsp), %xmm0
movss 0x102b9(%rip), %xmm1    # 0x18e088
ucomiss %xmm1, %xmm0
jbe 0x17dde4
movss 0x102ac(%rip), %xmm0    # 0x18e088
movss %xmm0, -0x28(%rsp)
jmp 0x17ddf0
movss -0x20(%rsp), %xmm0
movss %xmm0, -0x28(%rsp)
movss -0x28(%rsp), %xmm0
movss %xmm0, -0x4(%rsp)
movss -0x4(%rsp), %xmm0
retq
nopw %cs:(%rax,%rax)
nopl (%rax)