// File: /workspace/github_c_makefile_star2_O2/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 0x10ff53(%rip), %eax    # 0x1254f4
cmpl $0x63, %eax
jne 0x155b9
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16431
cmpb $0x0, 0x111a3c(%rip)    # 0x126ffc
jne 0x15615
movb $0x1, 0x111a33(%rip)    # 0x126ffc
callq 0x15fa2
leaq 0xb330b(%rip), %rax     # 0xc88e0
cmpl $0x0, (%rax)
movabsq $0x424f422044414548, %rax # imm = 0x424F422044414548
je 0x155f7
movq %rax, 0xb2775(%rip)     # 0xc7d60
movl $0x4e4f20, 0xb2773(%rip) # imm = 0x4E4F20
jmp 0x1560f
movabsq $0x46464f20424f42, %rcx # imm = 0x46464F20424F42
movq %rcx, 0xb275d(%rip)     # 0xc7d65
movq %rax, 0xb2751(%rip)     # 0xc7d60
movl 0x10fedf(%rip), %eax    # 0x1254f4
cmpl $0xff, %eax
jne 0x15646
pushq $0x35
popq %rdi
pushq $0x1
popq %r8
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x1ab2a
callq 0x134f8
andl $0x0, 0x10feba(%rip)    # 0x1254f4
movb $0x0, 0x1119bb(%rip)    # 0x126ffc
jmp 0x15787
leaq 0xc619b(%rip), %rcx     # 0xdb7e8
andl $0x0, (%rcx)
leaq 0xc618d(%rip), %rcx     # 0xdb7e4
andl $0x0, (%rcx)
leaq 0xc617f(%rip), %rcx     # 0xdb7e0
andl $0x0, (%rcx)
movslq %eax, %rbx
cmpb $0x0, 0x11198f(%rip)    # 0x126ffd
je 0x156be
leaq 0x563579(%rip), %rax    # 0x578bf0
leaq 0x5997e2(%rip), %rcx    # 0x5aee60
movl (%rcx), %ecx
subl (%rax), %ecx
leaq 0x5997e3(%rip), %rax    # 0x5aee6c
movl (%rax), %eax
decl %eax
cmpl %eax, %ecx
jl 0x156b2
leaq 0x5997cc(%rip), %rax    # 0x5aee64
movl (%rax), %eax
leaq 0x56535f(%rip), %rcx    # 0x57aa00
subl (%rcx), %eax
leaq 0x5997c6(%rip), %rcx    # 0x5aee70
movl (%rcx), %ecx
decl %ecx
cmpl %ecx, %eax
jge 0x156b7
callq 0x134f8
movb $0x0, 0x11193f(%rip)    # 0x126ffd
imulq $0xc0, %rbx, %rax
leaq 0xb26a4(%rip), %rbx     # 0xc7d70
cmpl $0x0, 0xb2f21(%rip)     # 0xc85f4
jne 0x156ed
movl 0x10fe19(%rip), %ecx    # 0x1254f4
andl $-0x2, %ecx
cmpl $0x6, %ecx
jne 0x156ed
movl $0x1, 0xb2f07(%rip)     # 0xc85f4
addq %rax, %rbx
callq 0x162e0
xorl %ebp, %ebp
cmpl $0x6, %ebp
je 0x15739
movq 0x8(%rbx), %r9
testq %r9, %r9
je 0x15735
movb $0x4, %al
cmpl 0xb2ee7(%rip), %ebp     # 0xc85f4
je 0x15712
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 0x1603c
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
je 0x15739
incl %ebp
jmp 0x156f7
movl 0x10fdb5(%rip), %eax    # 0x1254f4
cmpl $0x5, %eax
sete %dl
movl 0x1118b5(%rip), %ecx    # 0x127000
testl %ecx, %ecx
setne %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x15796
cmpl $0x4, %ecx
ja 0x15776
movslq %ecx, %rax
leaq 0x6be6b(%rip), %rcx     # 0x815d4
movslq -0x4(%rcx,%rax,4), %rdi
addq %rcx, %rdi
callq 0x15bef
andl $0x0, 0x111883(%rip)    # 0x127000
movl $0xff, 0x10fd6d(%rip)   # 0x1254f4
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ecx
andl $-0x2, %ecx
cmpl $0x6, %ecx
jne 0x1591b
leaq 0x5996c1(%rip), %rax    # 0x5aee6c
movl (%rax), %eax
sarl %eax
leaq 0x5a16ea(%rip), %rcx    # 0x5b6ea0
movswl 0xbaa(%rcx), %ecx
imull $0xc, %ecx, %edx
sarl %edx
addl %ecx, %edx
subl %edx, %eax
movswl %ax, %ebx
shll $0x10, %eax
addl $0x100000, %eax         # imm = 0x100000
movq %rax, 0x10(%rsp)
pushq $0x1
popq %r15
movw $0x3, %r12w
leaq 0x1117da(%rip), %rbp    # 0x126fc0
pushq $0x27
popq %r14
leaq 0x6c380(%rip), %r13     # 0x81b71
movl %ebx, 0xc(%rsp)
cmpq $0x6, %r15
je 0x15787
movl 0xb2df3(%rip), %eax     # 0xc85f4
movswl %r12w, %esi
cmpq %rax, %r15
jne 0x1585f
cmpl $0x0, 0x1117f3(%rip)    # 0x127004
je 0x15869
movl %ebx, %edi
xorl %edx, %edx
xorl %ecx, %ecx
pushq $0x4
popq %r8
movq %r13, %r9
xorl %eax, %eax
leaq 0x1117df(%rip), %r10    # 0x127008
pushq %r10
pushq %r15
callq 0x1603c
popq %rax
popq %rcx
leaq 0x53db2d(%rip), %rax    # 0x553368
movl (%rax), %eax
cmpl 0x1117d1(%rip), %eax    # 0x127014
jle 0x15887
addl $0x1e, %eax
movl %eax, 0x1117c6(%rip)    # 0x127014
movl 0x1117c4(%rip), %eax    # 0x127018
xorl $0x1, %eax
movl %eax, 0x1117bb(%rip)    # 0x127018
jmp 0x1588d
movl %ebx, %edi
xorl %edx, %edx
xorl %ecx, %ecx
pushq $0x1
jmp 0x15871
movl %ebx, %edi
xorl %edx, %edx
xorl %ecx, %ecx
pushq $0x4
popq %r8
movq %r13, %r9
xorl %eax, %eax
pushq %rbp
pushq %r15
callq 0x1603c
popq %rax
popq %rcx
jmp 0x15908
movl 0x11178b(%rip), %eax    # 0x127018
testl %eax, %eax
je 0x15908
leaq 0x5995d8(%rip), %rax    # 0x5aee70
movl (%rax), %ebx
cmpl $0x190, %ebx            # imm = 0x190
setge %cl
movl %r14d, %r13d
shll %cl, %r13d
leaq 0x111758(%rip), %rdi    # 0x127008
callq 0x85a0
shll $0x14, %eax
movq 0x10(%rsp), %rcx
leal (%rax,%rcx), %edi
addl $0x50000, %edi          # imm = 0x50000
shll $0x10, %r13d
leaq 0x59959b(%rip), %rax    # 0x5aee6c
movl (%rax), %eax
decl %eax
decl %ebx
movl %r13d, %esi
leaq 0x6c290(%rip), %r13     # 0x81b71
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x624, %r8d            # imm = 0x624
xorl %r9d, %r9d
pushq %rbx
movl 0x14(%rsp), %ebx
pushq %rax
pushq $0x0
pushq $0x0
pushq $0x18
pushq $0x0
callq 0x48ebe
addq $0x30, %rsp
incq %r15
incl %r12d
addq $0xc, %rbp
addl $0xc, %r14d
jmp 0x157f5
cmpl $0x9, %eax
je 0x15a84
cmpl $0x8, %eax
jne 0x15787
leaq 0x599538(%rip), %r14    # 0x5aee6c
movl (%r14), %eax
movl %eax, %r15d
sarl %r15d
leaq 0x5a155c(%rip), %rcx    # 0x5b6ea0
movswl 0xc42(%rcx), %ecx
shrl %ecx
movzwl %cx, %ecx
subl %ecx, %r15d
leaq 0x599516(%rip), %r12    # 0x5aee70
movl (%r12), %ecx
movl $0x190, %edx            # imm = 0x190
cmpl %edx, %ecx
movl $0x640000, %edx         # imm = 0x640000
movl $0x320000, %ebp         # imm = 0x320000
cmovgel %edx, %ebp
movl %r15d, %ebx
shll $0x10, %ebx
decl %eax
decl %ecx
subq $0x30, %rsp
andl $0x0, 0x18(%rsp)
movl %ecx, 0x28(%rsp)
andl $0x0, 0x10(%rsp)
movl %eax, 0x20(%rsp)
andl $0x0, (%rsp)
pushq $0x18
popq %r13
movl %r13d, 0x8(%rsp)
movl %ebx, %edi
movl %ebp, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x621, %r8d            # imm = 0x621
xorl %r9d, %r9d
callq 0x48ebe
addq $0x30, %rsp
imull $0x7, 0xb2c39(%rip), %eax # 0xc85fc
leal (%r15,%rax), %edi
addl $0xa, %edi
shll $0x10, %edi
movl (%r14), %eax
decl %eax
movl (%r12), %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 $0x0
pushq $0x0
pushq %r13
pushq $0x0
callq 0x48ebe
addq $0x30, %rsp
movl (%r12), %eax
movl $0x190, %ecx            # imm = 0x190
cmpl %ecx, %eax
movl $0xac0000, %ecx         # imm = 0xAC0000
movl $0x560000, %ebp         # imm = 0x560000
cmovgel %ecx, %ebp
movl (%r14), %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 $0x0
pushq $0x0
pushq %r13
pushq $0x0
callq 0x48ebe
addq $0x30, %rsp
imull $0x7, 0xb2baa(%rip), %eax # 0xc85f8
leal (%rax,%r15), %edi
addl $0xa, %edi
shll $0x10, %edi
movl (%r14), %eax
decl %eax
movl (%r12), %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 $0x0
pushq $0x0
pushq %r13
jmp 0x15b43
leaq 0x5993e1(%rip), %r14    # 0x5aee6c
movl (%r14), %eax
movl %eax, %ebp
sarl %ebp
leaq 0x5a1407(%rip), %rcx    # 0x5b6ea0
movswl 0xc42(%rcx), %ecx
shrl %ecx
movzwl %cx, %ecx
subl %ecx, %ebp
leaq 0x5993c2(%rip), %r15    # 0x5aee70
movl (%r15), %ecx
cmpl $0x190, %ecx            # imm = 0x190
movl $0x340000, %edx         # imm = 0x340000
movl $0x1a0000, %ebx         # imm = 0x1A0000
cmovgel %edx, %ebx
movl %ebp, %edi
shll $0x10, %edi
decl %eax
decl %ecx
subq $0x30, %rsp
andl $0x0, 0x18(%rsp)
movl %ecx, 0x28(%rsp)
andl $0x0, 0x10(%rsp)
movl %eax, 0x20(%rsp)
andl $0x0, (%rsp)
pushq $0x18
popq %r12
movl %r12d, 0x8(%rsp)
movl %ebx, %esi
movl $0x10000, %edx          # imm = 0x10000
xorl %ecx, %ecx
movl $0x621, %r8d            # imm = 0x621
xorl %r9d, %r9d
callq 0x48ebe
addq $0x30, %rsp
imull $0x7, 0x11150a(%rip), %edi # 0x12701c
addl %ebp, %edi
shll $0x10, %edi
addl $0xa0000, %edi          # imm = 0xA0000
movl (%r14), %eax
decl %eax
movl (%r15), %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 $0x0
pushq $0x0
pushq %r12
pushq $0x0
callq 0x48ebe
addq $0x48, %rsp
jmp 0x1578b