// File: /workspace/github_c_makefile_star2_O0/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 %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
cmpq $0x0, 0x34fc5(%rip)     # 0x3bee8
je 0x6feb
cmpl $0x0, 0x34f70(%rip)     # 0x3bea0
jl 0x6feb
movq 0x35073(%rip), %rsi     # 0x3bfb0
leaq 0x34f54(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x7e30
movq 0x35071(%rip), %rsi     # 0x3bfc8
leaq 0x34f3a(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x7e30
movq 0x3504f(%rip), %rsi     # 0x3bfc0
leaq 0x34f20(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x7e30
movq 0x3501d(%rip), %rsi     # 0x3bfa8
leaq 0x34f06(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x7e30
movq 0x3505b(%rip), %rsi     # 0x3c000
leaq 0x34eec(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x7e30
leaq 0x34ed9(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
leaq 0x2ba15(%rip), %rsi     # 0x329e2
callq 0x7e30
movl 0x34ec8(%rip), %esi     # 0x3bea0
leaq 0x34eb9(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0x7c00
cmpl $0x0, 0x34ea6(%rip)     # 0x3be98
jl 0x703b
cmpl $0x0, 0x350b9(%rip)     # 0x3c0b4
je 0x701b
movl 0x34e95(%rip), %edi     # 0x3be98
movl $0x2, %esi
leaq 0x34e89(%rip), %rdx     # 0x3be98
addq $0x1e0, %rdx            # imm = 0x1E0
callq 0x64c0
cmpl $0x0, 0x34e82(%rip)     # 0x3bea4
je 0x7039
movl 0x34e6e(%rip), %edi     # 0x3be98
callq 0x6260
movl $0x0, 0x34e6b(%rip)     # 0x3bea4
jmp 0x703b
leaq -0x98(%rbp), %rdi
xorl %esi, %esi
movl $0x98, %edx
callq 0x6230
movl $0x1c, %edi
leaq -0x98(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x60d0
cmpl $0x0, 0x34e3e(%rip)     # 0x3bea8
jl 0x7077
movl 0x34e36(%rip), %edi     # 0x3bea8
callq 0x6260
cmpl $0x0, 0x34e2e(%rip)     # 0x3beac
jl 0x708b
movl 0x34e26(%rip), %edi     # 0x3beac
callq 0x6260
leaq 0x34e06(%rip), %rdi     # 0x3be98
addq $0x1c0, %rdi            # imm = 0x1C0
callq 0xd190
leaq 0x34df3(%rip), %rdi     # 0x3be98
addq $0x1d0, %rdi            # imm = 0x1D0
callq 0xd190
leaq 0x34de0(%rip), %rdi     # 0x3be98
addq $0x190, %rdi            # imm = 0x190
callq 0xd210
leaq 0x34dcd(%rip), %rdi     # 0x3be98
addq $0x1a8, %rdi            # imm = 0x1A8
callq 0xd210
cmpq $0x0, 0x34df9(%rip)     # 0x3bed8
je 0x70ed
movq 0x34df0(%rip), %rdi     # 0x3bed8
callq 0x6050
leaq 0x34da4(%rip), %rdi     # 0x3be98
addq $0x170, %rdi            # imm = 0x170
callq 0xd250
callq 0x68b0
xorl %eax, %eax
addq $0xa0, %rsp
popq %rbp
retq