// File: /workspace/github_c_makefile_star2_O2/mruby-zest[P]osc-bridge/src/bridge.c
// Function: br_destroy
void br_destroy(bridge_t *br)
{
    int close;
    close = uv_udp_recv_stop(&br->socket);
    if(close)
        fprintf(stderr, "[Warning] UV UDP cannot be stopped [%d] (UV_EBUSY=%d)\n", close, UV_EBUSY);
    else
        fprintf(stderr, "[INFO] UV UDP Stopped\n");
    uv_close((uv_handle_t*)&br->socket, NULL);

    //Flush Events
    int i=100;
    while(uv_run(br->loop, UV_RUN_NOWAIT) > 1)
        if(i-- < 0)
            break;

    close = uv_loop_close(br->loop);
    if(close)
        fprintf(stderr, "[Warning] UV Loop Cannot be closed [%d] (UV_EBUSY=%d)\n", close, UV_EBUSY);
    else
        fprintf(stderr, "[INFO] UV Loop Stopped\n");
    free(br->loop);

    for(int i=0; i<br->cache_len; ++i) {
        free((void*)br->cache[i].path);
        if(br->cache[i].type == 'v') {
            declone_vec_value(br->cache[i].vec_type, br->cache[i].vec_value);
            //free((void*)br->cache[i].vec_type);
            //free((void*)br->cache[i].vec_value);
        } else
            declone_value(br->cache[i].type, br->cache[i].val);
    }
    free(br->cache);
    free(br->bounce);
    for(int i=0; i<br->callback_len; ++i) {
        free((void*)br->callback[i].data);
        free((void*)br->callback[i].path);
    }
    free(br->callback);
    free(br->address);
    free(br);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
leaq 0x8(%rdi), %r14
movq %r14, %rdi
callq 0x2060
movq 0x96dd(%rip), %r15      # 0xbff8
movq (%r15), %rcx
testl %eax, %eax
jne 0x2936
leaq 0x57c8(%rip), %rdi      # 0x80f1
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
callq 0x22b0
jmp 0x2950
leaq 0x577d(%rip), %rsi      # 0x80ba
pushq $-0x10
popq %r8
movq %rcx, %rdi
movl %eax, %edx
movl %r8d, %ecx
xorl %eax, %eax
callq 0x21b0
movq %r14, %rdi
xorl %esi, %esi
callq 0x2070
pushq $0x64
popq %r12
pushq $0x2
popq %r14
movq (%rbx), %rdi
movl %r14d, %esi
callq 0x2310
cmpl $0x2, %eax
jl 0x297f
leal -0x1(%r12), %eax
testl %r12d, %r12d
movl %eax, %r12d
jns 0x2962
movq (%rbx), %rdi
callq 0x21f0
movq (%r15), %rcx
testl %eax, %eax
jne 0x29a2
leaq 0x57aa(%rip), %rdi      # 0x813f
pushq $0x17
popq %rsi
pushq $0x1
popq %rdx
callq 0x22b0
jmp 0x29bc
leaq 0x575f(%rip), %rsi      # 0x8108
pushq $-0x10
popq %r8
movq %rcx, %rdi
movl %eax, %edx
movl %r8d, %ecx
xorl %eax, %eax
callq 0x21b0
movq (%rbx), %rdi
callq 0x2030
xorl %r14d, %r14d
xorl %r15d, %r15d
movslq 0x120(%rbx), %rax
movq 0x100(%rbx), %rdi
cmpq %rax, %r15
jge 0x2a21
movq (%rdi,%r14), %rdi
callq 0x2030
movq 0x100(%rbx), %rax
movzbl 0x9(%rax,%r14), %ecx
cmpl $0x62, %ecx
je 0x2a0e
cmpl $0x76, %ecx
jne 0x2a18
movq 0x20(%rax,%r14), %rdi
movq 0x28(%rax,%r14), %rsi
callq 0x2a8f
jmp 0x2a18
movq 0x28(%rax,%r14), %rdi
callq 0x2030
incq %r15
addq $0x30, %r14
jmp 0x29ca
callq 0x2030
movq 0x108(%rbx), %rdi
callq 0x2030
xorl %r14d, %r14d
xorl %r15d, %r15d
movslq 0x128(%rbx), %rax
movq 0x110(%rbx), %rdi
cmpq %rax, %r15
jge 0x2a6e
movq 0x10(%rdi,%r14), %rdi
callq 0x2030
movq 0x110(%rbx), %rax
movq (%rax,%r14), %rdi
callq 0x2030
incq %r15
addq $0x18, %r14
jmp 0x2a38
callq 0x2030
movq 0xf0(%rbx), %rdi
callq 0x2030
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2030