// File: /workspace/github_c_makefile_star2_O1/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, 0x1e7c1(%rip)     # 0x25ab8
je 0x73c1
cmpl $0x0, 0x1e76c(%rip)     # 0x25a70
js 0x73c1
movq 0x1e86f(%rip), %r14     # 0x25b80
movq %r14, %rdi
callq 0x6160
leaq 0x1e8f0(%rip), %rbx     # 0x25c10
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8728
movq 0x1e863(%rip), %r14     # 0x25b98
movq %r14, %rdi
callq 0x6160
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8728
movq 0x1e83e(%rip), %r14     # 0x25b90
movq %r14, %rdi
callq 0x6160
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8728
movq 0x1e809(%rip), %r14     # 0x25b78
movq %r14, %rdi
callq 0x6160
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8728
movq 0x1e844(%rip), %r14     # 0x25bd0
movq %r14, %rdi
callq 0x6160
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x8728
leaq 0x154d5(%rip), %rsi     # 0x1c87e
movl $0x20, %edx
movq %rbx, %rdi
callq 0x8728
movl 0x1e6b4(%rip), %edi     # 0x25a70
callq 0x7dbd
movl 0x1e6a1(%rip), %edi     # 0x25a68
testl %edi, %edi
js 0x7403
cmpl $0x0, 0x1e8b2(%rip)     # 0x25c84
je 0x73e5
leaq 0x1e86d(%rip), %rdx     # 0x25c48
movl $0x2, %esi
callq 0x64d0
cmpl $0x0, 0x1e688(%rip)     # 0x25a74
je 0x7403
movl 0x1e674(%rip), %edi     # 0x25a68
callq 0x6260
movl $0x0, 0x1e671(%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 0x1e64e(%rip), %edi     # 0x25a78
testl %edi, %edi
js 0x7433
callq 0x6260
movl 0x1e643(%rip), %edi     # 0x25a7c
testl %edi, %edi
js 0x7442
callq 0x6260
leaq 0x1e7df(%rip), %rdi     # 0x25c28
callq 0x136d5
leaq 0x1e7e3(%rip), %rdi     # 0x25c38
callq 0x136d5
movq 0x1e797(%rip), %rdi     # 0x25bf8
testq %rdi, %rdi
je 0x746b
callq 0x6050
pxor %xmm0, %xmm0
movdqu %xmm0, 0x1e781(%rip)    # 0x25bf8
movq $0x0, 0x1e786(%rip) # 0x25c08
movq 0x1e787(%rip), %rdi     # 0x25c10
testq %rdi, %rdi
je 0x7497
callq 0x6050
pxor %xmm0, %xmm0
movdqu %xmm0, 0x1e771(%rip)    # 0x25c10
movq $0x0, 0x1e776(%rip) # 0x25c20
movq 0x1e5f7(%rip), %rdi     # 0x25aa8
testq %rdi, %rdi
je 0x74bb
callq 0x6050
leaq 0x1e716(%rip), %rdi     # 0x25bd8
callq 0x1371c
leaq 0x1e59a(%rip), %rdi     # 0x25a68
movl 0x1e5a0(%rip), %ebx     # 0x25a74
movl $0x638, %edx            # imm = 0x638
xorl %esi, %esi
callq 0x6230
movq $-0x1, 0x1e57d(%rip) # 0x25a68
movl $0xffffffff, 0x1e57b(%rip) # imm = 0xFFFFFFFF
movl %ebx, 0x1e579(%rip)     # 0x25a74
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x1e571(%rip)    # 0x25a78
movdqu %xmm0, 0x1e579(%rip)    # 0x25a88
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x1e578(%rip)     # 0x25a98
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x1e56f(%rip)     # 0x25aa0
addq $0x98, %rsp
popq %rbx
popq %r14
retq