// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heather.cpp
// Function: init_screen(int)
void init_screen(int why)
{
Cursor cur;
unsigned char *vfx_font;
int font_height;
int i;
unsigned int j;
int old_sw, old_sh;

struct DECO_HINTS {  // stuff for disabling window decorations
   u32 flags;
   u32 functions;
   u32 decorations;
   u32 input_mode;
   u32 status;
} deco_hints;
Atom deco;

   // Initialize the graphics screen
printf("\nInit screen %d: %dx%d (potentially rotated)\n", why, SCREEN_WIDTH,SCREEN_HEIGHT);

   config_screen(3);  // initialize screen rendering variables for potentially rotated size
// VFX_io_done = 1;
   kill_screen();    // release any screen data structures currently in use

   old_sw = SCREEN_WIDTH;
   old_sh = SCREEN_HEIGHT;
   SWAP(SCREEN_WIDTH,SCREEN_HEIGHT);  // physical screen size
printf("Physical screen size: %dx%d\n", SCREEN_WIDTH,SCREEN_HEIGHT);

   // setup text drawing using WIN_VFX fonts
   if(user_font_size == 0)  {
      if(big_plot && (ebolt == 0)) {
         vfx_font = &h_medium_font[0];
         user_font_size = 14;
      }
      else {
         vfx_font = &h_font_12[0];
         user_font_size = 12;
      }
   }
   else if(user_font_size <= 8)  {
      vfx_font = &h_small_font[0];
      user_font_size = 8;
   }
   else if(user_font_size <= 12) {
      vfx_font = &h_font_12[0];
      user_font_size = 12;
   }
   else if(user_font_size <= 14) {
      vfx_font = &h_medium_font[0];
      user_font_size = 14;
   }
   else if(user_font_size <= 16) {
      vfx_font = &h_large_font[0];
      user_font_size = 16;
   }
   else {
      vfx_font = &h_font_12[0];
      user_font_size = 12;
   }

   font_height = user_font_size;
   TEXT_HEIGHT = font_height;
   TEXT_WIDTH  = 8;  // !!!!!!!
   if(font_height <= 12) {
      small_font = 2;
   }
   else small_font = 0;

   dot_font = (unsigned char *) (void *) vfx_font;



   /*  Window variables  */

   int          x, y;
   unsigned int width, height;
   char *window_name;
   char *icon_name;

   if(luxor) {
      window_name = "Luxor X11";
      icon_name   = "Luxor";
   }
   else {
      window_name = &szAppName[0];  // "Lady Heather X11";
      icon_name   = "Heather";
   }


   /*  Display variables  */

   char *       display_name = NULL;


   /*  Miscellaneous X11 variables  */

   XTextProperty windowName, iconName;
   XGCValues     values;

   if(luxor) appname = "LUXOR";  // !!!argv[0];
   else      appname = "HEATHER";  // !!!argv[0];


   /*  Allocate memory for X11 structures  */

   if ( !( size_hints  = XAllocSizeHints() ) ||
        !( wm_hints    = XAllocWMHints()   ) ||
        !( class_hints = XAllocClassHint() )    ) {
       sprintf(out, "%s: couldn't allocate memory.\n", appname);
       error_exit(10005, out);
   }


   /*  Connect to X11 server  */

   display = XOpenDisplay(display_name);
   if(display == NULL) {
      sprintf(out, "%s: couldn't connect to X server %s\n", appname, display_name);
      error_exit(10006, out);
   }


   /*  Get screen size from display structure macro  */

   screen_num     = DefaultScreen(display);
   display_width  = DisplayWidth(display, screen_num);
   display_height = DisplayHeight(display, screen_num);
   have_root_info = 1;

printf("Config disp: %dx%d  screen:%dx%d  kill_decorations:%d  go_full:%d\n", display_width,display_height, SCREEN_WIDTH,SCREEN_HEIGHT, kill_deco, go_fullscreen);
   if(go_fullscreen && (display_width >= MIN_WIDTH) && (display_height >= MIN_HEIGHT)) {
      SCREEN_WIDTH  = display_width;
      SCREEN_HEIGHT = display_height;
      go_fullscreen = 0;
   }
if(kill_deco) go_fullscreen = 1;
printf("Display size: %dx%d  screen:%dx%d  kill_decorations:%d  go_full:%d\n", display_width,display_height, SCREEN_WIDTH,SCREEN_HEIGHT, kill_deco, go_fullscreen);


   if(!RESTORE_MAXED_WINDOW) ; // don't attempt to restore maximized window size
   else if(((unsigned) SCREEN_WIDTH >= display_width) || ((unsigned) SCREEN_HEIGHT >= display_height)) {  // request for large screen
      if(x11_maxed) {
         if(have_restore_size) {
            SCREEN_WIDTH = restore_width;   //1024;
            SCREEN_HEIGHT = restore_height; // 768
         }
         x11_maxed = 0;
printf("have restore size %d: %d %d   new:%d %d\n", have_restore_size, restore_width,restore_height, new_width,new_height);
      }
      else {
         x11_maxed = 1;
printf("maximize window\n");
      }
   }




   /*  Set initial window size and position, and create it  */

   x = x11_left;
   y = x11_top;
   width  = SCREEN_WIDTH;
   height = SCREEN_HEIGHT;
printf("creating %dx%d simple window at %d,%d\n", width,height, x,y);
   screen = XCreateSimpleWindow(display, RootWindow(display,screen_num),
                             x,y, width,height, 0,
                             WhitePixel(display, screen_num),
                             BlackPixel(display, screen_num));

   if(screen == 0) {
       error_exit(10010, "Could not create X11 simple window");
   }

printf("Get window attributes\n");
   XGetWindowAttributes(display,screen, &wattr);  // winz
   x11_left = wattr.x;
   x11_top = wattr.y;
   if(x11_left < 0) x11_left = 0;
   if(x11_top < 0) x11_top = 0;
printf("Window color depth: %d  left/top:%dx%d\n", wattr.depth, x11_left,x11_top);


   // setup screen palette
   memset(palette,0xff,sizeof(palette));
   setup_palette();

//for(xx=0; xx<16; xx++) printf("pal %2d: %08lX\n", xx,palette[xx]);
//printf("white:  %08lX\n", WhitePixel(display,screen_num));

printf("Palette setup\n");
   /*  Set hints for window manager before mapping window  */

   if(XStringListToTextProperty(&window_name, 1, &windowName) == 0 ) {
      sprintf(out, "%s: structure allocation for windowName failed.\n", appname);
      error_exit(10007, out);
   }
printf("Text properties set.\n");
   if(XStringListToTextProperty(&icon_name, 1, &iconName) == 0 ) {
      sprintf(out, "%s: structure allocation for iconName failed.\n", appname);
      error_exit(10008, out);
   }
printf("Icon name set\n");
   /*  Create graphics context  */
printf("creating gc\n");
fflush(stdout);
   gc = XCreateGC(display,screen, 0, &values); // winz
   if(gc == 0) {
      sprintf(out, "Could not create graphics context");
      error_exit(10018, out);
   }

   // Create the icon pixmap
   i = read_pixmap_file();
   if(i) {  // XPM pixmap not loaded, try a monochrome XBM bitmap
      if(luxor) i = XReadBitmapFile(display,screen, "luxor.xbm", &j,&j, &icon_map, &i,&i);
      else      i = XReadBitmapFile(display,screen, "heather.xbm", &j,&j, &icon_map, &i,&i);
   }
   else {  // XPM pixmap created
      i = BitmapSuccess;
   }

   if(i != BitmapSuccess) {
printf("No icon image found.\n");
      icon_map = 0;
   }

   size_hints->flags       = PPosition | PSize | PMinSize;
   size_hints->min_width   = MIN_WIDTH;
   size_hints->min_height  = MIN_HEIGHT;

   if(icon_map) wm_hints->flags = StateHint | InputHint | IconPixmapHint;
   else         wm_hints->flags = StateHint | InputHint;
   wm_hints->initial_state = NormalState;
   wm_hints->input         = True;
   wm_hints->icon_pixmap   = icon_map;

   class_hints->res_name   = appname;
   if(luxor) class_hints->res_class  = "luxor";
   else      class_hints->res_class  = "heather";
printf("setting properties\n");
   XSetWMProperties(display,screen, &windowName, &iconName, 0,0, // winz- argv, argc,
                    size_hints, wm_hints, class_hints);

   wmDeleteMessage = XInternAtom(display, "WM_DELETE_WINDOW",  0);
   XSetWMProtocols(display,screen, &wmDeleteMessage, 1);


   if(kill_deco) {  // disable window decorations to get a full screen display
      deco_hints.flags = 2;
      deco_hints.functions = 0;
      deco_hints.decorations = 0;
      deco_hints.input_mode = 0;
      deco_hints.status = 0;

      deco = XInternAtom(display, "_MOTIF_WM_HINTS", 1);

      if(deco) {
printf("Killing window decorations!\n");
         touch_screen = 1;  // make sure virtual keyboard is available.
                            // If the window size does not match the monitor size
                            // you can lose access to the real keyboard.
         XChangeProperty(display,screen, deco,deco, 32, PropModeReplace, (unsigned char *) &deco_hints, 5);
      }
   }


   /*  Choose which events we want to handle  */

   XSelectInput(display,screen, ExposureMask | KeyPressMask | PointerMotionMask |
                ButtonPressMask | ButtonReleaseMask | StructureNotifyMask | EnterWindowMask | LeaveWindowMask);   // winz


   cur = XCreateFontCursor(display, 132);
   if(cur) XDefineCursor(display,screen, cur);    // winz


   XSetForeground(display,gc, WhitePixel(display, screen_num));


   /*  Display Window  */

   XMapWindow(display,screen);  // winz
printf("window mapped    Pixmap wh:%dx%d\n", width,height);
   pix_map = XCreatePixmap(display,screen, width,height, wattr.depth); // winz
   if(pix_map == 0) {
      error_exit(30000, "Could not create pix_map");
   }
printf("pixmap created\n");
   Sleep(X11_sleep);
   XFlush(display);

printf("Display size2: %dx%d\n", SCREEN_WIDTH,SCREEN_HEIGHT);
   SWAP(SCREEN_WIDTH,SCREEN_HEIGHT);
//SCREEN_WIDTH = old_sw;   //piss
//SCREEN_HEIGHT = old_sh;
   config_screen(why);  // re-initialize screen rendering variables
                        // to reflect any changes due to font size
   XFlush(display);

   #ifdef BUFFER_LLA
//lla clear_lla_points(0);
   #endif

printf("screen configured. why=%d  %dx%d (potentially rotated)\n", why, SCREEN_WIDTH,SCREEN_HEIGHT);
   erase_rectangle(0,0, SCREEN_WIDTH,SCREEN_HEIGHT);
printf("screen init done\n\n");
fflush(stdout);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl %edi, %ebx
movl 0x20c95c(%rip), %edx    # 0x218800
movl 0x20c95a(%rip), %ecx    # 0x218804
leaq 0xfdce6(%rip), %rdi     # 0x109b97
movl %ebx, %esi
xorl %eax, %eax
callq 0x9030
movl $0x3, %edi
callq 0xcf89
callq 0xc860
cmpl $0x0, 0x20c958(%rip)    # 0x218828
movl 0x20c92a(%rip), %eax    # 0x218800
movl 0x20c928(%rip), %esi    # 0x218804
je 0xbef4
movl %esi, 0x20c948(%rip)    # 0x21882c
movl %eax, 0x20c91a(%rip)    # 0x218804
movl %esi, 0x20c910(%rip)    # 0x218800
movl %eax, %edx
jmp 0xbef8
movl %esi, %edx
movl %eax, %esi
leaq 0xfdcc6(%rip), %rdi     # 0x109bc5
xorl %eax, %eax
callq 0x9030
movb 0x20c94c(%rip), %cl     # 0x218858
testb %cl, %cl
je 0xbf2a
movb $0x2, %al
cmpb $0x9, %cl
jae 0xbf6b
leaq 0x1444b2(%rip), %rcx    # 0x1503d0
movl $0x8, %esi
movb $0x8, %dl
jmp 0xbfc8
cmpb $0x0, 0x20c8ff(%rip)    # 0x218830
setne %cl
cmpl $0x0, 0x232fe9(%rip)    # 0x23ef24
sete %al
andb %cl, %al
leal (%rax,%rax), %edx
orb $0xc, %dl
movzbl %al, %edi
xorb $0x1, %al
addb %al, %al
leal 0xc(,%rdi,2), %esi
leaq 0x149c95(%rip), %r8     # 0x155bf0
leaq 0x14687e(%rip), %rcx    # 0x1527e0
testb %dil, %dil
cmovneq %r8, %rcx
jmp 0xbfc8
cmpb $0xd, %cl
jae 0xbf80
leaq 0x146869(%rip), %rcx    # 0x1527e0
movl $0xc, %esi
movb $0xc, %dl
jmp 0xbfc8
cmpb $0xf, %cl
jae 0xbf97
leaq 0x149c64(%rip), %rcx    # 0x155bf0
movl $0xe, %esi
movb $0xe, %dl
xorl %eax, %eax
jmp 0xbfc8
xorl %esi, %esi
cmpb $0x11, %cl
setae %al
setb %sil
leaq 0x14d856(%rip), %rdx    # 0x159800
leaq 0x14682f(%rip), %rcx    # 0x1527e0
cmovbq %rdx, %rcx
leal (,%rsi,4), %edx
addb $0xc, %dl
addb %al, %al
leal 0xc(,%rsi,4), %esi
movb %dl, 0x20c88a(%rip)     # 0x218858
movl %esi, 0x20c840(%rip)    # 0x218814
movl $0x8, 0x20c832(%rip)    # 0x218810
movb %al, 0x20c875(%rip)     # 0x218859
cmpb $0x0, 0x232f53(%rip)    # 0x23ef3e
leaq 0x151c1e(%rip), %rax    # 0x15dc10
leaq 0xfdbe9(%rip), %rdx     # 0x109be2
cmoveq %rax, %rdx
leaq 0xfdbe8(%rip), %rax     # 0x109bec
leaq 0x121d92(%rip), %rsi    # 0x12dd9d
cmoveq %rax, %rsi
movq %rcx, 0x333ed2(%rip)    # 0x33fee8
movq %rdx, -0x40(%rbp)
movq %rsi, -0x38(%rbp)
leaq 0xfdbd5(%rip), %rax     # 0x109bfa
leaq 0xfdbc8(%rip), %rcx     # 0x109bf4
cmoveq %rax, %rcx
movq %rcx, 0x164eb9(%rip)    # 0x170ef0
callq 0x9070
movq %rax, 0x333f15(%rip)    # 0x33ff58
testq %rax, %rax
je 0xc06a
callq 0x9280
movq %rax, 0x333f0c(%rip)    # 0x33ff60
testq %rax, %rax
je 0xc06a
callq 0x95a0
movq %rax, 0x333f03(%rip)    # 0x33ff68
testq %rax, %rax
jne 0xc096
movq 0x164e7f(%rip), %rdx    # 0x170ef0
leaq 0x3301a8(%rip), %r14    # 0x33c220
leaq 0xfdb83(%rip), %rsi     # 0x109c02
movq %r14, %rdi
xorl %eax, %eax
callq 0x9060
movl $0x2715, %edi           # imm = 0x2715
movq %r14, %rsi
callq 0xb424
xorl %edi, %edi
callq 0x94e0
movq %rax, 0x164e1c(%rip)    # 0x170ec0
testq %rax, %rax
jne 0xc0de
movq 0x164e40(%rip), %rdx    # 0x170ef0
leaq 0x330169(%rip), %r14    # 0x33c220
leaq 0xfdb63(%rip), %rsi     # 0x109c21
movq %r14, %rdi
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x9060
movl $0x2716, %edi           # imm = 0x2716
movq %r14, %rsi
callq 0xb424
movq 0x164de2(%rip), %rax    # 0x170ec0
movslq 0xe0(%rax), %rcx
movl %ecx, 0x164dfd(%rip)    # 0x170ee8
movq 0xe8(%rax), %rax
shlq $0x7, %rcx
movl 0x18(%rax,%rcx), %esi
movl %esi, 0x20c6f8(%rip)    # 0x2187f8
movl 0x1c(%rax,%rcx), %edx
movl %edx, 0x20c6f2(%rip)    # 0x2187fc
movl $0x1, 0x164d98(%rip)    # 0x170eac
movl 0x20c6e6(%rip), %ecx    # 0x218800
movl 0x20c6e3(%rip), %r8d    # 0x218804
movl 0x20c6fc(%rip), %r9d    # 0x218824
movl 0x20c6b2(%rip), %eax    # 0x2187e0
movl %eax, (%rsp)
leaq 0xfdb0e(%rip), %rdi     # 0x109c46
xorl %eax, %eax
callq 0x9030
movl 0x20c69b(%rip), %eax    # 0x2187e0
testl %eax, %eax
setne %cl
movl 0x20c6a8(%rip), %esi    # 0x2187f8
movl $0x140, %edi            # imm = 0x140
cmpl %edi, %esi
setae %r8b
movl 0x20c69b(%rip), %edx    # 0x2187fc
cmpl %edi, %edx
setae %dil
andb %r8b, %dil
andb %cl, %dil
cmpb $0x1, %dil
jne 0xc18b
movl %esi, 0x20c687(%rip)    # 0x218800
movl %edx, 0x20c685(%rip)    # 0x218804
movl $0x0, 0x20c657(%rip)    # 0x2187e0
xorl %eax, %eax
movl 0x20c692(%rip), %r9d    # 0x218824
testl %r9d, %r9d
je 0xc1a6
movl $0x1, 0x20c63f(%rip)    # 0x2187e0
movl $0x1, %eax
movl 0x20c654(%rip), %ecx    # 0x218800
movl 0x20c651(%rip), %r8d    # 0x218804
movl %eax, (%rsp)
leaq 0xfdacc(%rip), %rdi     # 0x109c89
xorl %eax, %eax
callq 0x9030
movl 0x20c636(%rip), %eax    # 0x218800
cmpl 0x20c628(%rip), %eax    # 0x2187f8
jae 0xc1e0
movl 0x20c62c(%rip), %eax    # 0x218804
cmpl 0x20c61e(%rip), %eax    # 0x2187fc
jb 0xc249
cmpl $0x0, 0x164cd5(%rip)    # 0x170ebc
je 0xc233
movl 0x164cc1(%rip), %esi    # 0x170eb0
movl 0x164cbf(%rip), %edx    # 0x170eb4
movl 0x164cbd(%rip), %ecx    # 0x170eb8
testl %esi, %esi
je 0xc20b
movl %edx, 0x20c5fb(%rip)    # 0x218800
movl %ecx, 0x20c5f9(%rip)    # 0x218804
movl $0x0, 0x164ca7(%rip)    # 0x170ebc
movl 0x20c634(%rip), %r8d    # 0x218850
movl 0x20c631(%rip), %r9d    # 0x218854
leaq 0xfdaa3(%rip), %rdi     # 0x109ccd
xorl %eax, %eax
callq 0x9030
jmp 0xc249
movl $0x1, 0x164c7f(%rip)    # 0x170ebc
leaq 0xff49e(%rip), %rdi     # 0x10b6e2
callq 0x95d0
movl 0x164ca8(%rip), %r12d   # 0x170ef8
movl 0x164ca5(%rip), %r13d   # 0x170efc
movl 0x20c5a2(%rip), %r14d   # 0x218800
movl 0x20c59f(%rip), %r15d   # 0x218804
leaq 0xfda8a(%rip), %rdi     # 0x109cf6
movl %r14d, %esi
movl %r15d, %edx
movl %r12d, %ecx
movl %r13d, %r8d
xorl %eax, %eax
callq 0x9030
movq 0x164c3a(%rip), %rdi    # 0x170ec0
movq 0xe8(%rdi), %rax
movslq 0x164c54(%rip), %rcx    # 0x170ee8
shlq $0x7, %rcx
movq 0x10(%rax,%rcx), %rsi
movdqu 0x58(%rax,%rcx), %xmm0
movdqu %xmm0, 0x8(%rsp)
movl $0x0, (%rsp)
movl %r12d, %edx
movl %r13d, %ecx
movl %r14d, %r8d
movl %r15d, %r9d
callq 0x90c0
movq %rax, 0x164c00(%rip)    # 0x170ec8
testq %rax, %rax
jne 0xc2de
leaq 0xfda49(%rip), %rsi     # 0x109d1d
movl $0x271a, %edi           # imm = 0x271A
callq 0xb424
leaq 0xff40d(%rip), %rdi     # 0x10b6f2
callq 0x95d0
movq 0x164bcf(%rip), %rdi    # 0x170ec0
movq 0x164bd0(%rip), %rsi    # 0x170ec8
leaq 0x333c71(%rip), %rdx    # 0x33ff70
callq 0x96d0
movl 0x333c66(%rip), %edx    # 0x33ff70
movl %edx, 0x164be8(%rip)    # 0x170ef8
movl 0x333c5e(%rip), %ecx    # 0x33ff74
movl %ecx, 0x164be0(%rip)    # 0x170efc
testl %edx, %edx
jns 0xc32c
movl $0x0, 0x164bce(%rip)    # 0x170ef8
xorl %edx, %edx
testl %ecx, %ecx
jns 0xc33c
movl $0x0, 0x164bc2(%rip)    # 0x170efc
xorl %ecx, %ecx
movl 0x333c42(%rip), %esi    # 0x33ff84
leaq 0xfd9f7(%rip), %rdi     # 0x109d40
xorl %eax, %eax
callq 0x9030
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0x164c24(%rip)   # 0x170f80
movdqa %xmm0, 0x164c2c(%rip)   # 0x170f90
movdqa %xmm0, 0x164c34(%rip)   # 0x170fa0
movdqa %xmm0, 0x164c3c(%rip)   # 0x170fb0
callq 0xd3bb
leaq 0xff388(%rip), %rdi     # 0x10b708
callq 0x95d0
leaq -0x40(%rbp), %rdi
leaq -0x98(%rbp), %rdx
movl $0x1, %esi
callq 0x9380
testl %eax, %eax
jne 0xc3ca
movq 0x164b4b(%rip), %rdx    # 0x170ef0
leaq 0x32fe74(%rip), %r12    # 0x33c220
leaq 0xfd9b5(%rip), %rsi     # 0x109d68
movq %r12, %rdi
xorl %eax, %eax
callq 0x9060
movl $0x2717, %edi           # imm = 0x2717
movq %r12, %rsi
callq 0xb424
leaq 0xff345(%rip), %rdi     # 0x10b716
callq 0x95d0
leaq -0x38(%rbp), %rdi
leaq -0x78(%rbp), %rdx
movl $0x1, %esi
callq 0x9380
testl %eax, %eax
jne 0xc418
movq 0x164afd(%rip), %rdx    # 0x170ef0
leaq 0x32fe26(%rip), %r12    # 0x33c220
leaq 0xfd998(%rip), %rsi     # 0x109d99
movq %r12, %rdi
xorl %eax, %eax
callq 0x9060
movl $0x2718, %edi           # imm = 0x2718
movq %r12, %rsi
callq 0xb424
leaq 0xff30c(%rip), %rdi     # 0x10b72b
callq 0x95d0
leaq 0xff30e(%rip), %rdi     # 0x10b739
callq 0x95d0
movq 0x143a39(%rip), %r13    # 0x14fe70
movq (%r13), %rdi
callq 0x9420
movq 0x164a79(%rip), %rdi    # 0x170ec0
movq 0x164a7a(%rip), %rsi    # 0x170ec8
leaq -0x118(%rbp), %rcx
xorl %edx, %edx
callq 0x9180
movq %rax, 0x164a7d(%rip)    # 0x170ee0
testq %rax, %rax
jne 0xc4a0
movups 0xfd969(%rip), %xmm0    # 0x109dd8
movaps %xmm0, 0x32fdba(%rip)   # 0x33c230
movdqu 0xfd94a(%rip), %xmm0    # 0x109dc8
movdqa %xmm0, 0x32fd9a(%rip)   # 0x33c220
movw $0x74, 0x32fdb1(%rip)   # 0x33c240
leaq 0x32fd8a(%rip), %rsi    # 0x33c220
movl $0x2722, %edi           # imm = 0x2722
callq 0xb424
callq 0xc99b
movl %eax, -0x2c(%rbp)
testl %eax, %eax
je 0xc514
cmpb $0x0, 0x232a8b(%rip)    # 0x23ef3e
movq 0x164a06(%rip), %rdi    # 0x170ec0
movq 0x164a07(%rip), %rsi    # 0x170ec8
leaq 0xfd92c(%rip), %rax     # 0x109df4
leaq 0xfd91b(%rip), %rdx     # 0x109dea
cmoveq %rax, %rdx
leaq -0x2c(%rbp), %r12
movq %r12, 0x8(%rsp)
movq %r12, (%rsp)
leaq 0x1649f1(%rip), %r9     # 0x170ed8
leaq -0x44(%rbp), %rcx
movq %rcx, %r8
callq 0x9670
movl %eax, (%r12)
testl %eax, %eax
je 0xc51b
leaq 0xff243(%rip), %rdi     # 0x10b745
callq 0x95d0
movq $0x0, 0x1649c6(%rip) # 0x170ed8
jmp 0xc51b
movl $0x0, -0x2c(%rbp)
movq 0x333a36(%rip), %rax    # 0x33ff58
movq $0x1c, (%rax)
movabsq $0x14000000140, %rcx    # imm = 0x14000000140
movq %rcx, 0x18(%rax)
xorl %eax, %eax
cmpq $0x0, 0x164997(%rip)    # 0x170ed8
setne %al
movq 0x333a15(%rip), %rcx    # 0x33ff60
leaq 0x3(,%rax,4), %rax
movq %rax, (%rcx)
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x8(%rcx)
movq 0x16496d(%rip), %rax    # 0x170ed8
movq %rax, 0x10(%rcx)
movq 0x16497a(%rip), %rax    # 0x170ef0
movq 0x3339eb(%rip), %rcx    # 0x33ff68
movq %rax, (%rcx)
cmpb $0x0, 0x2329b7(%rip)    # 0x23ef3e
leaq 0xfd4cc(%rip), %rax     # 0x109a5a
leaq 0xfd86b(%rip), %rcx     # 0x109e00
cmoveq %rax, %rcx
movq 0x3339c8(%rip), %rax    # 0x33ff68
movq %rcx, 0x8(%rax)
leaq 0xff1af(%rip), %rdi     # 0x10b75a
callq 0x95d0
movq 0x164909(%rip), %rdi    # 0x170ec0
movq 0x16490a(%rip), %rsi    # 0x170ec8
movq 0x333993(%rip), %rax    # 0x33ff58
movq 0x333994(%rip), %rcx    # 0x33ff60
movq 0x333995(%rip), %rdx    # 0x33ff68
movq %rdx, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
movq %rax, (%rsp)
leaq -0x98(%rbp), %rdx
leaq -0x78(%rbp), %rcx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x94f0
movq 0x1648c2(%rip), %rdi    # 0x170ec0
leaq 0xfd801(%rip), %rsi     # 0x109e06
xorl %edx, %edx
callq 0x9250
movq %rax, 0x3339e5(%rip)    # 0x33fff8
leaq 0x3339de(%rip), %rdx    # 0x33fff8
movq 0x16489f(%rip), %rdi    # 0x170ec0
movq 0x1648a0(%rip), %rsi    # 0x170ec8
movl $0x1, %ecx
callq 0x91c0
cmpl $0x0, 0x20c1eb(%rip)    # 0x218824
je 0xc6b0
movl $0x2, -0x58(%rbp)
pxor %xmm0, %xmm0
movdqu %xmm0, -0x54(%rbp)
movq 0x16486e(%rip), %rdi    # 0x170ec0
leaq 0xfd7be(%rip), %rsi     # 0x109e17
movl $0x1, %edx
callq 0x9250
testq %rax, %rax
je 0xc6b0
movq %rax, %r12
leaq 0xff0fb(%rip), %rdi     # 0x10b76d
callq 0x95d0
movb $0x1, 0x20eba0(%rip)    # 0x21b21e
movq 0x16483b(%rip), %rdi    # 0x170ec0
movq 0x16483c(%rip), %rsi    # 0x170ec8
leaq -0x58(%rbp), %rax
movq %rax, (%rsp)
movl $0x5, 0x8(%rsp)
movq %r12, %rdx
movq %r12, %rcx
movl $0x20, %r8d
xorl %r9d, %r9d
callq 0x92f0
movq 0x164809(%rip), %rdi    # 0x170ec0
movq 0x16480a(%rip), %rsi    # 0x170ec8
movl $0x2807d, %edx          # imm = 0x2807D
callq 0x9210
movq 0x1647f1(%rip), %rdi    # 0x170ec0
movl $0x84, %esi
callq 0x91d0
testq %rax, %rax
je 0xc6f4
movq 0x1647db(%rip), %rdi    # 0x170ec0
movq 0x1647dc(%rip), %rsi    # 0x170ec8
movq %rax, %rdx
callq 0x9690
movq 0x1647c5(%rip), %rdi    # 0x170ec0
movq 0x1647de(%rip), %rsi    # 0x170ee0
movq 0xe8(%rdi), %rax
movslq 0x1647d8(%rip), %rcx    # 0x170ee8
shlq $0x7, %rcx
movq 0x58(%rax,%rcx), %rdx
callq 0x90d0
movq 0x16479b(%rip), %rdi    # 0x170ec0
movq 0x16479c(%rip), %rsi    # 0x170ec8
callq 0x93f0
leaq 0xfd6ef(%rip), %rdi     # 0x109e27
movl %r14d, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0x9030
movq 0x164774(%rip), %rdi    # 0x170ec0
movq 0x164775(%rip), %rsi    # 0x170ec8
movl 0x33382a(%rip), %r8d    # 0x33ff84
movl %r14d, %edx
movl %r15d, %ecx
callq 0x90b0
movq %rax, 0x164764(%rip)    # 0x170ed0
testq %rax, %rax
jne 0xc782
leaq 0xfd6d1(%rip), %rsi     # 0x109e49
movl $0x7530, %edi           # imm = 0x7530
callq 0xb424
leaq 0xff017(%rip), %rdi     # 0x10b7a0
callq 0x95d0
movl $0x186a0, %edi          # imm = 0x186A0
callq 0x9540
movq 0x164721(%rip), %rdi    # 0x170ec0
callq 0x95c0
movl 0x20c056(%rip), %esi    # 0x218800
movl 0x20c054(%rip), %edx    # 0x218804
leaq 0xfd6ab(%rip), %rdi     # 0x109e62
xorl %eax, %eax
callq 0x9030
cmpl $0x0, 0x20c063(%rip)    # 0x218828
je 0xc7e5
movl 0x20c037(%rip), %eax    # 0x218804
movl %eax, 0x20c059(%rip)    # 0x21882c
movl 0x20c027(%rip), %ecx    # 0x218800
movl %ecx, 0x20c025(%rip)    # 0x218804
movl %eax, 0x20c01b(%rip)    # 0x218800
movl %ebx, %edi
callq 0xcf89
movq 0x1646cd(%rip), %rdi    # 0x170ec0
callq 0x95c0
movl 0x20c002(%rip), %edx    # 0x218800
movl 0x20c000(%rip), %ecx    # 0x218804
leaq 0xfd66d(%rip), %rdi     # 0x109e78
movl %ebx, %esi
xorl %eax, %eax
callq 0x9030
movl 0x20bfe6(%rip), %edx    # 0x218800
movl 0x20bfe4(%rip), %ecx    # 0x218804
xorl %edi, %edi
xorl %esi, %esi
xorl %r8d, %r8d
callq 0xf298
leaq 0xfef56(%rip), %rdi     # 0x10b789
callq 0x95d0
movq (%r13), %rdi
callq 0x9420
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq