#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ die(char *);
int /*<<< orphan*/ editorClearScreen();
int write(int /*<<< orphan*/, char *, int);
void consoleBufferClose() {
  if (write(STDOUT_FILENO, "\x1b[?9l", 5) == -1 ||
      write(STDOUT_FILENO, "\x1b[?47l", 6) == -1)
    die("Error restoring buffer state");
  editorClearScreen();
}


x86 assembly (clang, -O0):
<consoleBufferClose>:
push   %rbp
mov    %rsp,%rbp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0xebc(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
je     117a <consoleBufferClose+0x4a>
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
lea    0xe9f(%rip),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    1186 <consoleBufferClose+0x56>
lea    0xe8c(%rip),%rdi
call   1050 <die@plt>
mov    $0x0,%al
call   1040 <editorClearScreen@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<consoleBufferClose>:
push   %rbx
mov    0x2eb8(%rip),%rbx
mov    (%rbx),%edi
lea    0xebf(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
je     1168 <consoleBufferClose+0x38>
mov    (%rbx),%edi
lea    0xead(%rip),%rsi
mov    $0x6,%edx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
jne    1174 <consoleBufferClose+0x44>
lea    0xe9e(%rip),%rdi
call   1050 <die@plt>
xor    %eax,%eax
pop    %rbx
jmp    1040 <editorClearScreen@plt>

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
@.str = [6 x i8] c"\1B[?9l\00"
@.str.1 = [7 x i8] c"\1B[?47l\00"
@.str.2 = [29 x i8] c"Error restoring buffer state\00"
define void @consoleBufferClose() {
%1 = load i32, i32* @STDOUT_FILENO
%2 = call i32 @write(i32 %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%3 = icmp eq i32 %2, -1
br i1 %3, label %8, label %4
4: ; preds = %0
%5 = load i32, i32* @STDOUT_FILENO
%6 = call i32 @write(i32 %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %4, %0
%9 = call i32 @die(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %4
%11 = call i32 (...) @editorClearScreen()
ret void
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@.str = [6 x i8] c"\1B[?9l\00"
@.str.1 = [7 x i8] c"\1B[?47l\00"
@.str.2 = [29 x i8] c"Error restoring buffer state\00"
define void @consoleBufferClose() {
%1 = load i32, i32* @STDOUT_FILENO
%2 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%3 = icmp eq i32 %2, -1
br i1 %3, label %8, label %4
4: ; preds = %0
%5 = load i32, i32* @STDOUT_FILENO
%6 = tail call i32 @write(i32 %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 6)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %4, %0
%9 = tail call i32 @die(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %4
%11 = tail call i32 (...) @editorClearScreen()
ret void
}