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

/* Variables and functions */
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ TIOCGWINSZ;
int /*<<< orphan*/ ioctl(int /*<<< orphan*/, int /*<<< orphan*/,
                         struct winsize *);
int /*<<< orphan*/ mvwin(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ wresize(int /*<<< orphan*/ *, int, double);
void resize_w(WINDOW *win_com, WINDOW *win_games, WINDOW *win_comps) {
  struct winsize w;
  ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
  wresize(win_com, w.ws_row, (int)(w.ws_col * 2.0 / 3));
  wresize(win_games, w.ws_row / 2, w.ws_col / 3.0);
  wresize(win_comps, w.ws_row / 2, w.ws_col / 3.0);
  mvwin(win_com, 0, (int)(w.ws_col / 3.0));
  mvwin(win_games, 0, 0);
  mvwin(win_comps, w.ws_row / 2, 0);
}


x86 assembly (clang, -O0):
<resize_w>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1030 <ioctl@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
movsd  0xe9a(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  0xe85(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
call   1040 <wresize@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
movsd  -0x20(%rbp),%xmm0
movsd  0xe56(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <wresize@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
movsd  -0x20(%rbp),%xmm0
movsd  0xe2f(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <wresize@plt>
mov    -0x8(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
movsd  0xe15(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
xor    %esi,%esi
call   1050 <mvwin@plt>
mov    -0x10(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1050 <mvwin@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
xor    %edx,%edx
call   1050 <mvwin@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<resize_w>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
mov    0x2e7e(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
call   1030 <ioctl@plt>
mov    (%rsp),%esi
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
divsd  0xe8f(%rip),%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
mov    %rbx,%rdi
call   1040 <wresize@plt>
mov    (%rsp),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
movsd  0x8(%rsp),%xmm0
divsd  0xe65(%rip),%xmm0
mov    %r15,%rdi
call   1040 <wresize@plt>
mov    (%rsp),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
movsd  0x8(%rsp),%xmm0
divsd  0xe43(%rip),%xmm0
mov    %r14,%rdi
call   1040 <wresize@plt>
movsd  0x8(%rsp),%xmm0
divsd  0xe2d(%rip),%xmm0
cvttsd2si %xmm0,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <mvwin@plt>
mov    %r15,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1050 <mvwin@plt>
mov    (%rsp),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
mov    %r14,%rdi
xor    %edx,%edx
call   1050 <mvwin@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.winsize = type { i32, double }
@STDOUT_FILENO = global i32 0
@TIOCGWINSZ = global i32 0
define void @resize_w(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca %struct.winsize
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i32, i32* @STDOUT_FILENO
%9 = load i32, i32* @TIOCGWINSZ
%10 = call i32 @ioctl(i32 %8, i32 %9, %struct.winsize* %7)
%11 = load i32*, i32** %4
%12 = getelementptr inbounds %struct.winsize, %struct.winsize* %7, i32 0, i32 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.winsize, %struct.winsize* %7, i32 0, i32 1
%15 = load double, double* %14
%16 = fmul double %15, 2.000000e+00
%17 = fdiv double %16, 3.000000e+00
%18 = fptosi double %17 to i32
%19 = sitofp i32 %18 to double
%20 = call i32 @wresize(i32* %11, i32 %13, double %19)
%21 = load i32*, i32** %5
%22 = getelementptr inbounds %struct.winsize, %struct.winsize* %7, i32 0, i32 0
%23 = load i32, i32* %22
%24 = sdiv i32 %23, 2
%25 = getelementptr inbounds %struct.winsize, %struct.winsize* %7, i32 0, i32 1
%26 = load double, double* %25
%27 = fdiv double %26, 3.000000e+00
%28 = call i32 @wresize(i32* %21, i32 %24, double %27)
%29 = load i32*, i32** %6
%30 = getelementptr inbounds %struct.winsize, %struct.winsize* %7, i32 0, i32 0
%31 = load i32, i32* %30
%32 = sdiv i32 %31, 2
%33 = getelementptr inbounds %struct.winsize, %struct.winsize* %7, i32 0, i32 1
%34 = load double, double* %33
%35 = fdiv double %34, 3.000000e+00
%36 = call i32 @wresize(i32* %29, i32 %32, double %35)
%37 = load i32*, i32** %4
%38 = getelementptr inbounds %struct.winsize, %struct.winsize* %7, i32 0, i32 1
%39 = load double, double* %38
%40 = fdiv double %39, 3.000000e+00
%41 = fptosi double %40 to i32
%42 = call i32 @mvwin(i32* %37, i32 0, i32 %41)
%43 = load i32*, i32** %5
%44 = call i32 @mvwin(i32* %43, i32 0, i32 0)
%45 = load i32*, i32** %6
%46 = getelementptr inbounds %struct.winsize, %struct.winsize* %7, i32 0, i32 0
%47 = load i32, i32* %46
%48 = sdiv i32 %47, 2
%49 = call i32 @mvwin(i32* %45, i32 %48, i32 0)
ret void
}

LLVM IR (-O2):
%struct.winsize = type { i32, double }
@STDOUT_FILENO = global i32 0
@TIOCGWINSZ = global i32 0
define void @resize_w(i32* %0, i32* %1, i32* %2) {
%4 = alloca %struct.winsize
%5 = bitcast %struct.winsize* %4 to i8*
%6 = load i32, i32* @STDOUT_FILENO
%7 = load i32, i32* @TIOCGWINSZ
%8 = call i32 @ioctl(i32 %6, i32 %7, %struct.winsize* %4)
%9 = getelementptr inbounds %struct.winsize, %struct.winsize* %4, i64 0, i32 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.winsize, %struct.winsize* %4, i64 0, i32 1
%12 = load double, double* %11
%13 = fmul double %12, 2.000000e+00
%14 = fdiv double %13, 3.000000e+00
%15 = fptosi double %14 to i32
%16 = sitofp i32 %15 to double
%17 = call i32 @wresize(i32* %0, i32 %10, double %16)
%18 = load i32, i32* %9
%19 = sdiv i32 %18, 2
%20 = load double, double* %11
%21 = fdiv double %20, 3.000000e+00
%22 = call i32 @wresize(i32* %1, i32 %19, double %21)
%23 = load i32, i32* %9
%24 = sdiv i32 %23, 2
%25 = load double, double* %11
%26 = fdiv double %25, 3.000000e+00
%27 = call i32 @wresize(i32* %2, i32 %24, double %26)
%28 = load double, double* %11
%29 = fdiv double %28, 3.000000e+00
%30 = fptosi double %29 to i32
%31 = call i32 @mvwin(i32* %0, i32 0, i32 %30)
%32 = call i32 @mvwin(i32* %1, i32 0, i32 0)
%33 = load i32, i32* %9
%34 = sdiv i32 %33, 2
%35 = call i32 @mvwin(i32* %2, i32 %34, i32 0)
ret void
}