#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;
  int ws_row;
};

/* Variables and functions */
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ TIOCGWINSZ;
int /*<<< orphan*/ ioctl(int /*<<< orphan*/, int /*<<< orphan*/,
                         struct winsize *);
int /*<<< orphan*/ memset(struct winsize *, int /*<<< orphan*/, int);
void get_window_size(int *w, int *h) {
  struct winsize ws;
  memset(&ws, 0, sizeof(struct winsize));
  ioctl(STDIN_FILENO, TIOCGWINSZ, &ws);
  (*w) = ws.ws_col;
  (*h) = ws.ws_row;
}


x86 assembly (clang, -O0):
<get_window_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1040 <ioctl@plt>
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_window_size>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdx
call   1040 <ioctl@plt>
mov    0x8(%rsp),%eax
mov    %eax,(%rbx)
mov    0xc(%rsp),%eax
mov    %eax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.winsize = type { i32, i32 }
@STDIN_FILENO = global i32 0
@TIOCGWINSZ = global i32 0
define void @get_window_size(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca %struct.winsize
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = call i32 @memset(%struct.winsize* %5, i32 0, i32 8)
%7 = load i32, i32* @STDIN_FILENO
%8 = load i32, i32* @TIOCGWINSZ
%9 = call i32 @ioctl(i32 %7, i32 %8, %struct.winsize* %5)
%10 = getelementptr inbounds %struct.winsize, %struct.winsize* %5, i32 0, i32 0
%11 = load i32, i32* %10
%12 = load i32*, i32** %3
store i32 %11, i32* %12
%13 = getelementptr inbounds %struct.winsize, %struct.winsize* %5, i32 0, i32 1
%14 = load i32, i32* %13
%15 = load i32*, i32** %4
store i32 %14, i32* %15
ret void
}

LLVM IR (-O2):
%struct.winsize = type { i32, i32 }
@STDIN_FILENO = global i32 0
@TIOCGWINSZ = global i32 0
define void @get_window_size(i32* nocapture writeonly %0, i32* nocapture writeonly %1) {
%3 = alloca %struct.winsize
%4 = bitcast %struct.winsize* %3 to i8*
%5 = call i32 @memset(%struct.winsize* %3, i32 0, i32 8)
%6 = load i32, i32* @STDIN_FILENO
%7 = load i32, i32* @TIOCGWINSZ
%8 = call i32 @ioctl(i32 %6, i32 %7, %struct.winsize* %3)
%9 = getelementptr inbounds %struct.winsize, %struct.winsize* %3, i64 0, i32 0
%10 = load i32, i32* %9
store i32 %10, i32* %0
%11 = getelementptr inbounds %struct.winsize, %struct.winsize* %3, i64 0, i32 1
%12 = load i32, i32* %11
store i32 %12, i32* %1
ret void
}