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

/* Variables and functions */
#define VisibilityFullyOdirured 130
#define VisibilityPartiallyOdirured 129
#define VisibilityUnodirured 128
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
void do_VisibilityNotify(FILE *out_f, 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;
  }
  fprintf(out_f, "    state %s\n", v);
}


x86 assembly (clang, -O0):
<do_VisibilityNotify>:
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     1177 <do_VisibilityNotify+0x57>
jmp    1151 <do_VisibilityNotify+0x31>
mov    -0x30(%rbp),%eax
sub    $0x81,%eax
je     1187 <do_VisibilityNotify+0x67>
jmp    1164 <do_VisibilityNotify+0x44>
mov    -0x30(%rbp),%eax
sub    $0x82,%eax
je     1197 <do_VisibilityNotify+0x77>
jmp    11a7 <do_VisibilityNotify+0x87>
lea    0xe82(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11c5 <do_VisibilityNotify+0xa5>
lea    0xe87(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11c5 <do_VisibilityNotify+0xa5>
lea    0xe93(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11c5 <do_VisibilityNotify+0xa5>
lea    -0x2a(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x2a(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe89(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe78(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_VisibilityNotify>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
mov    (%rsi),%edx
lea    -0x80(%rdx),%eax
cmp    $0x3,%eax
jae    1146 <do_VisibilityNotify+0x26>
cltq
lea    0xf1f(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    115a <do_VisibilityNotify+0x3a>
lea    0xe(%rsp),%rbx
lea    0xef7(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
lea    0xeeb(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
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, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca %struct.TYPE_2__*
%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_2__*
store %struct.TYPE_2__* %9, %struct.TYPE_2__** %5
%10 = load %struct.TYPE_2__*, %struct.TYPE_2__** %5
%11 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %10, i32 0, i32 0
%12 = load i32, i32* %11
switch i32 %12, label %16 [
i32 128, label %13
i32 129, label %14
i32 130, label %15
]
13: ; preds = %2
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %6
br label %23
14: ; preds = %2
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8** %6
br label %23
15: ; preds = %2
store i8* getelementptr inbounds ([24 x i8], [24 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_2__*, %struct.TYPE_2__** %5
%20 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %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 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %25)
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, i32* nocapture %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_VisibilityNotify to i8*), i64 %12)
br label %14
14: ; preds = %10, %8
%15 = phi i8* [ %4, %8 ], [ %13, %10 ]
%16 = call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %15)
ret void
}