#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 request;
  int first_keycode;
  int count;
};
typedef TYPE_1__ XMappingEvent;
typedef int /*<<< orphan*/ XEvent;

/* Variables and functions */
#define MappingKeyboard 130
#define MappingModifier 129
#define MappingPointer 128
int /*<<< orphan*/ XRefreshKeyboardMapping(TYPE_1__ *);
int /*<<< orphan*/ printf(char *, char *, int, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
void do_MappingNotify(XEvent *eventp) {
  XMappingEvent *e = (XMappingEvent *)eventp;
  char *r;
  char rdummy[10];
  switch (e->request) {
  case MappingModifier:
    r = "MappingModifier";
    break;
  case MappingKeyboard:
    r = "MappingKeyboard";
    break;
  case MappingPointer:
    r = "MappingPointer";
    break;
  default:
    r = rdummy;
    sprintf(rdummy, "%d", e->request);
    break;
  }
  printf("    request %s, first_keycode %d, count %d\n", r, e->first_keycode,
         e->count);
  XRefreshKeyboardMapping(e);
}


x86 assembly (clang, -O0):
<do_MappingNotify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
sub    $0x80,%eax
je     11a3 <do_MappingNotify+0x73>
jmp    115d <do_MappingNotify+0x2d>
mov    -0x28(%rbp),%eax
sub    $0x81,%eax
je     1183 <do_MappingNotify+0x53>
jmp    1170 <do_MappingNotify+0x40>
mov    -0x28(%rbp),%eax
sub    $0x82,%eax
je     1193 <do_MappingNotify+0x63>
jmp    11b3 <do_MappingNotify+0x83>
lea    0xe76(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11d1 <do_MappingNotify+0xa1>
lea    0xe76(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11d1 <do_MappingNotify+0xa1>
lea    0xe76(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11d1 <do_MappingNotify+0xa1>
lea    -0x22(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x22(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xe63(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <XRefreshKeyboardMapping@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_MappingNotify>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    (%rdi),%edx
lea    -0x80(%rdx),%eax
cmp    $0x3,%eax
jae    1156 <do_MappingNotify+0x26>
cltq
lea    0xf13(%rip),%rcx
movslq (%rcx,%rax,4),%r14
add    %rcx,%r14
jmp    116a <do_MappingNotify+0x3a>
lea    0xe(%rsp),%r14
lea    0xecd(%rip),%rsi
mov    %r14,%rdi
call   1050 <sprintf@plt>
mov    0x4(%rbx),%edx
mov    0x8(%rbx),%ecx
lea    0xebb(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <XRefreshKeyboardMapping@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32, i32 }
@.str = [16 x i8] c"MappingModifier\00"
@.str.1 = [16 x i8] c"MappingKeyboard\00"
@.str.2 = [15 x i8] c"MappingPointer\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [44 x i8] c" request %s, first_keycode %d, count %d\0A\00"
define void @do_MappingNotify(i32* %0) {
%2 = alloca i32*
%3 = alloca %struct.TYPE_3__*
%4 = alloca i8*
%5 = alloca [10 x i8]
store i32* %0, i32** %2
%6 = load i32*, i32** %2
%7 = bitcast i32* %6 to %struct.TYPE_3__*
store %struct.TYPE_3__* %7, %struct.TYPE_3__** %3
%8 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
%10 = load i32, i32* %9
switch i32 %10, label %14 [
i32 129, label %11
i32 130, label %12
i32 128, label %13
]
11: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %4
br label %21
12: ; preds = %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %21
13: ; preds = %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %4
br label %21
14: ; preds = %1
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
store i8* %15, i8** %4
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%17 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %14, %13, %12, %11
%22 = load i8*, i8** %4
%23 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i32 0, i32 1
%25 = load i32, i32* %24
%26 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %26, i32 0, i32 2
%28 = load i32, i32* %27
%29 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* %22, i32 %25, i32 %28)
%30 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%31 = call i32 @XRefreshKeyboardMapping(%struct.TYPE_3__* %30)
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32, i32 }
@.str = [16 x i8] c"MappingModifier\00"
@.str.1 = [16 x i8] c"MappingKeyboard\00"
@.str.2 = [15 x i8] c"MappingPointer\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [44 x i8] c" request %s, first_keycode %d, count %d\0A\00"
@reltable.do_MappingNotify = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.do_MappingNotify to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.do_MappingNotify to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.do_MappingNotify to i64)) to i32)]
define void @do_MappingNotify(i32* %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = load i32, i32* %0
%5 = add i32 %4, -128
%6 = icmp ult i32 %5, 3
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %4)
br label %13
9: ; preds = %1
%10 = sext i32 %5 to i64
%11 = shl i64 %10, 2
%12 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.do_MappingNotify to i8*), i64 %11)
br label %13
13: ; preds = %9, %7
%14 = phi i8* [ %3, %7 ], [ %12, %9 ]
%15 = bitcast i32* %0 to %struct.TYPE_3__*
%16 = getelementptr inbounds i32, i32* %0, i64 1
%17 = load i32, i32* %16
%18 = getelementptr inbounds i32, i32* %0, i64 2
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* %14, i32 %17, i32 %19)
%21 = call i32 @XRefreshKeyboardMapping(%struct.TYPE_3__* %15)
ret void
}