// File: /workspace/github_c_makefile_star2_O0/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
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
callq 0x2050
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x2af4
movq 0xd51f(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movl -0xc(%rbp), %edx
leaq 0x95d4(%rip), %rsi      # 0xc0ba
movl $0xfffffff0, %ecx       # imm = 0xFFFFFFF0
movb $0x0, %al
callq 0x21b0
jmp 0x2b0c
movq 0xd4fd(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x95ec(%rip), %rsi      # 0xc0f1
movb $0x0, %al
callq 0x21b0
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2060
movl $0x64, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl $0x2, %esi
callq 0x22f0
cmpl $0x1, %eax
jle 0x2b4e
movl -0x10(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x10(%rbp)
cmpl $0x0, %eax
jge 0x2b4c
jmp 0x2b4e
jmp 0x2b24
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x21f0
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x2b85
movq 0xd48e(%rip), %rax      # 0xfff8
movq (%rax), %rdi
movl -0xc(%rbp), %edx
leaq 0x9591(%rip), %rsi      # 0xc108
movl $0xfffffff0, %ecx       # imm = 0xFFFFFFF0
movb $0x0, %al
callq 0x21b0
jmp 0x2b9d
movq 0xd46c(%rip), %rax      # 0xfff8
movq (%rax), %rdi
leaq 0x95a9(%rip), %rsi      # 0xc13f
movb $0x0, %al
callq 0x21b0
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x2030
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x120(%rcx), %eax
jge 0x2c8a
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x2030
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsbl 0x9(%rax), %eax
cmpl $0x76, %eax
jne 0x2c3b
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x20(%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq 0x28(%rax), %rsi
callq 0x2d40
jmp 0x2c7a
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rax
movslq -0x14(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movb 0x9(%rax), %al
movq -0x8(%rbp), %rcx
movq 0x100(%rcx), %rcx
movslq -0x14(%rbp), %rdx
imulq $0x30, %rdx, %rdx
addq %rdx, %rcx
movq 0x20(%rcx), %rsi
movq 0x28(%rcx), %rdx
movsbl %al, %edi
callq 0x2dc0
jmp 0x2c7c
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2bb0
movq -0x8(%rbp), %rax
movq 0x100(%rax), %rdi
callq 0x2030
movq -0x8(%rbp), %rax
movq 0x108(%rax), %rdi
callq 0x2030
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x128(%rcx), %eax
jge 0x2d08
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdi
callq 0x2030
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rax
movslq -0x18(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rdi
callq 0x2030
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2cb1
movq -0x8(%rbp), %rax
movq 0x110(%rax), %rdi
callq 0x2030
movq -0x8(%rbp), %rax
movq 0xf0(%rax), %rdi
callq 0x2030
movq -0x8(%rbp), %rdi
callq 0x2030
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)