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

/* Variables and functions */
int True;
int /*<<< orphan*/ XGetErrorText(int /*<<< orphan*/ *, scalar_t__, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int _Xerror(Display *display, XErrorEvent *err) {
  char buf[80];
  XGetErrorText(display, err->error_code, buf, 80);
  printf("*** X error *** %d 0x%x %ld %d %d\n", err->type,
         (unsigned int)err->resourceid, (long int)err->error_code,
         (int)err->request_code, err->minor_code);
  printf("txt: %s\n", buf);
  return True;
}


x86 assembly (clang, -O0):
<_Xerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
lea    -0x60(%rbp),%rdx
mov    $0x50,%ecx
call   1040 <XGetErrorText@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rcx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %eax,%r8d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r9d
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rsi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_Xerror>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbx
mov    0x20(%rsi),%rsi
mov    %rsp,%r14
mov    %r14,%rdx
mov    $0x50,%ecx
call   1040 <XGetErrorText@plt>
mov    (%rbx),%esi
mov    0x8(%rbx),%edx
mov    0x20(%rbx),%rcx
mov    0x18(%rbx),%r8d
mov    0x10(%rbx),%r9d
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i64, i32, i64, i64 }
@.str = [35 x i8] c"*** X error *** %d 0x%x %ld %d %d\0A\00"
@.str.1 = [9 x i8] c"txt: %s\0A\00"
@True = global i32 0
define i32 @_Xerror(i32* %0, %struct.TYPE_3__* %1) {
%3 = alloca i32*
%4 = alloca %struct.TYPE_3__*
%5 = alloca [80 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 4
%9 = load i64, i64* %8
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%11 = call i32 @XGetErrorText(i32* %6, i64 %9, i8* %10, i32 80)
%12 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %15, i32 0, i32 1
%17 = load i64, i64* %16
%18 = trunc i64 %17 to i32
%19 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %19, i32 0, i32 4
%21 = load i64, i64* %20
%22 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%23 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %22, i32 0, i32 3
%24 = load i64, i64* %23
%25 = trunc i64 %24 to i32
%26 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %26, i32 0, i32 2
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %14, i32 %18, i64 %21, i32 %25, i32 %28)
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @True
ret i32 %32
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i64, i32, i64, i64 }
@.str = [35 x i8] c"*** X error *** %d 0x%x %ld %d %d\0A\00"
@.str.1 = [9 x i8] c"txt: %s\0A\00"
@True = global i32 0
define i32 @_Xerror(i32* %0, %struct.TYPE_3__* nocapture %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 4
%6 = load i64, i64* %5
%7 = call i32 @XGetErrorText(i32* %0, i64 %6, i8* %4, i32 80)
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 1
%11 = load i64, i64* %10
%12 = trunc i64 %11 to i32
%13 = load i64, i64* %5
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 3
%15 = load i64, i64* %14
%16 = trunc i64 %15 to i32
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %1, i64 0, i32 2
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %12, i64 %13, i32 %16, i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%21 = load i32, i32* @True
ret i32 %21
}