#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 EXIT_FAILURE;
scalar_t__ FALSE;
int /*<<< orphan*/ endwin();
scalar_t__ has_colors();
int /*<<< orphan*/ initscr();
scalar_t__ isatty(int);
int /*<<< orphan*/ printf(char *);
int check_compatible() {
  if (isatty(1) == 0) {
    printf("Not a tty\n");
    return EXIT_FAILURE;
  }
  initscr();
  if (has_colors() == FALSE) {
    endwin();
    printf("Terminal not supporting colors!\n");
    return EXIT_FAILURE;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_compatible>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1030 <isatty@plt>
cmp    $0x0,%rax
jne    1189 <check_compatible+0x39>
lea    0xe8d(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d2 <check_compatible+0x82>
mov    $0x0,%al
call   1060 <initscr@plt>
mov    $0x0,%al
call   1040 <has_colors@plt>
mov    0x2e3a(%rip),%rcx
cmp    (%rcx),%rax
jne    11cb <check_compatible+0x7b>
mov    $0x0,%al
call   1070 <endwin@plt>
lea    0xe56(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11d2 <check_compatible+0x82>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_compatible>:
push   %rbx
mov    $0x1,%edi
call   1040 <isatty@plt>
test   %rax,%rax
je     118c <check_compatible+0x3c>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <initscr@plt>
xor    %eax,%eax
call   1050 <has_colors@plt>
mov    0x2e61(%rip),%rcx
cmp    (%rcx),%rax
jne    11a1 <check_compatible+0x51>
xor    %eax,%eax
call   1070 <endwin@plt>
lea    0xe76(%rip),%rdi
jmp    1193 <check_compatible+0x43>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Not a tty\0A\00"
@EXIT_FAILURE = global i32 0
@FALSE = global i64 0
@.str.1 = [33 x i8] c"Terminal not supporting colors!\0A\00"
define i32 @check_compatible() {
%1 = alloca i32
%2 = call i64 @isatty(i32 1)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
store i32 %6, i32* %1
br label %17
7: ; preds = %0
%8 = call i32 (...) @initscr()
%9 = call i64 (...) @has_colors()
%10 = load i64, i64* @FALSE
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = call i32 (...) @endwin()
%14 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %1
br label %17
16: ; preds = %7
store i32 0, i32* %1
br label %17
17: ; preds = %16, %12, %4
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@FALSE = global i64 0
@str = [32 x i8] c"Terminal not supporting colors!\00"
@str.2 = [10 x i8] c"Not a tty\00"
define i32 @check_compatible() {
%1 = tail call i64 @isatty(i32 1)
%2 = icmp eq i64 %1, 0
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = tail call i32 (...) @initscr()
%5 = tail call i64 (...) @has_colors()
%6 = load i64, i64* @FALSE
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %14
8: ; preds = %3
%9 = tail call i32 (...) @endwin()
br label %10
10: ; preds = %0, %8
%11 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0), %8 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.2, i64 0, i64 0), %0 ]
%12 = tail call i32 @puts(i8* dereferenceable(1) %11)
%13 = load i32, i32* @EXIT_FAILURE
br label %14
14: ; preds = %10, %3
%15 = phi i32 [ 0, %3 ], [ %13, %10 ]
ret i32 %15
}