LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/rafa9811[P]theIndiependenceGame/interface.c
// Function: interface_ini
Interface* interface_ini(){
    Interface *interface;
    interface = (Interface*)malloc(sizeof(Interface));
    /*The screen win, where our player moves, picks up objects, interacts... The main action in the game*/
    interface->screen = win_new(0, 0, SCREENY+2, SCREENX+3, BGCOLOR, CHARCOLOR);
    /*The dialogs window is where every dialog stored in interact_play will be printed:*/
    interface->dlgs = win_new(SCREENY+2, 0, DLGY, DLGX, BGCOLOR, CHARCOLOR);
    /*The clk window, that won't be used here, but in the main c, where it is constantly updating for showing the remaining time.
    If it was printed at the same pace as the rest of the windows, we would only get an update of the remaining time when we do something.*/
    interface->clk = win_new(0,SCREENX+5,CLKY,CLKX,BGCOLOR,CHARCOLOR);
    /*Stat screen, updated every time we do something, for showing our money, number of printers activated and so on:*/
    interface->stats = win_new(CLKY, SCREENX+2, STATY, STATX, BGCOLOR, CHARCOLOR);
    return interface;
}

// Assembly:
pushq %rbx
movl $0x20, %edi
callq 0x1130
movq %rax, %rbx
xorl %edi, %edi
xorl %esi, %esi
movl $0x26, %edx
movl $0x53, %ecx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x3f23
movq %rax, (%rbx)
movl $0x26, %edi
xorl %esi, %esi
movl $0xa, %edx
movl $0x78, %ecx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x3f23
movq %rax, 0x8(%rbx)
xorl %edi, %edi
movl $0x55, %esi
movl $0x5, %edx
movl $0x28, %ecx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x3f23
movq %rax, 0x18(%rbx)
movl $0x5, %edi
movl $0x52, %esi
movl $0x1f, %edx
movl $0x28, %ecx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0x3f23
movq %rax, 0x10(%rbx)
movq %rbx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/rafa9811[P]theIndiependenceGame/interface.c
// Function: interface_printDialog
int interface_printDialog(Interact* interact, Interface* interface){
    char *dialog,*ini,line[2*DLG_LINE];
    int len,i=0,linenumber=2;
    if(!interact || !interface) return -1;
    win_cls(interface->dlgs);
    dialog=(char*)malloc(1024);
    strcpy(dialog,interact_getDialog(interact));
    len = strlen(dialog);
    if(len>DLG_LINE){
        ini=dialog;
        while(i<len && linenumber<DLG_LINE){
        dialog = ini + i;
        memcpy(line,dialog,DLG_LINE);
        win_write_line_at(interface->dlgs,linenumber,2,line);
        i+=DLG_LINE;
        linenumber++;
        }
    }
    else win_write_line_at(interface->dlgs,linenumber,2,dialog);
    dialog=ini;
    if(dialog)free(dialog);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
orb %al, %cl
jne 0x50eb
movq %rsi, %rbx
movq %rdi, %r15
movq 0x8(%rsi), %rdi
callq 0x3f6e
movl $0x400, %edi            # imm = 0x400
callq 0x1130
movq %rax, %r14
movq %r15, %rdi
callq 0x4593
movq %r14, %rdi
movq %rax, %rsi
callq 0x1050
movq %r14, %rdi
callq 0x1080
movq %rax, %r15
cmpl $0x6a, %r15d
jl 0x50c6
andl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movl $0x2, %r13d
movl $0x69, %ebp
movq %rsp, %r12
leaq (%r14,%rbp), %rsi
addq $-0x69, %rsi
movl $0x69, %edx
movq %r12, %rdi
callq 0x1100
movq 0x8(%rbx), %rdi
movl %r13d, %esi
movl $0x2, %edx
movq %r12, %rcx
callq 0x4081
cmpq %r15, %rbp
jae 0x50dc
leal 0x1(%r13), %eax
addq $0x69, %rbp
cmpl $0x68, %r13d
movl %eax, %r13d
jb 0x5085
jmp 0x50dc
movq 0x8(%rbx), %rdi
movl $0x2, %esi
movl $0x2, %edx
movq %r14, %rcx
callq 0x4081
xorl %ebp, %ebp
testq %r14, %r14
je 0x50eb
movq %r14, %rdi
callq 0x1030
movl %ebp, %eax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/rafa9811[P]theIndiependenceGame/interface.c
// Function: interface_printScreen
int interface_printScreen(Interact *interact, Interface* interface){
    int linenumber=0,room;
    char line[SCREEN_LINE*2],*draw,*ini;
    int i=0;
    if(!interact || !interface) return -1;
    win_cls(interface->screen);
    room=player_get_room(interact_getPlayer(interact));
    draw=map_getRoomDraw(interact_getMap(interact),room);
    if(!draw)return -1;
    ini=draw;
    while(linenumber<=YLIMIT){
      draw = ini + i;
      memcpy(line,draw,SCREEN_LINE);
      win_write_line_at(interface->screen,linenumber,2,line);
      i+=SCREEN_LINE;
      linenumber++;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa0, %rsp
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
orb %al, %cl
jne 0x53a6
movq %rsi, %rbx
movq %rdi, %r14
movq (%rsi), %rdi
callq 0x3f6e
movq %r14, %rdi
callq 0x45e7
movq %rax, %rdi
callq 0x3e48
movl %eax, %r15d
movq %r14, %rdi
callq 0x45f3
movq %rax, %rdi
movl %r15d, %esi
callq 0x2ac3
testq %rax, %rax
je 0x53a6
movq %rax, %r14
xorl %ebp, %ebp
movq %rsp, %r15
xorl %r12d, %r12d
movl $0x50, %edx
movq %r15, %rdi
movq %r14, %rsi
callq 0x1100
movq (%rbx), %rdi
movl %r12d, %esi
movl $0x2, %edx
movq %r15, %rcx
callq 0x4081
incl %r12d
addq $0x50, %r14
cmpl $0x25, %r12d
jne 0x5376
movl %ebp, %eax
addq $0xa0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/rafa9811[P]theIndiependenceGame/interface.c
// Function: interface_printPlayer
int interface_printPlayer(Interact *interact, Interface* interface){
  int px,py;
  Player*player;
  if(!interact||!interface) return -1;
  player=interact_getPlayer(interact);
  if(!player) return -1;
  px=player_get_px(player);
  py=player_get_py(player);
  if(px<0||py<0||px>XLIMIT||py>YLIMIT) return -1;
  win_write_char_at(interface->screen,py,px,PLAYER_CHAR);
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
orb %al, %cl
jne 0x5420
movq %rsi, %rbx
callq 0x45e7
testq %rax, %rax
je 0x5420
movq %rax, %r15
movq %rax, %rdi
xorl %eax, %eax
callq 0x3e57
movl %eax, %r14d
movq %r15, %rdi
xorl %eax, %eax
callq 0x3e65
cmpl $0x51, %r14d
setae %cl
cmpl $0x25, %eax
setae %dl
orb %cl, %dl
jne 0x5420
movq (%rbx), %rdi
movl %eax, %esi
movl %r14d, %edx
movl $0x40, %ecx
callq 0x41a7
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/rafa9811[P]theIndiependenceGame/interface.c
// Function: interface_blankSpace
int interface_blankSpace(Interact *interact, Interface* interface){
  int px,py;
  if(!interact||!interface) return -1;
  px=interact_getPx(interact);
  py=interact_getPy(interact);
  if(px<0||py<0||px>XLIMIT||py>YLIMIT) return -1;
  win_write_char_at(interface->screen,py,px,' ');
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
orb %al, %cl
jne 0x5484
movq %rsi, %rbx
movq %rdi, %r15
callq 0x4627
movl %eax, %r14d
movq %r15, %rdi
callq 0x4639
cmpl $0x51, %r14d
setae %cl
cmpl $0x25, %eax
setae %dl
orb %cl, %dl
jne 0x5484
movq (%rbx), %rdi
movl %eax, %esi
movl %r14d, %edx
movl $0x20, %ecx
callq 0x41a7
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/rafa9811[P]theIndiependenceGame/interface.c
// Function: interface_printClock
void interface_printClock(sc_rectangle *clk,double remaining, short inDanger){
  char line[STAT_LINE];
  if(inDanger < 0 || inDanger > 1) return;
  win_cls(clk);
  if(inDanger == 0){
    if(remaining>0){
      if(((int)remaining)%60<10) sprintf(line,"Remaining time: %d:0%d\n",(int)remaining/60,(int)remaining%60);
      else sprintf(line,"Remaining time: %d:%d\n",(int)remaining/60,(int)remaining%60);
    }
    else sprintf(line,"TIME'S UP!");
  }
  else{
    if(remaining>0){
      if(((int)remaining)%60<10) sprintf(line,"Time until detention: %d:0%d\n",(int)remaining/60,(int)remaining%60);
      else sprintf(line,"Time until detention: %d:%d\n",(int)remaining/60,(int)remaining%60);
    }
    else sprintf(line,"ARRESTED!");
  }
  win_write_line_at(clk,1,2,line);
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebp
cmpw $0x1, %bp
ja 0x5932
movq %rdi, %rbx
movsd %xmm0, 0x8(%rsp)
callq 0x3f6e
xorpd %xmm0, %xmm0
testw %bp, %bp
je 0x5891
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x58ce
cvttsd2si %xmm1, %eax
movslq %eax, %rcx
imulq $-0x77777777, %rcx, %rdx # imm = 0x88888889
shrq $0x20, %rdx
addl %ecx, %edx
movl %edx, %eax
shrl $0x1f, %eax
sarl $0x5, %edx
addl %eax, %edx
imull $0x3c, %edx, %eax
subl %eax, %ecx
cmpl $0x9, %ecx
jg 0x58ff
leaq 0x12f7(%rip), %rsi      # 0x6b86
jmp 0x590f
movsd 0x8(%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x58e6
cvttsd2si %xmm1, %eax
movslq %eax, %rcx
imulq $-0x77777777, %rcx, %rdx # imm = 0x88888889
shrq $0x20, %rdx
addl %ecx, %edx
movl %edx, %eax
shrl $0x1f, %eax
sarl $0x5, %edx
addl %eax, %edx
imull $0x3c, %edx, %eax
subl %eax, %ecx
cmpl $0x9, %ecx
jg 0x5908
leaq 0x1280(%rip), %rsi      # 0x6b4c
jmp 0x590f
movabsq $0x4445545345525241, %rax # imm = 0x4445545345525241
movq %rax, 0x10(%rsp)
movw $0x21, 0x18(%rsp)
jmp 0x591b
movabsq $0x55205327454d4954, %rax # imm = 0x55205327454D4954
movq %rax, 0x10(%rsp)
movl $0x215055, 0x17(%rsp)   # imm = 0x215055
jmp 0x591b
leaq 0x129e(%rip), %rsi      # 0x6ba4
jmp 0x590f
leaq 0x1255(%rip), %rsi      # 0x6b64
leaq 0x10(%rsp), %rdi
xorl %eax, %eax
callq 0x11a0
leaq 0x10(%rsp), %rcx
movq %rbx, %rdi
movl $0x1, %esi
movl $0x2, %edx
callq 0x4081
addq $0x38, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/rafa9811[P]theIndiependenceGame/interface.c
// Function: interface_start
void interface_start(Interact *interact, Interface* interface){
  if(!interact || !interface) exit(-1);
  PRINT_DIALOG;
  PRINT_STAT;
  PRINT_SCREEN;
  PRINT_PLAYER;
  return;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x597d
movq %rsi, %rbx
testq %rsi, %rsi
je 0x597d
movq %rdi, %r14
movq %rbx, %rsi
callq 0x5006
movq %r14, %rdi
movq %rbx, %rsi
callq 0x50ff
movq %r14, %rdi
movq %rbx, %rsi
callq 0x530e
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x53b8
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11b0
// File: /workspace/github_c_makefile_star2_O1/rafa9811[P]theIndiependenceGame/interface.c
// Function: interface_play
void interface_play(Interact *interact, Interface* interface, State state){
  if(!interact || !interface || state > MEETING3) exit(-1);
  switch(state){
    case(QUIT1):{
      PRINT_DIALOG;
      PRINT_STAT;
      return;
    }
    case(QUIT2):{
      return;
    }
    case(NOTHING):{
      PRINT_STAT;
      return;
    }
    case(MOVE):{
      PRINT_PLAYER;
      PRINT_SPACE;
      PRINT_STAT;
      return;
    }
    case(PICK):{
      PRINT_DIALOG;
      PRINT_STAT;
      PRINT_SCREEN;
      PRINT_PLAYER;
      return;
    }
    case(SCREEN):{
      PRINT_DIALOG;
      PRINT_STAT;
      PRINT_SCREEN;
      PRINT_PLAYER;
      return;
    }
    case(TALK):{
      PRINT_DIALOG;
      PRINT_STAT;
      return;
    }
    case(INVENTORY):{
      PRINT_DIALOG;
      PRINT_INVENTORY;
      return;
    }
    case(SHOP):{
      PRINT_DIALOG;
      PRINT_SHOP;
      return;
    }
    case(MEETING1):{
      PRINT_DIALOG;
      PRINT_STAT;
      return;
    }
    case(MEETING2):{
      PRINT_DIALOG;
      PRINT_STAT;
      return;
    }
    case(MEETING3):{
      PRINT_DIALOG;
      PRINT_STAT;
      return;
    }
    default:exit(-1);
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x5a68
movq %rsi, %rbx
testq %rsi, %rsi
je 0x5a68
cmpl $0xc, %edx
jae 0x5a68
movq %rdi, %r14
movl %edx, %eax
leaq 0x10b7(%rip), %rcx      # 0x6a6c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5006
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x50ff
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5006
movq %r14, %rdi
movq %rbx, %rsi
callq 0x50ff
movq %r14, %rdi
movq %rbx, %rsi
callq 0x530e
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x53b8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5006
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x564d
movq %r14, %rdi
movq %rbx, %rsi
callq 0x53b8
movq %r14, %rdi
movq %rbx, %rsi
callq 0x542d
jmp 0x59c9
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5006
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x5491
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x11b0
// File: /workspace/github_c_makefile_star2_O1/lh3[P]pre-pe/pre-lianti.c
// Function: trim_bseq_5
static inline void trim_bseq_5(bseq1_t *s, int l)
{
	memmove(s->seq, s->seq + l, s->l_seq - l);
	memmove(s->qual, s->qual + l, s->l_seq - l);
	s->l_seq -= l;
	s->seq[s->l_seq] = s->qual[s->l_seq] = 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
movslq %esi, %r15
leaq (%rdi,%r15), %rsi
movl (%rbx), %edx
movl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
andq %r14, %rdx
subq %r15, %rdx
callq 0x21e0
movq 0x18(%rbx), %rdi
leaq (%rdi,%r15), %rsi
movl (%rbx), %edx
andq %r14, %rdx
subq %r15, %rdx
callq 0x21e0
movl (%rbx), %eax
movl %eax, %ecx
subl %r15d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
andl $0x80000000, %eax       # imm = 0x80000000
orl %ecx, %eax
movl %eax, (%rbx)
movq 0x18(%rbx), %rax
xorl %edx, %edx
movb %dl, (%rax,%rcx)
movq 0x10(%rbx), %rax
movl (%rbx), %ecx
andq %r14, %rcx
movb %dl, (%rax,%rcx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/anet.c
// Function: anetRead
int anetRead(int fd, char *buf, int count)
{
    int nread, totlen = 0;
    while(totlen != count) {
        nread = read(fd,buf,count-totlen);
        if (nread == 0) return totlen;
        if (nread == -1) return -1;
        totlen += nread;
        buf += nread;
    }
    return totlen;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testl %edx, %edx
je 0x218dd
movl %edx, %ebp
movq %rsi, %r14
movl %edi, %r15d
xorl %ebx, %ebx
movl %ebp, %eax
subl %ebx, %eax
movslq %eax, %rdx
movl %r15d, %edi
movq %r14, %rsi
callq 0x1f330
cmpl $-0x1, %eax
je 0x218e1
testl %eax, %eax
je 0x218e3
addl %eax, %ebx
cltq
addq %rax, %r14
cmpl %ebp, %ebx
jne 0x218b5
jmp 0x218e3
xorl %ebx, %ebx
jmp 0x218e3
movl %eax, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/anet.c
// Function: anetWrite
int anetWrite(int fd, char *buf, int count)
{
    int nwritten, totlen = 0;
    while(totlen != count) {
        nwritten = write(fd,buf,count-totlen);
        if (nwritten == 0) return totlen;
        if (nwritten == -1) return -1;
        totlen += nwritten;
        buf += nwritten;
    }
    return totlen;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testl %edx, %edx
je 0x2192d
movl %edx, %ebp
movq %rsi, %r14
movl %edi, %r15d
xorl %ebx, %ebx
movl %ebp, %eax
subl %ebx, %eax
movslq %eax, %rdx
movl %r15d, %edi
movq %r14, %rsi
callq 0x1fb30
cmpl $-0x1, %eax
je 0x21931
testl %eax, %eax
je 0x21933
addl %eax, %ebx
cltq
addq %rax, %r14
cmpl %ebp, %ebx
jne 0x21905
jmp 0x21933
xorl %ebx, %ebx
jmp 0x21933
movl %eax, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/anet.c
// Function: anetPeerToString
int anetPeerToString(int fd, char *ip, size_t ip_len, int *port) {
    struct sockaddr_storage sa;
    socklen_t salen = sizeof(sa);

    if (getpeername(fd,(struct sockaddr*)&sa,&salen) == -1) {
        if (port) *port = 0;
        ip[0] = '?';
        ip[1] = '\0';
        return -1;
    }
    if (sa.ss_family == AF_INET) {
        struct sockaddr_in *s = (struct sockaddr_in *)&sa;
        if (ip) inet_ntop(AF_INET,(void*)&(s->sin_addr),ip,ip_len);
        if (port) *port = ntohs(s->sin_port);
    } else {
        struct sockaddr_in6 *s = (struct sockaddr_in6 *)&sa;
        if (ip) inet_ntop(AF_INET6,(void*)&(s->sin6_addr),ip,ip_len);
        if (port) *port = ntohs(s->sin6_port);
    }
    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %r14
leaq 0xc(%rsp), %rdx
movl $0x80, (%rdx)
leaq 0x10(%rsp), %rsi
callq 0x1f2a0
cmpl $-0x1, %eax
je 0x21d4d
cmpw $0x2, 0x10(%rsp)
jne 0x21d65
testq %r14, %r14
je 0x21d7f
leaq 0x14(%rsp), %rsi
movl $0x2, %edi
jmp 0x21d74
testq %rbx, %rbx
je 0x21d58
movl $0x0, (%rbx)
movw $0x3f, (%r14)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x21d94
testq %r14, %r14
je 0x21d7f
leaq 0x18(%rsp), %rsi
movl $0xa, %edi
movq %r14, %rdx
movl %r15d, %ecx
callq 0x1fbc0
xorl %eax, %eax
testq %rbx, %rbx
je 0x21d94
movzwl 0x12(%rsp), %ecx
rolw $0x8, %cx
movzwl %cx, %ecx
movl %ecx, (%rbx)
addq $0x90, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictIntHashFunction
unsigned int dictIntHashFunction(unsigned int key)
{
    key += ~(key << 15);
    key ^=  (key >> 10);
    key +=  (key << 3);
    key ^=  (key >> 6);
    key += ~(key << 11);
    key ^=  (key >> 16);
    return key;
}

// Assembly:
movl %edi, %eax
shll $0xf, %eax
notl %eax
addl %edi, %eax
movl %eax, %ecx
shrl $0xa, %ecx
xorl %eax, %ecx
leal (%rcx,%rcx,8), %eax
movl %eax, %ecx
shrl $0x6, %ecx
xorl %eax, %ecx
movl %ecx, %edx
shll $0xb, %edx
notl %edx
addl %ecx, %edx
movl %edx, %eax
shrl $0x10, %eax
xorl %edx, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictAddRaw
dictEntry *dictAddRaw(dict *d, void *key)
{
    int index;
    dictEntry *entry;
    dictht *ht;

    // 如果条件允许的话，进行单步 rehash
    // T = O(1)
    if (dictIsRehashing(d)) _dictRehashStep(d);

    /* Get the index of the new element, or -1 if
     * the element already exists. */
    // 计算键在哈希表中的索引值
    // 如果值为 -1 ，那么表示键已经存在
    // T = O(N)
    if ((index = _dictKeyIndex(d, key)) == -1)
        return NULL;

    // T = O(1)
    /* Allocate the memory and store the new entry */
    // 如果字典正在 rehash ，那么将新键添加到 1 号哈希表
    // 否则，将新键添加到 0 号哈希表
    ht = dictIsRehashing(d) ? &d->ht[1] : &d->ht[0];
    // 为新节点分配空间
    entry = zmalloc(sizeof(*entry));
    // 将新节点插入到链表表头
    entry->next = ht->table[index];
    ht->table[index] = entry;
    // 更新哈希表已使用节点数量
    ht->used++;

    /* Set the hash entry fields. */
    // 设置新节点的键
    // T = O(1)
    dictSetKey(d, entry, key);

    return entry;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
cmpl $-0x1, 0x50(%rdi)
je 0x22324
cmpl $0x0, 0x54(%r14)
jne 0x22324
movq %r14, %rdi
movl $0x1, %esi
callq 0x2208c
cmpl $-0x1, 0x50(%r14)
je 0x223ff
movq (%r14), %rax
movq %rbx, %rdi
callq *(%rax)
movl %eax, 0x4(%rsp)
leaq 0x10(%r14), %r15
xorl %r13d, %r13d
movq %r13, %rax
shlq $0x5, %rax
movl 0x10(%r15,%rax), %r12d
andl 0x4(%rsp), %r12d
movq (%r15,%rax), %rax
movq (%rax,%r12,8), %rbp
testq %rbp, %rbp
je 0x2238b
movq (%r14), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x2237f
movq 0x8(%r14), %rdi
movq (%rbp), %rdx
movq %rbx, %rsi
callq *%rax
testl %eax, %eax
je 0x22385
jmp 0x2239c
cmpq %rbx, (%rbp)
je 0x2239c
movq 0x10(%rbp), %rbp
jmp 0x2235b
testq %r13, %r13
jne 0x223a2
incq %r13
cmpl $-0x1, 0x50(%r14)
jne 0x22342
jmp 0x223a2
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmpl $-0x1, %r12d
je 0x22435
xorl %r13d, %r13d
cmpl $-0x1, 0x50(%r14)
setne %r13b
shll $0x5, %r13d
movl $0x18, %edi
callq 0x29709
movq %rax, %r15
movq 0x10(%r14,%r13), %rax
movslq %r12d, %rcx
movq (%rax,%rcx,8), %rdx
movq %rdx, 0x10(%r15)
movq %r15, (%rax,%rcx,8)
incq 0x28(%r14,%r13)
movq (%r14), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x223fa
movq 0x8(%r14), %rdi
movq %rbx, %rsi
callq *%rax
movq %rax, %rbx
movq %rbx, (%r15)
jmp 0x22438
movq 0x18(%r14), %rcx
testq %rcx, %rcx
je 0x2244a
movq 0x28(%r14), %rsi
cmpq %rcx, %rsi
jb 0x2232f
cmpb $0x1, 0xa7b88(%rip)     # 0xc9fa4
jne 0x22430
movq %rsi, %rax
xorl %edx, %edx
divq %rcx
cmpq $0x6, %rax
jb 0x2232f
addq %rsi, %rsi
jmp 0x2244f
xorl %r15d, %r15d
movq %r15, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %esi
movq %r14, %rdi
callq 0x21ffe
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x223a2
jmp 0x2232f
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictReplace
int dictReplace(dict *d, void *key, void *val)
{
    dictEntry *entry, auxentry;

    /* Try to add the element. If the key
     * does not exists dictAdd will suceed. */
    // 尝试直接将键值对添加到字典
    // 如果键 key 不存在的话，添加会成功
    // T = O(N)
    if (dictAdd(d, key, val) == DICT_OK)
        return 1;

    /* It already exists, get the entry */
    // 运行到这里，说明键 key 已经存在，那么找出包含这个 key 的节点
    // T = O(1)
    entry = dictFind(d, key);
    /* Set the new value and free the old one. Note that it is important
     * to do that in this order, as the value may just be exactly the same
     * as the previous one. In this context, think to reference counting,
     * you want to increment (set), and then decrement (free), and not the
     * reverse. */
    // 先保存原有的值的指针
    auxentry = *entry;
    // 然后设置新的值
    // T = O(1)
    dictSetVal(d, entry, val);
    // 然后释放旧值
    // T = O(1)
    dictFreeVal(d, &auxentry);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
callq 0x222b6
testl %eax, %eax
je 0x224cc
movq %rbx, %rdi
movq %r15, %rsi
callq 0x224dc
movq %rax, %r12
movq 0x8(%rax), %r15
movq (%rbx), %rax
movq 0x10(%rax), %rax
testq %rax, %rax
je 0x224ae
movq 0x8(%rbx), %rdi
movq %r14, %rsi
callq *%rax
movq %rax, %r14
movq %r14, 0x8(%r12)
movq (%rbx), %rax
movq 0x28(%rax), %rax
xorl %ebp, %ebp
testq %rax, %rax
je 0x224d1
movq 0x8(%rbx), %rdi
movq %r15, %rsi
callq *%rax
jmp 0x224d1
movl $0x1, %ebp
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictFind
dictEntry *dictFind(dict *d, const void *key)
{
    dictEntry *he;
    unsigned int h, idx, table;

    // 字典（的哈希表）为空
    if (d->ht[0].size == 0) return NULL; /* We don't have a table at all */

    // 如果条件允许的话，进行单步 rehash
    if (dictIsRehashing(d)) _dictRehashStep(d);

    // 计算键的哈希值
    h = dictHashKey(d, key);
    // 在字典的哈希表中查找这个键
    // T = O(1)
    for (table = 0; table <= 1; table++) {

        // 计算索引值
        idx = h & d->ht[table].sizemask;

        // 遍历给定索引上的链表的所有节点，查找 key
        he = d->ht[table].table[idx];
        // T = O(1)
        while(he) {

            if (dictCompareKeys(d, key, he->key))
                return he;

            he = he->next;
        }

        // 如果程序遍历完 0 号哈希表，仍然没找到指定的键的节点
        // 那么程序会检查字典是否在进行 rehash ，
        // 然后才决定是直接返回 NULL ，还是继续查找 1 号哈希表
        if (!dictIsRehashing(d)) return NULL;
    }

    // 进行到这里时，说明两个哈希表都没找到
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpq $0x0, 0x18(%rdi)
je 0x2258a
movq %rsi, %rbx
movq %rdi, %r14
cmpl $-0x1, 0x50(%rdi)
je 0x22512
cmpl $0x0, 0x54(%r14)
jne 0x22512
movq %r14, %rdi
movl $0x1, %esi
callq 0x2208c
leaq 0x10(%r14), %r12
movq (%r14), %rax
movq %rbx, %rdi
callq *(%rax)
movl %eax, %ebp
movq $0x0, (%rsp)
xorl %r13d, %r13d
movq %r13, %rax
shlq $0x5, %rax
movl 0x10(%r12,%rax), %ecx
andl %ebp, %ecx
movq (%r12,%rax), %rax
movq (%rax,%rcx,8), %r15
testq %r15, %r15
je 0x2256f
movq (%r14), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x22564
movq 0x8(%r14), %rdi
movq (%r15), %rdx
movq %rbx, %rsi
callq *%rax
testl %eax, %eax
je 0x22569
jmp 0x22584
cmpq %rbx, (%r15)
je 0x22584
movq 0x10(%r15), %r15
jmp 0x22541
cmpl $-0x1, 0x50(%r14)
je 0x22592
leaq 0x1(%r13), %rax
testq %r13, %r13
movq %rax, %r13
je 0x2252b
jmp 0x22592
movq %r15, (%rsp)
jmp 0x22592
movq $0x0, (%rsp)
movq (%rsp), %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictFetchValue
void *dictFetchValue(dict *d, const void *key) {
    dictEntry *he;

    // T = O(1)
    he = dictFind(d,key);

    return he ? dictGetVal(he) : NULL;
}

// Assembly:
pushq %rax
callq 0x224dc
testq %rax, %rax
je 0x22824
movq 0x8(%rax), %rax
jmp 0x22826
xorl %eax, %eax
popq %rcx
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictGetSafeIterator
dictIterator *dictGetSafeIterator(dict *d) {
    dictIterator *i = dictGetIterator(d);

    // 设置安全迭代器标识
    i->safe = 1;

    return i;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl $0x30, %edi
callq 0x29709
movq %rbx, (%rax)
movabsq $-0x100000000, %rcx     # imm = 0xFFFFFFFF00000000
movq %rcx, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movl $0x1, 0x10(%rax)
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictGetRandomKey
dictEntry *dictGetRandomKey(dict *d)
{
    dictEntry *he, *orighe;
    unsigned int h;
    int listlen, listele;

    // 字典为空
    if (dictSize(d) == 0) return NULL;

    // 进行单步 rehash
    if (dictIsRehashing(d)) _dictRehashStep(d);

    // 如果正在 rehash ，那么将 1 号哈希表也作为随机查找的目标
    if (dictIsRehashing(d)) {
        // T = O(N)
        do {
            h = random() % (d->ht[0].size+d->ht[1].size);
            he = (h >= d->ht[0].size) ? d->ht[1].table[h - d->ht[0].size] :
                                      d->ht[0].table[h];
        } while(he == NULL);
    // 否则，只从 0 号哈希表中查找节点
    } else {
        // T = O(N)
        do {
            h = random() & d->ht[0].sizemask;
            he = d->ht[0].table[h];
        } while(he == NULL);
    }

    /* Now we found a non empty bucket, but it is a linked
     * list and we need to get a random element from the list.
     * The only sane way to do so is counting the elements and
     * select a random index. */
    // 目前 he 已经指向一个非空的节点链表
    // 程序将从这个链表随机返回一个节点
    listlen = 0;
    orighe = he;
    // 计算节点数量, T = O(1)
    while(he) {
        he = he->next;
        listlen++;
    }
    // 取模，得出随机节点的索引
    listele = random() % listlen;
    he = orighe;
    // 按索引查找节点
    // T = O(1)
    while(listele--) he = he->next;

    // 返回随机节点
    return he;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x28(%rdi), %rax
addq 0x48(%rdi), %rax
jne 0x22a32
xorl %r14d, %r14d
jmp 0x22acf
movq %rdi, %rbx
cmpl $-0x1, 0x50(%rdi)
je 0x22a4e
cmpl $0x0, 0x54(%rbx)
jne 0x22a4e
movq %rbx, %rdi
movl $0x1, %esi
callq 0x2208c
cmpl $-0x1, 0x50(%rbx)
je 0x22a92
callq 0x1f9c0
movq 0x18(%rbx), %rsi
movq 0x38(%rbx), %rcx
addq %rsi, %rcx
xorl %edx, %edx
divq %rcx
movl %edx, %ecx
movq %rcx, %rax
subq %rsi, %rax
jae 0x22a80
shlq $0x3, %rcx
addq 0x10(%rbx), %rcx
movq %rcx, %rax
jmp 0x22a88
shlq $0x3, %rax
addq 0x30(%rbx), %rax
movq (%rax), %r14
testq %r14, %r14
je 0x22a54
jmp 0x22aa7
callq 0x1f9c0
movq 0x10(%rbx), %rcx
andl 0x20(%rbx), %eax
movq (%rcx,%rax,8), %r14
testq %r14, %r14
je 0x22a92
xorl %ebx, %ebx
movq %r14, %rax
movq 0x10(%rax), %rax
incq %rbx
testq %rax, %rax
jne 0x22aac
callq 0x1f9c0
cqto
idivq %rbx
testq %rdx, %rdx
je 0x22acf
movq 0x10(%r14), %r14
decl %edx
jne 0x22ac7
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictGetRandomKeys
int dictGetRandomKeys(dict *d, dictEntry **des, int count) {
    int j; /* internal hash table id, 0 or 1. */
    int stored = 0;

    if (dictSize(d) < count) count = dictSize(d);
    while(stored < count) {
        for (j = 0; j < 2; j++) {
            /* Pick a random point inside the hash table 0 or 1. */
            unsigned int i = random() & d->ht[j].sizemask;
            int size = d->ht[j].size;

            /* Make sure to visit every bucket by iterating 'size' times. */
            while(size--) {
                dictEntry *he = d->ht[j].table[i];
                while (he) {
                    /* Collect all the elements of the buckets found non
                     * empty while iterating. */
                    *des = he;
                    des++;
                    he = he->next;
                    stored++;
                    if (stored == count) return stored;
                }
                i = (i+1) & d->ht[j].sizemask;
            }
            /* If there is only one table and we iterated it all, we should
             * already have 'count' elements. Assert this condition. */
            assert(dictIsRehashing(d) != 0);
        }
    }
    return stored; /* Never reached. */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x48(%rdi), %rax
addq 0x28(%rdi), %rax
movslq %edx, %r15
cmpq %r15, %rax
cmovbl %eax, %r15d
testl %r15d, %r15d
jle 0x22b8f
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x10(%rdi), %r12
xorl %r13d, %r13d
xorl %ebp, %ebp
callq 0x1f9c0
movq %r13, %rdx
shlq $0x5, %rdx
leaq (%r12,%rdx), %rcx
movl 0x8(%r12,%rdx), %esi
movl 0x10(%r12,%rdx), %edi
andl %edi, %eax
movl %esi, %edx
subl $0x1, %esi
jb 0x22b66
movl %eax, %r9d
shlq $0x3, %r9
addq (%rcx), %r9
movq (%r9), %r8
testq %r8, %r8
je 0x22b5b
movq %r8, (%rbx)
addq $0x8, %rbx
leaq 0x10(%r8), %r9
incl %ebp
cmpl %ebp, %r15d
jne 0x22b3c
movl %r15d, %ebp
jmp 0x22b5f
incl %eax
andl %edi, %eax
testq %r8, %r8
je 0x22b2b
jmp 0x22b6d
cmpl $-0x1, 0x50(%r14)
je 0x22ba2
testl %edx, %edx
jne 0x22b8a
leaq 0x1(%r13), %rax
testq %r13, %r13
movq %rax, %r13
je 0x22b0f
movl $0x0, %r13d
cmpl %r15d, %ebp
jl 0x22b0f
jmp 0x22b91
movl %r15d, %ebp
jmp 0x22b91
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7160e(%rip), %rdi     # 0x941b7
leaq 0x7d99e(%rip), %rsi     # 0xa054e
movl $0x478, %edx            # imm = 0x478
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/dict.c
// Function: dictEmpty
void dictEmpty(dict *d, void(callback)(void*)) {

    // 删除两个哈希表上的所有节点
    // T = O(N)
    _dictClear(d,&d->ht[0],callback);
    _dictClear(d,&d->ht[1],callback);
    // 重置属性 
    d->rehashidx = -1;
    d->iterators = 0;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x10(%rdi), %rsi
movq %rbx, %rdx
callq 0x2272e
leaq 0x30(%r14), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x2272e
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %rax, 0x50(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: infoCommand
void infoCommand(redisClient *c) {
    char *section = c->argc == 2 ? c->argv[1]->ptr : "default";

    if (c->argc > 2) {
        addReply(c,shared.syntaxerr);
        return;
    }
    sds info = genRedisInfoString(section);
    addReplySds(c,sdscatprintf(sdsempty(),"$%lu\r\n",
        (unsigned long)sdslen(info)));
    addReplySds(c,info);
    addReply(c,shared.crlf);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x30(%rdi), %eax
cmpl $0x2, %eax
jne 0x22e34
movq 0x38(%rbx), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%rcx), %rdi
jmp 0x22e3b
leaq 0x726d0(%rip), %rdi     # 0x9550b
cmpl $0x2, %eax
jle 0x22e49
leaq 0xa7a39(%rip), %rax     # 0xca880
jmp 0x22e88
callq 0x2690c
movq %rax, %r14
callq 0x281b2
movslq -0x8(%r14), %rdx
leaq 0x730ce(%rip), %rsi     # 0x95f2f
movq %rax, %rdi
xorl %eax, %eax
callq 0x28760
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2d894
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2d894
leaq 0xa7978(%rip), %rax     # 0xca800
movq (%rax), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2d6f0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: monitorCommand
void monitorCommand(redisClient *c) {
    /* ignore MONITOR if already slave or in monitor mode */

    // 这个客户端是从服务器，或者已经是监视器
    if (c->flags & REDIS_SLAVE) return;

    // 打开 SLAVE 标志和 MONITOR 标志
    c->flags |= (REDIS_SLAVE|REDIS_MONITOR);

    // 添加客户端到 monitors 链表
    listAddNodeTail(server.monitors,c);

    // 返回 OK
    addReply(c,shared.ok);
}

// Assembly:
movl 0x90(%rdi), %eax
testb $0x1, %al
jne 0x22ed0
pushq %rbx
movq %rdi, %rbx
orl $0x5, %eax
movl %eax, 0x90(%rdi)
movq 0xa72b8(%rip), %rdi     # 0xca170
movq %rbx, %rsi
callq 0x2045f
movq 0xa7941(%rip), %rsi     # 0xca808
movq %rbx, %rdi
popq %rbx
jmp 0x2d6f0
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: redisLogRaw
void redisLogRaw(int level, const char *msg) {
    const int syslogLevelMap[] = { LOG_DEBUG, LOG_INFO, LOG_NOTICE, LOG_WARNING };
    const char *c = ".-*#";
    FILE *fp;
    char buf[64];
    int rawmode = (level & REDIS_LOG_RAW);
    int log_to_stdout = server.logfile[0] == '\0';

    level &= 0xff; /* clear flags */
    if (level < server.verbosity) return;

    fp = log_to_stdout ? stdout : fopen(server.logfile,"a");
    if (!fp) return;

    if (rawmode) {
        fprintf(fp,"%s",msg);
    } else {
        int off;
        struct timeval tv;

        gettimeofday(&tv,NULL);
        off = strftime(buf,sizeof(buf),"%d %b %H:%M:%S.",localtime(&tv.tv_sec));
        snprintf(buf+off,sizeof(buf)-off,"%03d",(int)tv.tv_usec/1000);
        fprintf(fp,"[%d] %s %c %s\n",(int)getpid(),buf,c[level],msg);
    }
    fflush(fp);

    if (!log_to_stdout) fclose(fp);
    if (server.syslog_enabled) syslog(syslogLevelMap[level], "%s", msg);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edi, %ebp
movzbl %bpl, %r15d
cmpl 0xa74dc(%rip), %r15d    # 0xca40c
jl 0x23055
movq %rsi, %rbx
movq 0xa7638(%rip), %rdi     # 0xca578
movb (%rdi), %r12b
testb %r12b, %r12b
je 0x22f59
leaq 0x7f379(%rip), %rsi     # 0xa22c8
callq 0x1fa60
movq %rax, %r14
jmp 0x22f63
movq 0xa3090(%rip), %rax     # 0xc5ff0
movq (%rax), %r14
testq %r14, %r14
je 0x23055
btl $0xa, %ebp
jb 0x2300e
movq %rsp, %rbp
movq %rbp, %rdi
xorl %esi, %esi
callq 0x1f2f0
movq %rbp, %rdi
callq 0x1fb20
leaq 0x716ea(%rip), %rdx     # 0x9467c
leaq 0x10(%rsp), %rdi
movl $0x40, %r13d
movl $0x40, %esi
movq %rax, %rcx
callq 0x1fb60
cltq
leaq (%rsp,%rax), %rdi
addq $0x10, %rdi
subq %rax, %r13
movslq 0x8(%rbp), %rax
imulq $0x10624dd3, %rax, %rcx # imm = 0x10624DD3
movq %rcx, %rax
shrq $0x3f, %rax
sarq $0x26, %rcx
addl %eax, %ecx
leaq 0x716b6(%rip), %rdx     # 0x9468c
movq %r13, %rsi
xorl %eax, %eax
callq 0x1f120
callq 0x1f410
leaq 0x7168b(%rip), %rcx     # 0x94677
movsbl (%r15,%rcx), %r8d
leaq 0x71699(%rip), %rsi     # 0x94691
movq %r14, %rdi
movl %eax, %edx
leaq 0x10(%rsp), %rcx
movq %rbx, %r9
xorl %eax, %eax
callq 0x1fb10
jmp 0x23019
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1f6c0
movq %r14, %rdi
callq 0x1fc60
testb %r12b, %r12b
je 0x2302e
movq %r14, %rdi
callq 0x1f9a0
cmpl $0x0, 0xa754b(%rip)     # 0xca580
je 0x23055
movl %r15d, %eax
leaq 0x711af(%rip), %rcx     # 0x941f0
movl (%rcx,%rax,4), %edi
leaq 0x7c3c7(%rip), %rsi     # 0x9f412
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1f180
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: redisLog
void redisLog(int level, const char *fmt, ...) {
    va_list ap;
    char msg[REDIS_MAX_LOGMSG_LEN];

    if ((level&0xff) < server.verbosity) return;

    va_start(ap, fmt);
    vsnprintf(msg, sizeof(msg), fmt, ap);
    va_end(ap);

    redisLogRaw(level,msg);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x4d8, %rsp            # imm = 0x4D8
movl %edi, %ebx
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x230bf
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movzbl %bl, %eax
cmpl 0xa7344(%rip), %eax     # 0xca40c
jl 0x23114
movq %rsi, %r10
leaq 0x20(%rsp), %rax
movq %rsp, %rcx
movq %rax, 0x10(%rcx)
leaq 0x4f0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rcx)
leaq 0xd0(%rsp), %r14
movl $0x400, %esi            # imm = 0x400
movq %r14, %rdi
movq %r10, %rdx
callq 0x1f7b0
movl %ebx, %edi
movq %r14, %rsi
callq 0x22f15
addq $0x4d8, %rsp            # imm = 0x4D8
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: redisLogFromHandler
void redisLogFromHandler(int level, const char *msg) {
    int fd;
    int log_to_stdout = server.logfile[0] == '\0';
    char buf[64];

    if ((level&0xff) < server.verbosity || (log_to_stdout && server.daemonize))
        return;
    fd = log_to_stdout ? STDOUT_FILENO : 
                         open(server.logfile, O_APPEND|O_CREAT|O_WRONLY, 0644);
    if (fd == -1) return;
    ll2string(buf,sizeof(buf),getpid());
    if (write(fd,"[",1) == -1) goto err;
    if (write(fd,buf,strlen(buf)) == -1) goto err;
    if (write(fd," | signal handler] (",20) == -1) goto err;
    ll2string(buf,sizeof(buf),time(NULL));
    if (write(fd,buf,strlen(buf)) == -1) goto err;
    if (write(fd,") ",2) == -1) goto err;
    if (write(fd,msg,strlen(msg)) == -1) goto err;
    if (write(fd,"\n",1) == -1) goto err;
err:
    if (!log_to_stdout) close(fd);
}

// Assembly:
movzbl %dil, %eax
cmpl 0xa72e3(%rip), %eax     # 0xca40c
jl 0x2327f
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rsi, %rbx
movq 0xa7435(%rip), %rdi     # 0xca578
movb (%rdi), %r15b
testb %r15b, %r15b
jne 0x23158
cmpl $0x0, 0xa72da(%rip)     # 0xca42c
jne 0x23275
testb %r15b, %r15b
je 0x23172
movl $0x441, %esi            # imm = 0x441
movl $0x1a4, %edx            # imm = 0x1A4
xorl %eax, %eax
callq 0x1f640
movl %eax, %ebp
jmp 0x23177
movl $0x1, %ebp
cmpl $-0x1, %ebp
je 0x23275
callq 0x1f410
movslq %eax, %rdx
movq %rsp, %rdi
movl $0x40, %esi
callq 0x2fe12
leaq 0x71504(%rip), %rsi     # 0x946a0
movl $0x1, %edx
movl %ebp, %edi
callq 0x1fb30
cmpq $-0x1, %rax
je 0x23269
movq %rsp, %r14
movq %r14, %rdi
callq 0x1f4f0
movl %ebp, %edi
movq %r14, %rsi
movq %rax, %rdx
callq 0x1fb30
cmpq $-0x1, %rax
je 0x23269
leaq 0x714c7(%rip), %rsi     # 0x946a2
movl $0x14, %edx
movl %ebp, %edi
callq 0x1fb30
cmpq $-0x1, %rax
je 0x23269
xorl %edi, %edi
callq 0x1fc50
movq %rsp, %r14
movl $0x40, %esi
movq %r14, %rdi
movq %rax, %rdx
callq 0x2fe12
movq %r14, %rdi
callq 0x1f4f0
movl %ebp, %edi
movq %r14, %rsi
movq %rax, %rdx
callq 0x1fb30
cmpq $-0x1, %rax
je 0x23269
leaq 0x7aad8(%rip), %rsi     # 0x9dd01
movl $0x2, %edx
movl %ebp, %edi
callq 0x1fb30
cmpq $-0x1, %rax
je 0x23269
movq %rbx, %rdi
callq 0x1f4f0
movl %ebp, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1fb30
cmpq $-0x1, %rax
je 0x23269
leaq 0x734e4(%rip), %rsi     # 0x96741
movl $0x1, %edx
movl %ebp, %edi
callq 0x1fb30
testb %r15b, %r15b
je 0x23275
movl %ebp, %edi
callq 0x1f170
addq $0x48, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: dictEncObjHash
unsigned int dictEncObjHash(const void *key) {
    robj *o = (robj*) key;

    if (sdsEncodedObject(o)) {
        return dictGenHashFunction(o->ptr, sdslen((sds)o->ptr));
    } else {
        if (o->encoding == REDIS_ENCODING_INT) {
            char buf[32];
            int len;

            len = ll2string(buf,32,(long)o->ptr);
            return dictGenHashFunction((unsigned char*)buf, len);
        } else {
            unsigned int hash;

            o = getDecodedObject(o);
            hash = dictGenHashFunction(o->ptr, sdslen((sds)o->ptr));
            decrRefCount(o);
            return hash;
        }
    }
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x28, %rsp
movl (%rdi), %eax
shrl $0x4, %eax
andl $0xf, %eax
cmpl $0x8, %eax
je 0x23425
cmpl $0x1, %eax
je 0x23437
testl %eax, %eax
jne 0x23457
movq 0x8(%rdi), %rdi
movl -0x8(%rdi), %esi
addq $0x28, %rsp
popq %rbx
popq %rbp
jmp 0x21ed8
movq 0x8(%rdi), %rdx
movq %rsp, %rbx
movl $0x20, %esi
movq %rbx, %rdi
callq 0x2fe12
movq %rbx, %rdi
movl %eax, %esi
callq 0x21ed8
jmp 0x23477
callq 0x30ac3
movq %rax, %rbx
movq 0x8(%rax), %rdi
movl -0x8(%rdi), %esi
callq 0x21ed8
movl %eax, %ebp
movq %rbx, %rdi
callq 0x30834
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: htNeedsResize
int htNeedsResize(dict *dict) {
    long long size, used;

    size = dictSlots(dict);
    used = dictSize(dict);
    return (size && used && size > DICT_HT_INITIAL_SIZE &&
            (used*100/size < REDIS_HT_MINFILL));
}

// Assembly:
movq 0x38(%rdi), %rcx
movq 0x48(%rdi), %rdx
addq 0x18(%rdi), %rcx
addq 0x28(%rdi), %rdx
setne %al
cmpq $0x5, %rcx
setge %sil
andb %al, %sil
xorl %eax, %eax
cmpb $0x1, %sil
jne 0x234b9
imulq $0x64, %rdx, %rax
cqto
idivq %rcx
movq %rax, %rcx
xorl %eax, %eax
cmpq $0xa, %rcx
setl %al
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: tryResizeHashTables
void tryResizeHashTables(int dbid) {
    if (htNeedsResize(server.db[dbid].dict))
        dictResize(server.db[dbid].dict);
    if (htNeedsResize(server.db[dbid].expires))
        dictResize(server.db[dbid].expires);
}

// Assembly:
pushq %rbx
movq 0xa6af6(%rip), %rax     # 0xc9fb8
movslq %edi, %rbx
shlq $0x6, %rbx
movq (%rax,%rbx), %rdi
movq 0x38(%rdi), %rcx
addq 0x18(%rdi), %rcx
movq 0x48(%rdi), %rax
addq 0x28(%rdi), %rax
setne %dl
cmpq $0x5, %rcx
setge %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x23505
imulq $0x64, %rax, %rax
cqto
idivq %rcx
cmpq $0x9, %rax
jg 0x23505
callq 0x21fd6
movq 0xa6aac(%rip), %rax     # 0xc9fb8
movq 0x8(%rax,%rbx), %rdi
movq 0x38(%rdi), %rcx
addq 0x18(%rdi), %rcx
movq 0x48(%rdi), %rax
addq 0x28(%rdi), %rax
setne %dl
cmpq $0x5, %rcx
setge %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x23544
imulq $0x64, %rax, %rax
cqto
idivq %rcx
cmpq $0x9, %rax
jle 0x23546
popq %rbx
retq
popq %rbx
jmp 0x21fd6
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: incrementallyRehash
int incrementallyRehash(int dbid) {

    /* Keys dictionary */
    if (dictIsRehashing(server.db[dbid].dict)) {
        dictRehashMilliseconds(server.db[dbid].dict,1);
        return 1; /* already used our millisecond for this loop... */
    }

    /* Expires */
    if (dictIsRehashing(server.db[dbid].expires)) {
        dictRehashMilliseconds(server.db[dbid].expires,1);
        return 1; /* already used our millisecond for this loop... */
    }

    return 0;
}

// Assembly:
pushq %rbx
movq 0xa6a64(%rip), %rax     # 0xc9fb8
movslq %edi, %rcx
shlq $0x6, %rcx
movq (%rax,%rcx), %rdi
cmpl $-0x1, 0x50(%rdi)
jne 0x23572
addq %rcx, %rax
movq 0x8(%rax), %rdi
cmpl $-0x1, 0x50(%rdi)
je 0x23585
movl $0x1, %ebx
movl $0x1, %esi
callq 0x22201
movl %ebx, %eax
popq %rbx
retq
xorl %ebx, %ebx
jmp 0x23581
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: activeExpireCycleTryExpire
int activeExpireCycleTryExpire(redisDb *db, dictEntry *de, long long now) {
    // 获取键的过期时间
    long long t = dictGetSignedIntegerVal(de);
    if (now > t) {

        // 键已过期

        sds key = dictGetKey(de);
        robj *keyobj = createStringObject(key,sdslen(key));

        // 传播过期命令
        propagateExpire(db,keyobj);
        // 从数据库中删除该键
        dbDelete(db,keyobj);
        // 发送事件
        notifyKeyspaceEvent(REDIS_NOTIFY_EXPIRED,
            "expired",keyobj,db->id);
        decrRefCount(keyobj);
        // 更新计数器
        server.stat_expiredkeys++;
        return 1;
    } else {

        // 键未过期
        return 0;
    }
}

// Assembly:
xorl %eax, %eax
cmpq %rdx, 0x8(%rsi)
jge 0x2360e
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rsi), %rdi
movslq -0x8(%rdi), %rsi
callq 0x303b7
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
callq 0x328ff
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3174b
movl 0x30(%rbx), %ecx
leaq 0x710d1(%rip), %rsi     # 0x946b7
movl $0x100, %edi            # imm = 0x100
movq %r14, %rdx
callq 0x608b5
movq %r14, %rdi
callq 0x30834
incq 0xa6cfe(%rip)           # 0xca300
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: trackOperationsPerSecond
void trackOperationsPerSecond(void) {

    // 计算两次抽样之间的时间长度，毫秒格式
    long long t = mstime() - server.ops_sec_last_sample_time;

    // 计算两次抽样之间，执行了多少个命令
    long long ops = server.stat_numcommands - server.ops_sec_last_sample_ops;

    long long ops_sec;

    // 计算距离上一次抽样之后，每秒执行命令的数量
    ops_sec = t > 0 ? (ops*1000/t) : 0;

    // 将计算出的执行命令数量保存到抽样数组
    server.ops_sec_samples[server.ops_sec_idx] = ops_sec;
    // 更新抽样数组的索引
    server.ops_sec_idx = (server.ops_sec_idx+1) % REDIS_OPS_SEC_SAMPLES;
    // 更新最后一次抽样的时间
    server.ops_sec_last_sample_time = mstime();
    // 更新最后一次抽样时的执行命令数量
    server.ops_sec_last_sample_ops = server.stat_numcommands;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
xorl %ebx, %ebx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
xorl %esi, %esi
callq 0x1f2f0
imulq $0xf4240, (%r14), %rax  # imm = 0xF4240
addq 0x8(%r14), %rax
movabsq $0x20c49ba5e353f7cf, %r14 # imm = 0x20C49BA5E353F7CF
imulq %r14
movq %rdx, %rcx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rcx
addq %rax, %rcx
subq 0xa6a1c(%rip), %rcx     # 0xca378
jle 0x2397b
movq 0xa698b(%rip), %rax     # 0xca2f0
subq 0xa6a14(%rip), %rax     # 0xca380
imulq $0x3e8, %rax, %rax      # imm = 0x3E8
cqto
idivq %rcx
movq %rax, %rbx
movslq 0xa6a86(%rip), %rax     # 0xca408
leaq 0xa661f(%rip), %rcx     # 0xc9fa8
movq %rbx, 0x3e0(%rcx,%rax,8)
leal 0x1(%rax), %ecx
leal 0x10(%rax), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
andl $-0x10, %edx
negl %edx
addl %edx, %eax
incl %eax
movl %eax, 0xa6a5d(%rip)     # 0xca408
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1f2f0
imulq $0xf4240, (%rbx), %rax  # imm = 0xF4240
addq 0x8(%rbx), %rax
imulq %r14
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
movq %rdx, 0xa699b(%rip)     # 0xca378
movq 0xa690c(%rip), %rax     # 0xca2f0
movq %rax, 0xa6995(%rip)     # 0xca380
addq $0x18, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/redis.c
// Function: getOperationsPerSecond
long long getOperationsPerSecond(void) {
    int j;
    long long sum = 0;

    // 计算所有取样值的总和
    for (j = 0; j < REDIS_OPS_SEC_SAMPLES; j++)
        sum += server.ops_sec_samples[j];

    // 计算取样的平均值
    return sum / REDIS_OPS_SEC_SAMPLES;
}

// Assembly:
xorl %eax, %eax
leaq 0xa65ac(%rip), %rdx     # 0xc9fa8
xorl %ecx, %ecx
addq 0x3e0(%rdx,%rax,8), %rcx
incq %rax
cmpq $0x10, %rax
jne 0x239fe
leaq 0xf(%rcx), %rax
testq %rcx, %rcx
cmovnsq %rcx, %rax
sarq $0x4, %rax
retq