// File: /workspace/github_c_makefile_star2_O3/adsr[P]phpspy/vendor/termbox2/termbox2.h
// Function: tb_deinit
static int tb_deinit(void) {
    if (global.caps[0] != NULL && global.wfd >= 0) {
        bytebuf_puts(&global.out, global.caps[TB_CAP_SHOW_CURSOR]);
        bytebuf_puts(&global.out, global.caps[TB_CAP_SGR0]);
        bytebuf_puts(&global.out, global.caps[TB_CAP_CLEAR_SCREEN]);
        bytebuf_puts(&global.out, global.caps[TB_CAP_EXIT_CA]);
        bytebuf_puts(&global.out, global.caps[TB_CAP_EXIT_KEYPAD]);
        bytebuf_puts(&global.out, TB_HARDCAP_EXIT_MOUSE);
        bytebuf_flush(&global.out, global.wfd);
    }
    if (global.ttyfd >= 0) {
        if (global.has_orig_tios) {
            tcsetattr(global.ttyfd, TCSAFLUSH, &global.orig_tios);
        }
        if (global.ttyfd_open) {
            close(global.ttyfd);
            global.ttyfd_open = 0;
        }
    }

    sigaction(SIGWINCH, &(struct sigaction){.sa_handler = SIG_DFL}, NULL);
    if (global.resize_pipefd[0] >= 0)
        close(global.resize_pipefd[0]);
    if (global.resize_pipefd[1] >= 0)
        close(global.resize_pipefd[1]);

    cellbuf_free(&global.back);
    cellbuf_free(&global.front);
    bytebuf_free(&global.in);
    bytebuf_free(&global.out);

    if (global.terminfo)
        tb_free(global.terminfo);

    cap_trie_deinit(&global.cap_trie);

    tb_reset();
    return TB_OK;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x98, %rsp
cmpq $0x0, 0x1e84b(%rip)     # 0x25ab8
je 0x7337
cmpl $0x0, 0x1e7f6(%rip)     # 0x25a70
js 0x7337
movq 0x1e8f9(%rip), %r14     # 0x25b80
movq %r14, %rdi
callq 0x6160
leaq 0x1e97a(%rip), %rbx     # 0x25c10
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8535
movq 0x1e8ed(%rip), %r14     # 0x25b98
movq %r14, %rdi
callq 0x6160
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8535
movq 0x1e8c8(%rip), %r14     # 0x25b90
movq %r14, %rdi
callq 0x6160
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8535
movq 0x1e893(%rip), %r14     # 0x25b78
movq %r14, %rdi
callq 0x6160
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8535
movq 0x1e8ce(%rip), %r14     # 0x25bd0
movq %r14, %rdi
callq 0x6160
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8535
leaq 0x1555f(%rip), %rsi     # 0x1c87e
movl $0x20, %edx
movq %rbx, %rdi
callq 0x8535
movl 0x1e73e(%rip), %edi     # 0x25a70
callq 0x7cb7
movl 0x1e72b(%rip), %edi     # 0x25a68
testl %edi, %edi
js 0x7379
cmpl $0x0, 0x1e93c(%rip)     # 0x25c84
je 0x735b
leaq 0x1e8f7(%rip), %rdx     # 0x25c48
movl $0x2, %esi
callq 0x64d0
cmpl $0x0, 0x1e712(%rip)     # 0x25a74
je 0x7379
movl 0x1e6fe(%rip), %edi     # 0x25a68
callq 0x6260
movl $0x0, 0x1e6fb(%rip)     # 0x25a74
movq %rsp, %rbx
movl $0x98, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x6230
movl $0x1c, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x60d0
movl 0x1e6d8(%rip), %edi     # 0x25a78
testl %edi, %edi
js 0x73a9
callq 0x6260
movl 0x1e6cd(%rip), %edi     # 0x25a7c
testl %edi, %edi
js 0x73b8
callq 0x6260
leaq 0x1e869(%rip), %rdi     # 0x25c28
callq 0x133e4
leaq 0x1e86d(%rip), %rdi     # 0x25c38
callq 0x133e4
movq 0x1e821(%rip), %rdi     # 0x25bf8
testq %rdi, %rdi
je 0x73e1
callq 0x6050
pxor %xmm0, %xmm0
movdqu %xmm0, 0x1e80b(%rip)    # 0x25bf8
movq $0x0, 0x1e810(%rip) # 0x25c08
movq 0x1e811(%rip), %rdi     # 0x25c10
testq %rdi, %rdi
je 0x740d
callq 0x6050
pxor %xmm0, %xmm0
movdqu %xmm0, 0x1e7fb(%rip)    # 0x25c10
movq $0x0, 0x1e800(%rip) # 0x25c20
movq 0x1e681(%rip), %rdi     # 0x25aa8
testq %rdi, %rdi
je 0x7431
callq 0x6050
leaq 0x1e7a0(%rip), %rdi     # 0x25bd8
callq 0x1342d
leaq 0x1e664(%rip), %rdi     # 0x25aa8
movl $0x5f8, %edx            # imm = 0x5F8
xorl %esi, %esi
callq 0x6230
movq $-0x1, 0x1e60d(%rip) # 0x25a68
movl $0xffffffff, 0x1e60b(%rip) # imm = 0xFFFFFFFF
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x1e607(%rip)    # 0x25a78
movdqu %xmm0, 0x1e60f(%rip)    # 0x25a88
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x1e60e(%rip)     # 0x25a98
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x1e605(%rip)     # 0x25aa0
addq $0x98, %rsp
popq %rbx
popq %r14
retq