// File: /workspace/github_c_makefile_star2_O0/erikdubbelboer[P]discnt/src/server.c
// Function: main
int main(int argc, char **argv) {
    struct timeval tv;
    int j;

    /* 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(serverOutOfMemoryHandler);
    srand(time(NULL)^getpid());
    gettimeofday(&tv,NULL);
    dictSetHashFunctionSeed(tv.tv_sec^tv.tv_usec^getpid());
    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]);

    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: ./discnt-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 (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++;
        }
        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/discnt.conf", argv[0]);
    }

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

    initServer();
    if (background || server.pidfile) createPidFile();
    serverSetProcTitle(argv[0]);
    discntAsciiArt();

    /* Things not needed when running in Sentinel mode. */
    serverLog(LL_WARNING,"Server started, Discnt version " DISCNT_VERSION);
#ifdef __linux__
    linuxOvercommitMemoryWarning();
#endif
    checkTcpBacklogSettings();
    loadDataFromDisk();
    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);

    /* 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);
    /* Make sure to do a cron run before 1st client is served, so that we
     * can do periodic tasks there that we can assume to always be executed
     * at least once before the server starts serving queries. */
    serverCron(NULL,0,NULL);
    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 0x374d0
movl $0x3, %edi
leaq 0x88274(%rip), %rsi     # 0xa5d72
callq 0x12640
callq 0x20e20
leaq -0x3ff(%rip), %rdi      # 0x1d710
callq 0x20e30
xorl %eax, %eax
movl %eax, %edi
callq 0x12530
movq %rax, -0x50(%rbp)
callq 0x121d0
movl %eax, %ecx
movq -0x50(%rbp), %rax
movslq %ecx, %rcx
xorq %rcx, %rax
movl %eax, %edi
callq 0x12410
leaq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12330
movq -0x20(%rbp), %rax
xorq -0x18(%rbp), %rax
movq %rax, -0x48(%rbp)
callq 0x121d0
movl %eax, %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rcx
xorq %rcx, %rax
movl %eax, %edi
callq 0x15f80
callq 0x1a410
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x28e00
movq %rax, 0xa1576(%rip)     # 0xbf0f8
movl -0x8(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x20a00
movq %rax, 0xa1565(%rip)     # 0xbf100
movq 0xa155e(%rip), %rax     # 0xbf100
movslq -0x8(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x1dbeb
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x20d90
movq %rax, %rdx
movq 0xa1528(%rip), %rax     # 0xbf100
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1dbb5
cmpl $0x2, -0x8(%rbp)
jl 0x1de7d
movl $0x1, -0x24(%rbp)
callq 0x1e290
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x873a9(%rip), %rsi     # 0xa4fc5
callq 0x12480
cmpl $0x0, %eax
je 0x1dc3f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x87393(%rip), %rsi     # 0xa4fc8
callq 0x12480
cmpl $0x0, %eax
jne 0x1dc44
callq 0x1d2e0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x8737f(%rip), %rsi     # 0xa4fd2
callq 0x12480
cmpl $0x0, %eax
je 0x1dc76
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x8736d(%rip), %rsi     # 0xa4fd9
callq 0x12480
cmpl $0x0, %eax
jne 0x1dc7b
callq 0x1d350
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x87352(%rip), %rsi     # 0xa4fdc
callq 0x12480
cmpl $0x0, %eax
jne 0x1dcf5
cmpl $0x3, -0x8(%rbp)
jne 0x1dcbb
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x12820
movslq %eax, %rdi
movl $0x32, %esi
callq 0x373d0
xorl %edi, %edi
callq 0x12870
movq 0xa0336(%rip), %rax     # 0xbdff8
movq (%rax), %rdi
leaq 0x8731e(%rip), %rsi     # 0xa4fea
movb $0x0, %al
callq 0x124b0
movq 0xa031e(%rip), %rax     # 0xbdff8
movq (%rax), %rdi
leaq 0x87341(%rip), %rsi     # 0xa5025
movb $0x0, %al
callq 0x124b0
movl $0x1, %edi
callq 0x12870
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x1dd1e
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
je 0x1dd79
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x28e00
movq %rax, 0xa13b2(%rip)     # 0xbf0f0
movq 0xa13bb(%rip), %rax     # 0xbf100
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x20ce0
movq 0xa1397(%rip), %rdi     # 0xbf0f0
callq 0x20d90
movq %rax, %rdx
movq 0xa1398(%rip), %rax     # 0xbf100
movslq -0x24(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1dd7b
movl -0x24(%rbp), %eax
cmpl -0x8(%rbp), %eax
je 0x1de65
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x1de06
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2d, %eax
jne 0x1de06
movq -0x30(%rbp), %rdi
callq 0x18f50
cmpq $0x0, %rax
je 0x1ddd3
movq -0x30(%rbp), %rdi
leaq 0x86fde(%rip), %rsi     # 0xa4da8
callq 0x1ee70
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 0x1ee70
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x88993(%rip), %rsi     # 0xa678e
callq 0x1ee70
movq %rax, -0x30(%rbp)
jmp 0x1de57
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 0x12230
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rdx
callq 0x20060
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
leaq 0x88940(%rip), %rsi     # 0xa678e
callq 0x1ee70
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1dd7b
movq -0x38(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x2baf0
movq -0x30(%rbp), %rdi
callq 0x1e3c0
jmp 0x1de97
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movl $0x3, %edi
leaq 0x871c3(%rip), %rsi     # 0xa5053
movb $0x0, %al
callq 0x18b10
movl 0xa17ff(%rip), %edi     # 0xbf69c
callq 0x1da40
movl %eax, 0xa17f0(%rip)     # 0xbf698
xorl %eax, %eax
cmpl $0x0, 0xa17ef(%rip)     # 0xbf6a0
movb %al, -0x61(%rbp)
je 0x1dec5
cmpl $0x0, 0xa17db(%rip)     # 0xbf698
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 0x1dedb
callq 0x1d260
callq 0x1b150
cmpl $0x0, -0x3c(%rbp)
jne 0x1def0
cmpq $0x0, 0xa124a(%rip)     # 0xbf138
je 0x1def5
callq 0x1d200
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1d760
callq 0x1d470
movl $0x3, %edi
leaq 0x871bc(%rip), %rsi     # 0xa50ce
movb $0x0, %al
callq 0x18b10
callq 0x1d1d0
callq 0x1acc0
callq 0x1d670
cmpl $0x0, 0xa134d(%rip)     # 0xbf27c
jle 0x1df4a
movl 0xa1265(%rip), %edx     # 0xbf19c
movl $0x2, %edi
leaq 0x871b0(%rip), %rsi     # 0xa50f3
movb $0x0, %al
callq 0x18b10
cmpl $0x0, 0xa132f(%rip)     # 0xbf280
jle 0x1df6d
movq 0xa12d6(%rip), %rdx     # 0xbf230
movl $0x2, %edi
leaq 0x871c6(%rip), %rsi     # 0xa512c
movb $0x0, %al
callq 0x18b10
cmpq $0x0, 0xa1783(%rip)     # 0xbf6f8
jbe 0x1df9e
cmpq $0x100000, 0xa1776(%rip) # imm = 0x100000
jae 0x1df9e
movq 0xa176d(%rip), %rdx     # 0xbf6f8
movl $0x3, %edi
leaq 0x871c9(%rip), %rsi     # 0xa5160
movb $0x0, %al
callq 0x18b10
movq 0xa117b(%rip), %rdi     # 0xbf120
leaq -0x410c(%rip), %rsi     # 0x19ea0
callq 0x145a0
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rdi
movq %rdx, %rsi
callq 0x19a60
movq 0xa1159(%rip), %rdi     # 0xbf120
callq 0x14520
movq 0xa114d(%rip), %rdi     # 0xbf120
callq 0x13730
xorl %eax, %eax
addq $0x70, %rsp
popq %rbp
retq