// File: tomfunkhouser[P]gaps/pkgs/fglut/freeglut_window.c
// Function: fghFillContextAttributes
static void fghFillContextAttributes( int *attributes ) {
  int where = 0, contextFlags, contextProfile;

  if ( !fghIsLegacyContextVersionRequested() ) {
    ATTRIB_VAL( GLX_CONTEXT_MAJOR_VERSION_ARB, fgState.MajorVersion );
    ATTRIB_VAL( GLX_CONTEXT_MINOR_VERSION_ARB, fgState.MinorVersion );
  }

  contextFlags =
    fghMapBit( fgState.ContextFlags, GLUT_DEBUG, GLX_CONTEXT_DEBUG_BIT_ARB ) |
    fghMapBit( fgState.ContextFlags, GLUT_FORWARD_COMPATIBLE, GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB );
  if ( contextFlags != 0 ) {
    ATTRIB_VAL( GLX_CONTEXT_FLAGS_ARB, contextFlags );
  }

  contextProfile =
    fghMapBit( fgState.ContextProfile, GLUT_CORE_PROFILE, GLX_CONTEXT_CORE_PROFILE_BIT_ARB ) |
    fghMapBit( fgState.ContextProfile, GLUT_COMPATIBILITY_PROFILE, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB );
  if ( contextProfile != 0 ) {
    ATTRIB_VAL( GLX_CONTEXT_PROFILE_MASK_ARB, contextProfile );
  }

  ATTRIB( 0 );
}

// Assembly:
subq $0x28, %rsp
movq %rdi, 0x20(%rsp)
movl $0x0, 0x1c(%rsp)
callq 0x185060
cmpl $0x0, %eax
jne 0x184f31
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x1c(%rsp)
movslq %ecx, %rcx
movl $0x2091, (%rax,%rcx,4)  # imm = 0x2091
leaq 0x754be(%rip), %rax     # 0x1fa390
movl 0xbc(%rax), %edx
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x1c(%rsp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x1c(%rsp)
movslq %ecx, %rcx
movl $0x2092, (%rax,%rcx,4)  # imm = 0x2092
leaq 0x7547d(%rip), %rax     # 0x1fa390
movl 0xc0(%rax), %edx
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x1c(%rsp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
leaq 0x75458(%rip), %rax     # 0x1fa390
movl 0xc4(%rax), %edi
movl $0x1, %edx
movl %edx, %esi
callq 0x1850a0
movl %eax, 0x10(%rsp)
leaq 0x7543b(%rip), %rax     # 0x1fa390
movl 0xc4(%rax), %edi
movl $0x2, %edx
movl %edx, %esi
callq 0x1850a0
movl %eax, %ecx
movl 0x10(%rsp), %eax
orl %ecx, %eax
movl %eax, 0x18(%rsp)
cmpl $0x0, 0x18(%rsp)
je 0x184fb2
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x1c(%rsp)
movslq %ecx, %rcx
movl $0x2094, (%rax,%rcx,4)  # imm = 0x2094
movl 0x18(%rsp), %edx
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x1c(%rsp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
leaq 0x753d7(%rip), %rax     # 0x1fa390
movl 0xc8(%rax), %edi
movl $0x1, %edx
movl %edx, %esi
callq 0x1850a0
movl %eax, 0xc(%rsp)
leaq 0x753ba(%rip), %rax     # 0x1fa390
movl 0xc8(%rax), %edi
movl $0x2, %edx
movl %edx, %esi
callq 0x1850a0
movl %eax, %ecx
movl 0xc(%rsp), %eax
orl %ecx, %eax
movl %eax, 0x14(%rsp)
cmpl $0x0, 0x14(%rsp)
je 0x185033
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x1c(%rsp)
movslq %ecx, %rcx
movl $0x9126, (%rax,%rcx,4)  # imm = 0x9126
movl 0x14(%rsp), %edx
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x1c(%rsp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq 0x20(%rsp), %rax
movl 0x1c(%rsp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, 0x1c(%rsp)
movslq %ecx, %rcx
movl $0x0, (%rax,%rcx,4)
addq $0x28, %rsp
retq
nopw %cs:(%rax,%rax)