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

/* Variables and functions */
int /*<<< orphan*/ XGetErrorText(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                 char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int error_handler(Display *display, XErrorEvent *event) {
  char error[100];
  XGetErrorText(display, event->error_code, error, sizeof error);
  fprintf(stderr, "[serial %ld request %d/%d error: %s]\n", event->serial,
          event->request_code, event->minor_code, error);
  return 0;
}


x86 assembly (clang, -O0):
<error_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%esi
lea    -0x80(%rbp),%rdx
mov    $0x64,%ecx
call   1040 <XGetErrorText@plt>
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    (%rax),%r8d
lea    -0x80(%rbp),%r9
lea    0xe8b(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<error_handler>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%rbx
mov    0xc(%rsi),%esi
mov    %rsp,%r14
mov    %r14,%rdx
mov    $0x64,%ecx
call   1040 <XGetErrorText@plt>
mov    0x2e9c(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%edx
mov    (%rbx),%r8d
mov    0x4(%rbx),%ecx
lea    0xeaa(%rip),%rsi
mov    %r14,%r9
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [38 x i8] c"[serial %ld request %d/%d error: %s]\0A\00"
define i32 @error_handler(i32* %0, %struct.TYPE_3__* %1) {
%3 = alloca i32*
%4 = alloca %struct.TYPE_3__*
%5 = alloca [100 x i8]
store i32* %0, i32** %3
store %struct.TYPE_3__* %1, %struct.TYPE_3__** %4
%6 = load i32*, i32** %3
%7 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 3
%9 = load i32, i32* %8
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%11 = call i32 @XGetErrorText(i32* %6, i32 %9, i8* %10, i32 100)
%12 = load i32, i32* @stderr
%13 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %13, i32 0, i32 2
%15 = load i32, i32* %14
%16 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i32 0, i32 1
%18 = load i32, i32* %17
%19 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%23 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %18, i32 %21, i8* %22)
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [38 x i8] c"[serial %ld request %d/%d error: %s]\0A\00"
define i32 @error_handler(i32* %0, %struct.TYPE_3__* nocapture %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 3
%6 = load i32, i32* %5
%7 = call i32 @XGetErrorText(i32* %0, i32 %6, i8* %4, i32 100)
%8 = load i32, i32* @stderr
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 2
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%14 = load i32, i32* %13
%15 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %12, i32 %14, i8* %4)
ret i32 0
}