// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/server.c
// Function: main
int main(int argc, char **argv) {
    struct timeval tv;
    int j;

#ifdef REDIS_TEST
    if (argc == 3 && !strcasecmp(argv[1], "test")) {
        if (!strcasecmp(argv[2], "ziplist")) {
            return ziplistTest(argc, argv);
        } else if (!strcasecmp(argv[2], "quicklist")) {
            quicklistTest(argc, argv);
        } else if (!strcasecmp(argv[2], "intset")) {
            return intsetTest(argc, argv);
        } else if (!strcasecmp(argv[2], "zipmap")) {
            return zipmapTest(argc, argv);
        } else if (!strcasecmp(argv[2], "sha1test")) {
            return sha1Test(argc, argv);
        } else if (!strcasecmp(argv[2], "util")) {
            return utilTest(argc, argv);
        } else if (!strcasecmp(argv[2], "sds")) {
            return sdsTest(argc, argv);
        } else if (!strcasecmp(argv[2], "endianconv")) {
            return endianconvTest(argc, argv);
        } else if (!strcasecmp(argv[2], "crc64")) {
            return crc64Test(argc, argv);
        }

        return -1; /* test not found */
    }
#endif

    /* We need to initialize our libraries, and the server configuration. */
#ifdef INIT_SETPROCTITLE_REPLACEMENT
    spt_init(argc, argv);
#endif
    setlocale(LC_COLLATE,"");
    zmalloc_enable_thread_safeness();
    zmalloc_set_oom_handler(redisOutOfMemoryHandler);
    srand(time(NULL)^getpid());
    gettimeofday(&tv,NULL);
    dictSetHashFunctionSeed(tv.tv_sec^tv.tv_usec^getpid());
    server.sentinel_mode = checkForSentinelMode(argc,argv);
    initServerConfig();

    /* Store the executable path and arguments in a safe place in order
     * to be able to restart the server later. */
    server.executable = getAbsolutePath(argv[0]);
    server.exec_argv = zmalloc(sizeof(char*)*(argc+1));
    server.exec_argv[argc] = NULL;
    for (j = 0; j < argc; j++) server.exec_argv[j] = zstrdup(argv[j]);

    /* We need to init sentinel right now as parsing the configuration file
     * in sentinel mode will have the effect of populating the sentinel
     * data structures with master nodes to monitor. */
    if (server.sentinel_mode) {
        initSentinelConfig();
        initSentinel();
    }

    /* Check if we need to start in redis-check-rdb mode. We just execute
     * the program main. However the program is part of the Redis executable
     * so that we can easily execute an RDB check on loading errors. */
    if (strstr(argv[0],"redis-check-rdb") != NULL)
        redis_check_rdb_main(argc,argv);

    if (argc >= 2) {
        j = 1; /* First option to parse in argv[] */
        sds options = sdsempty();
        char *configfile = NULL;

        /* Handle special options --help and --version */
        if (strcmp(argv[1], "-v") == 0 ||
            strcmp(argv[1], "--version") == 0) version();
        if (strcmp(argv[1], "--help") == 0 ||
            strcmp(argv[1], "-h") == 0) usage();
        if (strcmp(argv[1], "--test-memory") == 0) {
            if (argc == 3) {
                memtest(atoi(argv[2]),50);
                exit(0);
            } else {
                fprintf(stderr,"Please specify the amount of memory to test in megabytes.\n");
                fprintf(stderr,"Example: ./redis-server --test-memory 4096\n\n");
                exit(1);
            }
        }

        /* First argument is the config file name? */
        if (argv[j][0] != '-' || argv[j][1] != '-') {
            configfile = argv[j];
            server.configfile = getAbsolutePath(configfile);
            /* Replace the config file in server.exec_argv with
             * its absoulte path. */
            zfree(server.exec_argv[j]);
            server.exec_argv[j] = zstrdup(server.configfile);
            j++;
        }

        /* All the other options are parsed and conceptually appended to the
         * configuration file. For instance --port 6380 will generate the
         * string "port 6380\n" to be parsed after the actual file name
         * is parsed, if any. */
        while(j != argc) {
            if (argv[j][0] == '-' && argv[j][1] == '-') {
                /* Option name */
                if (!strcmp(argv[j], "--check-rdb")) {
                    /* Argument has no options, need to skip for parsing. */
                    j++;
                    continue;
                }
                if (sdslen(options)) options = sdscat(options,"\n");
                options = sdscat(options,argv[j]+2);
                options = sdscat(options," ");
            } else {
                /* Option argument */
                options = sdscatrepr(options,argv[j],strlen(argv[j]));
                options = sdscat(options," ");
            }
            j++;
        }
        if (server.sentinel_mode && configfile && *configfile == '-') {
            serverLog(LL_WARNING,
                "Sentinel config from STDIN not allowed.");
            serverLog(LL_WARNING,
                "Sentinel needs config file on disk to save state.  Exiting...");
            exit(1);
        }
        resetServerSaveParams();
        loadServerConfig(configfile,options);
        sdsfree(options);
    } else {
        serverLog(LL_WARNING, "Warning: no config file specified, using the default config. In order to specify a config file use %s /path/to/%s.conf", argv[0], server.sentinel_mode ? "sentinel" : "redis");
    }

    server.supervised = redisIsSupervised(server.supervised_mode);
    int background = server.daemonize && !server.supervised;
    if (background) daemonize();

    initServer();
    if (background || server.pidfile) createPidFile();
    redisSetProcTitle(argv[0]);
    redisAsciiArt();
    checkTcpBacklogSettings();

    if (!server.sentinel_mode) {
        /* Things not needed when running in Sentinel mode. */
        serverLog(LL_WARNING,"Server started, Redis version " REDIS_VERSION);
    #ifdef __linux__
        linuxMemoryWarnings();
    #endif
        loadDataFromDisk();
        if (server.cluster_enabled) {
            if (verifyClusterConfigWithData() == C_ERR) {
                serverLog(LL_WARNING,
                    "You can't have keys in a DB different than DB 0 when in "
                    "Cluster mode. Exiting.");
                exit(1);
            }
        }
        if (server.ipfd_count > 0)
            serverLog(LL_NOTICE,"The server is now ready to accept connections on port %d", server.port);
        if (server.sofd > 0)
            serverLog(LL_NOTICE,"The server is now ready to accept connections at %s", server.unixsocket);
    } else {
        sentinelIsRunning();
    }

    /* Warning the user about suspicious maxmemory setting. */
    if (server.maxmemory > 0 && server.maxmemory < 1024*1024) {
        serverLog(LL_WARNING,"WARNING: You specified a maxmemory value that is less than 1MB (current value is %llu bytes). Are you sure this is what you really want?", server.maxmemory);
    }

    aeSetBeforeSleepProc(server.el,beforeSleep);
    aeMain(server.el);
    aeDeleteEventLoop(server.el);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movl %edi, %r14d
callq 0x80228
leaq 0x8ae54(%rip), %rsi     # 0xc3a6d
movl $0x3, %edi
callq 0x26b50
callq 0x3b45a
leaq -0x336(%rip), %rdi      # 0x388f9
callq 0x3b462
xorl %edi, %edi
callq 0x26ce0
movq %rax, %r15
callq 0x26430
xorl %eax, %r15d
movl %r15d, %edi
callq 0x26970
leaq 0x8(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x26310
movl 0x8(%r15), %ebp
xorl (%r15), %ebp
callq 0x26430
xorl %eax, %ebp
movl %ebp, %edi
callq 0x316a7
movl %r14d, %edi
movq %rbx, %rsi
callq 0x387a0
movl %eax, 0xcdc71(%rip)     # 0x1068f4
callq 0x34a6b
movq (%rbx), %rdi
callq 0x4383c
movq %rax, 0xcdbd1(%rip)     # 0x106868
movslq %r14d, %r15
leaq 0x8(,%r15,8), %rdi
callq 0x3b29d
movq %rax, 0xcdbc2(%rip)     # 0x106870
movq $0x0, (%rax,%r15,8)
testl %r15d, %r15d
jle 0x38cdd
movl %r14d, %r15d
xorl %r12d, %r12d
movq (%rbx,%r12,8), %rdi
callq 0x3b419
movq 0xcdb9f(%rip), %rcx     # 0x106870
movq %rax, (%rcx,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0x38cc1
cmpl $0x0, 0xcdc10(%rip)     # 0x1068f4
je 0x38cf0
callq 0x7a16f
callq 0x7a181
movq (%rbx), %rdi
leaq 0x893e2(%rip), %rsi     # 0xc20dc
callq 0x266c0
testq %rax, %rax
je 0x38d0f
movl %r14d, %edi
movq %rbx, %rsi
callq 0x84238
cmpl $0x2, %r14d
jl 0x38dbf
callq 0x39222
movq %rax, %r13
movq 0x8(%rbx), %r12
leaq 0x893c0(%rip), %rsi     # 0xc20ec
movq %r12, %rdi
callq 0x26900
testl %eax, %eax
je 0x3909e
leaq 0x893ac(%rip), %rsi     # 0xc20ef
movq %r12, %rdi
callq 0x26900
testl %eax, %eax
je 0x3909e
movq 0x8(%rbx), %r12
leaq 0x8939b(%rip), %rsi     # 0xc20f9
movq %r12, %rdi
callq 0x26900
testl %eax, %eax
je 0x390a3
leaq 0x8938b(%rip), %rsi     # 0xc2100
movq %r12, %rdi
callq 0x26900
testl %eax, %eax
je 0x390a3
movq 0x8(%rbx), %r12
leaq 0x89373(%rip), %rsi     # 0xc2103
movq %r12, %rdi
callq 0x26900
testl %eax, %eax
je 0x390a8
cmpb $0x2d, (%r12)
jne 0x38df0
cmpb $0x2d, 0x1(%r12)
jne 0x38df0
movl $0x1, %r12d
movq $0x0, (%rsp)
jmp 0x38e30
movq (%rbx), %rdx
cmpl $0x0, 0xcdb2b(%rip)     # 0x1068f4
leaq 0x87286(%rip), %rax     # 0xc0056
leaq 0x96cef(%rip), %rcx     # 0xcfac6
cmoveq %rax, %rcx
leaq 0x89409(%rip), %rsi     # 0xc21eb
movl $0x3, %edi
xorl %eax, %eax
callq 0x32ea6
jmp 0x38e6d
movq %r12, (%rsp)
movq %r12, %rdi
callq 0x4383c
movq %rax, 0xcda5d(%rip)     # 0x106860
movq 0xcda66(%rip), %rax     # 0x106870
movq 0x8(%rax), %rdi
callq 0x3b3df
movq 0xcda46(%rip), %rdi     # 0x106860
callq 0x3b419
movq 0xcda4a(%rip), %rcx     # 0x106870
movq %rax, 0x8(%rcx)
movl $0x2, %r12d
cmpl %r14d, %r12d
jne 0x38fb7
movq (%rsp), %r14
testq %r14, %r14
je 0x38e55
cmpl $0x0, 0xcdaab(%rip)     # 0x1068f4
je 0x38e55
cmpb $0x2d, (%r14)
je 0x390d0
callq 0x5a848
movq %r14, %rdi
movq %r13, %rsi
callq 0x5c0bc
movq %r13, %rdi
callq 0x392b6
movl 0xcdfed(%rip), %edi     # 0x106e60
callq 0x38bac
movl %eax, 0xcdfde(%rip)     # 0x106e5c
cmpl $0x0, 0xcdfdf(%rip)     # 0x106e64
setne %cl
testl %eax, %eax
sete %bpl
andb %cl, %bpl
cmpb $0x1, %bpl
jne 0x38e9c
callq 0x383fe
callq 0x356bd
cmpq $0x0, 0xcda0f(%rip)     # 0x1068b8
setne %al
orb %al, %bpl
cmpb $0x1, %bpl
jne 0x38eba
callq 0x383a2
movq (%rbx), %rdi
callq 0x38932
callq 0x3860e
callq 0x3539e
cmpl $0x0, 0xcda21(%rip)     # 0x1068f4
je 0x38edc
callq 0x7a27b
jmp 0x38f55
leaq 0x8937f(%rip), %rsi     # 0xc2262
movl $0x3, %edi
xorl %eax, %eax
callq 0x32ea6
callq 0x38366
callq 0x38809
cmpl $0x0, 0xce2e4(%rip)     # 0x1071e4
je 0x38f10
callq 0x6dd65
cmpl $-0x1, %eax
je 0x390ec
cmpl $0x0, 0xcdabd(%rip)     # 0x1069d4
jle 0x38f32
movl 0xcd9d9(%rip), %edx     # 0x1068f8
leaq 0x893af(%rip), %rsi     # 0xc22d5
movl $0x2, %edi
xorl %eax, %eax
callq 0x32ea6
cmpl $0x0, 0xcda9f(%rip)     # 0x1069d8
jle 0x38f55
movq 0xcda46(%rip), %rdx     # 0x106988
leaq 0x893c5(%rip), %rsi     # 0xc230e
movl $0x2, %edi
xorl %eax, %eax
callq 0x32ea6
movq 0xce1f4(%rip), %rdx     # 0x107150
leaq -0x1(%rdx), %rax
cmpq $0xffffe, %rax          # imm = 0xFFFFE
ja 0x38f7b
leaq 0x893d3(%rip), %rsi     # 0xc2342
movl $0x3, %edi
xorl %eax, %eax
callq 0x32ea6
movq 0xcd916(%rip), %rdi     # 0x106898
leaq -0x4bd5(%rip), %rsi     # 0x343b4
callq 0x30652
movq 0xcd903(%rip), %rdi     # 0x106898
callq 0x3061c
movq 0xcd8f7(%rip), %rdi     # 0x106898
callq 0x2fe9a
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
negl %r14d
movslq %r12d, %rax
leal 0x1(%rax), %r12d
leaq (%rbx,%rax,8), %r15
movq (%r15), %rbp
cmpb $0x2d, (%rbp)
jne 0x39003
cmpb $0x2d, 0x1(%rbp)
jne 0x39003
movq %rbp, %rdi
leaq 0x8919b(%rip), %rsi     # 0xc2179
callq 0x26900
testl %eax, %eax
jne 0x3901b
addq $0x8, %r15
leal (%r14,%r12), %eax
incl %eax
movl %r12d, %ecx
incl %ecx
movl %ecx, %r12d
cmpl $0x1, %eax
jne 0x38fc5
jmp 0x38e39
movq %rbp, %rdi
callq 0x26510
movq %r13, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x3abb1
jmp 0x3907b
movq %r13, %rdi
movzbl -0x1(%r13), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x39059
leaq 0x86478(%rip), %rdx     # 0xbf4ac
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %eax
jmp 0x3905b
movq -0x11(%rdi), %rax
jmp 0x3905b
movzwl -0x5(%rdi), %eax
jmp 0x3905b
movl -0x9(%rdi), %eax
jmp 0x3905b
movzbl -0x3(%rdi), %eax
jmp 0x3905b
xorl %eax, %eax
testq %rax, %rax
je 0x3906f
leaq 0x88df0(%rip), %rsi     # 0xc1e57
callq 0x39b26
movq %rax, %rdi
movq (%r15), %rsi
addq $0x2, %rsi
callq 0x39b26
movq %rax, %rdi
leaq 0x8ebac(%rip), %rsi     # 0xc7c31
callq 0x39b26
movq %rax, %r13
movl %r14d, %eax
addl %r12d, %eax
jne 0x38fba
jmp 0x38e39
callq 0x38460
callq 0x384b7
cmpl $0x3, %r14d
jne 0x390cb
movq 0x10(%rbx), %rdi
callq 0x26770
movslq %eax, %rdi
movl $0x32, %esi
callq 0x77248
xorl %edi, %edi
callq 0x262d0
callq 0x270ef
leaq 0x890ae(%rip), %rsi     # 0xc2185
movl $0x3, %edi
xorl %eax, %eax
callq 0x32ea6
leaq 0x890c3(%rip), %rsi     # 0xc21ad
jmp 0x390f3
leaq 0x89193(%rip), %rsi     # 0xc2286
movl $0x3, %edi
xorl %eax, %eax
callq 0x32ea6
movl $0x1, %edi
callq 0x262d0
nopl (%rax)