#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_row;
  int ws_col;
  int ws_xpixel;
  int ws_ypixel;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ TIOCGWINSZ;
int /*<<< orphan*/ ioctl(int /*<<< orphan*/, int /*<<< orphan*/,
                         struct winsize *);
int /*<<< orphan*/ printf(char *, int, int, int, int);
int main(int argc, char *argv[]) {
  struct winsize ws = {0};
  ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
  printf("cells: %dx%d\npixels: %dx%d\n", ws.ws_row, ws.ws_col, ws.ws_xpixel,
         ws.ws_ypixel);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
mov    0x2e93(%rip),%rax
mov    (%rax),%edi
mov    0x2e6a(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1050 <ioctl@plt>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    0x2eb6(%rip),%rax
mov    (%rax),%edi
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
call   1040 <ioctl@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.winsize = type { i32, i32, i32, i32, i32 }
@STDOUT_FILENO = global i32 0
@TIOCGWINSZ = global i32 0
@.str = [28 x i8] c"cells: %dx%d\0Apixels: %dx%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.winsize
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = bitcast %struct.winsize* %6 to i8*
%8 = load i32, i32* @STDOUT_FILENO
%9 = load i32, i32* @TIOCGWINSZ
%10 = call i32 @ioctl(i32 %8, i32 %9, %struct.winsize* %6)
%11 = getelementptr inbounds %struct.winsize, %struct.winsize* %6, i32 0, i32 0
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.winsize, %struct.winsize* %6, i32 0, i32 1
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.winsize, %struct.winsize* %6, i32 0, i32 2
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.winsize, %struct.winsize* %6, i32 0, i32 3
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %14, i32 %16, i32 %18)
ret i32 0
}

LLVM IR (-O2):
%struct.winsize = type { i32, i32, i32, i32, i32 }
@STDOUT_FILENO = global i32 0
@TIOCGWINSZ = global i32 0
@.str = [28 x i8] c"cells: %dx%d\0Apixels: %dx%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.winsize
%4 = bitcast %struct.winsize* %3 to i8*
%5 = load i32, i32* @STDOUT_FILENO
%6 = load i32, i32* @TIOCGWINSZ
%7 = call i32 @ioctl(i32 %5, i32 %6, %struct.winsize* %3)
%8 = getelementptr inbounds %struct.winsize, %struct.winsize* %3, i64 0, i32 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.winsize, %struct.winsize* %3, i64 0, i32 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.winsize, %struct.winsize* %3, i64 0, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.winsize, %struct.winsize* %3, i64 0, i32 3
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11, i32 %13, i32 %15)
ret i32 0
}