#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;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
#define MappingKeyboard 130
#define MappingModifier 129
#define MappingPointer 128
int /*<<< orphan*/ XRefreshKeyboardMapping(TYPE_1__ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, int, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
void do_MappingNotify(FILE *out_f, 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;
  }
  fprintf(out_f, "    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    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
sub    $0x80,%eax
je     11a7 <do_MappingNotify+0x77>
jmp    1161 <do_MappingNotify+0x31>
mov    -0x30(%rbp),%eax
sub    $0x81,%eax
je     1187 <do_MappingNotify+0x57>
jmp    1174 <do_MappingNotify+0x44>
mov    -0x30(%rbp),%eax
sub    $0x82,%eax
je     1197 <do_MappingNotify+0x67>
jmp    11b7 <do_MappingNotify+0x87>
lea    0xe72(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d5 <do_MappingNotify+0xa5>
lea    0xe72(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d5 <do_MappingNotify+0xa5>
lea    0xe72(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11d5 <do_MappingNotify+0xa5>
lea    -0x2a(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x2a(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe5f(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%r8d
lea    0xe3f(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <XRefreshKeyboardMapping@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_MappingNotify>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%edx
lea    -0x80(%rdx),%eax
cmp    $0x3,%eax
jae    115b <do_MappingNotify+0x2b>
cltq
lea    0xf0e(%rip),%rcx
movslq (%rcx,%rax,4),%r15
add    %rcx,%r15
jmp    116f <do_MappingNotify+0x3f>
lea    0x6(%rsp),%r15
lea    0xec8(%rip),%rsi
mov    %r15,%rdi
call   1050 <sprintf@plt>
mov    0x4(%rbx),%ecx
mov    0x8(%rbx),%r8d
lea    0xeb5(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
call   1030 <fprintf@plt>
mov    %rbx,%rdi
call   1040 <XRefreshKeyboardMapping@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
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, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca %struct.TYPE_3__*
%6 = alloca i8*
%7 = alloca [10 x i8]
store i32* %0, i32** %3
store i32* %1, i32** %4
%8 = load i32*, i32** %4
%9 = bitcast i32* %8 to %struct.TYPE_3__*
store %struct.TYPE_3__* %9, %struct.TYPE_3__** %5
%10 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 0
%12 = load i32, i32* %11
switch i32 %12, label %16 [
i32 129, label %13
i32 130, label %14
i32 128, label %15
]
13: ; preds = %2
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %6
br label %23
14: ; preds = %2
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %23
15: ; preds = %2
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %6
br label %23
16: ; preds = %2
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
store i8* %17, i8** %6
%18 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%19 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %16, %15, %14, %13
%24 = load i32*, i32** %3
%25 = load i8*, i8** %6
%26 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %26, i32 0, i32 1
%28 = load i32, i32* %27
%29 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%30 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %29, i32 0, i32 2
%31 = load i32, i32* %30
%32 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* %25, i32 %28, i32 %31)
%33 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%34 = call i32 @XRefreshKeyboardMapping(%struct.TYPE_3__* %33)
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* nocapture %0, i32* %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* %1
%6 = add i32 %5, -128
%7 = icmp ult i32 %6, 3
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %5)
br label %14
10: ; preds = %2
%11 = sext i32 %6 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.do_MappingNotify to i8*), i64 %12)
br label %14
14: ; preds = %10, %8
%15 = phi i8* [ %4, %8 ], [ %13, %10 ]
%16 = bitcast i32* %1 to %struct.TYPE_3__*
%17 = getelementptr inbounds i32, i32* %1, i64 1
%18 = load i32, i32* %17
%19 = getelementptr inbounds i32, i32* %1, i64 2
%20 = load i32, i32* %19
%21 = call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* %15, i32 %18, i32 %20)
%22 = call i32 @XRefreshKeyboardMapping(%struct.TYPE_3__* %16)
ret void
}