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

/* Variables and functions */
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 sz;
  ioctl(0, TIOCGWINSZ, &sz);
  printf("%i %i %i %i\n", sz.ws_row, sz.ws_col, sz.ws_xpixel, sz.ws_ypixel);
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
mov    0x2ead(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
xor    %edi,%edi
call   1040 <ioctl@plt>
mov    0x8(%rsp),%esi
mov    0xc(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    0x14(%rsp),%r8d
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.winsize = type { i32, i32, i32, i32 }
@TIOCGWINSZ = global i32 0
@.str = [13 x i8] c"%i %i %i %i\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 = load i32, i32* @TIOCGWINSZ
%8 = call i32 @ioctl(i32 0, i32 %7, %struct.winsize* %6)
%9 = getelementptr inbounds %struct.winsize, %struct.winsize* %6, i32 0, i32 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.winsize, %struct.winsize* %6, i32 0, i32 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.winsize, %struct.winsize* %6, i32 0, i32 2
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.winsize, %struct.winsize* %6, i32 0, i32 3
%16 = load i32, i32* %15
%17 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %12, i32 %14, i32 %16)
ret i32 0
}

LLVM IR (-O2):
%struct.winsize = type { i32, i32, i32, i32 }
@TIOCGWINSZ = global i32 0
@.str = [13 x i8] c"%i %i %i %i\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* @TIOCGWINSZ
%6 = call i32 @ioctl(i32 0, i32 %5, %struct.winsize* %3)
%7 = getelementptr inbounds %struct.winsize, %struct.winsize* %3, i64 0, i32 0
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.winsize, %struct.winsize* %3, i64 0, i32 1
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.winsize, %struct.winsize* %3, i64 0, i32 2
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.winsize, %struct.winsize* %3, i64 0, i32 3
%14 = load i32, i32* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %10, i32 %12, i32 %14)
ret i32 0
}