// File: /workspace/github_c_makefile_star2_O3/gplessis[P]dotdeb-redis/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 $0x28, %rsp
movq %rsi, %rbx
movl %edi, %r14d
callq 0x7c7c8
leaq 0x8ae75(%rip), %rsi     # 0xc0ab5
movl $0x3, %edi
callq 0x26b40
callq 0x3848e
leaq -0x303(%rip), %rdi      # 0x35953
callq 0x38496
xorl %edi, %edi
callq 0x26cd0
movq %rax, %r15
callq 0x26420
xorl %eax, %r15d
movl %r15d, %edi
callq 0x26960
leaq 0x18(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x26300
movl 0x8(%r15), %ebp
xorl (%r15), %ebp
callq 0x26420
xorl %eax, %ebp
movl %ebp, %edi
callq 0x2e5bf
movl %r14d, %edi
movq %rbx, %rsi
callq 0x357fa
movl %eax, 0xcbc9a(%rip)     # 0x101944
callq 0x31992
movq (%rbx), %rdi
callq 0x403ef
movq %rax, 0xcbbfa(%rip)     # 0x1018b8
movslq %r14d, %r15
leaq 0x8(,%r15,8), %rdi
callq 0x382d1
movq %rax, 0xcbbeb(%rip)     # 0x1018c0
movq $0x0, (%rax,%r15,8)
testl %r15d, %r15d
jle 0x35d04
movl %r14d, %r15d
xorl %r12d, %r12d
movq (%rbx,%r12,8), %rdi
callq 0x3844d
movq 0xcbbc8(%rip), %rcx     # 0x1018c0
movq %rax, (%rcx,%r12,8)
incq %r12
cmpq %r12, %r15
jne 0x35ce8
cmpl $0x0, 0xcbc39(%rip)     # 0x101944
je 0x35d17
callq 0x7669f
callq 0x766b1
movq (%rbx), %rdi
leaq 0x8942a(%rip), %rsi     # 0xbf14b
callq 0x266b0
testq %rax, %rax
je 0x35d36
movl %r14d, %edi
movq %rbx, %rsi
callq 0x80789
cmpl $0x2, %r14d
jl 0x35ddf
callq 0x3628d
movq %rax, %r12
movq 0x8(%rbx), %r15
movb (%r15), %bpl
cmpb $0x2d, %bpl
jne 0x35d67
cmpb $0x76, 0x1(%r15)
jne 0x35d67
cmpb $0x0, 0x2(%r15)
je 0x3610b
leaq 0x893ed(%rip), %rsi     # 0xbf15b
movq %r15, %rdi
callq 0x268f0
testl %eax, %eax
je 0x3610b
leaq 0x893e0(%rip), %rsi     # 0xbf165
movq %r15, %rdi
callq 0x268f0
testl %eax, %eax
je 0x36110
cmpb $0x2d, %bpl
jne 0x35e13
cmpb $0x68, 0x1(%r15)
jne 0x35dad
cmpb $0x0, 0x2(%r15)
je 0x36110
leaq 0x893b8(%rip), %rsi     # 0xbf16c
movq %r15, %rdi
callq 0x268f0
testl %eax, %eax
je 0x36115
cmpb $0x2d, 0x1(%r15)
jne 0x35e2a
movl $0x1, %r15d
movq $0x0, 0x10(%rsp)
jmp 0x35e6b
movq (%rbx), %rdx
cmpl $0x0, 0xcbb5b(%rip)     # 0x101944
leaq 0x872d8(%rip), %rax     # 0xbd0c8
leaq 0x96dcf(%rip), %rcx     # 0xccbc6
cmoveq %rax, %rcx
leaq 0x89452(%rip), %rsi     # 0xbf254
movl $0x3, %edi
xorl %eax, %eax
callq 0x2fdad
jmp 0x35fc1
leaq 0x89352(%rip), %rsi     # 0xbf16c
movq %r15, %rdi
callq 0x268f0
testl %eax, %eax
je 0x36115
movq %r15, 0x10(%rsp)
movq %r15, %rdi
callq 0x403ef
movq %rax, 0xcba72(%rip)     # 0x1018b0
movq 0xcba7b(%rip), %rax     # 0x1018c0
movq 0x8(%rax), %rdi
callq 0x38413
movq 0xcba5b(%rip), %rdi     # 0x1018b0
callq 0x3844d
movq 0xcba5f(%rip), %rcx     # 0x1018c0
movq %rax, 0x8(%rcx)
movl $0x2, %r15d
cmpl %r14d, %r15d
je 0x35f8c
negl %r14d
leaq 0x89364(%rip), %r13     # 0xbf1e2
movq %r12, 0x8(%rsp)
movslq %r15d, %rax
leal 0x1(%rax), %r15d
leaq (%rbx,%rax,8), %r12
movq (%r12), %rbp
cmpb $0x2d, (%rbp)
jne 0x35ec9
cmpb $0x2d, 0x1(%rbp)
jne 0x35ec9
movq %rbp, %rdi
movq %r13, %rsi
callq 0x268f0
testl %eax, %eax
jne 0x35ee6
addq $0x8, %r12
leal (%r14,%r15), %eax
incl %eax
movl %r15d, %ecx
incl %ecx
movl %ecx, %r15d
cmpl $0x1, %eax
jne 0x35e8e
jmp 0x35f87
movq %rbp, %rdi
callq 0x26500
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x37c36
jmp 0x35f67
movq 0x8(%rsp), %rax
movzbl -0x1(%rax), %eax
movl %eax, %ecx
andl $0x7, %ecx
cmpl $0x4, %ecx
ja 0x35f56
leaq 0x865f4(%rip), %rdx     # 0xbc4f4
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
shrl $0x3, %eax
jmp 0x35f37
movq 0x8(%rsp), %rax
movq -0x11(%rax), %rax
jmp 0x35f37
movq 0x8(%rsp), %rax
movzwl -0x5(%rax), %eax
jmp 0x35f37
movq 0x8(%rsp), %rax
movl -0x9(%rax), %eax
jmp 0x35f37
movq 0x8(%rsp), %rax
movzbl -0x3(%rax), %eax
testq %rax, %rax
je 0x35f56
movq 0x8(%rsp), %rdi
leaq 0x88f81(%rip), %rsi     # 0xbeec9
callq 0x36b9c
movq %rax, %rdi
movq (%r12), %rbp
jmp 0x35f5b
movq 0x8(%rsp), %rdi
addq $0x2, %rbp
movq %rbp, %rsi
callq 0x36b9c
movq %rax, %rdi
leaq 0x8ed2c(%rip), %rsi     # 0xc4c9d
callq 0x36b9c
movq %rax, %r12
movl %r14d, %eax
addl %r15d, %eax
jne 0x35e7e
jmp 0x35f8c
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %r14
testq %r14, %r14
je 0x35fa9
cmpl $0x0, 0xcb9a7(%rip)     # 0x101944
je 0x35fa9
cmpb $0x2d, (%r14)
je 0x3613d
callq 0x56e98
movq %r14, %rdi
movq %r12, %rsi
callq 0x5855f
movq %r12, %rdi
callq 0x36330
movl 0xcbef9(%rip), %edi     # 0x101ec0
callq 0x35bd3
movl %eax, 0xcbeea(%rip)     # 0x101ebc
cmpl $0x0, 0xcbeeb(%rip)     # 0x101ec4
setne %cl
testl %eax, %eax
sete %bpl
andb %cl, %bpl
cmpb $0x1, %bpl
jne 0x35ff0
callq 0x35458
callq 0x32637
cmpq $0x0, 0xcb90b(%rip)     # 0x101908
setne %al
orb %al, %bpl
cmpb $0x1, %bpl
jne 0x3600e
callq 0x353fe
movq (%rbx), %rdi
callq 0x3598c
callq 0x35668
callq 0x32327
cmpl $0x0, 0xcb91d(%rip)     # 0x101944
je 0x36030
callq 0x767ab
jmp 0x360a9
leaq 0x89294(%rip), %rsi     # 0xbf2cb
movl $0x3, %edi
xorl %eax, %eax
callq 0x2fdad
callq 0x353c2
callq 0x35863
cmpl $0x0, 0xcc1f0(%rip)     # 0x102244
je 0x36064
callq 0x6a220
cmpl $-0x1, %eax
je 0x36159
cmpl $0x0, 0xcb9b9(%rip)     # 0x101a24
jle 0x36086
movl 0xcb8d5(%rip), %edx     # 0x101948
leaq 0x892c5(%rip), %rsi     # 0xbf33f
movl $0x2, %edi
xorl %eax, %eax
callq 0x2fdad
cmpl $0x0, 0xcb99b(%rip)     # 0x101a28
jle 0x360a9
movq 0xcb942(%rip), %rdx     # 0x1019d8
leaq 0x892db(%rip), %rsi     # 0xbf378
movl $0x2, %edi
xorl %eax, %eax
callq 0x2fdad
movq 0xcc100(%rip), %rdx     # 0x1021b0
leaq -0x1(%rdx), %rax
cmpq $0xffffe, %rax          # imm = 0xFFFFE
ja 0x360cf
leaq 0x892e9(%rip), %rsi     # 0xbf3ac
movl $0x3, %edi
xorl %eax, %eax
callq 0x2fdad
movq 0xcb812(%rip), %rdi     # 0x1018e8
leaq -0x4e02(%rip), %rsi     # 0x312db
callq 0x2d579
movq 0xcb7ff(%rip), %rdi     # 0x1018e8
callq 0x2d543
movq 0xcb7f3(%rip), %rdi     # 0x1018e8
callq 0x2cdf9
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x354ba
callq 0x35511
cmpl $0x3, %r14d
jne 0x36138
movq 0x10(%rbx), %rdi
callq 0x26760
movslq %eax, %rdi
movl $0x32, %esi
callq 0x737cd
xorl %edi, %edi
callq 0x262c0
callq 0x27126
leaq 0x890aa(%rip), %rsi     # 0xbf1ee
movl $0x3, %edi
xorl %eax, %eax
callq 0x2fdad
leaq 0x890bf(%rip), %rsi     # 0xbf216
jmp 0x36160
leaq 0x89190(%rip), %rsi     # 0xbf2f0
movl $0x3, %edi
xorl %eax, %eax
callq 0x2fdad
movl $0x1, %edi
callq 0x262c0
nop