#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_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int state;
};
typedef TYPE_1__ XVisibilityEvent;
typedef int /*<<< orphan*/ XEvent;

/* Variables and functions */
#define VisibilityFullyOdirured 130
#define VisibilityPartiallyOdirured 129
#define VisibilityUnodirured 128
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void do_VisibilityNotify(XEvent *eventp) {
  XVisibilityEvent *e = (XVisibilityEvent *)eventp;
  char *v;
  char vdummy[10];
  switch (e->state) {
  case VisibilityUnodirured:
    v = "VisibilityUnodirured";
    break;
  case VisibilityPartiallyOdirured:
    v = "VisibilityPartiallyOdirured";
    break;
  case VisibilityFullyOdirured:
    v = "VisibilityFullyOdirured";
    break;
  default:
    v = vdummy;
    sprintf(vdummy, "%d", e->state);
    break;
  }
  printf("    state %s\n", v);
}


x86 assembly (clang, -O0):
<do_VisibilityNotify>:
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     1173 <do_VisibilityNotify+0x53>
jmp    114d <do_VisibilityNotify+0x2d>
mov    -0x28(%rbp),%eax
sub    $0x81,%eax
je     1183 <do_VisibilityNotify+0x63>
jmp    1160 <do_VisibilityNotify+0x40>
mov    -0x28(%rbp),%eax
sub    $0x82,%eax
je     1193 <do_VisibilityNotify+0x73>
jmp    11a3 <do_VisibilityNotify+0x83>
lea    0xe86(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11c1 <do_VisibilityNotify+0xa1>
lea    0xe8b(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11c1 <do_VisibilityNotify+0xa1>
lea    0xe97(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11c1 <do_VisibilityNotify+0xa1>
lea    -0x22(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x22(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xe8d(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe80(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_VisibilityNotify>:
push   %rbx
sub    $0x10,%rsp
mov    (%rdi),%edx
lea    -0x80(%rdx),%eax
cmp    $0x3,%eax
jae    1141 <do_VisibilityNotify+0x21>
cltq
lea    0xf24(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    1155 <do_VisibilityNotify+0x35>
lea    0x6(%rsp),%rbx
lea    0xefc(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
lea    0xef0(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_2__ = type { i32 }
@.str = [21 x i8] c"VisibilityUnodirured\00"
@.str.1 = [28 x i8] c"VisibilityPartiallyOdirured\00"
@.str.2 = [24 x i8] c"VisibilityFullyOdirured\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [14 x i8] c" state %s\0A\00"
define void @do_VisibilityNotify(i32* %0) {
%2 = alloca i32*
%3 = alloca %struct.TYPE_2__*
%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_2__*
store %struct.TYPE_2__* %7, %struct.TYPE_2__** %3
%8 = load %struct.TYPE_2__*, %struct.TYPE_2__** %3
%9 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %8, i32 0, i32 0
%10 = load i32, i32* %9
switch i32 %10, label %14 [
i32 128, label %11
i32 129, label %12
i32 130, label %13
]
11: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %4
br label %21
12: ; preds = %1
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %21
13: ; preds = %1
store i8* getelementptr inbounds ([24 x i8], [24 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_2__*, %struct.TYPE_2__** %3
%18 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %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 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %22)
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"VisibilityUnodirured\00"
@.str.1 = [28 x i8] c"VisibilityPartiallyOdirured\00"
@.str.2 = [24 x i8] c"VisibilityFullyOdirured\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [14 x i8] c" state %s\0A\00"
@reltable.do_VisibilityNotify = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.do_VisibilityNotify to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.do_VisibilityNotify to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.do_VisibilityNotify to i64)) to i32)]
define void @do_VisibilityNotify(i32* nocapture %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_VisibilityNotify to i8*), i64 %11)
br label %13
13: ; preds = %9, %7
%14 = phi i8* [ %3, %7 ], [ %12, %9 ]
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %14)
ret void
}