// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x9cff0
movl $0x3, %edi
leaq 0x1039e4(%rip), %rsi    # 0x13b612
callq 0x26b50
callq 0x3b0e0
leaq -0x44f(%rip), %rdi      # 0x377f0
callq 0x3b0f0
xorl %eax, %eax
movl %eax, %edi
callq 0x26ce0
movq %rax, -0x50(%rbp)
callq 0x26420
movl %eax, %ecx
movq -0x50(%rbp), %rax
movslq %ecx, %rcx
xorq %rcx, %rax
movl %eax, %edi
callq 0x26970
leaq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x26310
movq -0x20(%rbp), %rax
xorq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
callq 0x26420
movl %eax, %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rcx
xorq %rcx, %rax
movl %eax, %edi
callq 0x2d190
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0x37670
movl %eax, 0x1405c8(%rip)    # 0x178274
callq 0x32020
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x48130
movq %rax, 0x140524(%rip)    # 0x1781e8
movl -0x8(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x3acd0
movq %rax, 0x140513(%rip)    # 0x1781f0
movq 0x14050c(%rip), %rax    # 0x1781f0
movslq -0x8(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x37d2d
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3b040
movq %rax, %rdx
movq 0x1404d6(%rip), %rax    # 0x1781f0
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x37cf7
cmpl $0x0, 0x140540(%rip)    # 0x178274
je 0x37d40
callq 0x94460
callq 0x94480
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x102370(%rip), %rsi    # 0x13a0be
callq 0x266c0
cmpq $0x0, %rax
je 0x37d65
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
callq 0xa3710
cmpl $0x2, -0x8(%rbp)
jl 0x38074
movl $0x1, -0x24(%rbp)
callq 0x384f0
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x102338(%rip), %rsi    # 0x13a0ce
callq 0x268f0
cmpl $0x0, %eax
je 0x37db9
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x102322(%rip), %rsi    # 0x13a0d1
callq 0x268f0
cmpl $0x0, %eax
jne 0x37dbe
callq 0x37240
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x10230e(%rip), %rsi    # 0x13a0db
callq 0x268f0
cmpl $0x0, %eax
je 0x37df0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x1022fc(%rip), %rsi    # 0x13a0e2
callq 0x268f0
cmpl $0x0, %eax
jne 0x37df5
callq 0x372b0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x1022e1(%rip), %rsi    # 0x13a0e5
callq 0x268f0
cmpl $0x0, %eax
jne 0x37e6f
cmpl $0x3, -0x8(%rbp)
jne 0x37e35
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x26760
movslq %eax, %rdi
movl $0x32, %esi
callq 0x900a0
xorl %edi, %edi
callq 0x262d0
movq 0x13b1ac(%rip), %rax    # 0x172fe8
movq (%rax), %rdi
leaq 0x1022ad(%rip), %rsi    # 0x13a0f3
movb $0x0, %al
callq 0x26ba0
movq 0x13b194(%rip), %rax    # 0x172fe8
movq (%rax), %rdi
leaq 0x1022d0(%rip), %rsi    # 0x13a12e
movb $0x0, %al
callq 0x26ba0
movl $0x1, %edi
callq 0x262d0
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x37e98
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
je 0x37ef3
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x48130
movq %rax, 0x140328(%rip)    # 0x1781e0
movq 0x140331(%rip), %rax    # 0x1781f0
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3afa0
movq 0x14030d(%rip), %rdi    # 0x1781e0
callq 0x3b040
movq %rax, %rdx
movq 0x14030e(%rip), %rax    # 0x1781f0
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x37ef5
movl -0x24(%rbp), %eax
cmpl -0x8(%rbp), %eax
je 0x3800b
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x37fac
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
jne 0x37fac
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x10221a(%rip), %rsi    # 0x13a15b
callq 0x268f0
cmpl $0x0, %eax
jne 0x37f56
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x37ef5
movq -0x30(%rbp), %rdi
callq 0x30060
cmpq $0x0, %rax
je 0x37f79
movq -0x30(%rbp), %rdi
leaq 0x101ec9(%rip), %rsi    # 0x139e39
callq 0x390d0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
addq $0x2, %rsi
callq 0x390d0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x1071a8(%rip), %rsi    # 0x13f149
callq 0x390d0
movq %rax, -0x30(%rbp)
jmp 0x37ffd
movq -0x30(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x264f0
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rdx
callq 0x3a2c0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x107155(%rip), %rsi    # 0x13f149
callq 0x390d0
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x37ef5
cmpl $0x0, 0x140262(%rip)    # 0x178274
je 0x38057
cmpq $0x0, -0x38(%rbp)
je 0x38057
movq -0x38(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x38057
movl $0x3, %edi
leaq 0x102134(%rip), %rsi    # 0x13a167
movb $0x0, %al
callq 0x2fc60
movl $0x3, %edi
leaq 0x102149(%rip), %rsi    # 0x13a18f
movb $0x0, %al
callq 0x2fc60
movl $0x1, %edi
callq 0x262d0
callq 0x687c0
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x6a830
movq -0x30(%rbp), %rdi
callq 0x38620
jmp 0x380a9
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movl 0x1401f3(%rip), %esi    # 0x178274
leaq 0xfffb0(%rip), %rcx     # 0x138038
leaq 0x10e843(%rip), %rax    # 0x1468d2
cmpl $0x0, %esi
cmovneq %rax, %rcx
movl $0x3, %edi
leaq 0x10212b(%rip), %rsi    # 0x13a1cd
movb $0x0, %al
callq 0x2fc60
movl 0x140741(%rip), %edi    # 0x1787f0
callq 0x37b70
movl %eax, 0x140732(%rip)    # 0x1787ec
xorl %eax, %eax
cmpl $0x0, 0x140731(%rip)    # 0x1787f4
movb %al, -0x61(%rbp)
je 0x380d7
cmpl $0x0, 0x14071d(%rip)    # 0x1787ec
setne %al
xorb $-0x1, %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x380ed
callq 0x371c0
callq 0x331a0
cmpl $0x0, -0x3c(%rbp)
jne 0x38102
cmpq $0x0, 0x140138(%rip)    # 0x178238
je 0x38107
callq 0x37140
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x37840
callq 0x37400
callq 0x32c60
cmpl $0x0, 0x140150(%rip)    # 0x178274
jne 0x381c0
movl $0x3, %edi
leaq 0x10210e(%rip), %rsi    # 0x13a244
movb $0x0, %al
callq 0x2fc60
callq 0x37100
callq 0x37700
cmpl $0x0, 0x140a26(%rip)    # 0x178b74
je 0x38179
callq 0x834a0
cmpl $-0x1, %eax
jne 0x38177
movl $0x3, %edi
leaq 0x102103(%rip), %rsi    # 0x13a269
movb $0x0, %al
callq 0x2fc60
movl $0x1, %edi
callq 0x262d0
jmp 0x38179
cmpl $0x0, 0x1401d4(%rip)    # 0x178354
jle 0x3819b
movl 0x1400f0(%rip), %edx    # 0x178278
movl $0x2, %edi
leaq 0x102124(%rip), %rsi    # 0x13a2b8
movb $0x0, %al
callq 0x2fc60
cmpl $0x0, 0x1401b6(%rip)    # 0x178358
jle 0x381be
movq 0x14015d(%rip), %rdx    # 0x178308
movl $0x2, %edi
leaq 0x10213a(%rip), %rsi    # 0x13a2f1
movb $0x0, %al
callq 0x2fc60
jmp 0x381c5
callq 0x945c0
cmpq $0x0, 0x140913(%rip)    # 0x178ae0
jbe 0x381f6
cmpq $0x100000, 0x140906(%rip) # imm = 0x100000
jae 0x381f6
movq 0x1408fd(%rip), %rdx    # 0x178ae0
movl $0x3, %edi
leaq 0x102136(%rip), %rsi    # 0x13a325
movb $0x0, %al
callq 0x2fc60
movq 0x14001b(%rip), %rdi    # 0x178218
leaq -0x6914(%rip), %rsi     # 0x318f0
callq 0x2b6b0
movq 0x140008(%rip), %rdi    # 0x178218
callq 0x2b630
movq 0x13fffc(%rip), %rdi    # 0x178218
callq 0x2a850
xorl %eax, %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)