// File: /workspace/github_c_makefile_star2_O3/jonof[P]jftekwar/src/tekmsc.c
// Function: domenu
void
domenu(void)
{
     char pal;
     int  i;
     int dax,dax2,day,day2;
     struct menu *mptr;
     static int firstpass;
    #ifdef DYNAMICSAVESETUP
     static int odiff,osoundv,omusicv,omousesens,oheadb;
    #endif

     if (activemenu == HELPSCREEN) {
          showhelpscreen();
          return;
     }
     if (firstpass == 0) {
          firstpass=1;
          getloadsavenames();
         #ifdef DYNAMICSAVESETUP
          odiff=difficulty;
          osoundv=soundv;
          omusicv=musicv;
          omousesens=mousesensitivity;
          oheadb=headbobon;
         #endif
          if (headbobon) {
               strcpy(headbobstr,"HEAD BOB ON");
          }
          else {
               strcpy(headbobstr,"HEAD BOB OFF");
          }
     }
     if (activemenu == 255) {
         #ifdef DYNAMICSAVESETUP
          if (odiff != difficulty || osoundv != soundv
             || omusicv != musicv || omousesens != mousesensitivity
             || oheadb != headbobon) {
               teksavesetup();
          }
         #endif
          playsound( S_MENUSOUND2 ,0,0,0,ST_IMMEDIATE);
          setup3dscreen();
          activemenu=0;
          firstpass=0;
          return;
     }
     vel=svel=angvel=0;
     mptr=&menu[activemenu][0];
     if (redrawborders) {
          dax=windowx1;
          dax2=windowx2;
          day=windowy1;
          day2=windowy2;
          if (dax2-dax < xdim-1 || day2-day < ydim-1) {
               setup3dscreen();
          }
          redrawborders=0;
     }
     if (selopt == 0) {
          switch (activemenu) {
          case MENULOADGAME:
          case MENUSAVEGAME:
               selopt=1;
               break;
          }
     }
     showmenu();
     for (i=0 ; i < MAXSUBOPTIONS ; i++) {
          if (mptr->label != NULL) {
               if (selopt == i) {
                    pal=4;
               }
               else {
                    pal=mptr->pal;
               }
               mprintf(mptr->x,mptr->y,mptr->proportional,mptr->shade,pal,
                    mptr->label);
               if (mptr->nextopt != NULL) {
                    mptr=mptr->nextopt;
               }
               else {
                    break;
               }
          }
     }
     if (activemenu == 5 && loadnewgame) {   // select a mission
          switch (loadnewgame) {
          case 1:   // day mission
               newgame("city.map");
               break;
          case 2:   // night mission
               newgame("hospital.map");
               break;
          case 3:
               newgame("police.map");
               break;
          case 4:
               newgame("warehse.map");
               break;
          }
          loadnewgame=0;
          activemenu=255;
     }
     if (activemenu == 6 || activemenu == 7) {    // load/save a game
          dax=(xdim>>1)-((MAXLOADSAVESIZE*tilesizx[MFONT_A])>>1);
          dax-=tilesizx[MFONT_A];
          for (i=1 ; i <= MAXLOADSAVEOPTS ; i++) {
               if (selopt == i) {
                    pal=4;
                    if (loctypemode == 0) {
                         mprintf(dax,2+i,0,0,pal,"%d %s",i,loadsavenames[i-1]);
                    }
                    else {
                         mprintf(dax,2+i,0,0,pal,"%d %s",i,lockeybuf);
                         if (totalclock > curblinkclock) {
                              curblinkclock=totalclock+(CLKIPS>>2);
                              curblink^=1;
                         }
                         if (curblink) {
                              day=((2+i)*MFONTYSTEP)+3;
                              if (ydim >= 400) {
                                   day<<=1;
                              }
                              rotatesprite((dax+(((int)strlen(lockeybuf)+1)*16)+5)<<16, day<<16, 65536l, 0, YELLOWLIGHTPIC,
                                   0, 0, 8+16, 0, 0, xdim-1, ydim-1);
                         }
                    }
               }
               else {
                    pal=1;
                    mprintf(dax,2+i,0,0,pal,"%d %s",i,loadsavenames[i-1]);
               }
          }
     }
     else if (activemenu == 8) {   // sound/music volume
          dax=(xdim>>1)-(tilesizx[SLIDERBARPIC]>>1);
          day=50;
          if (ydim >= 400) {
               day<<=1;
          }
          rotatesprite(dax<<16, day<<16, 65536l, 0, SLIDERBARPIC,
               0, 0, 8+16, 0, 0, xdim-1, ydim-1);
          rotatesprite((dax+10+(soundv*7))<<16, day<<16, 65536l, 0, SLIDERKNOBPIC,
               0, 0, 8+16, 0, 0, xdim-1, ydim-1);
          day=86;
          if (ydim >= 400) {
               day<<=1;
          }
          rotatesprite(dax<<16, day<<16, 65536l, 0, SLIDERBARPIC,
               0, 0, 8+16, 0, 0, xdim-1, ydim-1);
          rotatesprite((dax+10+(musicv*7))<<16, day<<16, 65536l, 0, SLIDERKNOBPIC,
               0, 0, 8+16, 0, 0, xdim-1, ydim-1);
     }
     else if (activemenu == 9) {   // mouse sensitivity
          dax=(xdim>>1)-(tilesizx[SLIDERBARPIC]>>1);
          day=26;
          if (ydim >= 400) {
               day<<=1;
          }
          rotatesprite(dax<<16, day<<16, 65536l, 0, SLIDERBARPIC,
               0, 0, 8+16, 0, 0, xdim-1, ydim-1);
          dax+=(10+(mousesensitivity*7));
          rotatesprite(dax<<16, day<<16, 65536l, 0, SLIDERKNOBPIC,
               0, 0, 8+16, 0, 0, xdim-1, ydim-1);
     }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl 0x118b31(%rip), %eax    # 0x12f4f4
cmpl $0x63, %eax
jne 0x169db
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x178b4
cmpb $0x0, 0x11a61a(%rip)    # 0x130ffc
jne 0x16a37
movb $0x1, 0x11a611(%rip)    # 0x130ffc
callq 0x1741c
leaq 0xbbee9(%rip), %rax     # 0xd28e0
cmpl $0x0, (%rax)
movabsq $0x424f422044414548, %rax # imm = 0x424F422044414548
je 0x16a19
movq %rax, 0xbb353(%rip)     # 0xd1d60
movl $0x4e4f20, 0xbb351(%rip) # imm = 0x4E4F20
jmp 0x16a31
movabsq $0x46464f20424f42, %rcx # imm = 0x46464F20424F42
movq %rcx, 0xbb33b(%rip)     # 0xd1d65
movq %rax, 0xbb32f(%rip)     # 0xd1d60
movl 0x118abd(%rip), %eax    # 0x12f4f4
cmpl $0xff, %eax
jne 0x16a6f
movl $0x35, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x1c370
callq 0x14983
movl $0x0, 0x118a91(%rip)    # 0x12f4f4
movb $0x0, 0x11a592(%rip)    # 0x130ffc
jmp 0x16ed5
leaq 0xced72(%rip), %rcx     # 0xe57e8
xorl %edx, %edx
movl %edx, (%rcx)
leaq 0xced63(%rip), %rcx     # 0xe57e4
movl %edx, (%rcx)
leaq 0xced56(%rip), %rcx     # 0xe57e0
movl %edx, (%rcx)
cltq
leaq (%rax,%rax,2), %r14
cmpb $0x0, 0x11a564(%rip)    # 0x130ffd
je 0x16ae9
leaq 0x56c14e(%rip), %rax    # 0x582bf0
leaq 0x5a23b7(%rip), %rcx    # 0x5b8e60
movl (%rcx), %ecx
subl (%rax), %ecx
leaq 0x5a23b8(%rip), %rax    # 0x5b8e6c
movl (%rax), %eax
decl %eax
cmpl %eax, %ecx
jl 0x16add
leaq 0x5a23a1(%rip), %rax    # 0x5b8e64
movl (%rax), %eax
leaq 0x56df34(%rip), %rcx    # 0x584a00
subl (%rcx), %eax
leaq 0x5a239b(%rip), %rcx    # 0x5b8e70
movl (%rcx), %ecx
decl %ecx
cmpl %ecx, %eax
jge 0x16ae2
callq 0x14983
movb $0x0, 0x11a514(%rip)    # 0x130ffd
shlq $0x6, %r14
leaq 0xbb27c(%rip), %rbx     # 0xd1d70
cmpl $0x0, 0xbbaf9(%rip)     # 0xd25f4
jne 0x16b15
movl 0x1189f1(%rip), %eax    # 0x12f4f4
andl $-0x2, %eax
cmpl $0x6, %eax
jne 0x16b15
movl $0x1, 0xbbadf(%rip)     # 0xd25f4
addq %r14, %rbx
callq 0x17772
xorl %ebp, %ebp
movq 0x8(%rbx), %r9
testq %r9, %r9
je 0x16b58
movb $0x4, %al
cmpl 0xbbac4(%rip), %ebp     # 0xd25f4
je 0x16b35
movb 0x6(%rbx), %al
movswl (%rbx), %edi
movswl 0x2(%rbx), %esi
movsbl 0x4(%rbx), %edx
movsbl 0x5(%rbx), %ecx
movsbl %al, %r8d
xorl %eax, %eax
callq 0x174ba
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
je 0x16b5f
incl %ebp
cmpl $0x6, %ebp
jne 0x16b1f
movl 0x11898f(%rip), %eax    # 0x12f4f4
cmpl $0x5, %eax
sete %dl
movl 0x11a48f(%rip), %ecx    # 0x131000
testl %ecx, %ecx
setne %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x16bb5
cmpl $0x4, %ecx
ja 0x16b9c
movslq %ecx, %rax
leaq 0x78a45(%rip), %rcx     # 0x8f5d4
movslq -0x4(%rcx,%rax,4), %rdi
addq %rcx, %rdi
callq 0x1705b
movl $0x0, 0x11a45a(%rip)    # 0x131000
movl $0xff, 0x118944(%rip)   # 0x12f4f4
jmp 0x16ed5
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x6, %ecx
jne 0x16d62
leaq 0x5a22a2(%rip), %rax    # 0x5b8e6c
movl (%rax), %eax
sarl %eax
leaq 0x5aa2cb(%rip), %rcx    # 0x5c0ea0
movswl 0xbaa(%rcx), %ecx
leal (,%rcx,4), %edx
leal (%rdx,%rdx,2), %edx
sarl %edx
addl %ecx, %edx
subl %edx, %eax
movswl %ax, %ebx
shll $0x10, %eax
addl $0x100000, %eax         # imm = 0x100000
movq %rax, 0x10(%rsp)
movl $0x1, %r12d
movl $0x27, %ebp
leaq 0x11a3b2(%rip), %r13    # 0x130fc0
leaq 0x78f5c(%rip), %r14     # 0x8fb71
movl %ebx, 0xc(%rsp)
movl 0xbb9d5(%rip), %eax     # 0xd25f4
cmpq %rax, %r12
jne 0x16c85
cmpl $0x0, 0x11a3d9(%rip)    # 0x131004
je 0x16c9b
leal 0x2(%r12), %eax
movswl %ax, %esi
movl %ebx, %edi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x4, %r8d
movq %r14, %r9
xorl %eax, %eax
leaq 0x11a3bb(%rip), %r10    # 0x131008
pushq %r10
pushq %r12
callq 0x174ba
addq $0x10, %rsp
leaq 0x546707(%rip), %rax    # 0x55d368
movl (%rax), %eax
cmpl 0x11a3ab(%rip), %eax    # 0x131014
jle 0x16cc6
addl $0x1e, %eax
movl %eax, 0x11a3a0(%rip)    # 0x131014
movl 0x11a39e(%rip), %eax    # 0x131018
xorl $0x1, %eax
movl %eax, 0x11a395(%rip)    # 0x131018
jmp 0x16ccc
leal 0x2(%r12), %eax
movswl %ax, %esi
movl %ebx, %edi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
jmp 0x16caf
leal 0x2(%r12), %eax
movswl %ax, %esi
movl %ebx, %edi
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x4, %r8d
movq %r14, %r9
xorl %eax, %eax
pushq %r13
pushq %r12
callq 0x174ba
addq $0x10, %rsp
jmp 0x16d49
movl 0x11a34c(%rip), %eax    # 0x131018
testl %eax, %eax
je 0x16d49
movq %r14, %rbx
leaq 0x5a2196(%rip), %rax    # 0x5b8e70
movl (%rax), %r14d
cmpl $0x190, %r14d           # imm = 0x190
setge %cl
movl %ebp, %r15d
shll %cl, %r15d
leaq 0x11a314(%rip), %rdi    # 0x131008
callq 0x85a0
shll $0x14, %eax
movq 0x10(%rsp), %rcx
leal (%rax,%rcx), %edi
addl $0x50000, %edi          # imm = 0x50000
shll $0x10, %r15d
leaq 0x5a2157(%rip), %rax    # 0x5b8e6c
movl (%rax), %eax
decl %eax
decl %r14d
movl %r15d, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x624, %r8d            # imm = 0x624
xorl %r9d, %r9d
pushq %r14
movq %rbx, %r14
movl 0x14(%rsp), %ebx
pushq %rax
xorl %eax, %eax
pushq %rax
pushq %rax
pushq $0x18
pushq %rax
callq 0x4dcbd
addq $0x30, %rsp
incq %r12
addl $0xc, %ebp
addq $0xc, %r13
cmpq $0x6, %r12
jne 0x16c19
jmp 0x16ed5
cmpl $0x9, %eax
je 0x16ee4
cmpl $0x8, %eax
jne 0x16ed5
leaq 0x5a20f1(%rip), %r12    # 0x5b8e6c
movl (%r12), %eax
movl %eax, %r13d
sarl %r13d
leaq 0x5aa114(%rip), %rcx    # 0x5c0ea0
movswl 0xc42(%rcx), %ecx
shrl %ecx
movzwl %cx, %ecx
subl %ecx, %r13d
leaq 0x5a20ce(%rip), %r15    # 0x5b8e70
movl (%r15), %r10d
movl $0x190, %ecx            # imm = 0x190
cmpl %ecx, %r10d
movl $0x640000, %ecx         # imm = 0x640000
movl $0x320000, %ebp         # imm = 0x320000
cmovgel %ecx, %ebp
movl %r13d, %ebx
shll $0x10, %ebx
decl %eax
decl %r10d
xorl %r14d, %r14d
movl $0x18, %r11d
movl %ebx, %edi
movl %ebp, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x621, %r8d            # imm = 0x621
xorl %r9d, %r9d
pushq %r10
pushq %rax
pushq %r14
pushq %r14
pushq %r11
pushq %r14
callq 0x4dcbd
addq $0x30, %rsp
movl 0xbb800(%rip), %eax     # 0xd25fc
leal (,%rax,8), %ecx
subl %eax, %ecx
leal (%rcx,%r13), %edi
addl $0xa, %edi
shll $0x10, %edi
movl (%r12), %eax
decl %eax
movl (%r15), %r10d
decl %r10d
movl %ebp, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x626, %r8d            # imm = 0x626
xorl %r9d, %r9d
pushq %r10
pushq %rax
pushq %r14
pushq %r14
movl $0x18, %eax
pushq %rax
pushq %r14
callq 0x4dcbd
addq $0x30, %rsp
movl (%r15), %eax
movl $0x190, %ecx            # imm = 0x190
cmpl %ecx, %eax
movl $0xac0000, %ecx         # imm = 0xAC0000
movl $0x560000, %ebp         # imm = 0x560000
cmovgel %ecx, %ebp
movl (%r12), %r10d
decl %r10d
decl %eax
movl %ebx, %edi
movl %ebp, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x621, %r8d            # imm = 0x621
xorl %r9d, %r9d
pushq %rax
pushq %r10
pushq %r14
pushq %r14
movl $0x18, %ebx
pushq %rbx
pushq %r14
callq 0x4dcbd
addq $0x30, %rsp
movl 0xbb761(%rip), %eax     # 0xd25f8
leal (,%rax,8), %ecx
subl %eax, %ecx
leal (%rcx,%r13), %edi
addl $0xa, %edi
shll $0x10, %edi
movl (%r12), %eax
decl %eax
movl (%r15), %r10d
decl %r10d
movl %ebp, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x626, %r8d            # imm = 0x626
xorl %r9d, %r9d
pushq %r10
pushq %rax
pushq %r14
pushq %r14
pushq %rbx
jmp 0x16fa0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5a1f81(%rip), %r15    # 0x5b8e6c
movl (%r15), %eax
movl %eax, %ebp
sarl %ebp
leaq 0x5a9fa7(%rip), %rcx    # 0x5c0ea0
movswl 0xc42(%rcx), %ecx
shrl %ecx
movzwl %cx, %ecx
subl %ecx, %ebp
leaq 0x5a1f62(%rip), %r13    # 0x5b8e70
movl (%r13), %r10d
cmpl $0x190, %r10d           # imm = 0x190
movl $0x340000, %ecx         # imm = 0x340000
movl $0x1a0000, %ebx         # imm = 0x1A0000
cmovgel %ecx, %ebx
movl %ebp, %edi
shll $0x10, %edi
decl %eax
decl %r10d
xorl %r14d, %r14d
movl $0x18, %r12d
movl %ebx, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x621, %r8d            # imm = 0x621
xorl %r9d, %r9d
pushq %r10
pushq %rax
pushq %r14
pushq %r14
pushq %r12
pushq %r14
callq 0x4dcbd
addq $0x30, %rsp
movl 0x11a0b7(%rip), %eax    # 0x13101c
leal (,%rax,8), %edi
subl %eax, %edi
addl %ebp, %edi
shll $0x10, %edi
addl $0xa0000, %edi          # imm = 0xA0000
movl (%r15), %eax
decl %eax
movl (%r13), %r10d
decl %r10d
movl %ebx, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x626, %r8d            # imm = 0x626
xorl %r9d, %r9d
pushq %r10
pushq %rax
pushq %r14
pushq %r14
pushq %r12
pushq %r14
callq 0x4dcbd
addq $0x48, %rsp
jmp 0x16ed9