// File: /workspace/github_c_makefile_star2_O0/yancanchen[P]mc-bloom-filter/mc_bloom_filter.c
// Function: main
int main(int argc, char *argv[]) 
{
    int c;
    conn *l_conn;
    struct in_addr addr;
    int daemonize = 1;
    struct passwd *pw;
    struct sigaction sa;
    struct rlimit rlim;

    /* init my_srv */
    init_my_srv_default();

    /* set stderr non-buffering (for running under, say, daemontools) */
    setbuf(stderr, NULL);

    /* process arguments */
    while ((c = getopt(argc, argv, "p:c:khirvdl:u:P:m:")) != -1) {
        switch (c) {
        case 'p':
            my_srv.port = atoi(optarg);
            break;
        // max memory now not use 
        case 'm':
            my_srv.maxbytes = ((size_t)atoi(optarg))*1024*1024;
            break;
        case 'c':
            my_srv.maxconns = atoi(optarg);
            break;
        case 'h':
            usage();
            exit(0);
        case 'i':
            usage_license();
            exit(0);
        case 'k':
            my_srv.lock_memory = 1;
            break;
        case 'v':
            my_srv.verbose++;
            break;
        case 'l':
            if (!inet_pton(AF_INET, optarg, &addr)) {
                fprintf(stderr, "Illegal address: %s\n", optarg);
                return 1;
            } else {
                my_srv.interface = addr;
            }
            break;
        case 'd':
            daemonize = 1;
            break;
        case 'r':
            my_srv.maxcore = 1;
            break;
        case 'u':
            my_srv.username = optarg;
            break;
        case 'P':
            my_srv.pid_file = optarg;
            break;
        default:
            fprintf(stderr, "Illegal argument \"%c\"\n", c);
            return 1;
        }
    }

    if (my_srv.maxcore) {
        struct rlimit rlim_new;
        /* 
         * First try raising to infinity; if that fails, try bringing
         * the soft limit to the hard. 
         */
        if (getrlimit(RLIMIT_CORE, &rlim)==0) {
            rlim_new.rlim_cur = rlim_new.rlim_max = RLIM_INFINITY;
            if (setrlimit(RLIMIT_CORE, &rlim_new)!=0) {
                /* failed. try raising just to the old max */
                rlim_new.rlim_cur = rlim_new.rlim_max = 
                    rlim.rlim_max;
                (void) setrlimit(RLIMIT_CORE, &rlim_new);
            }
        }
        /* 
         * getrlimit again to see what we ended up with. Only fail if 
         * the soft limit ends up 0, because then no core files will be 
         * created at all.
         */

        if ((getrlimit(RLIMIT_CORE, &rlim)!=0) || rlim.rlim_cur==0) {
            fprintf(stderr, "failed to ensure corefile creation\n");
            exit(1);
        }
    }

    /* 
     * If needed, increase rlimits to allow as many connections
     * as needed.
     */

    if (getrlimit(RLIMIT_NOFILE, &rlim) != 0) {
        fprintf(stderr, "failed to getrlimit number of files\n");
        exit(1);
    } else {
        int maxfiles = my_srv.maxconns;
        if (rlim.rlim_cur < maxfiles) 
            rlim.rlim_cur = maxfiles + 3;
        if (rlim.rlim_max < rlim.rlim_cur)
            rlim.rlim_max = rlim.rlim_cur;
        if (setrlimit(RLIMIT_NOFILE, &rlim) != 0) {
            fprintf(stderr, "failed to set rlimit for open files. "
                    "Try running as root or requesting smaller maxconns value.\n");
            exit(1);
        }
    }

    /* 
     * initialization order: first create the listening socket
     * (may need root on low ports), then drop root if needed,
     * then daemonise if needed, then init libevent (in some cases
     * descriptors created by libevent wouldn't survive forking).
     */

    /* create the listening socket and bind it */
    l_socket = server_socket(my_srv.port);
    if (l_socket == -1) {
        fprintf(stderr, "failed to listen\n");
        exit(1);
    }

    /* lose root privileges if we have them */
    if (getuid()== 0 || geteuid()==0) {
        if (my_srv.username==0 || *(my_srv.username)=='\0') {
            fprintf(stderr, "can't run as root without the username switch\n");
            return 1;
        }
        if ((pw = getpwnam(my_srv.username)) == 0) {
            fprintf(stderr, "can't find the user %s to switch to\n", my_srv.username);
            return 1;
        }
        if (setgid(pw->pw_gid)<0 || setuid(pw->pw_uid)<0) {
            fprintf(stderr, "failed to assume identity of user %s\n", my_srv.username);
            return 1;
        }
    }

    stats_init();

    /* daemonize if requested */
    /* if we want to ensure our ability to dump core, don't chdir to / */
    if (daemonize) {
        int res;
        res = daemon(my_srv.maxcore, my_srv.verbose);
        if (res == -1) {
            fprintf(stderr, "failed to daemon() in order to daemonize\n");
            return 1;
        }
    }


    /* initialize other stuff */
    event_init();
    conn_init();
            
    if (blooms_init(my_srv.maxbytes)) {
        fprintf(stderr, "blooms init failed, No enough memory?");
        exit(-1);
    }

    /* lock paged memory if needed */
    if (my_srv.lock_memory) {
#define HAVE_MLOCKALL
#ifdef HAVE_MLOCKALL
        mlockall(MCL_CURRENT | MCL_FUTURE);
#else
        fprintf(stderr, "warning: mlockall() not supported on this platform.  proceeding without.\n");
#endif
    }

    /*
     * ignore SIGPIPE signals; we can use errno==EPIPE if we
     * need that information
     */
    sa.sa_handler = SIG_IGN;
    sa.sa_flags = 0;
    if (sigemptyset(&sa.sa_mask) == -1 ||
            sigaction(SIGPIPE, &sa, 0) == -1) {
        perror("failed to ignore SIGPIPE; sigaction");
        exit(1); 
    }

    /* create the initial listening connection */
    if (!(l_conn = conn_new(l_socket, conn_listening, EV_READ | EV_PERSIST))) {
        fprintf(stderr, "failed to create listening connection");
        exit(1);
    }

    /* save the PID in if we're a daemon */
    if (daemonize)
        save_pid(getpid(),my_srv.pid_file);

    fprintf(stderr, "service started!\r\n");

    /* enter the loop */
    event_loop(0);

    /* remove the PID file if we're a daemon */
    if (daemonize)
        remove_pidfile(my_srv.pid_file);

    return 0;
}

// Assembly:
subq $0xf8, %rsp
movl $0x0, 0xf4(%rsp)
movl %edi, 0xf0(%rsp)
movq %rsi, 0xe8(%rsp)
movl $0x1, 0xd0(%rsp)
callq 0x3570
movq 0x3fc0(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2130
movl 0xf0(%rsp), %edi
movq 0xe8(%rsp), %rsi
leaq 0x1c0b(%rip), %rdx      # 0x7c65
callq 0x2390
movl %eax, 0xe4(%rsp)
cmpl $-0x1, %eax
je 0x6205
movl 0xe4(%rsp), %eax
addl $-0x50, %eax
movl %eax, %ecx
movq %rcx, (%rsp)
subl $0x26, %eax
ja 0x61d1
movq (%rsp), %rax
leaq 0x11d1(%rip), %rcx      # 0x7264
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x3f35(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
callq 0x23b0
movl %eax, 0x41ef(%rip)      # 0xa2a0
jmp 0x6200
movq 0x3f1b(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
callq 0x23b0
cltq
shlq $0xa, %rax
shlq $0xa, %rax
movq %rax, 0x41da(%rip)      # 0xa2b0
jmp 0x6200
movq 0x3ef6(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
callq 0x23b0
movl %eax, 0x41a8(%rip)      # 0xa298
jmp 0x6200
callq 0x5f20
xorl %edi, %edi
callq 0x23e0
callq 0x5fd0
xorl %edi, %edi
callq 0x23e0
movl $0x1, 0x4191(%rip)      # 0xa2a8
jmp 0x6200
movl 0x4182(%rip), %eax      # 0xa2a4
addl $0x1, %eax
movl %eax, 0x4179(%rip)      # 0xa2a4
jmp 0x6200
movq 0x3ea1(%rip), %rax      # 0x9fd8
movq (%rax), %rsi
movl $0x2, %edi
leaq 0xd4(%rsp), %rdx
callq 0x2270
cmpl $0x0, %eax
jne 0x6183
movq 0x3ea0(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x3e76(%rip), %rax      # 0x9fd8
movq (%rax), %rdx
leaq 0x1b0c(%rip), %rsi      # 0x7c78
movb $0x0, %al
callq 0x2250
movl $0x1, 0xf4(%rsp)
jmp 0x662a
movl 0xd4(%rsp), %eax
movl %eax, 0x4138(%rip)      # 0xa2c8
jmp 0x6200
movl $0x1, 0xd0(%rsp)
jmp 0x6200
movl $0x1, 0x40f3(%rip)      # 0xa29c
jmp 0x6200
movq 0x3e26(%rip), %rax      # 0x9fd8
movq (%rax), %rax
movq %rax, 0x40fc(%rip)      # 0xa2b8
jmp 0x6200
movq 0x3e13(%rip), %rax      # 0x9fd8
movq (%rax), %rax
movq %rax, 0x40f1(%rip)      # 0xa2c0
jmp 0x6200
movq 0x3e20(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl 0xe4(%rsp), %edx
leaq 0x1aa4(%rip), %rsi      # 0x7c8d
movb $0x0, %al
callq 0x2250
movl $0x1, 0xf4(%rsp)
jmp 0x662a
jmp 0x6044
cmpl $0x0, 0x4090(%rip)      # 0xa29c
je 0x62ac
movl $0x4, %edi
leaq 0x20(%rsp), %rsi
callq 0x23f0
cmpl $0x0, %eax
jne 0x626c
movq $-0x1, 0x18(%rsp)
movq $-0x1, 0x10(%rsp)
movl $0x4, %edi
leaq 0x10(%rsp), %rsi
callq 0x22d0
cmpl $0x0, %eax
je 0x626a
movq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
movq %rax, 0x10(%rsp)
movl $0x4, %edi
leaq 0x10(%rsp), %rsi
callq 0x22d0
jmp 0x626c
movl $0x4, %edi
leaq 0x20(%rsp), %rsi
callq 0x23f0
cmpl $0x0, %eax
jne 0x6288
cmpq $0x0, 0x20(%rsp)
jne 0x62aa
movq 0x3d69(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x1a0b(%rip), %rsi      # 0x7ca4
movb $0x0, %al
callq 0x2250
movl $0x1, %edi
callq 0x23e0
jmp 0x62ac
movl $0x7, %edi
leaq 0x20(%rsp), %rsi
callq 0x23f0
cmpl $0x0, %eax
je 0x62e2
movq 0x3d31(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x19f7(%rip), %rsi      # 0x7cc8
movb $0x0, %al
callq 0x2250
movl $0x1, %edi
callq 0x23e0
movl 0x3fb0(%rip), %eax      # 0xa298
movl %eax, 0xc(%rsp)
movq 0x20(%rsp), %rax
movslq 0xc(%rsp), %rcx
cmpq %rcx, %rax
jae 0x6309
movl 0xc(%rsp), %eax
addl $0x3, %eax
cltq
movq %rax, 0x20(%rsp)
movq 0x28(%rsp), %rax
cmpq 0x20(%rsp), %rax
jae 0x631f
movq 0x20(%rsp), %rax
movq %rax, 0x28(%rsp)
movl $0x7, %edi
leaq 0x20(%rsp), %rsi
callq 0x22d0
cmpl $0x0, %eax
je 0x6355
movq 0x3cbe(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x19a9(%rip), %rsi      # 0x7ced
movb $0x0, %al
callq 0x2250
movl $0x1, %edi
callq 0x23e0
jmp 0x6357
movl 0x3f43(%rip), %edi      # 0xa2a0
callq 0x5ca0
movl %eax, 0x3f78(%rip)      # 0xa2e0
cmpl $-0x1, 0x3f71(%rip)     # 0xa2e0
jne 0x6393
movq 0x3c80(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x19cb(%rip), %rsi      # 0x7d4d
movb $0x0, %al
callq 0x2250
movl $0x1, %edi
callq 0x23e0
callq 0x2120
cmpl $0x0, %eax
je 0x63ab
callq 0x21c0
cmpl $0x0, %eax
jne 0x6490
cmpq $0x0, 0x3f05(%rip)      # 0xa2b8
je 0x63c4
movq 0x3efc(%rip), %rax      # 0xa2b8
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x63ec
movq 0x3c2d(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x198a(%rip), %rsi      # 0x7d5f
movb $0x0, %al
callq 0x2250
movl $0x1, 0xf4(%rsp)
jmp 0x662a
movq 0x3ec5(%rip), %rdi      # 0xa2b8
callq 0x2240
movq %rax, 0xc8(%rsp)
cmpq $0x0, %rax
jne 0x6435
movq 0x3beb(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x3ea1(%rip), %rdx      # 0xa2b8
leaq 0x1970(%rip), %rsi      # 0x7d8e
movb $0x0, %al
callq 0x2250
movl $0x1, 0xf4(%rsp)
jmp 0x662a
movq 0xc8(%rsp), %rax
movl 0x14(%rax), %edi
callq 0x2320
cmpl $0x0, %eax
jl 0x645f
movq 0xc8(%rsp), %rax
movl 0x10(%rax), %edi
callq 0x2400
cmpl $0x0, %eax
jge 0x648e
movq 0x3b92(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq 0x3e48(%rip), %rdx      # 0xa2b8
leaq 0x193c(%rip), %rsi      # 0x7db3
movb $0x0, %al
callq 0x2250
movl $0x1, 0xf4(%rsp)
jmp 0x662a
jmp 0x6490
callq 0x34b0
cmpl $0x0, 0xd0(%rsp)
je 0x64e5
movl 0x3df7(%rip), %edi      # 0xa29c
movl 0x3df9(%rip), %esi      # 0xa2a4
callq 0x33d0
movl %eax, 0x8(%rsp)
cmpl $-0x1, 0x8(%rsp)
jne 0x64e3
movq 0x3b36(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x190d(%rip), %rsi      # 0x7dd9
movb $0x0, %al
callq 0x2250
movl $0x1, 0xf4(%rsp)
jmp 0x662a
jmp 0x64e5
callq 0x2420
callq 0x3640
movq 0x3dba(%rip), %rdi      # 0xa2b0
callq 0x3210
cmpl $0x0, %eax
je 0x6522
movq 0x3af1(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x18f2(%rip), %rsi      # 0x7e03
movb $0x0, %al
callq 0x2250
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x23e0
cmpl $0x0, 0x3d7f(%rip)      # 0xa2a8
je 0x6535
movl $0x3, %edi
callq 0x22f0
movl $0x1, %eax
movq %rax, 0x30(%rsp)
movl $0x0, 0xb8(%rsp)
leaq 0x30(%rsp), %rdi
addq $0x8, %rdi
callq 0x2260
cmpl $-0x1, %eax
je 0x6575
movl $0xd, %edi
leaq 0x30(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x2090
cmpl $-0x1, %eax
jne 0x658b
leaq 0x18ad(%rip), %rdi      # 0x7e29
callq 0x2380
movl $0x1, %edi
callq 0x23e0
movl 0x3d4f(%rip), %edi      # 0xa2e0
xorl %esi, %esi
movl $0x12, %edx
callq 0x3670
movq %rax, 0xd8(%rsp)
cmpq $0x0, %rax
jne 0x65cd
movq 0x3a46(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x1891(%rip), %rsi      # 0x7e4d
movb $0x0, %al
callq 0x2250
movl $0x1, %edi
callq 0x23e0
cmpl $0x0, 0xd0(%rsp)
je 0x65ea
callq 0x20d0
movl %eax, %edi
movq 0x3cdb(%rip), %rsi      # 0xa2c0
callq 0x5e40
movq 0x3a07(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x1878(%rip), %rsi      # 0x7e73
movb $0x0, %al
callq 0x2250
xorl %edi, %edi
callq 0x2340
cmpl $0x0, 0xd0(%rsp)
je 0x661f
movq 0x3ca6(%rip), %rdi      # 0xa2c0
callq 0x5ee0
movl $0x0, 0xf4(%rsp)
movl 0xf4(%rsp), %eax
addq $0xf8, %rsp
retq
nopl (%rax)