#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) - 1);
      buf[sizeof(buf) - 1] = '\0';
    } 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    12ba <dummy_handler+0x16a>
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     12ae <dummy_handler+0x15e>
lea    -0x110(%rbp),%rdi
mov    -0x218(%rbp),%rax
mov    (%rax),%rsi
mov    $0xff,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x11(%rbp)
jmp    12b5 <dummy_handler+0x165>
movb   $0x0,-0x110(%rbp)
jmp    12ba <dummy_handler+0x16a>
mov    0x2d1f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
lea    -0x110(%rbp),%rcx
lea    0xd43(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
cmpl   $0x80,0x4(%rax)
jl     139b <dummy_handler+0x24b>
cmpq   $0x0,-0x218(%rbp)
je     139b <dummy_handler+0x24b>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    $0x100,%esi
lea    0xd2e(%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    0xcff(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x210(%rbp),%rdx
lea    -0x110(%rbp),%r8
lea    0xcae(%rip),%rsi
lea    0xcd7(%rip),%rcx
mov    $0x100,%r9d
call   1050 <XGetErrorDatabaseText@plt>
mov    0x2c63(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edx
lea    -0x110(%rbp),%rcx
lea    0xcb5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x220(%rbp)
sub    $0x80,%eax
je     13cd <dummy_handler+0x27d>
jmp    13b7 <dummy_handler+0x267>
mov    -0x220(%rbp),%eax
sub    $0x81,%eax
je     13f3 <dummy_handler+0x2a3>
jmp    1419 <dummy_handler+0x2c9>
mov    0x2c0c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %eax,%edx
lea    0xc8a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    143a <dummy_handler+0x2ea>
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %eax,%edx
lea    0xc89(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    143a <dummy_handler+0x2ea>
mov    0x2bc0(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %eax,%edx
lea    0xc88(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2b9f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%edx
lea    0xc8f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2b81(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xc9f(%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    121f <dummy_handler+0xcf>
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    121f <dummy_handler+0xcf>
mov    (%rbx),%rsi
mov    %rsp,%rdi
mov    $0xff,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xff(%rsp)
mov    0x0(%r13),%edi
mov    0x4(%rbp),%edx
lea    0xdee(%rip),%rsi
mov    %rsp,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x4(%rbp),%ecx
cmp    $0x80,%ecx
jl     12bf <dummy_handler+0x16f>
test   %rbx,%rbx
je     12bf <dummy_handler+0x16f>
lea    0xdf8(%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    0xdd0(%rip),%rdx
mov    %r15,%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0xd89(%rip),%rsi
lea    0xdb2(%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    0xd94(%rip),%rsi
mov    %r12,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x0(%rbp),%eax
mov    0x10(%rbp),%edx
cmp    $0x81,%eax
lea    0xdc5(%rip),%rcx
lea    0xde3(%rip),%rdi
cmove  %rcx,%rdi
cmp    $0x80,%eax
lea    0xd89(%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    0xddb(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x0(%r13),%edi
mov    (%r14),%edx
lea    0xdf3(%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 %68
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 %65
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 255)
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 255
store i8 0, i8* %64
br label %67
65: ; preds = %55
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
store i8 0, i8* %66
br label %67
67: ; preds = %65, %58
br label %68
68: ; preds = %67, %21
%69 = load i32, i32* @stderr
%70 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%71 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %70, i32 0, i32 1
%72 = load i32, i32* %71
%73 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %72, i8* %73)
%75 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%76 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %75, i32 0, i32 1
%77 = load i32, i32* %76
%78 = icmp sge i32 %77, 128
br i1 %78, label %79, label %106
79: ; preds = %68
%80 = load %struct.TYPE_10__*, %struct.TYPE_10__** %7
%81 = icmp ne %struct.TYPE_10__* %80, null
br i1 %81, label %82, label %106
82: ; preds = %79
%83 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%84 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%85 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %84, i32 0, i32 1
%86 = load i32, i32* %85
%87 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %83, i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %86)
%88 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%89 = load %struct.TYPE_10__*, %struct.TYPE_10__** %7
%90 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %89, i32 0, i32 0
%91 = load i8*, i8** %90
%92 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%93 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %92, i32 0, i32 2
%94 = load i32, i32* %93
%95 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %88, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %91, i32 %94)
%96 = load %struct.TYPE_12__*, %struct.TYPE_12__** %3
%97 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%98 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%99 = call i32 @XGetErrorDatabaseText(%struct.TYPE_12__* %96, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %97, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0), i8* %98, i32 256)
%100 = load i32, i32* @stderr
%101 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%102 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %101, i32 0, i32 2
%103 = load i32, i32* %102
%104 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%105 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %103, i8* %104)
br label %106
106: ; preds = %82, %79, %68
%107 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%108 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %107, i32 0, i32 0
%109 = load i32, i32* %108
switch i32 %109, label %124 [
i32 128, label %110
i32 129, label %117
]
110: ; preds = %106
%111 = load i32, i32* @stderr
%112 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%113 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %112, i32 0, i32 4
%114 = load i64, i64* %113
%115 = trunc i64 %114 to i32
%116 = call i32 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %115)
br label %131
117: ; preds = %106
%118 = load i32, i32* @stderr
%119 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%120 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %119, i32 0, i32 4
%121 = load i64, i64* %120
%122 = trunc i64 %121 to i32
%123 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i32 %122)
br label %131
124: ; preds = %106
%125 = load i32, i32* @stderr
%126 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%127 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %126, i32 0, i32 4
%128 = load i64, i64* %127
%129 = trunc i64 %128 to i32
%130 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0), i32 %129)
br label %131
131: ; preds = %124, %117, %110
%132 = load i32, i32* @stderr
%133 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%134 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %133, i32 0, i32 3
%135 = load i32, i32* %134
%136 = call i32 (i32, i8*, ...) @fprintf(i32 %132, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i32 %135)
%137 = load i32, i32* @stderr
%138 = load %struct.TYPE_12__*, %struct.TYPE_12__** %3
%139 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %138, i32 0, i32 0
%140 = load i32, i32* %139
%141 = call i32 (i32, i8*, ...) @fprintf(i32 %137, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0), i32 %140)
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 %39
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 %38, 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 %38, 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 255)
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 255
store i8 0, i8* %37
br label %39
38: ; preds = %29, %18
store i8 0, i8* %5
br label %39
39: ; preds = %33, %38, %15
%40 = phi %struct.TYPE_10__* [ null, %15 ], [ %25, %33 ], [ null, %38 ]
%41 = load i32, i32* @stderr
%42 = load i32, i32* %12
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %42, i8* %5)
%44 = load i32, i32* %12
%45 = icmp sgt i32 %44, 127
%46 = icmp ne %struct.TYPE_10__* %40, null
%47 = select i1 %45, i1 %46, i1 false
br i1 %47, label %48, label %59
48: ; preds = %39
%49 = 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 %44)
%50 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %40, i64 0, i32 0
%51 = load i8*, i8** %50
%52 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 2
%53 = load i32, i32* %52
%54 = 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* %51, i32 %53)
%55 = 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)
%56 = load i32, i32* @stderr
%57 = load i32, i32* %52
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %57, i8* %5)
br label %59
59: ; preds = %48, %39
%60 = load i32, i32* %7
%61 = icmp eq i32 %60, 129
%62 = select i1 %61, 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)
%63 = icmp eq i32 %60, 128
%64 = select i1 %63, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i8* %62
%65 = load i32, i32* @stderr
%66 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 4
%67 = load i64, i64* %66
%68 = trunc i64 %67 to i32
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* %64, i32 %68)
%70 = load i32, i32* @stderr
%71 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %1, i64 0, i32 3
%72 = load i32, i32* %71
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i32 %72)
%74 = load i32, i32* @stderr
%75 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %0, i64 0, i32 0
%76 = load i32, i32* %75
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0), i32 %76)
ret i32 0
}