#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_12__ TYPE_4__;
typedef struct TYPE_11__ TYPE_3__;
typedef struct TYPE_10__ TYPE_2__;
typedef struct TYPE_9__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ request;
typedef int /*<<< orphan*/ buf;
struct TYPE_9__ {
  scalar_t__ major_opcode;
};
struct TYPE_10__ {
  char *name;
  struct TYPE_10__ *next;
  TYPE_1__ codes;
};
typedef TYPE_2__ _XExtension;
struct TYPE_11__ {
  int error_code;
  int request_code;
  int minor_code;
  int serial;
  scalar_t__ resourceid;
};
typedef TYPE_3__ XErrorEvent;
struct TYPE_12__ {
  int request;
  TYPE_2__ *ext_procs;
};
typedef TYPE_4__ Display;

/* Variables and functions */
#define BadAtom 129
#define BadValue 128
int /*<<< orphan*/ XGetErrorDatabaseText(TYPE_4__ *, char *, char *, char *,
                                         char *, int);
int /*<<< orphan*/ XGetErrorText(TYPE_4__ *, int, char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncpy(char *, char *, int);
int dummy_handler(Display *dpy, XErrorEvent *ev) {
  char buf[256];
  char request[256];
  _XExtension *ext = NULL;
  XGetErrorText(dpy, ev->error_code, buf, sizeof(buf));
  fprintf(stderr, "ErrorHandler: %s\n", buf);
  if (ev->request_code < 128) {
    snprintf(request, sizeof(request), "%d", ev->request_code);
    XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf));
  } else {
    for (ext = dpy->ext_procs;
         ext && ext->codes.major_opcode != ev->request_code; ext = ext->next)
      ;
    if (ext)
      strncpy(buf, ext->name, sizeof(buf));
    else
      buf[0] = '\0';
  }
  fprintf(stderr, "                 Major opcode: %d (%s)\n", ev->request_code,
          buf);
  if (ev->request_code >= 128 && ext) {
    snprintf(request, sizeof(request), "%d", ev->request_code);
    snprintf(request, sizeof(request), "%s.%d", ext->name, ev->minor_code);
    XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf));
    fprintf(stderr, "                 Minor opcode: %d (%s)\n", ev->minor_code,
            buf);
  }
  switch (ev->error_code) {
  case BadValue:
    fprintf(stderr, "                 Value:        0x%x\n",
            (int)ev->resourceid);
    break;
  case BadAtom:
    fprintf(stderr, "                 AtomID:       0x%x\n",
            (int)ev->resourceid);
    break;
  default:
    fprintf(stderr, "                 ResourceID:   0x%x\n",
            (int)ev->resourceid);
    break;
  }
  fprintf(stderr, "                 Failed serial number:  %ld\n", ev->serial);
  fprintf(stderr, "                 Current serial number: %ld\n",
          dpy->request);
  return 0;
}


x86 assembly (clang, -O0):
<dummy_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x218(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    -0x110(%rbp),%rdx
mov    $0x100,%ecx
call   1070 <XGetErrorText@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rdx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x80,0x4(%rax)
jge    1209 <dummy_handler+0xb9>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    $0x100,%esi
lea    0xe74(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x210(%rbp),%rdx
lea    -0x110(%rbp),%r8
lea    0xe20(%rip),%rsi
lea    0xe49(%rip),%rcx
mov    $0x100,%r9d
call   1050 <XGetErrorDatabaseText@plt>
jmp    12b6 <dummy_handler+0x166>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x218(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x218(%rbp)
mov    %al,-0x219(%rbp)
je     124d <dummy_handler+0xfd>
mov    -0x218(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x10(%rbp),%rcx
movslq 0x4(%rcx),%rcx
cmp    %rcx,%rax
setne  %al
mov    %al,-0x219(%rbp)
mov    -0x219(%rbp),%al
test   $0x1,%al
jne    1260 <dummy_handler+0x110>
jmp    127c <dummy_handler+0x12c>
jmp    1265 <dummy_handler+0x115>
mov    -0x218(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x218(%rbp)
jmp    1218 <dummy_handler+0xc8>
cmpq   $0x0,-0x218(%rbp)
je     12aa <dummy_handler+0x15a>
lea    -0x110(%rbp),%rdi
mov    -0x218(%rbp),%rax
mov    (%rax),%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
jmp    12b1 <dummy_handler+0x161>
movb   $0x0,-0x110(%rbp)
jmp    12b6 <dummy_handler+0x166>
mov    0x2d23(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
lea    -0x110(%rbp),%rcx
lea    0xd47(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x80,0x4(%rax)
jl     1397 <dummy_handler+0x247>
cmpq   $0x0,-0x218(%rbp)
je     1397 <dummy_handler+0x247>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    $0x100,%esi
lea    0xd32(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    -0x210(%rbp),%rdi
mov    -0x218(%rbp),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8d
mov    $0x100,%esi
lea    0xd03(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x210(%rbp),%rdx
lea    -0x110(%rbp),%r8
lea    0xcb2(%rip),%rsi
lea    0xcdb(%rip),%rcx
mov    $0x100,%r9d
call   1050 <XGetErrorDatabaseText@plt>
mov    0x2c67(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edx
lea    -0x110(%rbp),%rcx
lea    0xcb9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x220(%rbp)
sub    $0x80,%eax
je     13c9 <dummy_handler+0x279>
jmp    13b3 <dummy_handler+0x263>
mov    -0x220(%rbp),%eax
sub    $0x81,%eax
je     13ef <dummy_handler+0x29f>
jmp    1415 <dummy_handler+0x2c5>
mov    0x2c10(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %eax,%edx
lea    0xc8e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1436 <dummy_handler+0x2e6>
mov    0x2bea(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %eax,%edx
lea    0xc8d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    1436 <dummy_handler+0x2e6>
mov    0x2bc4(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %eax,%edx
lea    0xc8c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2ba3(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%edx
lea    0xc93(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2b85(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xca3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dummy_handler>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rsi,%rbp
mov    %rdi,%r14
mov    (%rsi),%esi
mov    %rsp,%r15
mov    %r15,%rdx
mov    $0x100,%ecx
call   1070 <XGetErrorText@plt>
mov    0x2e60(%rip),%r13
mov    0x0(%r13),%edi
lea    0xe75(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x4(%rbp),%ecx
cmp    $0x7f,%ecx
jg     11e1 <dummy_handler+0x91>
lea    0xea2(%rip),%rdx
xor    %ebx,%ebx
lea    0x100(%rsp),%r15
mov    %r15,%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xe4e(%rip),%rsi
lea    0xe77(%rip),%rcx
mov    %rsp,%r8
mov    %r14,%rdi
mov    %r15,%rdx
mov    $0x100,%r9d
call   1050 <XGetErrorDatabaseText@plt>
jmp    1217 <dummy_handler+0xc7>
mov    0x8(%r14),%rbx
test   %rbx,%rbx
je     11ff <dummy_handler+0xaf>
nopw   0x0(%rax,%rax,1)
cmp    %rcx,0x10(%rbx)
je     1207 <dummy_handler+0xb7>
mov    0x8(%rbx),%rbx
test   %rbx,%rbx
jne    11f0 <dummy_handler+0xa0>
movb   $0x0,(%rsp)
xor    %ebx,%ebx
jmp    1217 <dummy_handler+0xc7>
mov    (%rbx),%rsi
mov    %rsp,%rdi
mov    $0x100,%edx
call   1030 <strncpy@plt>
mov    0x0(%r13),%edi
mov    0x4(%rbp),%edx
lea    0xdf6(%rip),%rsi
mov    %rsp,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x4(%rbp),%ecx
cmp    $0x80,%ecx
jl     12b7 <dummy_handler+0x167>
test   %rbx,%rbx
je     12b7 <dummy_handler+0x167>
lea    0xe00(%rip),%rdx
lea    0x100(%rsp),%r15
mov    %r15,%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    (%rbx),%rcx
mov    0x8(%rbp),%r8d
lea    0xdd8(%rip),%rdx
mov    %r15,%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xd91(%rip),%rsi
lea    0xdba(%rip),%rcx
mov    %rsp,%r12
mov    %r14,%rdi
mov    %r15,%rdx
mov    %r12,%r8
mov    $0x100,%r9d
call   1050 <XGetErrorDatabaseText@plt>
mov    0x0(%r13),%edi
mov    0x8(%rbp),%edx
lea    0xd9c(%rip),%rsi
mov    %r12,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x0(%rbp),%eax
mov    0x10(%rbp),%edx
cmp    $0x81,%eax
lea    0xdcd(%rip),%rcx
lea    0xdeb(%rip),%rdi
cmove  %rcx,%rdi
cmp    $0x80,%eax
lea    0xd91(%rip),%rsi
cmovne %rdi,%rsi
mov    0x0(%r13),%edi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x0(%r13),%edi
mov    0xc(%rbp),%edx
lea    0xde3(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x0(%r13),%edi
mov    (%r14),%edx
lea    0xdfb(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_12__ = type { i32, %struct.TYPE_10__* }
%struct.TYPE_10__ = type { i8*, %struct.TYPE_10__*, %struct.TYPE_9__ }
%struct.TYPE_9__ = type { i64 }
%struct.TYPE_11__ = type { i32, i32, i32, i32, i64 }
@stderr = global i32 0
@.str = [18 x i8] c"ErrorHandler: %s\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"XRequest\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [40 x i8] c" Major opcode: %d (%s)\0A\00"
@.str.5 = [6 x i8] c"%s.%d\00"
@.str.6 = [40 x i8] c" Minor opcode: %d (%s)\0A\00"
@.str.7 = [37 x i8] c" Value: 0x%x\0A\00"
@.str.8 = [37 x i8] c" AtomID: 0x%x\0A\00"
@.str.9 = [37 x i8] c" ResourceID: 0x%x\0A\00"
@.str.10 = [45 x i8] c" Failed serial number: %ld\0A\00"
@.str.11 = [45 x i8] c" Current serial number: %ld\0A\00"
define i32 @dummy_handler(%struct.TYPE_12__* %0, %struct.TYPE_11__* %1) {
%3 = alloca %struct.TYPE_12__*
%4 = alloca %struct.TYPE_11__*
%5 = alloca [256 x i8]
%6 = alloca [256 x i8]
%7 = alloca %struct.TYPE_10__*
store %struct.TYPE_12__* %0, %struct.TYPE_12__** %3
store %struct.TYPE_11__* %1, %struct.TYPE_11__** %4
store %struct.TYPE_10__* null, %struct.TYPE_10__** %7
%8 = load %struct.TYPE_12__*, %struct.TYPE_12__** %3
%9 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%10 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%13 = call i32 @XGetErrorText(%struct.TYPE_12__* %8, i32 %11, i8* %12, i32 256)
%14 = load i32, i32* @stderr
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%18 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %17, i32 0, i32 1
%19 = load i32, i32* %18
%20 = icmp slt i32 %19, 128
br i1 %20, label %21, label %31
21: ; preds = %2
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%23 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%24 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %23, i32 0, i32 1
%25 = load i32, i32* %24
%26 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %22, i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load %struct.TYPE_12__*, %struct.TYPE_12__** %3
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%30 = call i32 @XGetErrorDatabaseText(%struct.TYPE_12__* %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %28, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %29, i32 256)
br label %67
31: ; preds = %2
%32 = load %struct.TYPE_12__*, %struct.TYPE_12__** %3
%33 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %32, i32 0, i32 1
%34 = load %struct.TYPE_10__*, %struct.TYPE_10__** %33
store %struct.TYPE_10__* %34, %struct.TYPE_10__** %7
br label %35
35: ; preds = %51, %31
%36 = load %struct.TYPE_10__*, %struct.TYPE_10__** %7
%37 = icmp ne %struct.TYPE_10__* %36, null
br i1 %37, label %38, label %48
38: ; preds = %35
%39 = load %struct.TYPE_10__*, %struct.TYPE_10__** %7
%40 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %39, i32 0, i32 2
%41 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %40, i32 0, i32 0
%42 = load i64, i64* %41
%43 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%44 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %43, i32 0, i32 1
%45 = load i32, i32* %44
%46 = sext i32 %45 to i64
%47 = icmp ne i64 %42, %46
br label %48
48: ; preds = %38, %35
%49 = phi i1 [ false, %35 ], [ %47, %38 ]
br i1 %49, label %50, label %55
50: ; preds = %48
br label %51
51: ; preds = %50
%52 = load %struct.TYPE_10__*, %struct.TYPE_10__** %7
%53 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %52, i32 0, i32 1
%54 = load %struct.TYPE_10__*, %struct.TYPE_10__** %53
store %struct.TYPE_10__* %54, %struct.TYPE_10__** %7
br label %35
55: ; preds = %48
%56 = load %struct.TYPE_10__*, %struct.TYPE_10__** %7
%57 = icmp ne %struct.TYPE_10__* %56, null
br i1 %57, label %58, label %64
58: ; preds = %55
%59 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%60 = load %struct.TYPE_10__*, %struct.TYPE_10__** %7
%61 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %60, i32 0, i32 0
%62 = load i8*, i8** %61
%63 = call i32 @strncpy(i8* %59, i8* %62, i32 256)
br label %66
64: ; preds = %55
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
store i8 0, i8* %65
br label %66
66: ; preds = %64, %58
br label %67
67: ; preds = %66, %21
%68 = load i32, i32* @stderr
%69 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%70 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %69, i32 0, i32 1
%71 = load i32, i32* %70
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %71, i8* %72)
%74 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%75 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %74, i32 0, i32 1
%76 = load i32, i32* %75
%77 = icmp sge i32 %76, 128
br i1 %77, label %78, label %105
78: ; preds = %67
%79 = load %struct.TYPE_10__*, %struct.TYPE_10__** %7
%80 = icmp ne %struct.TYPE_10__* %79, null
br i1 %80, label %81, label %105
81: ; preds = %78
%82 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%83 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%84 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %83, i32 0, i32 1
%85 = load i32, i32* %84
%86 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %82, i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %85)
%87 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%88 = load %struct.TYPE_10__*, %struct.TYPE_10__** %7
%89 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %88, i32 0, i32 0
%90 = load i8*, i8** %89
%91 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%92 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %91, i32 0, i32 2
%93 = load i32, i32* %92
%94 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %87, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %90, i32 %93)
%95 = load %struct.TYPE_12__*, %struct.TYPE_12__** %3
%96 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%97 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%98 = call i32 @XGetErrorDatabaseText(%struct.TYPE_12__* %95, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %96, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %97, i32 256)
%99 = load i32, i32* @stderr
%100 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%101 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %100, i32 0, i32 2
%102 = load i32, i32* %101
%103 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %102, i8* %103)
br label %105
105: ; preds = %81, %78, %67
%106 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%107 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %106, i32 0, i32 0
%108 = load i32, i32* %107
switch i32 %108, label %123 [
i32 128, label %109
i32 129, label %116
]
109: ; preds = %105
%110 = load i32, i32* @stderr
%111 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%112 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %111, i32 0, i32 4
%113 = load i64, i64* %112
%114 = trunc i64 %113 to i32
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %114)
br label %130
116: ; preds = %105
%117 = load i32, i32* @stderr
%118 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%119 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %118, i32 0, i32 4
%120 = load i64, i64* %119
%121 = trunc i64 %120 to i32
%122 = call i32 (i32, i8*, ...) @fprintf(i32 %117, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i32 %121)
br label %130
123: ; preds = %105
%124 = load i32, i32* @stderr
%125 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%126 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %125, i32 0, i32 4
%127 = load i64, i64* %126
%128 = trunc i64 %127 to i32
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0), i32 %128)
br label %130
130: ; preds = %123, %116, %109
%131 = load i32, i32* @stderr
%132 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%133 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %132, i32 0, i32 3
%134 = load i32, i32* %133
%135 = call i32 (i32, i8*, ...) @fprintf(i32 %131, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i32 %134)
%136 = load i32, i32* @stderr
%137 = load %struct.TYPE_12__*, %struct.TYPE_12__** %3
%138 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %137, i32 0, i32 0
%139 = load i32, i32* %138
%140 = call i32 (i32, i8*, ...) @fprintf(i32 %136, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0), i32 %139)
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_12__ = type { i32, %struct.TYPE_10__* }
%struct.TYPE_10__ = type { i8*, %struct.TYPE_10__*, %struct.TYPE_9__ }
%struct.TYPE_9__ = type { i64 }
%struct.TYPE_11__ = type { i32, i32, i32, i32, i64 }
@stderr = global i32 0
@.str = [18 x i8] c"ErrorHandler: %s\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"XRequest\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [40 x i8] c" Major opcode: %d (%s)\0A\00"
@.str.5 = [6 x i8] c"%s.%d\00"
@.str.6 = [40 x i8] c" Minor opcode: %d (%s)\0A\00"
@.str.7 = [37 x i8] c" Value: 0x%x\0A\00"
@.str.8 = [37 x i8] c" AtomID: 0x%x\0A\00"
@.str.9 = [37 x i8] c" ResourceID: 0x%x\0A\00"
@.str.10 = [45 x i8] c" Failed serial number: %ld\0A\00"
@.str.11 = [45 x i8] c" Current serial number: %ld\0A\00"
define i32 @dummy_handler(%struct.TYPE_12__* %0, %struct.TYPE_11__* nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 0
%8 = load i32, i32* %7
%9 = call i32 @XGetErrorText(%struct.TYPE_12__* %0, i32 %8, i8* %5, i32 256)
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %5)
%12 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 1
%13 = load i32, i32* %12
%14 = icmp slt i32 %13, 128
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %6, i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%17 = call i32 @XGetErrorDatabaseText(%struct.TYPE_12__* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %5, i32 256)
br label %38
18: ; preds = %2
%19 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %0, i64 0, i32 1
%20 = load %struct.TYPE_10__*, %struct.TYPE_10__** %19
%21 = icmp eq %struct.TYPE_10__* %20, null
br i1 %21, label %37, label %22
22: ; preds = %18
%23 = zext i32 %13 to i64
br label %24
24: ; preds = %22, %29
%25 = phi %struct.TYPE_10__* [ %20, %22 ], [ %31, %29 ]
%26 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %25, i64 0, i32 2, i32 0
%27 = load i64, i64* %26
%28 = icmp eq i64 %27, %23
br i1 %28, label %33, label %29
29: ; preds = %24
%30 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %25, i64 0, i32 1
%31 = load %struct.TYPE_10__*, %struct.TYPE_10__** %30
%32 = icmp eq %struct.TYPE_10__* %31, null
br i1 %32, label %37, label %24
33: ; preds = %24
%34 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %25, i64 0, i32 0
%35 = load i8*, i8** %34
%36 = call i32 @strncpy(i8* %5, i8* %35, i32 256)
br label %38
37: ; preds = %29, %18
store i8 0, i8* %5
br label %38
38: ; preds = %33, %37, %15
%39 = phi %struct.TYPE_10__* [ null, %15 ], [ %25, %33 ], [ null, %37 ]
%40 = load i32, i32* @stderr
%41 = load i32, i32* %12
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %41, i8* %5)
%43 = load i32, i32* %12
%44 = icmp sgt i32 %43, 127
%45 = icmp ne %struct.TYPE_10__* %39, null
%46 = select i1 %44, i1 %45, i1 false
br i1 %46, label %47, label %58
47: ; preds = %38
%48 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %6, i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%49 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %39, i64 0, i32 0
%50 = load i8*, i8** %49
%51 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 2
%52 = load i32, i32* %51
%53 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %6, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %50, i32 %52)
%54 = call i32 @XGetErrorDatabaseText(%struct.TYPE_12__* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %5, i32 256)
%55 = load i32, i32* @stderr
%56 = load i32, i32* %51
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %56, i8* %5)
br label %58
58: ; preds = %47, %38
%59 = load i32, i32* %7
%60 = icmp eq i32 %59, 129
%61 = select i1 %60, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0)
%62 = icmp eq i32 %59, 128
%63 = select i1 %62, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %61
%64 = load i32, i32* @stderr
%65 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 4
%66 = load i64, i64* %65
%67 = trunc i64 %66 to i32
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* %63, i32 %67)
%69 = load i32, i32* @stderr
%70 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 3
%71 = load i32, i32* %70
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i32 %71)
%73 = load i32, i32* @stderr
%74 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %0, i64 0, i32 0
%75 = load i32, i32* %74
%76 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0), i32 %75)
ret i32 0
}