LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: scriptingEnableGlobalsProtection
void scriptingEnableGlobalsProtection(lua_State *lua) {
    char *s[32];
    sds code = sdsempty();
    int j = 0;

    /* strict.lua from: http://metalua.luaforge.net/src/lib/strict.lua.html.
     * Modified to be adapted to Redis. */
    s[j++]="local mt = {}\n";
    s[j++]="setmetatable(_G, mt)\n";
    s[j++]="mt.__newindex = function (t, n, v)\n";
    s[j++]="  if debug.getinfo(2) then\n";
    s[j++]="    local w = debug.getinfo(2, \"S\").what\n";
    s[j++]="    if w ~= \"main\" and w ~= \"C\" then\n";
    s[j++]="      error(\"Script attempted to create global variable '\"..tostring(n)..\"'\", 2)\n";
    s[j++]="    end\n";
    s[j++]="  end\n";
    s[j++]="  rawset(t, n, v)\n";
    s[j++]="end\n";
    s[j++]="mt.__index = function (t, n)\n";
    s[j++]="  if debug.getinfo(2) and debug.getinfo(2, \"S\").what ~= \"C\" then\n";
    s[j++]="    error(\"Script attempted to access unexisting global variable '\"..tostring(n)..\"'\", 2)\n";
    s[j++]="  end\n";
    s[j++]="  return rawget(t, n)\n";
    s[j++]="end\n";
    s[j++]=NULL;

    for (j = 0; s[j] != NULL; j++) code = sdscatlen(code,s[j],strlen(s[j]));
    luaL_loadbuffer(lua,code,sdslen(code),"@enable_strict_lua");
    lua_pcall(lua,0,0,0);
    sdsfree(code);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %rbx
callq 0x281b2
movq %rax, %r14
leaq 0x4606d(%rip), %r15     # 0x9d900
movq %r15, (%rsp)
leaq 0x46071(%rip), %rax     # 0x9d90f
movq %rax, 0x8(%rsp)
leaq 0x4607b(%rip), %rax     # 0x9d925
movq %rax, 0x10(%rsp)
leaq 0x46093(%rip), %rax     # 0x9d949
movq %rax, 0x18(%rsp)
leaq 0x460a3(%rip), %rax     # 0x9d965
movq %rax, 0x20(%rsp)
leaq 0x460c1(%rip), %rax     # 0x9d98f
movq %rax, 0x28(%rsp)
leaq 0x460db(%rip), %rax     # 0x9d9b5
movq %rax, 0x30(%rsp)
leaq 0x46121(%rip), %rax     # 0x9da07
movq %rax, 0x38(%rsp)
leaq 0x46117(%rip), %rax     # 0x9da09
movq %rax, 0x40(%rsp)
leaq 0x46112(%rip), %rcx     # 0x9da10
movq %rcx, 0x48(%rsp)
leaq 0x462ca(%rip), %rcx     # 0x9dbd4
movq %rcx, 0x50(%rsp)
leaq 0x4610d(%rip), %rdx     # 0x9da23
movq %rdx, 0x58(%rsp)
leaq 0x4611f(%rip), %rdx     # 0x9da41
movq %rdx, 0x60(%rsp)
leaq 0x46155(%rip), %rdx     # 0x9da83
movq %rdx, 0x68(%rsp)
movq %rax, 0x70(%rsp)
leaq 0x4619f(%rip), %rax     # 0x9dade
movq %rax, 0x78(%rsp)
movq %rcx, 0x80(%rsp)
movq $0x0, 0x88(%rsp)
testq %r15, %r15
je 0x57988
leaq 0x8(%rsp), %r12
movq %r15, %rdi
callq 0x1f4f0
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x28380
movq %rax, %r14
movq (%r12), %r15
addq $0x8, %r12
testq %r15, %r15
jne 0x57962
movslq -0x8(%r14), %rdx
leaq 0x46162(%rip), %rcx     # 0x9daf5
movq %rbx, %rdi
movq %r14, %rsi
callq 0x71cc8
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x66dd8
movq %r14, %rdi
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x28204
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: redis_math_random
int redis_math_random (lua_State *L) {
  /* the `%' avoids the (rare) case of r==1, and is needed also because on
     some systems (SunOS!) `rand()' may return a value larger than RAND_MAX */
  lua_Number r = (lua_Number)(redisLrand48()%REDIS_LRAND48_MAX) /
                                (lua_Number)REDIS_LRAND48_MAX;
  switch (lua_gettop(L)) {  /* check number of arguments */
    case 0: {  /* no arguments */
      lua_pushnumber(L, r);  /* Number between 0 and 1 */
      break;
    }
    case 1: {  /* only upper limit */
      int u = luaL_checkint(L, 1);
      luaL_argcheck(L, 1<=u, 1, "interval is empty");
      lua_pushnumber(L, floor(r*u)+1);  /* int between 1 and `u' */
      break;
    }
    case 2: {  /* lower and upper limits */
      int l = luaL_checkint(L, 1);
      int u = luaL_checkint(L, 2);
      luaL_argcheck(L, l<=u, 2, "interval is empty");
      lua_pushnumber(L, floor(r*(u-l+1))+l);  /* int between `l' and `u' */
      break;
    }
    default: return luaL_error(L, "wrong number of arguments");
  }
  return 1;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
xorl %eax, %eax
callq 0x591d4
cltq
movq %rax, %rcx
shlq $0x1e, %rcx
addq %rax, %rcx
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x3d, %rcx
addl %edx, %ecx
addl %ecx, %eax
shll $0x1f, %ecx
addl %eax, %ecx
cvtsi2sd %ecx, %xmm0
divsd 0x458cf(%rip), %xmm0    # 0x9d600
movsd %xmm0, 0x8(%rsp)
movq %rbx, %rdi
callq 0x66095
cmpl $0x2, %eax
je 0x57da6
cmpl $0x1, %eax
je 0x57d5f
testl %eax, %eax
jne 0x57e19
movq %rbx, %rdi
movsd 0x8(%rsp), %xmm0
jmp 0x57e05
movq %rbx, %rdi
movl $0x1, %esi
callq 0x71293
movq %rax, %r14
testl %r14d, %r14d
jg 0x57d88
leaq 0x46098(%rip), %rdx     # 0x9de13
movq %rbx, %rdi
movl $0x1, %esi
callq 0x70d3c
cvtsi2sd %r14d, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x1fad0
addsd 0x3f50c(%rip), %xmm0    # 0x972b0
jmp 0x57e02
movq %rbx, %rdi
movl $0x1, %esi
callq 0x71293
movq %rax, %r14
movq %rbx, %rdi
movl $0x2, %esi
callq 0x71293
movq %rax, %r15
subl %r14d, %r15d
jge 0x57ddf
leaq 0x46041(%rip), %rdx     # 0x9de13
movq %rbx, %rdi
movl $0x2, %esi
callq 0x70d3c
incl %r15d
cvtsi2sd %r15d, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm1, %xmm0
callq 0x1fad0
xorps %xmm1, %xmm1
cvtsi2sd %r14d, %xmm1
addsd %xmm1, %xmm0
movq %rbx, %rdi
callq 0x666d1
movl $0x1, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x4226d(%rip), %rsi     # 0x9a08d
movq %rbx, %rdi
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x70df6
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: scriptingReset
void scriptingRelease(void) {

    // 释放记录脚本的字典
    dictRelease(server.lua_scripts);

    // 关闭 Lua 环境
    lua_close(server.lua);
}

// Assembly:
pushq %rbx
leaq 0x72136(%rip), %rbx     # 0xc9fa8
movq 0x7f8(%rbx), %rdi
callq 0x227ed
movq 0x7e0(%rbx), %rdi
callq 0x6d74b
popq %rbx
jmp 0x579c2
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/scripting.c
// Function: luaSetGlobalArray
void luaSetGlobalArray(lua_State *lua, char *var, robj **elev, int elec) {
    int j;

    lua_newtable(lua);
    for (j = 0; j < elec; j++) {
        lua_pushlstring(lua,(char*)elev[j]->ptr,sdslen(elev[j]->ptr));
        lua_rawseti(lua,-2,j+1);
    }
    lua_setglobal(lua,var);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
xorl %esi, %esi
xorl %edx, %edx
callq 0x66a47
testl %ebp, %ebp
jle 0x581c6
movl %ebp, %r13d
xorl %r12d, %r12d
movq (%r14,%r12,8), %rax
movq 0x8(%rax), %rsi
movslq -0x8(%rsi), %rdx
movq %r15, %rdi
callq 0x66700
incq %r12
movq %r15, %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
movl %r12d, %edx
callq 0x66c27
cmpq %r12, %r13
jne 0x5819a
movq %r15, %rdi
movl $0xffffd8ee, %esi       # imm = 0xFFFFD8EE
movq %rbx, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x66b6a
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/bio.c
// Function: bioInit
void bioInit(void) {
    pthread_attr_t attr;
    pthread_t thread;
    size_t stacksize;
    int j;

    /* Initialization of state vars and objects 
     *
     * 初始化 job 队列，以及线程状态
     */
    for (j = 0; j < REDIS_BIO_NUM_OPS; j++) {
        pthread_mutex_init(&bio_mutex[j],NULL);
        pthread_cond_init(&bio_condvar[j],NULL);
        bio_jobs[j] = listCreate();
        bio_pending[j] = 0;
    }

    /* Set the stack size as by default it may be small in some system 
     *
     * 设置栈大小
     */
    pthread_attr_init(&attr);
    pthread_attr_getstacksize(&attr,&stacksize);
    if (!stacksize) stacksize = 1; /* The world is full of Solaris Fixes */
    while (stacksize < REDIS_THREAD_STACK_SIZE) stacksize *= 2;
    pthread_attr_setstacksize(&attr, stacksize);

    /* Ready to spawn our threads. We use the single argument the thread
     * function accepts in order to pass the job ID the thread is
     * responsible of. 
     *
     * 创建线程
     */
    for (j = 0; j < REDIS_BIO_NUM_OPS; j++) {
        void *arg = (void*)(unsigned long) j;
        if (pthread_create(&thread,&attr,bioProcessBackgroundJobs,arg) != 0) {
            redisLog(REDIS_WARNING,"Fatal: Can't initialize Background Jobs.");
            exit(1);
        }
        bio_threads[j] = thread;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x50, %rsp
leaq 0x85dc4(%rip), %rbx     # 0xde840
leaq 0x85d6d(%rip), %r14     # 0xde7f0
xorl %r15d, %r15d
leaq 0x85e13(%rip), %r12     # 0xde8a0
leaq 0x85e1c(%rip), %r13     # 0xde8b0
movq %r14, %rdi
xorl %esi, %esi
callq 0x1f420
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1f510
callq 0x2038c
movq %rax, (%r15,%r12)
movq $0x0, (%r15,%r13)
addq $0x8, %r15
addq $0x30, %rbx
addq $0x28, %r14
cmpq $0x8, %r15
je 0x58a94
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x1f9e0
leaq 0x8(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1f870
cmpq $0x0, (%r14)
jne 0x58af7
movq $0x1, 0x8(%rsp)
movq 0x8(%rsp), %rsi
cmpq $0x3fffff, %rsi         # imm = 0x3FFFFF
ja 0x58b18
movq %rsi, %rax
addq %rsi, %rsi
cmpq $0x200000, %rax         # imm = 0x200000
jb 0x58b05
movq %rsi, 0x8(%rsp)
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x1f760
leaq 0x85d94(%rip), %r13     # 0xde8c0
xorl %r14d, %r14d
leaq 0x5b(%rip), %r15        # 0x58b91
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movq %r14, %rcx
callq 0x1f490
testl %eax, %eax
jne 0x58b74
movq 0x10(%rsp), %rax
movq %rax, (%r13)
incq %r14
addq $0x8, %r13
cmpq $0x1, %r14
je 0x58b3b
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x453cf(%rip), %rsi     # 0x9df4a
movl $0x3, %edi
xorl %eax, %eax
callq 0x23064
movl $0x1, %edi
callq 0x1f2b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/bio.c
// Function: bioCreateBackgroundJob
void bioCreateBackgroundJob(int type, void *arg1, void *arg2, void *arg3) {
    struct bio_job *job = zmalloc(sizeof(*job));

    job->time = time(NULL);
    job->arg1 = arg1;
    job->arg2 = arg2;
    job->arg3 = arg3;

    pthread_mutex_lock(&bio_mutex[type]);

    // 将新工作推入队列
    listAddNodeTail(bio_jobs[type],job);
    bio_pending[type]++;

    pthread_cond_signal(&bio_condvar[type]);

    pthread_mutex_unlock(&bio_mutex[type]);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %ebp
movl $0x20, %edi
callq 0x29709
movq %rax, %r12
xorl %edi, %edi
callq 0x1fc50
movq %rax, (%r12)
movq %r15, 0x8(%r12)
movq %r14, 0x10(%r12)
movq %rbx, 0x18(%r12)
movslq %ebp, %r14
leaq (%r14,%r14,4), %rax
leaq 0x85ade(%rip), %rcx     # 0xde7f0
leaq (%rcx,%rax,8), %rbx
movq %rbx, %rdi
callq 0x1faa0
leaq 0x85b7b(%rip), %rax     # 0xde8a0
movq (%rax,%r14,8), %rdi
movq %r12, %rsi
callq 0x2045f
leaq 0x85b78(%rip), %rax     # 0xde8b0
incq (%rax,%r14,8)
leaq (%r14,%r14,2), %rax
shlq $0x4, %rax
leaq 0x85af5(%rip), %rdi     # 0xde840
addq %rax, %rdi
callq 0x1f270
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1fbb0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/bio.c
// Function: bioKillThreads
void bioKillThreads(void) {
    int err, j;

    for (j = 0; j < REDIS_BIO_NUM_OPS; j++) {
        if (pthread_cancel(bio_threads[j]) == 0) {
            if ((err = pthread_join(bio_threads[j],NULL)) != 0) {
                redisLog(REDIS_WARNING,
                    "Bio thread for job type #%d can be joined: %s",
                        j, strerror(err));
            } else {
                redisLog(REDIS_WARNING,
                    "Bio thread for job type #%d terminated",j);
            }
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
leaq 0x85b12(%rip), %r12     # 0xde8c0
leaq 0x45252(%rip), %rbx     # 0x9e007
leaq 0x4521d(%rip), %r14     # 0x9dfd9
xorl %r15d, %r15d
movq (%r12), %rdi
callq 0x1f750
testl %eax, %eax
jne 0x58e0b
movq (%r12), %rdi
xorl %esi, %esi
callq 0x1f080
testl %eax, %eax
je 0x58df9
movl %eax, %edi
callq 0x1f630
movl $0x3, %edi
movq %r14, %rsi
movl %r15d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x23064
jmp 0x58e0b
movl $0x3, %edi
movq %rbx, %rsi
movl %r15d, %edx
xorl %eax, %eax
callq 0x23064
incq %r15
addq $0x8, %r12
cmpq $0x1, %r15
je 0x58dbf
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rio.c
// Function: rioWriteBulkString
size_t rioWriteBulkString(rio *r, const char *buf, size_t len) {
    size_t nwritten;

    // 写入 $<count>\r\n
    if ((nwritten = rioWriteBulkCount(r,'$',len)) == 0) return 0;

    // 写入 <payload>
    if (len > 0 && rioWrite(r,buf,len) == 0) return 0;

    // 写入 \r\n
    if (rioWrite(r,"\r\n",2) == 0) return 0;

    // 返回写入总量
    return nwritten+len+2;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r14
movl $0x24, %esi
callq 0x58eae
testq %rax, %rax
je 0x5904e
movq %rax, %r15
testq %rbx, %rbx
je 0x58fe3
movq %rbx, %rcx
testq %rcx, %rcx
je 0x58fe3
movq %rcx, %rbp
movq 0x18(%r14), %rax
movq 0x30(%r14), %rcx
cmpq %rbp, %rcx
movq %rbp, %r13
cmovbq %rcx, %r13
testq %rcx, %rcx
cmoveq %rbp, %r13
testq %rax, %rax
je 0x58fb5
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq *%rax
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq *0x8(%r14)
testq %rax, %rax
je 0x58fd6
addq %r13, %r12
movq %rbp, %rcx
subq %r13, %rcx
addq %r13, 0x28(%r14)
jmp 0x58fd9
movq %rbp, %rcx
testq %rax, %rax
jne 0x58f84
testq %rbp, %rbp
jne 0x5904e
movl $0x2, %ecx
leaq 0x406d8(%rip), %r12     # 0x996c7
testq %rcx, %rcx
je 0x59052
movq %rcx, %rbp
movq 0x18(%r14), %rax
movq 0x30(%r14), %rcx
cmpq %rbp, %rcx
movq %rbp, %r13
cmovbq %rcx, %r13
testq %rcx, %rcx
cmoveq %rbp, %r13
testq %rax, %rax
je 0x59020
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq *%rax
movq %r14, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq *0x8(%r14)
testq %rax, %rax
je 0x59041
addq %r13, %r12
movq %rbp, %rcx
subq %r13, %rcx
addq %r13, 0x28(%r14)
jmp 0x59044
movq %rbp, %rcx
testq %rax, %rax
jne 0x58fef
testq %rbp, %rbp
je 0x59052
xorl %eax, %eax
jmp 0x5905a
leaq (%rbx,%r15), %rax
addq $0x2, %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/rio.c
// Function: rioBufferRead
static size_t rioBufferRead(rio *r, void *buf, size_t len) {

    // r 中的内容的长度不足 len 
    if (sdslen(r->io.buffer.ptr)-r->io.buffer.pos < len)
        return 0; /* not enough buffer to return len bytes. */
    
    // 复制 r 中的内容到 buf
    memcpy(buf,r->io.buffer.ptr+r->io.buffer.pos,len);
    r->io.buffer.pos += len;

    return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq 0x38(%rdi), %rax
movq 0x40(%rdi), %rcx
movslq -0x8(%rax), %rdx
subq %rcx, %rdx
cmpq %rbx, %rdx
jae 0x59180
xorl %eax, %eax
jmp 0x5919d
movq %rdi, %r14
addq %rcx, %rax
movq %rsi, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x1fbd0
addq %rbx, 0x40(%r14)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rio.c
// Function: rioBufferWrite
static size_t rioBufferWrite(rio *r, const void *buf, size_t len) {

    // 追加
    r->io.buffer.ptr = sdscatlen(r->io.buffer.ptr,(char*)buf,len);

    // 更新偏移量
    r->io.buffer.pos += len;

    return 1;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rdi, %r14
movq 0x38(%rdi), %rdi
callq 0x28380
movq %rax, 0x38(%r14)
addq %rbx, 0x40(%r14)
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/rand.c
// Function: redisLrand48
static void next() {
    uint32_t p[2], q[2], r[2], carry0, carry1;

    MUL(a[0], x[0], p);
    ADDEQU(p[0], c, carry0);
    ADDEQU(p[1], carry0, carry1);
    MUL(a[0], x[1], q);
    ADDEQU(p[1], q[0], carry0);
    MUL(a[1], x[0], r);
    x[2] = LOW(carry0 + carry1 + CARRY(p[1], r[0]) + q[1] + r[1] +
            a[0] * x[2] + a[1] * x[1] + a[2] * x[0]);
    x[1] = LOW(p[1] + r[0]);
    x[0] = LOW(p[0]);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl 0x7098a(%rip), %edi     # 0xc9b68
imull $0xe66d, %edi, %ecx     # imm = 0xE66D
movl $0xffff, %edx           # imm = 0xFFFF
movl %ecx, %eax
andl %edx, %eax
movl %ecx, %esi
shrl $0x10, %esi
addl $0xb, %ecx
andl %edx, %ecx
cmpl $0xfff5, %eax           # imm = 0xFFF5
sbbl $-0x1, %esi
movl %esi, %eax
andl %edx, %eax
movl 0x70962(%rip), %r10d    # 0xc9b6c
imull $0xe66d, %r10d, %r11d   # imm = 0xE66D
movl %r11d, %r8d
andl %edx, %r8d
addl %eax, %r8d
leal (%rsi,%r11), %eax
shrl $0x10, %r11d
movl %eax, %ebx
andl $0xfffc, %ebx           # imm = 0xFFFC
imull $0xdeec, %edi, %r9d     # imm = 0xDEEC
movl %r9d, %ebp
andl %edx, %ebp
addl %ebx, %ebp
movl %r9d, %ebx
shrl $0x10, %ebx
imull $0xe66d, 0x70927(%rip), %r14d # imm = 0xE66D
addl %r11d, %r14d
imull $0xdeec, %r10d, %r10d   # imm = 0xDEEC
leal (%rdi,%rdi,4), %edi
addl %r10d, %edi
addl %ebx, %edi
addl %r14d, %edi
movl $0x10000, %r10d         # imm = 0x10000
cmpl %r10d, %esi
sbbl $-0x1, %edi
cmpl %r10d, %r8d
sbbl $-0x1, %edi
cmpl %r10d, %ebp
sbbl $-0x1, %edi
andl %edx, %edi
movl %edi, 0x708f2(%rip)     # 0xc9b70
addl %r9d, %eax
andl %edx, %eax
movl %eax, 0x708e3(%rip)     # 0xc9b6c
movl %ecx, 0x708d9(%rip)     # 0xc9b68
shll $0xf, %edi
shrl %eax
orl %edi, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/bitops.c
// Function: getBitOffsetFromArgument
static int getBitOffsetFromArgument(redisClient *c, robj *o, size_t *offset) {
    long long loffset;
    char *err = "bit offset is not an integer or out of range";

    if (getLongLongFromObjectOrReply(c,o,&loffset,err) != REDIS_OK)
        return REDIS_ERR;

    /* Limit offset to 512MB in bytes */
    if ((loffset < 0) || ((unsigned long long)loffset >> 3) >= (512*1024*1024))
    {
        addReplyError(c,err);
        return REDIS_ERR;
    }

    *offset = (size_t)loffset;
    return REDIS_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %r15
movq %rdi, %r14
leaq 0x44ea9(%rip), %rcx     # 0x9ed0b
leaq 0x8(%rsp), %rdx
callq 0x31082
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x59e99
movq 0x8(%rsp), %rax
movq %rax, %rcx
shrq $0x20, %rcx
je 0x59e94
leaq 0x44e81(%rip), %rsi     # 0x9ed0b
movq %r14, %rdi
callq 0x2d9d7
jmp 0x59e99
movq %rax, (%r15)
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/bitops.c
// Function: getbitCommand
void getbitCommand(redisClient *c) {
    robj *o;
    char llbuf[32];
    size_t bitoffset;
    size_t byte, bit;
    size_t bitval = 0;

    // 读取 offset 参数
    if (getBitOffsetFromArgument(c,c->argv[2],&bitoffset) != REDIS_OK)
        return;

    // 查找对象，并进行类型检查
    if ((o = lookupKeyReadOrReply(c,c->argv[1],shared.czero)) == NULL ||
        checkType(c,o,REDIS_STRING)) return;

    // 计算出 offset 所指定的位所在的字节
    byte = bitoffset >> 3;
    // 计算出位所在的位置
    bit = 7 - (bitoffset & 0x7);

    // 取出位
    if (sdsEncodedObject(o)) {
        // 字符串编码，直接取值
        if (byte < sdslen(o->ptr))
            bitval = ((uint8_t*)o->ptr)[byte] & (1 << bit);
    } else {
        // 整数编码，先转换成字符串，再取值
        if (byte < (size_t)ll2string(llbuf,sizeof(llbuf),(long)o->ptr))
            bitval = llbuf[byte] & (1 << bit);
    }

    // 返回位
    addReply(c, bitval ? shared.cone : shared.czero);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
movq 0x38(%rdi), %rax
movq 0x10(%rax), %rsi
leaq 0x8(%rsp), %rdx
callq 0x59e4c
testl %eax, %eax
je 0x59ed9
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x38(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0x70918(%rip), %r15     # 0xca800
movq 0x20(%r15), %rdx
movq %rbx, %rdi
callq 0x31475
testq %rax, %rax
je 0x59ecb
movq %rax, %r14
movq %rbx, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x308e7
testl %eax, %eax
jne 0x59ecb
movq 0x8(%rsp), %r12
movq %r12, %r13
shrq $0x3, %r13
movl (%r14), %eax
shrl $0x4, %eax
testb $0x7, %al
jne 0x59f37
movq 0x8(%r14), %rax
movslq -0x8(%rax), %rdx
movb $0x1, %cl
cmpq %rdx, %r13
jae 0x59f6e
addq %r13, %rax
jmp 0x59f5b
movq 0x8(%r14), %rdx
leaq 0x10(%rsp), %rdi
movl $0x20, %esi
callq 0x2fe12
cltq
movb $0x1, %cl
cmpq %rax, %r13
jae 0x59f6e
leaq (%rsp,%r13), %rax
addq $0x10, %rax
movzbl (%rax), %eax
notb %r12b
movzbl %r12b, %ecx
andl $0x7, %ecx
btl %ecx, %eax
setae %cl
xorb $0x1, %cl
movzbl %cl, %eax
movq 0x20(%r15,%rax,8), %rsi
movq %rbx, %rdi
callq 0x2d6f0
jmp 0x59ecb
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: releaseSentinelRedisInstance
void releaseSentinelRedisInstance(sentinelRedisInstance *ri) {

    /* Release all its slaves or sentinels if any. */
    // 释放（可能有的）sentinel 和 slave
    dictRelease(ri->sentinels);
    dictRelease(ri->slaves);

    /* Release hiredis connections. */
    // 释放连接
    if (ri->cc) sentinelKillLink(ri,ri->cc);
    if (ri->pc) sentinelKillLink(ri,ri->pc);

    /* Free other resources. */
    // 释放其他资源
    sdsfree(ri->name);
    sdsfree(ri->runid);
    sdsfree(ri->notification_script);
    sdsfree(ri->client_reconfig_script);
    sdsfree(ri->slave_master_host);
    sdsfree(ri->leader);
    sdsfree(ri->auth_pass);
    releaseSentinelAddr(ri->addr);

    /* Clear state into the master if needed. */
    // 清除故障转移带来的状态
    if ((ri->flags & SRI_SLAVE) && (ri->flags & SRI_PROMOTED) && ri->master)
        ri->master->promoted_slave = NULL;

    zfree(ri);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0xc0(%rdi), %rdi
callq 0x227ed
movq 0xc8(%rbx), %rdi
callq 0x227ed
movq 0x28(%rbx), %rsi
testq %rsi, %rsi
je 0x5aa30
movq %rbx, %rdi
callq 0x5c411
movq 0x30(%rbx), %rsi
testq %rsi, %rsi
je 0x5aa41
movq %rbx, %rdi
callq 0x5c411
movq 0x8(%rbx), %rdi
callq 0x28204
movq 0x10(%rbx), %rdi
callq 0x28204
movq 0x160(%rbx), %rdi
callq 0x28204
movq 0x168(%rbx), %rdi
callq 0x28204
movq 0x100(%rbx), %rdi
callq 0x28204
movq 0x118(%rbx), %rdi
callq 0x28204
movq 0xd8(%rbx), %rdi
callq 0x28204
movq 0x20(%rbx), %r14
movq (%r14), %rdi
callq 0x28204
movq %r14, %rdi
callq 0x2984b
movl (%rbx), %eax
notl %eax
testl $0x102, %eax            # imm = 0x102
jne 0x5aac5
movq 0xf8(%rbx), %rax
testq %rax, %rax
je 0x5aac5
movq $0x0, 0x158(%rax)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2984b
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelPublishCommand
void sentinelPublishCommand(redisClient *c) {
    if (strcmp(c->argv[1]->ptr,SENTINEL_HELLO_CHANNEL)) {
        addReplyError(c, "Only HELLO messages are accepted by Sentinel instances.");
        return;
    }
    sentinelProcessHelloMessage(c->argv[2]->ptr,sdslen(c->argv[2]->ptr));
    addReplyLongLong(c,1);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x38(%rdi), %r14
movq 0x8(%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x4435e(%rip), %rsi     # 0x9f4b7
callq 0x1f880
testl %eax, %eax
je 0x5b178
leaq 0x44ac1(%rip), %rsi     # 0x9fc2a
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2d9d7
movq 0x10(%r14), %rax
movq 0x8(%rax), %rdi
movl -0x8(%rdi), %esi
callq 0x5e3a5
movl $0x1, %esi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2dea3
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: initSentinel
void initSentinel(void) {
    int j;

    /* Remove usual Redis commands from the command table, then just add
     * the SENTINEL command. */

    // 清空 Redis 服务器的命令表（该表用于普通模式）
    dictEmpty(server.commands,NULL);
    // 将 SENTINEL 模式所用的命令添加进命令表
    for (j = 0; j < sizeof(sentinelcmds)/sizeof(sentinelcmds[0]); j++) {
        int retval;
        struct redisCommand *cmd = sentinelcmds+j;

        retval = dictAdd(server.commands, sdsnew(cmd->name), cmd);
        redisAssert(retval == DICT_OK);
    }

    /* Initialize various data structures. */
    /* 初始化 Sentinel 的状态 */
    // 初始化纪元
    sentinel.current_epoch = 0;

    // 初始化保存主服务器信息的字典
    sentinel.masters = dictCreate(&instancesDictType,NULL);

    // 初始化 TILT 模式的相关选项
    sentinel.tilt = 0;
    sentinel.tilt_start_time = 0;
    sentinel.previous_time = mstime();

    // 初始化脚本相关选项
    sentinel.running_scripts = 0;
    sentinel.scripts_queue = listCreate();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
leaq 0x6ebb6(%rip), %r15     # 0xc9fa8
movq 0x18(%r15), %rdi
xorl %r12d, %r12d
xorl %esi, %esi
callq 0x22d54
leaq 0x6e7d9(%rip), %r13     # 0xc9be0
leaq (%r12,%r13), %rbx
movq 0x18(%r15), %r14
movq (%r12,%r13), %rdi
callq 0x281da
movq %r14, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x222b6
testl %eax, %eax
jne 0x5b48a
addq $0x50, %r12
cmpq $0x2d0, %r12            # imm = 0x2D0
jne 0x5b407
xorl %ebx, %ebx
movq %rbx, 0x834a8(%rip)     # 0xde8e8
leaq 0x6e739(%rip), %rdi     # 0xc9b80
xorl %esi, %esi
callq 0x21f97
movq %rax, 0x8349b(%rip)     # 0xde8f0
movl %ebx, 0x8349d(%rip)     # 0xde8f8
movq %rbx, 0x8349e(%rip)     # 0xde900
callq 0x232a3
movq %rax, 0x8349a(%rip)     # 0xde908
movl %ebx, 0x83488(%rip)     # 0xde8fc
callq 0x2038c
movq %rax, 0x83490(%rip)     # 0xde910
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x3d355(%rip), %rdi     # 0x987e6
leaq 0x4391c(%rip), %rsi     # 0x9edb4
movl $0x28c, %edx            # imm = 0x28C
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelIsRunning
void sentinelIsRunning(void) {
    redisLog(REDIS_WARNING,"Sentinel runid is %s", server.runid);

    // Sentinel 不能在没有配置文件的情况下执行
    if (server.configfile == NULL) {
        redisLog(REDIS_WARNING,
            "Sentinel started without a config file. Exiting...");
        exit(1);
    } else if (access(server.configfile,W_OK) == -1) {
        redisLog(REDIS_WARNING,
            "Sentinel config file %s is not writable: %s. Exiting...",
            server.configfile,strerror(errno));
        exit(1);
    }

    /* We want to generate a +monitor event for every configured master
     * at startup. */
    sentinelGenerateInitialMonitorEvents();
}

// Assembly:
pushq %rbx
leaq 0x6eaf4(%rip), %rbx     # 0xc9fa8
leaq 0x58(%rbx), %rdx
leaq 0x43900(%rip), %rsi     # 0x9edbf
movl $0x3, %edi
xorl %eax, %eax
callq 0x23064
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x5b4e8
movl $0x2, %esi
callq 0x1fa20
cmpl $-0x1, %eax
je 0x5b4fd
popq %rbx
jmp 0x5b52f
leaq 0x438e5(%rip), %rsi     # 0x9edd4
movl $0x3, %edi
xorl %eax, %eax
callq 0x23064
jmp 0x5b525
movq (%rbx), %rbx
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x438f4(%rip), %rsi     # 0x9ee07
movl $0x3, %edi
movq %rbx, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x23064
movl $0x1, %edi
callq 0x1f2b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelGenerateInitialMonitorEvents
void sentinelGenerateInitialMonitorEvents(void) {
    dictIterator *di;
    dictEntry *de;

    di = dictGetIterator(sentinel.masters);
    while((de = dictNext(di)) != NULL) {
        sentinelRedisInstance *ri = dictGetVal(de);
        sentinelEvent(REDIS_WARNING,"+monitor",ri,"%@ quorum %d",ri->quorum);
    }
    dictReleaseIterator(di);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq 0x833b5(%rip), %rdi     # 0xde8f0
callq 0x228b5
movq %rax, %rbx
movq %rax, %rdi
callq 0x22913
testq %rax, %rax
je 0x5b588
leaq 0x4390b(%rip), %r14     # 0x9ee62
leaq 0x4390d(%rip), %r15     # 0x9ee6b
movq 0x8(%rax), %rdx
movl 0xd0(%rdx), %r8d
movl $0x3, %edi
movq %r14, %rsi
movq %r15, %rcx
xorl %eax, %eax
callq 0x5b66f
movq %rbx, %rdi
callq 0x22913
testq %rax, %rax
jne 0x5b55e
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x229b9
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: createSentinelAddr
sentinelAddr *createSentinelAddr(char *hostname, int port) {
    char buf[32];
    sentinelAddr *sa;

    // 检查端口号
    if (port <= 0 || port > 65535) {
        errno = EINVAL;
        return NULL;
    }

    // 检查并创建地址
    if (anetResolve(NULL,hostname,buf,sizeof(buf)) == ANET_ERR) {
        errno = ENOENT;
        return NULL;
    }

    // 创建并返回地址结构
    sa = zmalloc(sizeof(*sa));
    sa->ip = sdsnew(buf);
    sa->port = port;
    return sa;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebx
movl $0xffff0000, %eax       # imm = 0xFFFF0000
leal (%rbx,%rax), %ecx
cmpl %eax, %ecx
ja 0x5b5b7
callq 0x1f810
movl $0x16, (%rax)
jmp 0x5b5f7
movq %rdi, %rsi
movq %rsp, %rdx
movl $0x20, %ecx
xorl %edi, %edi
callq 0x2152c
cmpl $-0x1, %eax
je 0x5b5ec
movl $0x10, %edi
callq 0x29709
movq %rax, %r14
movq %rsp, %rdi
callq 0x281da
movq %rax, (%r14)
movl %ebx, 0x8(%r14)
jmp 0x5b5fa
callq 0x1f810
movl $0x2, (%rax)
xorl %r14d, %r14d
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: dupSentinelAddr
sentinelAddr *dupSentinelAddr(sentinelAddr *src) {
    sentinelAddr *sa;

    sa = zmalloc(sizeof(*sa));
    sa->ip = sdsnew(src->ip);
    sa->port = src->port;
    return sa;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x10, %edi
callq 0x29709
movq %rax, %r14
movq (%rbx), %rdi
callq 0x281da
movq %rax, (%r14)
movl 0x8(%rbx), %eax
movl %eax, 0x8(%r14)
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelReleaseScriptJob
void sentinelReleaseScriptJob(sentinelScriptJob *sj) {
    int j = 0;

    while(sj->argv[j]) sdsfree(sj->argv[j++]);
    zfree(sj->argv);
    zfree(sj);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x5bb3c
movl $0x8, %r14d
callq 0x28204
movq 0x8(%rbx), %rax
movq (%rax,%r14), %rdi
addq $0x8, %r14
testq %rdi, %rdi
jne 0x5bb26
movq %rax, %rdi
callq 0x2984b
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2984b
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelGetScriptListNodeByPid
listNode *sentinelGetScriptListNodeByPid(pid_t pid) {
    listNode *ln;
    listIter li;

    listRewind(sentinel.scripts_queue,&li);
    while ((ln = listNext(&li)) != NULL) {
        sentinelScriptJob *sj = ln->value;

        if ((sj->flags & SENTINEL_SCRIPT_RUNNING) && sj->pid == pid)
            return ln;
    }
    return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edi, %ebx
movq 0x82dab(%rip), %rdi     # 0xde910
movq %rsp, %r14
movq %r14, %rsi
callq 0x205d2
movq %r14, %rdi
callq 0x205ef
testq %rax, %rax
je 0x5bb9a
movq 0x10(%rax), %rcx
testb $0x1, (%rcx)
je 0x5bb92
cmpl %ebx, 0x18(%rcx)
jne 0x5bb92
xorl %ecx, %ecx
movq %rax, %r15
jmp 0x5bb94
movb $0x1, %cl
testb %cl, %cl
jne 0x5bb70
jmp 0x5bb9d
xorl %r15d, %r15d
movq %r15, %rax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelKillTimedoutScripts
void sentinelKillTimedoutScripts(void) {
    listNode *ln;
    listIter li;
    mstime_t now = mstime();

    // 遍历队列中的所有脚本
    listRewind(sentinel.scripts_queue,&li);
    while ((ln = listNext(&li)) != NULL) {
        sentinelScriptJob *sj = ln->value;

        // 选出那些正在执行，并且执行时间超过限制的脚本
        if (sj->flags & SENTINEL_SCRIPT_RUNNING &&
            (now - sj->start_time) > SENTINEL_SCRIPT_MAX_RUNTIME)
        {
            // 发送脚本超时事件
            sentinelEvent(REDIS_WARNING,"-script-timeout",NULL,"%s %ld",
                sj->argv[0], (long)sj->pid);

            // 杀死脚本进程
            kill(sj->pid,SIGKILL);
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
callq 0x232a3
movq %rax, %rbx
movq 0x82a9e(%rip), %rdi     # 0xde910
movq %rsp, %r14
movq %r14, %rsi
callq 0x205d2
movq %r14, %rdi
callq 0x205ef
testq %rax, %rax
je 0x5beef
movq %rsp, %r14
leaq 0x430a3(%rip), %r15     # 0x9ef37
leaq 0x3e58b(%rip), %r12     # 0x9a426
movq 0x10(%rax), %r13
testb $0x1, (%r13)
je 0x5bee2
movq %rbx, %rax
subq 0x10(%r13), %rax
cmpq $0xea61, %rax           # imm = 0xEA61
jl 0x5bee2
movq 0x8(%r13), %rax
movq (%rax), %r8
movslq 0x18(%r13), %r9
movl $0x3, %edi
movq %r15, %rsi
xorl %edx, %edx
movq %r12, %rcx
xorl %eax, %eax
callq 0x5b66f
movl 0x18(%r13), %edi
movl $0x9, %esi
callq 0x1f620
movq %r14, %rdi
callq 0x205ef
testq %rax, %rax
jne 0x5be9b
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelCallClientReconfScript
void sentinelCallClientReconfScript(sentinelRedisInstance *master, int role, char *state, sentinelAddr *from, sentinelAddr *to) {
    char fromport[32], toport[32];

    if (master->client_reconfig_script == NULL) return;
    ll2string(fromport,sizeof(fromport),from->port);
    ll2string(toport,sizeof(toport),to->port);
    // 将给定参数和脚本放进度列，等待执行
    sentinelScheduleScriptExecution(master->client_reconfig_script,
        master->name,
        (role == SENTINEL_LEADER) ? "leader" : "observer",
        state, from->ip, fromport, to->ip, toport, NULL);
}

// Assembly:
cmpq $0x0, 0x168(%rdi)
je 0x5c138
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %rbx
movq %rcx, %r15
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %r13
movslq 0x8(%rcx), %rdx
movq %rsp, %rdi
movl $0x20, %esi
callq 0x2fe12
movslq 0x8(%rbx), %rdx
leaq 0x20(%rsp), %r12
movl $0x20, %esi
movq %r12, %rdi
callq 0x2fe12
movq 0x8(%r13), %rsi
movq 0x168(%r13), %rdi
cmpl $0x20000, %ebp          # imm = 0x20000
leaq 0x43cb0(%rip), %rax     # 0x9fdb3
leaq 0x42e67(%rip), %rdx     # 0x9ef71
cmoveq %rax, %rdx
movq (%r15), %r8
subq $0x8, %rsp
movq %r14, %rcx
leaq 0x8(%rsp), %r9
xorl %eax, %eax
pushq $0x0
pushq %r12
pushq (%rbx)
callq 0x5b92e
addq $0x68, %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/sentinel.c
// Function: sentinelRedisInstanceLookupSlave
sentinelRedisInstance *sentinelRedisInstanceLookupSlave(
                sentinelRedisInstance *ri, char *ip, int port)
{
    sds key;
    sentinelRedisInstance *slave;
  
    redisAssert(ri->flags & SRI_MASTER);
    key = sdscatprintf(sdsempty(),
        strchr(ip,':') ? "[%s]:%d" : "%s:%d",
        ip,port);
    slave = dictFetchValue(ri->slaves,key);
    sdsfree(key);
    return slave;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testb $0x1, (%rdi)
je 0x5c4c2
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
callq 0x281b2
movq %rax, %r15
movq %r14, %rdi
movl $0x3a, %esi
callq 0x1f790
testq %rax, %rax
leaq 0x3c4b4(%rip), %rax     # 0x98931
leaq 0x3abaa(%rip), %rsi     # 0x9702e
cmoveq %rax, %rsi
movq %r15, %rdi
movq %r14, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x28760
movq %rax, %r14
movq 0xc8(%rbx), %rdi
movq %rax, %rsi
callq 0x22813
movq %rax, %rbx
movq %r14, %rdi
callq 0x28204
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x42b04(%rip), %rdi     # 0x9efcd
leaq 0x428e4(%rip), %rsi     # 0x9edb4
movl $0x5b1, %edx            # imm = 0x5B1
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: removeMatchingSentinelsFromMaster
int removeMatchingSentinelsFromMaster(sentinelRedisInstance *master, char *ip, int port, char *runid) {
    dictIterator *di;
    dictEntry *de;
    int removed = 0;

    di = dictGetSafeIterator(master->sentinels);
    while((de = dictNext(di)) != NULL) {
        sentinelRedisInstance *ri = dictGetVal(de);

        // 运行 ID 相同，或者 IP 和端口号相同，那么移除该实例
        if ((ri->runid && runid && strcmp(ri->runid,runid) == 0) ||
            (ip && strcmp(ri->addr->ip,ip) == 0 && port == ri->addr->port))
        {
            dictDelete(master->sentinels,ri->name);
            removed++;
        }
    }
    dictReleaseIterator(di);

    return removed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %rbx
movl %edx, 0xc(%rsp)
movq %rsi, %r15
movq %rdi, 0x10(%rsp)
movq 0xc0(%rdi), %rdi
callq 0x228e4
movq %rax, %r14
movq %rax, %rdi
callq 0x22913
xorl %r13d, %r13d
testq %rax, %rax
je 0x5c584
movq 0x8(%rax), %rbp
testq %rbx, %rbx
je 0x5c53e
movq 0x10(%rbp), %rdi
testq %rdi, %rdi
je 0x5c53e
movq %rbx, %rsi
callq 0x1f880
testl %eax, %eax
je 0x5c562
testq %r15, %r15
je 0x5c57a
movq 0x20(%rbp), %r12
movq (%r12), %rdi
movq %r15, %rsi
callq 0x1f880
testl %eax, %eax
jne 0x5c57a
movl 0xc(%rsp), %eax
cmpl %eax, 0x8(%r12)
jne 0x5c57a
movq 0x10(%rsp), %rax
movq 0xc0(%rax), %rdi
movq 0x8(%rbp), %rsi
callq 0x225d3
incl %r13d
movq %r14, %rdi
callq 0x22913
jmp 0x5c51b
movq %r14, %rdi
callq 0x229b9
movl %r13d, %eax
addq $0x18, %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/sentinel.c
// Function: getSentinelRedisInstanceByAddrAndRunID
sentinelRedisInstance *getSentinelRedisInstanceByAddrAndRunID(dict *instances, char *ip, int port, char *runid) {
    dictIterator *di;
    dictEntry *de;
    sentinelRedisInstance *instance = NULL;

    redisAssert(ip || runid);   /* User must pass at least one search param. */

    // 遍历所有输入实例
    di = dictGetIterator(instances);
    while((de = dictNext(di)) != NULL) {
        sentinelRedisInstance *ri = dictGetVal(de);

        // runid 不相同，忽略该实例
        if (runid && !ri->runid) continue;

        // 检查 ip 和端口号是否相同
        if ((runid == NULL || strcmp(ri->runid, runid) == 0) &&
            (ip == NULL || (strcmp(ri->addr->ip, ip) == 0 &&
                            ri->addr->port == port)))
        {
            instance = ri;
            break;
        }
    }
    dictReleaseIterator(di);

    return instance;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, 0xc(%rsp)
movq %rsi, 0x10(%rsp)
movq %rsi, %rax
orq %rcx, %rax
je 0x5c657
movq %rcx, %rbx
callq 0x228b5
movq %rax, %r15
xorl %r13d, %r13d
movq %r15, %rdi
callq 0x22913
testq %rax, %rax
je 0x5c63a
movq 0x8(%rax), %r12
testq %rbx, %rbx
je 0x5c5ed
cmpq $0x0, 0x10(%r12)
je 0x5c62b
testq %rbx, %rbx
je 0x5c603
movq 0x10(%r12), %rdi
movq %rbx, %rsi
callq 0x1f880
testl %eax, %eax
jne 0x5c62b
movb $0x1, %bpl
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x5c630
movq 0x20(%r12), %r14
movq (%r14), %rdi
callq 0x1f880
testl %eax, %eax
jne 0x5c62b
movl 0xc(%rsp), %eax
cmpl %eax, 0x8(%r14)
je 0x5c630
xorl %ebp, %ebp
movq %r13, %r12
movq %r12, %r13
testb %bpl, %bpl
je 0x5c5cf
jmp 0x5c63d
movq %r13, %r12
movq %r15, %rdi
callq 0x229b9
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x42986(%rip), %rdi     # 0x9efe4
leaq 0x4274f(%rip), %rsi     # 0x9edb4
movl $0x60b, %edx            # imm = 0x60B
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelGetMasterByName
sentinelRedisInstance *sentinelGetMasterByName(char *name) {
    sentinelRedisInstance *ri;
    sds sdsname = sdsnew(name);

    ri = dictFetchValue(sentinel.masters,sdsname);
    sdsfree(sdsname);
    return ri;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
callq 0x281da
movq %rax, %rbx
movq 0x82264(%rip), %rdi     # 0xde8f0
movq %rax, %rsi
callq 0x22813
movq %rax, %r14
movq %rbx, %rdi
callq 0x28204
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelAddFlagsToDictOfRedisInstances
void sentinelAddFlagsToDictOfRedisInstances(dict *instances, int flags) {
    dictIterator *di;
    dictEntry *de;

    di = dictGetIterator(instances);
    while((de = dictNext(di)) != NULL) {
        sentinelRedisInstance *ri = dictGetVal(de);
        ri->flags |= flags;
    }
    dictReleaseIterator(di);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
callq 0x228b5
movq %rax, %r14
movq %rax, %rdi
callq 0x22913
testq %rax, %rax
je 0x5c6d0
movq 0x8(%rax), %rax
orl %ebx, (%rax)
movq %r14, %rdi
jmp 0x5c6bb
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x229b9
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelResetMaster
void sentinelResetMaster(sentinelRedisInstance *ri, int flags) {

    redisAssert(ri->flags & SRI_MASTER);

    dictRelease(ri->slaves);
    ri->slaves = dictCreate(&instancesDictType,NULL);

    if (!(flags & SENTINEL_RESET_NO_SENTINELS)) {
        dictRelease(ri->sentinels);
        ri->sentinels = dictCreate(&instancesDictType,NULL);
    }

    if (ri->cc) sentinelKillLink(ri,ri->cc);

    if (ri->pc) sentinelKillLink(ri,ri->pc);

    // 设置标识为断线的主服务器
    ri->flags &= SRI_MASTER|SRI_DISCONNECTED;

    if (ri->leader) {
        sdsfree(ri->leader);
        ri->leader = NULL;
    }

    ri->failover_state = SENTINEL_FAILOVER_STATE_NONE;
    ri->failover_state_change_time = 0;
    ri->failover_start_time = 0;
    ri->promoted_slave = NULL;
    sdsfree(ri->runid);
    sdsfree(ri->slave_master_host);
    ri->runid = NULL;
    ri->slave_master_host = NULL;
    ri->last_ping_time = mstime();
    ri->last_avail_time = mstime();
    ri->last_pong_time = mstime();
    ri->role_reported_time = mstime();
    ri->role_reported = SRI_MASTER;
    // 发送主服务器重置事件
    if (flags & SENTINEL_GENERATE_EVENT)
        sentinelEvent(REDIS_WARNING,"+reset-master",ri,"%@");
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
testb $0x1, (%rdi)
je 0x5c854
movl %esi, %ebp
movq %rdi, %rbx
movq 0xc8(%rdi), %rdi
callq 0x227ed
leaq 0x6d43d(%rip), %rdi     # 0xc9b80
xorl %esi, %esi
callq 0x21f97
movq %rax, 0xc8(%rbx)
testb $0x1, %bpl
jne 0x5c778
movq 0xc0(%rbx), %rdi
callq 0x227ed
leaq 0x6d416(%rip), %rdi     # 0xc9b80
xorl %esi, %esi
callq 0x21f97
movq %rax, 0xc0(%rbx)
movq 0x28(%rbx), %rsi
testq %rsi, %rsi
je 0x5c789
movq %rbx, %rdi
callq 0x5c411
movq 0x30(%rbx), %rsi
testq %rsi, %rsi
je 0x5c79a
movq %rbx, %rdi
callq 0x5c411
andl $0x9, (%rbx)
movq 0x118(%rbx), %rdi
testq %rdi, %rdi
je 0x5c7b9
callq 0x28204
movq $0x0, 0x118(%rbx)
movl $0x0, 0x130(%rbx)
xorl %r14d, %r14d
movq %r14, 0x158(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x138(%rbx)
movq 0x10(%rbx), %rdi
callq 0x28204
movq 0x100(%rbx), %rdi
callq 0x28204
movq %r14, 0x10(%rbx)
movq %r14, 0x100(%rbx)
callq 0x232a3
movq %rax, 0x60(%rbx)
callq 0x232a3
movq %rax, 0x58(%rbx)
callq 0x232a3
movq %rax, 0x68(%rbx)
callq 0x232a3
movq %rax, 0xb0(%rbx)
movl $0x1, 0xa8(%rbx)
btl $0x10, %ebp
jb 0x5c833
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x427b6(%rip), %rsi     # 0x9eff0
leaq 0x427bd(%rip), %rcx     # 0x9effe
movl $0x3, %edi
movq %rbx, %rdx
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x5b66f
leaq 0x42772(%rip), %rdi     # 0x9efcd
leaq 0x42552(%rip), %rsi     # 0x9edb4
movl $0x662, %edx            # imm = 0x662
callq 0x4d037
movl $0x1, %edi
callq 0x1f3b0
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelResetMastersByPattern
int sentinelResetMastersByPattern(char *pattern, int flags) {
    dictIterator *di;
    dictEntry *de;
    int reset = 0;

    di = dictGetIterator(sentinel.masters);
    while((de = dictNext(di)) != NULL) {
        sentinelRedisInstance *ri = dictGetVal(de);

        if (ri->name) {
            if (stringmatch(pattern,ri->name,0)) {
                sentinelResetMaster(ri,flags);
                reset++;
            }
        }
    }
    dictReleaseIterator(di);
    return reset;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebp
movq %rdi, %r14
movq 0x82066(%rip), %rdi     # 0xde8f0
callq 0x228b5
movq %rax, %rbx
movq %rax, %rdi
callq 0x22913
xorl %r15d, %r15d
testq %rax, %rax
je 0x5c8d5
movq 0x8(%rax), %r12
movq 0x8(%r12), %rsi
testq %rsi, %rsi
je 0x5c8cb
movq %r14, %rdi
xorl %edx, %edx
callq 0x2fc0c
testl %eax, %eax
je 0x5c8cb
movq %r12, %rdi
movl %ebp, %esi
callq 0x5c71e
incl %r15d
movq %rbx, %rdi
callq 0x22913
jmp 0x5c89d
movq %rbx, %rdi
callq 0x229b9
movl %r15d, %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/sentinel.c
// Function: sentinelFlushConfig
void sentinelFlushConfig(void) {
    int fd = -1;
    int saved_hz = server.hz;
    int rewrite_status;

    server.hz = REDIS_DEFAULT_HZ;
    rewrite_status = rewriteConfig(server.configfile);
    server.hz = saved_hz;

    if (rewrite_status == -1) goto werr;
    if ((fd = open(server.configfile,O_RDONLY)) == -1) goto werr;
    if (fsync(fd) == -1) goto werr;
    if (close(fd) == EOF) goto werr;
    return;

werr:
    if (fd != -1) close(fd);
    redisLog(REDIS_WARNING,"WARNING: Sentinel was not able to save the new configuration on disk!!!: %s", strerror(errno));
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
leaq 0x6d4dc(%rip), %r14     # 0xc9fa8
movl 0x8(%r14), %ebx
movl $0xa, 0x8(%r14)
movq (%r14), %rdi
callq 0x48a88
movl %ebx, 0x8(%r14)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x5cb22
movq (%r14), %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x1f640
cmpl $-0x1, %eax
je 0x5cb22
movl %eax, %ebp
movl %eax, %edi
callq 0x1f5d0
cmpl $-0x1, %eax
je 0x5cb20
movl %ebp, %edi
callq 0x1f170
movl %ebp, %ebx
cmpl $-0x1, %eax
je 0x5cb22
popq %rbx
popq %r14
popq %rbp
retq
movl %ebp, %ebx
cmpl $-0x1, %ebx
je 0x5cb2e
movl %ebx, %edi
callq 0x1f170
callq 0x1f810
movl (%rax), %edi
callq 0x1f630
leaq 0x42888(%rip), %rsi     # 0x9f3c9
movl $0x3, %edi
movq %rax, %rdx
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x23064
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelRedisInstanceNoDownFor
int sentinelRedisInstanceNoDownFor(sentinelRedisInstance *ri, mstime_t ms) {
    mstime_t most_recent;

    most_recent = ri->s_down_since_time;
    if (ri->o_down_since_time > most_recent)
        most_recent = ri->o_down_since_time;
    return most_recent == 0 || (mstime() - most_recent) > ms;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq 0x88(%rdi), %r14
movq 0x90(%rdi), %rax
cmpq %r14, %rax
cmovgq %rax, %r14
testq %r14, %r14
je 0x5cb8a
movq %rsi, %rbx
callq 0x232a3
movq %rax, %rcx
subq %r14, %rcx
xorl %eax, %eax
cmpq %rbx, %rcx
setg %al
jmp 0x5cb8f
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/nilyang[P]redis-tdd-annotation/src/sentinel.c
// Function: sentinelPropagateDownAfterPeriod
void sentinelPropagateDownAfterPeriod(sentinelRedisInstance *master) {
    dictIterator *di;
    dictEntry *de;
    int j;
    dict *d[] = {master->slaves, master->sentinels, NULL};

    for (j = 0; d[j]; j++) {
        di = dictGetIterator(d[j]);
        while((de = dictNext(di)) != NULL) {
            sentinelRedisInstance *ri = dictGetVal(de);
            ri->down_after_period = master->down_after_period;
        }
        dictReleaseIterator(di);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rdi, %rbx
movq 0xc8(%rdi), %rdi
movq %rdi, (%rsp)
movq 0xc0(%rbx), %rax
movq %rax, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
testq %rdi, %rdi
je 0x5cc2e
xorl %r15d, %r15d
callq 0x228b5
movq %rax, %r14
movq %rax, %rdi
callq 0x22913
testq %rax, %rax
je 0x5cc19
movq 0x8(%rax), %rax
movq 0x98(%rbx), %rcx
movq %rcx, 0x98(%rax)
movq %r14, %rdi
jmp 0x5cbf8
movq %r14, %rdi
callq 0x229b9
movq 0x8(%rsp,%r15,8), %rdi
incq %r15
testq %rdi, %rdi
jne 0x5cbed
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq