// File: /workspace/github_c_makefile_star2_O0/desion[P]terminal/src/connection.c
// Function: conn_close
void conn_close(conn *c) {
    event_del(&c->event);

    if (settings.verbose > 1)
        fprintf(stderr, "<%d connection closed.\n", c->sfd);

    close(c->sfd);

    if (freecurr < freetotal) {
        freeconns[freecurr++] = c;
    } else {
        conn **new_freeconns = realloc(freeconns, sizeof(conn *)*freetotal*2);
        if (new_freeconns) {
            freetotal *= 2;
            freeconns = new_freeconns;
            freeconns[freecurr++] = c;
        } else {
            if (settings.verbose > 0)
                fprintf(stderr, "Couldn't realloc freeconns\n");
            free(c->rbuf);
            free(c->wbuf);
            free(c);

            STATS_LOCK(stats);
            stats.conn_structs--;
            STATS_UNLOCK(stats);
        }
    }

    STATS_LOCK(stats);
    stats.curr_conns--;
    STATS_UNLOCK(stats);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
callq 0x2160
leaq 0x6998(%rip), %rax      # 0xaa78
cmpl $0x1, 0x10(%rax)
jle 0x4104
movq 0x5f0b(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movl (%rax), %edx
leaq 0x3116(%rip), %rsi      # 0x7213
movb $0x0, %al
callq 0x2260
movq -0x8(%rbp), %rax
movl (%rax), %edi
callq 0x21c0
leaq 0x6a76(%rip), %rax      # 0xab8c
movl (%rax), %eax
leaq 0x6a69(%rip), %rcx      # 0xab88
cmpl (%rcx), %eax
jge 0x4154
movq -0x8(%rbp), %rdx
leaq 0x6a52(%rip), %rax      # 0xab80
movq (%rax), %rax
leaq 0x6a54(%rip), %rcx      # 0xab8c
movl (%rcx), %ecx
movl %ecx, %edi
addl $0x1, %edi
leaq 0x6a46(%rip), %rsi      # 0xab8c
movl %edi, (%rsi)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x4259
leaq 0x6a25(%rip), %rax      # 0xab80
movq (%rax), %rdi
leaq 0x6a23(%rip), %rax      # 0xab88
movslq (%rax), %rsi
shlq $0x3, %rsi
shlq %rsi
callq 0x2330
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x41d2
leaq 0x6a02(%rip), %rax      # 0xab88
movl (%rax), %ecx
shll %ecx
leaq 0x69f7(%rip), %rax      # 0xab88
movl %ecx, (%rax)
movq -0x10(%rbp), %rcx
leaq 0x69e2(%rip), %rax      # 0xab80
movq %rcx, (%rax)
movq -0x8(%rbp), %rdx
leaq 0x69d4(%rip), %rax      # 0xab80
movq (%rax), %rax
leaq 0x69d6(%rip), %rcx      # 0xab8c
movl (%rcx), %ecx
movl %ecx, %edi
addl $0x1, %edi
leaq 0x69c8(%rip), %rsi      # 0xab8c
movl %edi, (%rsi)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x4257
leaq 0x689f(%rip), %rax      # 0xaa78
cmpl $0x0, 0x10(%rax)
jle 0x41f7
movq 0x5e12(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x303b(%rip), %rsi      # 0x722b
movb $0x0, %al
callq 0x2260
movq -0x8(%rbp), %rax
movq 0x90(%rax), %rdi
callq 0x2030
movq -0x8(%rbp), %rax
movq 0xa8(%rax), %rdi
callq 0x2030
movq -0x8(%rbp), %rdi
callq 0x2030
leaq 0x6969(%rip), %rdi      # 0xab90
addq $0x28, %rdi
callq 0x2490
leaq 0x6959(%rip), %rax      # 0xab90
movl 0x4(%rax), %ecx
addl $-0x1, %ecx
leaq 0x694c(%rip), %rax      # 0xab90
movl %ecx, 0x4(%rax)
leaq 0x6942(%rip), %rdi      # 0xab90
addq $0x28, %rdi
callq 0x22d0
jmp 0x4259
leaq 0x6930(%rip), %rdi      # 0xab90
addq $0x28, %rdi
callq 0x2490
leaq 0x6920(%rip), %rax      # 0xab90
movl (%rax), %ecx
addl $-0x1, %ecx
leaq 0x6914(%rip), %rax      # 0xab90
movl %ecx, (%rax)
leaq 0x690b(%rip), %rdi      # 0xab90
addq $0x28, %rdi
callq 0x22d0
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop