// File: /workspace/github_c_makefile_star2_O2/yancanchen[P]mc-bloom-filter/mc_bloom_filter.c
// Function: conn_new
conn *conn_new(int sfd, int init_state, int event_flags) {
    conn *c;

    /* do we have a free conn structure from a previous close? */
    if (freecurr > 0) {
        c = freeconns[--freecurr];
    } else { /* allocate a new one */
        if (!(c = (conn *)malloc(sizeof(conn)))) {
            perror("malloc()");
            return 0;
        }
        c->rbuf = c->wbuf = 0;
        c->rbuf = (char *) malloc(DATA_BUFFER_SIZE);
        c->wbuf = (char *) malloc(DATA_BUFFER_SIZE);

        if (c->rbuf == 0 || c->wbuf == 0) {
            if (c->rbuf != 0) free(c->rbuf);
            if (c->wbuf != 0) free(c->wbuf);
            free(c);
            perror("malloc()");
            return 0;
        }
        c->rsize = c->wsize = DATA_BUFFER_SIZE;
        c->rcurr = c->rbuf;
        stats.conn_structs++;
    }

    if (my_srv.verbose > 1) {
        if (init_state == conn_listening)
            fprintf(stderr, "<%d server listening\n", sfd);
        else
            fprintf(stderr, "<%d new client connection\n", sfd);
    }

    c->sfd = sfd;
    c->state = init_state;
    c->rbytes = c->wbytes = 0;
    c->rlbytes = 0;
    c->wcurr = c->wbuf;
    c->write_and_go = conn_read;
    c->is_corked = 0;
    
    event_set(&c->event, sfd, event_flags, event_handler, (void *)c);
    c->ev_flags = event_flags;

    if (event_add(&c->event, 0) == -1) {
        if (freecurr < freetotal) {
            freeconns[freecurr++] = c;
        } else {
            free (c->rbuf);
            free (c->wbuf);
            free (c);
        }
        return 0;
    }

    stats.curr_conns++;
    stats.total_conns++;

    return c;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r14d
movl %esi, %r15d
movl %edi, %ebp
movl 0x54af(%rip), %eax      # 0x82cc
testl %eax, %eax
jle 0x2e36
movq 0x54a8(%rip), %rcx      # 0x82d0
decl %eax
movl %eax, 0x549c(%rip)      # 0x82cc
movq (%rcx,%rax,8), %rbx
jmp 0x2ea4
movl $0xf8, %edi
callq 0x2280
testq %rax, %rax
je 0x2fd3
movq %rax, %rbx
movl $0x800, %edi            # imm = 0x800
callq 0x2280
movq %rax, %r12
movq %rax, 0x90(%rbx)
movl $0x800, %edi            # imm = 0x800
callq 0x2280
movq %rax, %r13
movq %rax, 0xb0(%rbx)
testq %r12, %r12
je 0x2fbb
testq %r13, %r13
je 0x2fbb
movl $0x800, %eax            # imm = 0x800
movl %eax, 0xc0(%rbx)
movl %eax, 0xa0(%rbx)
movq %r12, 0x98(%rbx)
incl 0x53ac(%rip)            # 0x8250
cmpl $0x2, 0x53f1(%rip)      # 0x829c
jge 0x2f8e
movl %ebp, (%rbx)
movl %r15d, 0x4(%rbx)
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0xc4(%rbx)
andq $0x0, 0xa4(%rbx)
movq 0xb0(%rbx), %rax
movq %rax, 0xb8(%rbx)
movb $0x0, 0xcc(%rbx)
leaq 0x8(%rbx), %r15
movswl %r14w, %r14d
leaq 0xed(%rip), %rcx        # 0x2fe1
movq %r15, %rdi
movl %ebp, %esi
movl %r14d, %edx
movq %rbx, %r8
callq 0x2310
movw %r14w, 0x88(%rbx)
movq %r15, %rdi
xorl %esi, %esi
callq 0x2210
cmpl $-0x1, %eax
je 0x2f35
movq 0x5325(%rip), %xmm0     # 0x8248
pcmpeqd %xmm1, %xmm1
psubd %xmm1, %xmm0
movq %xmm0, 0x5315(%rip)     # 0x8248
jmp 0x2f7c
movslq 0x5390(%rip), %rax      # 0x82cc
cmpl 0x5386(%rip), %eax      # 0x82c8
jge 0x2f5a
movq 0x5385(%rip), %rcx      # 0x82d0
leal 0x1(%rax), %edx
movl %edx, 0x5378(%rip)      # 0x82cc
movq %rbx, (%rcx,%rax,8)
jmp 0x2f7a
movq 0x90(%rbx), %rdi
callq 0x2030
movq 0xb0(%rbx), %rdi
callq 0x2030
movq %rbx, %rdi
callq 0x2030
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testl %r15d, %r15d
movq 0x5060(%rip), %rax      # 0x7ff8
movq (%rax), %rdi
leaq 0x232b(%rip), %rax      # 0x52cd
leaq 0x233a(%rip), %rsi      # 0x52e3
cmoveq %rax, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x2230
jmp 0x2eb1
movq %r12, %rdi
callq 0x2030
movq %r13, %rdi
callq 0x2030
movq %rbx, %rdi
callq 0x2030
leaq 0x22ea(%rip), %rdi      # 0x52c4
callq 0x2360
jmp 0x2f7a