// File: /workspace/github_c_makefile_star2_O3/jrrk[P]cbzone/c_scores.c
// Function: scores
LONG scores(score)
     LONG score;
{
  struct score_struct {
    LONG score;
    int uid;
    char name[50];
    struct score_struct *next;
  } player, *current, *top_score, *prev_score;

  FILE *sfile;
  char buf[100];
  char version[100];
  char *login, *getlogin();
  int i;
  Font fontid;
  int numgame = 0;
  int numscore = 0;
  int numscoreable = 0;
  int player_scores = 0;
  int tries = MAX_RETRIES;
  Bool score_printed = False;
  Bool scoresonly = False;
  Bool wrong_version = False;
  Bool file_readable = False;
  Bool file_writeable = False;
  Bool practice = opt->practice;
  struct passwd* pw;
  void (*p)();

  version[0] ='\0';
  if (score < 0) {
    practice = True;
    scoresonly = True;
    p = nprintf;
  }
  else {
    p = xprintf;
    gprsetclippingactive(False);
    fontid = gprloadfontfile(GAMEOVERFONT);
    gprsettextfont(fontid);
    printstring (165, 300, "GAME OVER", 9);
    fontid = gprloadfontfile(GENERALFONT);
    gprsettextfont(fontid);
    printstring (165, 320, "1986 JSR", 8);
    flushwindow();
    sleep(1);
    clearentirescreen();
  }

  x = 350;
  y = 100;
  ydelta = 15;

  sprintf(buf,"%s%s",TANKDIR,SCOREFILE);
  sfile = fopen(buf,"r");       /* just check if it is there */

  if (sfile == NULL) {
    p("Score file not readable.", opt->output);
    if (scoresonly)
      return 1;
    else {
      p("Will try and create new scorefile.", opt->output);
    }
  }
  else
    file_readable = True;

  if (!scoresonly) {
    (void) signal(SIGINT, SIG_IGN); /* no leaving this routine */
    (void) signal(SIGHUP, SIG_IGN); /* no how, no way */
    file_writeable = True;
    if (sfile != NULL)
      fclose(sfile);

  retry:
    if (file_readable)
      sfile = fopen(buf,"r+");  /* okay, now open for update */
    else
      sfile = fopen(buf,"w");

    if (sfile != NULL) {
      if (flock(fileno(sfile),LOCK_EX) < 0) {
        if (errno == EWOULDBLOCK && AFS) {
          fclose(sfile);
          sleep(AFS_SLEEP);
          if (tries--)
            goto retry;
        }
        p("File not lockable, scores will not be saved.", opt->output);
        file_writeable = False;
      }
    }
    else {
      p("File not writeable, scores will not be saved.", opt->output);
      file_writeable = False;
    }

    /* okay, it's possible we could have closed the file and never
     * reopened it.  Also, we just may not have been able to lock
     * it.  In either case, lets close it again and then open only
     * for reading.
     */
    if (file_readable && !file_writeable) {
      if (sfile != NULL)
        fclose(sfile);
      if ((sfile = fopen(buf, "r")) == NULL)
        file_readable = False;
    }
  }

  if (!file_readable && !file_writeable) {
    p("Scorefile not readable or writeable...Goodbye!", opt->output);
    (void) signal(SIGINT, SIG_DFL); /* this would probably happen */
    (void) signal(SIGHUP, SIG_DFL); /* on exit anyway             */
    if (!scoresonly)
      printandwait("Press any key to continue...", 0);
    return 1;
  }

  if (file_readable) {
    if(fgets(version,200,sfile) && file_writeable) {
      version[strlen(version)-1] = '\0'; /* strip the newline */
      if (strcmp(version,VERSION)) {
        wrong_version = True;
        p("Incorrect version played for this scorefile.", opt->output);
        p("Score not valid for inclusion.", opt->output);
        sprintf(buf,"Your version is \"%s\", while",VERSION);
        p(buf, opt->output);
        sprintf(buf, "  the scorefile version is \"%s\"", version);
        p(buf, opt->output);
      }
    }

    if (*version == '\0')
      strcpy(version,VERSION);

    if(fgets(buf,200,sfile))
      sscanf(buf,"%d %d",&numgame,&numscoreable);
    top_score = (struct score_struct*) malloc(sizeof(struct score_struct));
    current = top_score;

    while(fgets(buf,200,sfile) && numscore < NUMHIGH)
      if (sscanf(buf,"%d %d %[^\n]",&current->score,
                 &current->uid,current->name) != 3) {
        p("Invalid line in score file...Skipping.", opt->output);
      }
      else {
        current->next = (struct score_struct*)
          malloc(sizeof(struct score_struct));
        prev_score = current;
        current = current->next;
        numscore ++;
      }
  }

  if (numscore)
    prev_score->next = NULL;
  else
    top_score = NULL;

  if (numgame < numscoreable)
    numgame = numscoreable;

  if (!scoresonly) {
    /* try to get it from the passwd file first, just in case this
     * person su'd from another acct.
     */
    player.uid = getuid();
    player.score = score;
    pw = getpwuid(player.uid);
    if (pw == NULL)
      if ((login = getlogin()) != NULL)
        strcpy(player.name, login);
      else {
        p("Can't find out who you are....bye.", opt->output);
        fclose(sfile);
        (void) signal(SIGINT, SIG_DFL);
        (void) signal(SIGHUP, SIG_DFL);
        if (!scoresonly)
          printandwait("Press any key to continue...", 0);
        return 1;
      }
    else
      strcpy(player.name, pw->pw_name);

    if (numscore < NUMHIGH || player.score > prev_score->score) {
      score_printed = True;
      numscore++;

      for (current = top_score;
           current != NULL && player.score <= current->score;
           prev_score = current, current = current->next);

      player.next = current;

      if (current == top_score)
        top_score = &player;
      else
        prev_score->next = &player;
    }

    numgame++;
    if (!practice && !wrong_version)
      numscoreable++;
  }

  sprintf(buf, "High scores after %d games, %d scoreable:",
          numgame, numscoreable);
  p(buf, opt->output);
  current = top_score;
  while (current != NULL) {
    if (current == &player)
      *buf = '>';
    else
      *buf = ' ';
    sprintf(buf+1, "%-20s %8d", current->name, current->score);
    p(buf, opt->output);

    if (((wrong_version || practice) && current==&player) ||
        (current->uid==player.uid && !strcmp(player.name, current->name) &&
         ++player_scores>INDIVIDUAL_SCORES)) {
      numscore--;
      if (current == top_score)
        top_score = current->next;
      else
        prev_score->next = current->next;
    }
    else
      prev_score = current;
    current = current->next;
  }

  if (!scoresonly && !score_printed) {
    p("...", opt->output);
    sprintf(buf, ">%-20s %8d", player.name,player.score);
    p(buf, opt->output);
  }

  if (file_writeable) {
    rewind(sfile);
    fprintf(sfile,"%s\n",version);
    fprintf(sfile,"%d %d\n",numgame,numscoreable);
    for(current = top_score, i = 0;
        current != NULL && i < NUMHIGH;
        current = current->next, i++)
      fprintf(sfile,"%d %d %s\n",current->score,current->uid,current->name);
    if (practice) {
      y += ydelta;
      p("Your game was for practice only...", opt->output);
      p("For a valid score use:  cbzone [-q] [-d 0-5]", opt->output);
    }
  }

  fclose(sfile);
  (void) signal(SIGINT, SIG_DFL);
  (void) signal(SIGHUP, SIG_DFL);

  if (!scoresonly)
    printandwait("Press any key when ready...", 0);

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rdi, %r14
xorl %eax, %eax
movl %eax, 0x8(%rsp)
movl %eax, 0xc(%rsp)
leaq 0x713e(%rip), %r12      # 0x14580
movq (%r12), %rax
movl 0x38(%rax), %ebx
movb $0x0, 0x100(%rsp)
testq %rdi, %rdi
js 0xd4f5
xorl %edi, %edi
xorl %eax, %eax
callq 0x7212
leaq 0x1ba6(%rip), %rdi      # 0xf010
xorl %eax, %eax
callq 0x75e9
movq %rax, %rdi
xorl %eax, %eax
callq 0x6d89
leaq 0x1bbc(%rip), %rdx      # 0xf03e
movl $0xa5, %edi
movl $0x12c, %esi            # imm = 0x12C
movl $0x9, %ecx
xorl %eax, %eax
callq 0x6d9f
leaq 0x15f2(%rip), %rdi      # 0xea91
xorl %eax, %eax
callq 0x75e9
movq %rax, %rdi
xorl %eax, %eax
callq 0x6d89
leaq 0x1b91(%rip), %rdx      # 0xf048
movl $0xa5, %edi
movl $0x140, %esi            # imm = 0x140
movl $0x8, %ecx
xorl %eax, %eax
callq 0x6d9f
xorl %eax, %eax
callq 0x7895
movl $0x1, %edi
callq 0x4320
xorl %eax, %eax
callq 0x7882
testl %ebx, %ebx
setne 0x7(%rsp)
leaq -0x177(%rip), %r13      # 0xd37c
jmp 0xd501
leaq -0x144(%rip), %r13      # 0xd3b8
movb $0x1, 0x7(%rsp)
movl $0x15e, 0x73f9(%rip)    # imm = 0x15E
movl $0x64, 0x73f3(%rip)     # 0x14908
movl $0xf, 0x73ed(%rip)      # 0x1490c
leaq 0x1998(%rip), %rsi      # 0xeebe
leaq 0x1996(%rip), %rdx      # 0xeec3
leaq 0x1b1d(%rip), %rcx      # 0xf051
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x42e0
leaq 0x1587(%rip), %rsi      # 0xead4
movq %rbx, %rdi
callq 0x41a0
movq %rax, %rbx
testq %rax, %rax
movq %r14, 0x18(%rsp)
movq %r13, 0x20(%rsp)
je 0xd597
movl $0x1, %ebp
testq %r14, %r14
jns 0xd5c8
leaq 0x100(%rsp), %rdi
movl $0xc8, %esi
movq %rbx, %rdx
callq 0x4230
xorl %r14d, %r14d
movq $0x0, 0x28(%rsp)
jmp 0xd892
movq (%r12), %rax
movl 0x3c(%rax), %esi
leaq 0x1abe(%rip), %rdi      # 0xf063
xorl %ebp, %ebp
xorl %eax, %eax
callq *%r13
testq %r14, %r14
js 0xdda6
movq (%r12), %rax
movl 0x3c(%rax), %esi
leaq 0x1ab9(%rip), %rdi      # 0xf07c
xorl %eax, %eax
callq *%r13
movl $0x1, %esi
movl $0x2, %edi
callq 0x43a0
movl $0x1, %esi
movl $0x1, %edi
callq 0x43a0
testq %rbx, %rbx
je 0xd5f3
movq %rbx, %rdi
callq 0x4500
movq %rbx, %r14
testq %rbx, %rbx
leaq 0xf4a(%rip), %rax       # 0xe54a
leaq 0x1a98(%rip), %rbx      # 0xf09f
cmoveq %rax, %rbx
movl $0xfffffffa, %r12d      # imm = 0xFFFFFFFA
leaq 0x90(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x41a0
testq %rax, %rax
je 0xd698
movq %rax, %r13
movq %rax, %rdi
callq 0x4030
movl %eax, %edi
movl $0x2, %esi
callq 0x4360
testl %eax, %eax
jns 0xd6ee
callq 0x43f0
cmpl $0xb, (%rax)
jne 0xd669
movq %r13, %rdi
callq 0x4500
movl $0x2, %edi
callq 0x4320
incl %r12d
jne 0xd619
leaq 0x6f10(%rip), %r12      # 0x14580
movq (%r12), %rax
movl 0x3c(%rax), %esi
leaq 0x1a24(%rip), %rdi      # 0xf0a2
xorl %eax, %eax
callq *0x20(%rsp)
testq %r14, %r14
je 0xd708
movq %r13, %rdi
callq 0x4500
movq 0x18(%rsp), %r15
jmp 0xd6c1
leaq 0x6ee1(%rip), %r12      # 0x14580
movq (%r12), %rax
movl 0x3c(%rax), %esi
leaq 0x1a22(%rip), %rdi      # 0xf0cf
xorl %eax, %eax
callq *0x20(%rsp)
testq %r14, %r14
movq 0x18(%rsp), %r15
je 0xdd52
leaq 0x140c(%rip), %rsi      # 0xead4
leaq 0x90(%rsp), %rdi
callq 0x41a0
xorl %ebp, %ebp
movq %rax, %r13
testq %rax, %rax
setne %bpl
movq $0x0, 0x30(%rsp)
xorl %eax, %eax
jmp 0xd718
movl $0x1, %eax
movb $0x1, %cl
movq %rcx, 0x30(%rsp)
movq 0x18(%rsp), %r15
leaq 0x6e7a(%rip), %r12      # 0x14580
jmp 0xd718
movq $0x0, 0x30(%rsp)
xorl %eax, %eax
movq 0x18(%rsp), %r15
orl %ebp, %eax
je 0xd838
testl %ebp, %ebp
je 0xd87e
leaq 0x100(%rsp), %rbx
movq %rbx, %rdi
movl $0xc8, %esi
movq %r13, %r15
movq %r13, %rdx
callq 0x4230
testq %rax, %rax
sete %al
movq 0x30(%rsp), %r14
movl %r14d, %ecx
xorb $0x1, %cl
movq $0x0, 0x28(%rsp)
orb %al, %cl
jne 0xd88f
movq %rbx, %rdi
callq 0x4280
movb $0x0, -0x1(%rax,%rbx)
movdqa 0x100(%rsp), %xmm0
movdqu 0x10d(%rsp), %xmm1
pcmpeqb 0x1864(%rip), %xmm1     # 0xeff0
pcmpeqb 0x186c(%rip), %xmm0     # 0xf000
pand %xmm1, %xmm0
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0xd833
movq (%r12), %rax
movl 0x3c(%rax), %esi
leaq 0x1994(%rip), %rdi      # 0xf149
xorl %eax, %eax
movq 0x20(%rsp), %r15
callq *%r15
movq (%r12), %rax
movl 0x3c(%rax), %esi
leaq 0x19a9(%rip), %rdi      # 0xf176
xorl %eax, %eax
callq *%r15
leaq 0x19bc(%rip), %rsi      # 0xf195
leaq 0x1793(%rip), %rdx      # 0xef73
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x42e0
movq (%r12), %rax
movl 0x3c(%rax), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq *%r15
leaq 0x19a9(%rip), %rsi      # 0xf1b1
leaq 0x100(%rsp), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x42e0
movq (%r12), %rax
movl 0x3c(%rax), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq *%r15
movl $0x1, %eax
movq %rax, 0x28(%rsp)
movq %r13, %rbx
jmp 0xd892
movq (%r12), %rax
movl 0x3c(%rax), %esi
leaq 0x18b7(%rip), %rdi      # 0xf0fd
xorl %eax, %eax
callq *0x20(%rsp)
movl $0x2, %edi
xorl %esi, %esi
callq 0x43a0
movl $0x1, %edi
xorl %esi, %esi
callq 0x43a0
movl $0x1, %ebx
testq %r15, %r15
js 0xddab
leaq 0x18b3(%rip), %rdi      # 0xf12c
jmp 0xdd49
movb $0x1, %bpl
movq $0x0, 0x28(%rsp)
jmp 0xd9d4
movq %r15, %rbx
cmpb $0x0, 0x100(%rsp)
jne 0xd8bc
movups 0x16dd(%rip), %xmm0     # 0xef80
movups %xmm0, 0x10d(%rsp)
movdqu 0x16c0(%rip), %xmm0     # 0xef73
movdqa %xmm0, 0x100(%rsp)
movq %r14, 0x30(%rsp)
leaq 0x90(%rsp), %rdi
movl $0xc8, %esi
movq %rbx, %rdx
callq 0x4230
testq %rax, %rax
je 0xd8fb
leaq 0x18ef(%rip), %rsi      # 0xf1d1
leaq 0x90(%rsp), %rdi
leaq 0x8(%rsp), %rdx
leaq 0xc(%rsp), %rcx
xorl %eax, %eax
callq 0x40f0
movl $0x48, %edi
callq 0x4190
movq %rax, %r15
leaq 0x90(%rsp), %rdi
movl $0xc8, %esi
movq %rbx, %rdx
callq 0x4230
movb $0x1, %bpl
testq %rax, %rax
je 0xd9d1
leaq 0x18a7(%rip), %r12      # 0xf1d7
leaq 0x90(%rsp), %r14
xorl %r13d, %r13d
movq %r15, %rbp
leaq 0x8(%rbp), %rcx
leaq 0xc(%rbp), %r8
movq %r14, %rdi
movq %r12, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x40f0
cmpl $0x3, %eax
jne 0xd976
movl $0x48, %edi
callq 0x4190
movq %rax, 0x40(%rbp)
incl %r13d
movq %rbp, 0x10(%rsp)
movq %rax, %rbp
jmp 0xd990
leaq 0x6c03(%rip), %rax      # 0x14580
movq (%rax), %rax
movl 0x3c(%rax), %esi
leaq 0x1859(%rip), %rdi      # 0xf1e3
xorl %eax, %eax
callq *0x20(%rsp)
movq %r14, %rdi
movl $0xc8, %esi
movq %rbx, %rdx
callq 0x4230
testq %rax, %rax
je 0xd9ab
cmpl $0x14, %r13d
jl 0xd93e
testl %r13d, %r13d
je 0xd9d9
movq 0x10(%rsp), %rax
movq $0x0, 0x40(%rax)
cmpl $0x14, %r13d
setl %bpl
movq %rbx, %r13
leaq 0x6bb1(%rip), %r12      # 0x14580
jmp 0xd9e9
movq %rbx, %r13
xorl %r15d, %r15d
jmp 0xd9e9
xorl %r15d, %r15d
movq %rbx, %r13
leaq 0x6b9a(%rip), %r12      # 0x14580
movb $0x1, %bpl
movl 0x8(%rsp), %edx
movl 0xc(%rsp), %ecx
cmpl %ecx, %edx
jge 0xd9fb
movl %ecx, 0x8(%rsp)
movl %ecx, %edx
movq 0x18(%rsp), %rbx
testq %rbx, %rbx
movq %r13, 0x40(%rsp)
js 0xda33
callq 0x44a0
movl %eax, 0x50(%rsp)
movq %rbx, 0x48(%rsp)
movl %eax, %edi
callq 0x4240
testq %rax, %rax
movq 0x20(%rsp), %r13
je 0xda45
leaq 0x54(%rsp), %rdi
movq (%rax), %rsi
jmp 0xda5b
movl $0x0, 0x3c(%rsp)
movq 0x20(%rsp), %r13
jmp 0xdaeb
callq 0x40a0
testq %rax, %rax
je 0xdd63
leaq 0x54(%rsp), %rdi
movq %rax, %rsi
callq 0x4470
testb %bpl, %bpl
jne 0xda76
movq 0x48(%rsp), %rax
xorl %esi, %esi
movq 0x10(%rsp), %rcx
cmpq (%rcx), %rax
jle 0xdac9
testq %r15, %r15
je 0xdaa0
movq 0x48(%rsp), %rcx
movq %r15, %rax
cmpq (%r15), %rcx
jg 0xdaa2
movq %r15, %rax
movq %rax, 0x10(%rsp)
movq 0x40(%rax), %rax
testq %rax, %rax
je 0xdaa0
cmpq (%rax), %rcx
jle 0xda8b
jmp 0xdaa2
xorl %eax, %eax
movq %rax, 0x88(%rsp)
movl $0x1, %esi
cmpq %r15, %rax
je 0xdac4
leaq 0x48(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rax, 0x40(%rcx)
jmp 0xdac9
leaq 0x48(%rsp), %r15
movl 0x8(%rsp), %edx
incl %edx
movl %edx, 0x8(%rsp)
movb 0x7(%rsp), %al
orb 0x28(%rsp), %al
movl 0xc(%rsp), %ecx
movl %esi, 0x3c(%rsp)
jne 0xdaeb
incl %ecx
movl %ecx, 0xc(%rsp)
leaq 0x173b(%rip), %rsi      # 0xf22d
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x42e0
movq (%r12), %rax
movl 0x3c(%rax), %esi
movq %rbx, %rdi
xorl %eax, %eax
movq %r13, %r14
callq *%r13
testq %r15, %r15
je 0xdbf0
movq 0x28(%rsp), %rax
orb 0x7(%rsp), %al
movq %rax, 0x28(%rsp)
xorl %ebx, %ebx
movq %r15, %rbp
leaq 0x48(%rsp), %rax
cmpq %rax, %r15
movl $0x20, %eax
movl $0x3e, %ecx
cmovel %ecx, %eax
sete %r12b
movb %al, 0x90(%rsp)
leaq 0xc(%r15), %r13
movq (%r15), %rcx
leaq 0x91(%rsp), %rdi
leaq 0x16f0(%rip), %rsi      # 0xf258
movq %r13, %rdx
xorl %eax, %eax
callq 0x42e0
leaq 0x6a07(%rip), %rax      # 0x14580
movq (%rax), %rax
movl 0x3c(%rax), %esi
leaq 0x90(%rsp), %rdi
xorl %eax, %eax
callq *%r14
testb %r12b, 0x28(%rsp)
je 0xdba9
movl %ebx, %eax
movq 0x40(%r15), %rcx
cmpq %rbp, %r15
je 0xdbcd
movq 0x10(%rsp), %rdx
movq %rcx, 0x40(%rdx)
jmp 0xdbd0
movl 0x8(%r15), %eax
cmpl 0x50(%rsp), %eax
jne 0xdbc4
leaq 0x54(%rsp), %rdi
movq %r13, %rsi
callq 0x4440
testl %eax, %eax
je 0xdbe1
movq %r15, 0x10(%rsp)
movl %ebx, %eax
jmp 0xdbd0
movq %rcx, %rbp
movq 0x40(%r15), %r15
movl %eax, %ebx
testq %r15, %r15
jne 0xdb32
jmp 0xdbf2
leal 0x1(%rbx), %eax
cmpl $0x3, %ebx
jge 0xdb95
movq %r15, 0x10(%rsp)
jmp 0xdbd0
xorl %ebp, %ebp
movq 0x18(%rsp), %r15
testq %r15, %r15
sets %al
movl 0x3c(%rsp), %ecx
orb %al, %cl
leaq 0x6976(%rip), %r12      # 0x14580
jne 0xdc50
movq (%r12), %rax
movl 0x3c(%rax), %esi
leaq 0x152b(%rip), %rdi      # 0xf145
xorl %eax, %eax
callq *%r14
leaq 0x54(%rsp), %rdx
movq -0xc(%rdx), %rcx
leaq 0x1628(%rip), %rsi      # 0xf257
leaq 0x90(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x42e0
movq (%r12), %rax
movl 0x3c(%rax), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq *%r14
cmpb $0x0, 0x30(%rsp)
je 0xdd17
movq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x4370
leaq 0x1600(%rip), %rsi      # 0xf26f
leaq 0x100(%rsp), %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4570
movl 0x8(%rsp), %edx
movl 0xc(%rsp), %ecx
leaq 0x15d2(%rip), %rsi      # 0xf262
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4570
testq %rbp, %rbp
je 0xdcd9
leaq 0x15c3(%rip), %rbx      # 0xf269
xorl %r15d, %r15d
movq (%rbp), %rdx
movl 0x8(%rbp), %ecx
leaq 0xc(%rbp), %r8
movq 0x40(%rsp), %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4570
movq 0x40(%rbp), %rbp
testq %rbp, %rbp
je 0xdcd9
leal 0x1(%r15), %eax
cmpl $0x13, %r15d
movl %eax, %r15d
jb 0xdca9
cmpb $0x0, 0x7(%rsp)
movq 0x18(%rsp), %r15
je 0xdd17
movl 0x6c21(%rip), %eax      # 0x1490c
addl %eax, 0x6c17(%rip)      # 0x14908
movq (%r12), %rax
movl 0x3c(%rax), %esi
leaq 0x1574(%rip), %rdi      # 0xf273
xorl %eax, %eax
callq *%r14
movq (%r12), %rax
movl 0x3c(%rax), %esi
leaq 0x1584(%rip), %rdi      # 0xf296
xorl %eax, %eax
callq *%r14
movq 0x40(%rsp), %rdi
callq 0x4500
xorl %ebx, %ebx
movl $0x2, %edi
xorl %esi, %esi
callq 0x43a0
movl $0x1, %edi
xorl %esi, %esi
callq 0x43a0
testq %r15, %r15
js 0xddab
leaq 0x157c(%rip), %rdi      # 0xf2c3
xorl %ebx, %ebx
xorl %esi, %esi
callq 0xd3c1
jmp 0xddab
movq $0x0, 0x30(%rsp)
xorl %r13d, %r13d
jmp 0xd6ea
movq (%r12), %rax
movl 0x3c(%rax), %esi
leaq 0x1499(%rip), %rdi      # 0xf20a
xorl %eax, %eax
callq *%r13
movq 0x40(%rsp), %rdi
callq 0x4500
movl $0x2, %edi
xorl %esi, %esi
callq 0x43a0
movl $0x1, %edi
xorl %esi, %esi
callq 0x43a0
leaq 0x138d(%rip), %rdi      # 0xf12c
xorl %esi, %esi
callq 0xd3c1
movl $0x1, %ebx
movq %rbx, %rax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq