#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int width;
  int height;
};
typedef TYPE_1__ XWindowAttributes;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ XGetWindowAttributes(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, TYPE_1__ *);
int /*<<< orphan*/ XMoveWindow(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                               int);
void move(Display *d, Window win, Window container) {
  XWindowAttributes wa, wac;
  int dx, dy;
  XGetWindowAttributes(d, win, &wa);
  XGetWindowAttributes(d, container, &wac);
  dx = (wa.width - wac.width) / 2;
  dy = (wa.height - wac.height) / 2;
  if (dy < 0)
    dy = 0;
  XMoveWindow(d, container, dx, dy);
}


x86 assembly (clang, -O0):
<move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x18(%rbp),%rdx
call   1040 <XGetWindowAttributes@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
lea    -0x20(%rbp),%rdx
call   1040 <XGetWindowAttributes@plt>
mov    -0x18(%rbp),%eax
sub    -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1185 <move+0x65>
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
call   1030 <XMoveWindow@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<move>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebp
mov    %rdi,%rbx
lea    0x10(%rsp),%rdx
call   1040 <XGetWindowAttributes@plt>
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <XGetWindowAttributes@plt>
mov    0x10(%rsp),%eax
sub    0x8(%rsp),%eax
mov    0x14(%rsp),%esi
mov    %eax,%edx
shr    $0x1f,%edx
add    %eax,%edx
sar    %edx
sub    0xc(%rsp),%esi
mov    %esi,%ecx
shr    $0x1f,%ecx
add    %esi,%ecx
xor    %eax,%eax
sar    %ecx
cmovs  %eax,%ecx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <XMoveWindow@plt>
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
define void @move(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.TYPE_3__
%8 = alloca %struct.TYPE_3__
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = call i32 @XGetWindowAttributes(i32* %11, i32 %12, %struct.TYPE_3__* %7)
%14 = load i32*, i32** %4
%15 = load i32, i32* %6
%16 = call i32 @XGetWindowAttributes(i32* %14, i32 %15, %struct.TYPE_3__* %8)
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
%20 = load i32, i32* %19
%21 = sub nsw i32 %18, %20
%22 = sdiv i32 %21, 2
store i32 %22, i32* %9
%23 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 1
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 1
%26 = load i32, i32* %25
%27 = sub nsw i32 %24, %26
%28 = sdiv i32 %27, 2
store i32 %28, i32* %10
%29 = load i32, i32* %10
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %3
store i32 0, i32* %10
br label %32
32: ; preds = %31, %3
%33 = load i32*, i32** %4
%34 = load i32, i32* %6
%35 = load i32, i32* %9
%36 = load i32, i32* %10
%37 = call i32 @XMoveWindow(i32* %33, i32 %34, i32 %35, i32 %36)
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
define void @move(i32* %0, i32 %1, i32 %2) {
%4 = alloca %struct.TYPE_3__
%5 = alloca %struct.TYPE_3__
%6 = bitcast %struct.TYPE_3__* %4 to i8*
%7 = bitcast %struct.TYPE_3__* %5 to i8*
%8 = call i32 @XGetWindowAttributes(i32* %0, i32 %1, %struct.TYPE_3__* %4)
%9 = call i32 @XGetWindowAttributes(i32* %0, i32 %2, %struct.TYPE_3__* %5)
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i64 0, i32 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i64 0, i32 0
%13 = load i32, i32* %12
%14 = sub nsw i32 %11, %13
%15 = sdiv i32 %14, 2
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i64 0, i32 1
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i64 0, i32 1
%19 = load i32, i32* %18
%20 = sub nsw i32 %17, %19
%21 = sdiv i32 %20, 2
%22 = icmp sgt i32 %21, 0
%23 = select i1 %22, i32 %21, i32 0
%24 = call i32 @XMoveWindow(i32* %0, i32 %2, i32 %15, i32 %23)
ret void
}