#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_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int width;
  int height;
};
struct TYPE_4__ {
  scalar_t__ type;
  TYPE_2__ xconfigure;
};
typedef TYPE_1__ XEvent;
typedef TYPE_2__ XConfigureEvent;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
scalar_t__ ConfigureNotify;
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, TYPE_1__ *);
void wait_for_resolution_change(Display *display, int *width, int *height) {
  while (1) {
    XEvent e;
    XNextEvent(display, &e);
    if (e.type == ConfigureNotify) {
      XConfigureEvent xce = e.xconfigure;
      if (xce.width != *width || xce.height != *height) {
        *width = xce.width;
        *height = xce.height;
        return;
      }
    }
  }
}


x86 assembly (clang, -O0):
<wait_for_resolution_change>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <XNextEvent@plt>
mov    -0x28(%rbp),%rax
mov    0x2eac(%rip),%rcx
cmp    (%rcx),%rax
jne    1188 <wait_for_resolution_change+0x78>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jne    116b <wait_for_resolution_change+0x5b>
mov    -0x2c(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
je     1183 <wait_for_resolution_change+0x73>
mov    -0x30(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret
jmp    1188 <wait_for_resolution_change+0x78>
jmp    1124 <wait_for_resolution_change+0x14>

x86 assembly (clang, -O2):
<wait_for_resolution_change>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsp,%r12
mov    0x2eb8(%rip),%r13
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <XNextEvent@plt>
mov    (%rsp),%rax
cmp    0x0(%r13),%rax
jne    1130 <wait_for_resolution_change+0x20>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
cmp    (%r15),%eax
jne    1157 <wait_for_resolution_change+0x47>
cmp    (%r14),%ecx
je     1130 <wait_for_resolution_change+0x20>
mov    %eax,(%r15)
mov    %ecx,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i64, %struct.TYPE_5__ }
%struct.TYPE_5__ = type { i32, i32 }
@ConfigureNotify = global i64 0
define void @wait_for_resolution_change(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca %struct.TYPE_4__
%8 = alloca %struct.TYPE_5__
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
br label %9
9: ; preds = %3, %39
%10 = load i32*, i32** %4
%11 = call i32 @XNextEvent(i32* %10, %struct.TYPE_4__* %7)
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 0
%13 = load i64, i64* %12
%14 = load i64, i64* @ConfigureNotify
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %39
16: ; preds = %9
%17 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 1
%18 = bitcast %struct.TYPE_5__* %8 to i8*
%19 = bitcast %struct.TYPE_5__* %17 to i8*
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 0
%21 = load i32, i32* %20
%22 = load i32*, i32** %5
%23 = load i32, i32* %22
%24 = icmp ne i32 %21, %23
br i1 %24, label %31, label %25
25: ; preds = %16
%26 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 1
%27 = load i32, i32* %26
%28 = load i32*, i32** %6
%29 = load i32, i32* %28
%30 = icmp ne i32 %27, %29
br i1 %30, label %31, label %38
31: ; preds = %25, %16
%32 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 0
%33 = load i32, i32* %32
%34 = load i32*, i32** %5
store i32 %33, i32* %34
%35 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i32 0, i32 1
%36 = load i32, i32* %35
%37 = load i32*, i32** %6
store i32 %36, i32* %37
ret void
38: ; preds = %25
br label %39
39: ; preds = %38, %9
br label %9
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i64, %struct.TYPE_5__ }
%struct.TYPE_5__ = type { i32, i32 }
@ConfigureNotify = global i64 0
define void @wait_for_resolution_change(i32* %0, i32* nocapture %1, i32* nocapture %2) {
%4 = alloca %struct.TYPE_4__
%5 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i64 0, i32 1, i32 0
%6 = bitcast %struct.TYPE_4__* %4 to i8*
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i64 0, i32 0
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i64 0, i32 1, i32 1
br label %9
9: ; preds = %22, %3
%10 = call i32 @XNextEvent(i32* %0, %struct.TYPE_4__* %4)
%11 = load i64, i64* %7
%12 = load i64, i64* @ConfigureNotify
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %9
%15 = load i32, i32* %5
%16 = load i32, i32* %8
%17 = load i32, i32* %1
%18 = icmp eq i32 %15, %17
br i1 %18, label %19, label %23
19: ; preds = %14
%20 = load i32, i32* %2
%21 = icmp eq i32 %16, %20
br i1 %21, label %22, label %23
22: ; preds = %9, %19
br label %9
23: ; preds = %14, %19
store i32 %15, i32* %1
store i32 %16, i32* %2
ret void
}