// File: /workspace/github_cpp_makefile_star2_O1/tomfunkhouser[P]gaps/pkgs/fglut/freeglut_state.c
// Function: glutGetModeValues
int * FGAPIENTRY glutGetModeValues(GLenum eWhat, int * size)
{
  int * array;

#if TARGET_HOST_POSIX_X11
  int attributes[9];
  GLXFBConfig * fbconfigArray;  /*  Array of FBConfigs  */
  int fbconfigArraySize;        /*  Number of FBConfigs in the array  */
  int attribute_name = 0;
#endif

  FREEGLUT_EXIT_IF_NOT_INITIALISED("glutGetModeValues");

  array = NULL;
  *size = 0;

  switch (eWhat)
    {
#if TARGET_HOST_POSIX_X11
    case GLUT_AUX:
    case GLUT_MULTISAMPLE:

      attributes[0] = GLX_BUFFER_SIZE;
      attributes[1] = GLX_DONT_CARE;

      switch (eWhat)
        {
        case GLUT_AUX:
          /*
            FBConfigs are now sorted by increasing number of auxiliary
            buffers.  We want at least one buffer.
          */
          attributes[2] = GLX_AUX_BUFFERS;
          attributes[3] = 1;
          attributes[4] = None;

          attribute_name = GLX_AUX_BUFFERS;

          break;


        case GLUT_MULTISAMPLE:
          attributes[2] = GLX_AUX_BUFFERS;
          attributes[3] = GLX_DONT_CARE;
          attributes[4] = GLX_SAMPLE_BUFFERS;
          attributes[5] = 1;
          /*
            FBConfigs are now sorted by increasing number of samples per
            pixel.  We want at least one sample.
          */
          attributes[6] = GLX_SAMPLES;
          attributes[7] = 1;
          attributes[8] = None;

          attribute_name = GLX_SAMPLES;

          break;
        }

      fbconfigArray = glXChooseFBConfig(fgDisplay.Display,
                                        fgDisplay.Screen,
                                        attributes,
                                        &fbconfigArraySize);

      if (fbconfigArray != NULL)
        {
          int * temp_array;
          int previous_value;
          int i;

          temp_array = malloc(sizeof(int) * fbconfigArraySize);
          previous_value = 0;

          for (i = 0; i < fbconfigArraySize; i++)
            {
              int value;

              glXGetFBConfigAttrib(fgDisplay.Display,
                                            fbconfigArray[i],
                                            attribute_name,
                                            &value);
              if (value > previous_value)
                {
                  temp_array[*size] = value;
                  previous_value = value;
                  (*size)++;
                }
            }

          array = malloc(sizeof(int) * (*size));
          for (i = 0; i < *size; i++)
            {
              array[i] = temp_array[i];
            }

          free(temp_array);
          XFree(fbconfigArray);
        }

      break;
#endif      

    default:
      break;
    }

  return array;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movl %edi, %ebp
leaq 0x6fdb6(%rip), %rax     # 0x1441c0
cmpb $0x0, 0x1c(%rax)
jne 0xd4425
leaq 0x1714f(%rip), %rdi     # 0xeb566
leaq 0x285b1(%rip), %rsi     # 0xfc9cf
xorl %eax, %eax
callq 0xd1cf7
movl $0x0, (%r14)
xorl %ebx, %ebx
cmpl $0x1000, %ebp           # imm = 0x1000
je 0xd4442
cmpl $0x80, %ebp
jne 0xd4571
movabsq $-0xfffffffe, %rax      # imm = 0xFFFFFFFF00000002
movq %rax, 0x10(%rsp)
cmpl $0x1000, %ebp           # imm = 0x1000
je 0xd4482
cmpl $0x80, %ebp
jne 0xd44a4
leaq 0x30(%rsp), %rax
leaq 0x2c(%rsp), %rcx
leaq 0x28(%rsp), %rdx
movaps 0x28439(%rip), %xmm0    # 0xfc8b0
movups %xmm0, -0x10(%rdx)
movl $0x186a1, %ebx          # imm = 0x186A1
jmp 0xd4496
leaq 0x20(%rsp), %rax
leaq 0x1c(%rsp), %rcx
leaq 0x18(%rsp), %rdx
movl $0x7, %ebx
movl %ebx, (%rdx)
movl $0x1, (%rcx)
movl $0x0, (%rax)
leaq 0x74325(%rip), %rax     # 0x1487d0
movq (%rax), %rdi
movl 0x8(%rax), %esi
leaq 0x10(%rsp), %rdx
movq %rsp, %rcx
callq 0x21cd0
testq %rax, %rax
je 0xd456f
movq %rax, %r15
movslq (%rsp), %r12
leaq (,%r12,4), %rdi
callq 0x21c70
movq %rax, 0x8(%rsp)
testq %r12, %r12
jle 0xd452f
xorl %ebp, %ebp
leaq 0x4(%rsp), %r13
xorl %r12d, %r12d
leaq 0x742da(%rip), %rax     # 0x1487d0
movq (%rax), %rdi
movq (%r15,%rbp,8), %rsi
movl %ebx, %edx
movq %r13, %rcx
callq 0x21270
movl 0x4(%rsp), %eax
cmpl %r12d, %eax
jle 0xd4523
movslq (%r14), %rcx
movq 0x8(%rsp), %rdx
movl %eax, (%rdx,%rcx,4)
incl %ecx
movl %ecx, (%r14)
movl %eax, %r12d
incq %rbp
movslq (%rsp), %rax
cmpq %rax, %rbp
jl 0xd44ef
movslq (%r14), %r12
leaq (,%r12,4), %r14
movq %r14, %rdi
callq 0x21c70
movq %rax, %rbx
testq %r12, %r12
movq 0x8(%rsp), %r12
jle 0xd455d
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x21720
movq %r12, %rdi
callq 0x21ae0
movq %r15, %rdi
callq 0x21c00
jmp 0xd4571
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop