#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 error_code;
};
typedef TYPE_1__ XErrorEvent;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stderr;
int xhk_eks_handler(Display *dpy, XErrorEvent *evt) {
  static int been_there_done_that = 0;
  if (!been_there_done_that) {
    been_there_done_that++;
    fprintf(stderr, "*** X ERROR %d\n", evt->error_code);
    (void)dpy;
  }
  return 0;
}


x86 assembly (clang, -O0):
<xhk_eks_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,0x2f05(%rip)
jne    1157 <xhk_eks_handler+0x47>
mov    0x2ef9(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ef0(%rip)
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xeae(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xhk_eks_handler>:
push   %rax
cmpb   $0x0,0x2f14(%rip)
jne    1138 <xhk_eks_handler+0x28>
movb   $0x1,0x2f0b(%rip)
mov    0x2eb8(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%edx
lea    0xecd(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32 }
@xhk_eks_handler.been_there_done_that = internal global i32 0
@stderr = global i32 0
@.str = [16 x i8] c"*** X ERROR %d\0A\00"
define i32 @xhk_eks_handler(i32* %0, %struct.TYPE_3__* %1) {
%3 = alloca i32*
%4 = alloca %struct.TYPE_3__*
store i32* %0, i32** %3
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %4
%5 = load i32, i32* @xhk_eks_handler.been_there_done_that
%6 = icmp ne i32 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %2
%8 = load i32, i32* @xhk_eks_handler.been_there_done_that
%9 = add nsw i32 %8, 1
store i32 %9, i32* @xhk_eks_handler.been_there_done_that
%10 = load i32, i32* @stderr
%11 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%12 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32*, i32** %3
br label %16
16: ; preds = %7, %2
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32 }
@xhk_eks_handler.been_there_done_that = internal unnamed_addr global i1 false
@stderr = global i32 0
@.str = [16 x i8] c"*** X ERROR %d\0A\00"
define i32 @xhk_eks_handler(i32* nocapture readnone %0, %struct.TYPE_3__* nocapture %1) {
%3 = load i1, i1* @xhk_eks_handler.been_there_done_that
br i1 %3, label %9, label %4
4: ; preds = %2
store i1 true, i1* @xhk_eks_handler.been_there_done_that
%5 = load i32, i32* @stderr
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%7 = load i32, i32* %6
%8 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %4, %2
ret i32 0
}