#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 */
struct winsize {
  int ws_col;
};

/* Variables and functions */
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ TIOCGWINSZ;
int /*<<< orphan*/ ioctl(int /*<<< orphan*/, int /*<<< orphan*/,
                         struct winsize *);
int /*<<< orphan*/ isatty(int /*<<< orphan*/);
int check_window_size(void) {
  struct winsize winsize;
  if (!isatty(STDOUT_FILENO))
    return 0;
  ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize);
  if (winsize.ws_col >= 80)
    return 0;
  return -1;
}


x86 assembly (clang, -O0):
<check_window_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ec1(%rip),%rax
mov    (%rax),%edi
call   1030 <isatty@plt>
cmp    $0x0,%eax
jne    114b <check_window_size+0x2b>
movl   $0x0,-0x4(%rbp)
jmp    1183 <check_window_size+0x63>
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
mov    0x2e75(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdx
call   1040 <ioctl@plt>
cmpl   $0x50,-0x8(%rbp)
jl     117c <check_window_size+0x5c>
movl   $0x0,-0x4(%rbp)
jmp    1183 <check_window_size+0x63>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_window_size>:
push   %rbx
sub    $0x10,%rsp
mov    0x2ec4(%rip),%rbx
mov    (%rbx),%edi
call   1030 <isatty@plt>
test   %eax,%eax
je     115a <check_window_size+0x3a>
mov    (%rbx),%edi
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
call   1040 <ioctl@plt>
xor    %eax,%eax
cmpl   $0x50,0x8(%rsp)
setl   %al
neg    %eax
jmp    115c <check_window_size+0x3c>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.winsize = type { i32 }
@STDOUT_FILENO = global i32 0
@TIOCGWINSZ = global i32 0
define i32 @check_window_size() {
%1 = alloca i32
%2 = alloca %struct.winsize
%3 = load i32, i32* @STDOUT_FILENO
%4 = call i32 @isatty(i32 %3)
%5 = icmp ne i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %0
store i32 0, i32* %1
br label %16
7: ; preds = %0
%8 = load i32, i32* @STDOUT_FILENO
%9 = load i32, i32* @TIOCGWINSZ
%10 = call i32 @ioctl(i32 %8, i32 %9, %struct.winsize* %2)
%11 = getelementptr inbounds %struct.winsize, %struct.winsize* %2, i32 0, i32 0
%12 = load i32, i32* %11
%13 = icmp sge i32 %12, 80
br i1 %13, label %14, label %15
14: ; preds = %7
store i32 0, i32* %1
br label %16
15: ; preds = %7
store i32 -1, i32* %1
br label %16
16: ; preds = %15, %14, %6
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
%struct.winsize = type { i32 }
@STDOUT_FILENO = global i32 0
@TIOCGWINSZ = global i32 0
define i32 @check_window_size() {
%1 = alloca %struct.winsize
%2 = bitcast %struct.winsize* %1 to i8*
%3 = load i32, i32* @STDOUT_FILENO
%4 = tail call i32 @isatty(i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %0
%7 = load i32, i32* @STDOUT_FILENO
%8 = load i32, i32* @TIOCGWINSZ
%9 = call i32 @ioctl(i32 %7, i32 %8, %struct.winsize* %1)
%10 = getelementptr inbounds %struct.winsize, %struct.winsize* %1, i64 0, i32 0
%11 = load i32, i32* %10
%12 = icmp slt i32 %11, 80
%13 = sext i1 %12 to i32
br label %14
14: ; preds = %6, %0
%15 = phi i32 [ 0, %0 ], [ %13, %6 ]
ret i32 %15
}