// File: tomfunkhouser[P]gaps/apps/mshview/mshview.cpp
// Function: GLUTInit(int*, char**)
void GLUTInit(int *argc, char **argv)
{
  // Open window 
  glutInit(argc, argv);
  glutInitWindowPosition(100, 100);
  glutInitWindowSize(GLUTwindow_width, GLUTwindow_height);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_MULTISAMPLE);
  GLUTwindow = glutCreateWindow("OpenGL Viewer");

  // Initialize grfx (after create context because calls glewInit)
  RNInitGrfx();

  // Initialize multisampling
  glEnable(GL_MULTISAMPLE);
  
  // Initialize background color 
  glClearColor(background[0], background[1], background[2], 1.0);

  // Initialize lights
  static GLfloat lmodel_ambient[] = { 0.2, 0.2, 0.2, 1.0 };
  glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
  glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);
  glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
  static GLfloat light0_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
  glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_diffuse);
  glEnable(GL_LIGHT0);
  static GLfloat light1_diffuse[] = { 0.5, 0.5, 0.5, 1.0 };
  glLightfv(GL_LIGHT1, GL_DIFFUSE, light1_diffuse);
  glEnable(GL_LIGHT1);
  glEnable(GL_NORMALIZE);

  // Initialize color settings
  glEnable(GL_COLOR_MATERIAL);
  glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);

  // Initialize graphics modes  
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_CULL_FACE);

  // Initialize GLUT callback functions 
  glutDisplayFunc(GLUTRedraw);
  glutReshapeFunc(GLUTResize);
  glutKeyboardFunc(GLUTKeyboard);
  glutSpecialFunc(GLUTSpecial);
  glutMouseFunc(GLUTMouse);
  glutMotionFunc(GLUTMotion);
}

// Assembly:
subq $0x18, %rsp
movq %rdi, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
movq 0x10(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x17a410
movl $0x64, %esi
movl %esi, %edi
callq 0x17ab90
movl 0x1cb2c9(%rip), %edi    # 0x1f4ab8
movl 0x1cb2c7(%rip), %esi    # 0x1f4abc
callq 0x17abd0
movl $0x92, %edi
callq 0x17ac10
leaq 0x163a7b(%rip), %rdi    # 0x18d286
callq 0x183430
movl %eax, 0x1d1aea(%rip)    # 0x1fb300
callq 0xedf20
movl $0x809d, %edi           # imm = 0x809D
callq 0x22900
leaq 0x1d1374(%rip), %rdi    # 0x1faba0
xorl %esi, %esi
callq 0x2af00
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, (%rsp)
leaq 0x1d1359(%rip), %rdi    # 0x1faba0
movl $0x1, %esi
callq 0x2af00
movsd (%rax), %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, 0x4(%rsp)
leaq 0x1d133a(%rip), %rdi    # 0x1faba0
movl $0x2, %esi
callq 0x2af00
movss (%rsp), %xmm0
movss 0x4(%rsp), %xmm1
movsd (%rax), %xmm2
cvtsd2ss %xmm2, %xmm2
movss 0x1637fd(%rip), %xmm3   # 0x18d088
callq 0x22fb0
movl $0xb53, %edi            # imm = 0xB53
leaq 0x1cb224(%rip), %rsi    # 0x1f4ac0
callq 0x233b0
movl $0xb51, %edi            # imm = 0xB51
movl $0x1, %esi
callq 0x22170
movl $0xb52, %edi            # imm = 0xB52
movl $0x1, %esi
callq 0x22170
movl $0x4000, %edi           # imm = 0x4000
movl $0x1201, %esi           # imm = 0x1201
leaq 0x1cb200(%rip), %rdx    # 0x1f4ad0
callq 0x23240
movl $0x4000, %edi           # imm = 0x4000
callq 0x22900
movl $0x4001, %edi           # imm = 0x4001
movl $0x1201, %esi           # imm = 0x1201
leaq 0x1cb1f0(%rip), %rdx    # 0x1f4ae0
callq 0x23240
movl $0x4001, %edi           # imm = 0x4001
callq 0x22900
movl $0xba1, %edi            # imm = 0xBA1
callq 0x22900
movl $0xb57, %edi            # imm = 0xB57
callq 0x22900
movl $0x408, %edi            # imm = 0x408
movl $0x1602, %esi           # imm = 0x1602
callq 0x22630
movl $0xb71, %edi            # imm = 0xB71
callq 0x22900
movl $0xb44, %edi            # imm = 0xB44
callq 0x22900
leaq -0x206d(%rip), %rdi     # 0x278d0
callq 0x1783b0
leaq -0xd59(%rip), %rdi      # 0x28bf0
callq 0x178430
leaq -0x875(%rip), %rdi      # 0x290e0
callq 0x1784a0
leaq -0x961(%rip), %rdi      # 0x29000
callq 0x178510
leaq -0xc0d(%rip), %rdi      # 0x28d60
callq 0x178a40
leaq -0xd39(%rip), %rdi      # 0x28c40
callq 0x178b20
addq $0x18, %rsp
retq
nopw %cs:(%rax,%rax)