// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/fglut/freeglut_input_devices.c
// Function: fgInitialiseInputDevices
void fgInitialiseInputDevices ( void )
{
    if( !fgState.InputDevsInitialised )
    {
      /* will return true for VC8 (VC2005) and higher */
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
        char *dial_device=NULL;
        size_t sLen;
        errno_t err = _dupenv_s( &dial_device, &sLen, "GLUT_DIALS_SERIAL" );
        if (err)
            fgError("Error getting GLUT_DIALS_SERIAL environment variable");
#else
        const char *dial_device=NULL;
        dial_device = getenv ( "GLUT_DIALS_SERIAL" );
#endif
#if TARGET_HOST_MS_WINDOWS
        if (!dial_device){
            static char devname[256];
            DWORD size=sizeof(devname);
            DWORD type = REG_SZ;
            HKEY key;
            if (RegOpenKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\FreeGLUT",&key)==ERROR_SUCCESS) {
                if (RegQueryValueExA(key,"DialboxSerialPort",NULL,&type,(LPBYTE)devname,&size)==ERROR_SUCCESS){
                    dial_device=devname;
                }
                RegCloseKey(key);
            }
        }
#endif
        if ( !dial_device ) return;
        if ( !( dialbox_port = serial_open ( dial_device ) ) ) return;
      /* will return true for VC8 (VC2005) and higher */
#if TARGET_HOST_MS_WINDOWS && ( _MSC_VER >= 1400 ) && HAVE_ERRNO
        free ( dial_device );  dial_device = NULL;  /* dupenv_s allocates a string that we must free */
#endif
        serial_putchar(dialbox_port,DIAL_INITIALIZE);
        glutTimerFunc ( 10, poll_dials, 0 );
        fgState.InputDevsInitialised = GL_TRUE;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
leaq 0x739ca(%rip), %r15     # 0x1441c0
cmpb $0x0, 0xb1(%r15)
je 0xd080b
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2b96a(%rip), %rdi     # 0xfc17c
callq 0x21b20
testq %rax, %rax
je 0xd0800
movq %rax, %rbx
movq %rax, %rdi
movl $0x802, %esi            # imm = 0x802
xorl %eax, %eax
callq 0x21670
testl %eax, %eax
js 0xd0917
movl %eax, %ebp
movl $0x7c, %edi
callq 0x21c70
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x40(%rax)
movups %xmm0, 0x50(%rax)
movups %xmm0, 0x60(%rax)
movups %xmm0, 0x6c(%rax)
leaq 0x40(%rax), %rsi
movl %ebp, (%rax)
movl %ebp, %edi
callq 0x219f0
movq %rsp, %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movaps %xmm0, 0x10(%r14)
movaps %xmm0, 0x20(%r14)
movups %xmm0, 0x2c(%r14)
movl $0x4b0, 0x8(%r14)       # imm = 0x4B0
movl $0x5, (%r14)
movw $0x100, 0x16(%r14)      # imm = 0x100
movq %r14, %rdi
movl $0xd, %esi
callq 0x21530
movq %r14, %rdi
movl $0xd, %esi
callq 0x21980
movl %ebp, %edi
xorl %esi, %esi
movq %r14, %rdx
callq 0x21c10
movl (%rbx), %edi
movl $0x2, %esi
callq 0x21ea0
movq %rbx, 0x77f3c(%rip)     # 0x148818
testq %rbx, %rbx
je 0xd0800
movq %rsp, %rsi
movb $0x20, (%rsi)
movl (%rbx), %edi
movl $0x1, %edx
callq 0x212f0
leaq 0x25(%rip), %rsi        # 0xd0923
movl $0xa, %edi
xorl %edx, %edx
callq 0xcec6d
movb $0x1, 0xb1(%r15)
jmp 0xd0800
movq %rbx, %rdi
callq 0x21760
xorl %ebx, %ebx
jmp 0xd08d5