#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 /*<<< orphan*/ ws_col;
  int /*<<< orphan*/ ws_row;
};

/* Variables and functions */
int /*<<< orphan*/ COLS;
int /*<<< orphan*/ LINES;
int /*<<< orphan*/ TIOCGWINSZ;
int /*<<< orphan*/ display_init();
int /*<<< orphan*/ display_kill();
int /*<<< orphan*/ display_refresh();
int ioctl(int, int /*<<< orphan*/, struct winsize *);
int /*<<< orphan*/ refresh();
void display_resize(void) {
  struct winsize ws;
  if (ioctl(1, TIOCGWINSZ, &ws) != -1) {
    LINES = ws.ws_row;
    COLS = ws.ws_col;
  }
  display_kill();
  refresh();
  display_init();
  display_refresh();
}


x86 assembly (clang, -O0):
<display_resize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
lea    -0x8(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1190 <display_resize+0x40>
mov    -0x4(%rbp),%ecx
mov    0x2e66(%rip),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%ecx
mov    0x2e52(%rip),%rax
mov    %ecx,(%rax)
mov    $0x0,%al
call   1060 <display_kill@plt>
mov    $0x0,%al
call   1070 <refresh@plt>
mov    $0x0,%al
call   1040 <display_init@plt>
mov    $0x0,%al
call   1030 <display_refresh@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_resize>:
push   %rax
mov    0x2e70(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    $0x1,%edi
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
je     1185 <display_resize+0x35>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
mov    0x2e6e(%rip),%rdx
mov    %ecx,(%rdx)
mov    0x2e5d(%rip),%rcx
mov    %eax,(%rcx)
xor    %eax,%eax
call   1060 <display_kill@plt>
xor    %eax,%eax
call   1070 <refresh@plt>
xor    %eax,%eax
call   1040 <display_init@plt>
xor    %eax,%eax
call   1030 <display_refresh@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.winsize = type { i32, i32 }
@TIOCGWINSZ = global i32 0
@LINES = global i32 0
@COLS = global i32 0
define void @display_resize() {
%1 = alloca %struct.winsize
%2 = load i32, i32* @TIOCGWINSZ
%3 = call i32 @ioctl(i32 1, i32 %2, %struct.winsize* %1)
%4 = icmp ne i32 %3, -1
br i1 %4, label %5, label %10
5: ; preds = %0
%6 = getelementptr inbounds %struct.winsize, %struct.winsize* %1, i32 0, i32 1
%7 = load i32, i32* %6
store i32 %7, i32* @LINES
%8 = getelementptr inbounds %struct.winsize, %struct.winsize* %1, i32 0, i32 0
%9 = load i32, i32* %8
store i32 %9, i32* @COLS
br label %10
10: ; preds = %5, %0
%11 = call i32 (...) @display_kill()
%12 = call i32 (...) @refresh()
%13 = call i32 (...) @display_init()
%14 = call i32 (...) @display_refresh()
ret void
}

LLVM IR (-O2):
%struct.winsize = type { i32, i32 }
@TIOCGWINSZ = global i32 0
@LINES = global i32 0
@COLS = global i32 0
define void @display_resize() {
%1 = alloca %struct.winsize
%2 = bitcast %struct.winsize* %1 to i8*
%3 = load i32, i32* @TIOCGWINSZ
%4 = call i32 @ioctl(i32 1, i32 %3, %struct.winsize* %1)
%5 = icmp eq i32 %4, -1
br i1 %5, label %11, label %6
6: ; preds = %0
%7 = getelementptr inbounds %struct.winsize, %struct.winsize* %1, i64 0, i32 1
%8 = load i32, i32* %7
store i32 %8, i32* @LINES
%9 = getelementptr inbounds %struct.winsize, %struct.winsize* %1, i64 0, i32 0
%10 = load i32, i32* %9
store i32 %10, i32* @COLS
br label %11
11: ; preds = %6, %0
%12 = call i32 (...) @display_kill()
%13 = call i32 (...) @refresh()
%14 = call i32 (...) @display_init()
%15 = call i32 (...) @display_refresh()
ret void
}