#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 */

/* Type definitions */
typedef enum ibv_event_type { ____Placeholder_ibv_event_type } ibv_event_type;

/* Variables and functions */
#define IBV_EVENT_CLIENT_REREGISTER 145
#define IBV_EVENT_COMM_EST 144
#define IBV_EVENT_CQ_ERR 143
#define IBV_EVENT_DEVICE_FATAL 142
#define IBV_EVENT_LID_CHANGE 141
#define IBV_EVENT_PATH_MIG 140
#define IBV_EVENT_PATH_MIG_ERR 139
#define IBV_EVENT_PKEY_CHANGE 138
#define IBV_EVENT_PORT_ACTIVE 137
#define IBV_EVENT_PORT_ERR 136
#define IBV_EVENT_QP_ACCESS_ERR 135
#define IBV_EVENT_QP_FATAL 134
#define IBV_EVENT_QP_LAST_WQE_REACHED 133
#define IBV_EVENT_QP_REQ_ERR 132
#define IBV_EVENT_SM_CHANGE 131
#define IBV_EVENT_SQ_DRAINED 130
#define IBV_EVENT_SRQ_ERR 129
#define IBV_EVENT_SRQ_LIMIT_REACHED 128
const char *event_name_str(enum ibv_event_type event_type) {
  switch (event_type) {
  case IBV_EVENT_DEVICE_FATAL:
    return "IBV_EVENT_DEVICE_FATAL";
  case IBV_EVENT_PORT_ACTIVE:
    return "IBV_EVENT_PORT_ACTIVE";
  case IBV_EVENT_PORT_ERR:
    return "IBV_EVENT_PORT_ERR";
  case IBV_EVENT_LID_CHANGE:
    return "IBV_EVENT_LID_CHANGE";
  case IBV_EVENT_PKEY_CHANGE:
    return "IBV_EVENT_PKEY_CHANGE";
  case IBV_EVENT_SM_CHANGE:
    return "IBV_EVENT_SM_CHANGE";
  case IBV_EVENT_CLIENT_REREGISTER:
    return "IBV_EVENT_CLIENT_REREGISTER";
  case IBV_EVENT_CQ_ERR:
  case IBV_EVENT_QP_FATAL:
  case IBV_EVENT_QP_REQ_ERR:
  case IBV_EVENT_QP_ACCESS_ERR:
  case IBV_EVENT_COMM_EST:
  case IBV_EVENT_SQ_DRAINED:
  case IBV_EVENT_PATH_MIG:
  case IBV_EVENT_PATH_MIG_ERR:
  case IBV_EVENT_SRQ_ERR:
  case IBV_EVENT_SRQ_LIMIT_REACHED:
  case IBV_EVENT_QP_LAST_WQE_REACHED:
  default:
    return "unexpected";
  }
}


x86 assembly (clang, -O0):
<event_name_str>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x11,%eax
ja     11a5 <event_name_str+0xa5>
mov    -0x18(%rbp),%rax
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf11(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b0 <event_name_str+0xb0>
lea    0xf18(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b0 <event_name_str+0xb0>
lea    0xf1e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b0 <event_name_str+0xb0>
lea    0xf21(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b0 <event_name_str+0xb0>
lea    0xf26(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b0 <event_name_str+0xb0>
lea    0xf2c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b0 <event_name_str+0xb0>
lea    0xf30(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11b0 <event_name_str+0xb0>
jmp    11a5 <event_name_str+0xa5>
lea    0xf37(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<event_name_str>:
add    $0xffffff7d,%edi
cmp    $0xe,%edi
ja     111d <event_name_str+0x1d>
movslq %edi,%rax
lea    0xf93(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0xf77(%rip),%rax
ret

LLVM IR (-O0):
@.str = [23 x i8] c"IBV_EVENT_DEVICE_FATAL\00"
@.str.1 = [22 x i8] c"IBV_EVENT_PORT_ACTIVE\00"
@.str.2 = [19 x i8] c"IBV_EVENT_PORT_ERR\00"
@.str.3 = [21 x i8] c"IBV_EVENT_LID_CHANGE\00"
@.str.4 = [22 x i8] c"IBV_EVENT_PKEY_CHANGE\00"
@.str.5 = [20 x i8] c"IBV_EVENT_SM_CHANGE\00"
@.str.6 = [28 x i8] c"IBV_EVENT_CLIENT_REREGISTER\00"
@.str.7 = [11 x i8] c"unexpected\00"
define i8* @event_name_str(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %13 [
i32 142, label %5
i32 137, label %6
i32 136, label %7
i32 141, label %8
i32 138, label %9
i32 131, label %10
i32 145, label %11
i32 143, label %12
i32 134, label %12
i32 132, label %12
i32 135, label %12
i32 144, label %12
i32 130, label %12
i32 140, label %12
i32 139, label %12
i32 129, label %12
i32 128, label %12
i32 133, label %12
]
5: ; preds = %1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8** %2
br label %14
6: ; preds = %1
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %14
7: ; preds = %1
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %14
8: ; preds = %1
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %14
9: ; preds = %1
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %14
10: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %14
11: ; preds = %1
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %14
12: ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1
br label %13
13: ; preds = %1, %12
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %14
14: ; preds = %13, %11, %10, %9, %8, %7, %6, %5
%15 = load i8*, i8** %2
ret i8* %15
}

LLVM IR (-O2):
@.str = [23 x i8] c"IBV_EVENT_DEVICE_FATAL\00"
@.str.1 = [22 x i8] c"IBV_EVENT_PORT_ACTIVE\00"
@.str.2 = [19 x i8] c"IBV_EVENT_PORT_ERR\00"
@.str.3 = [21 x i8] c"IBV_EVENT_LID_CHANGE\00"
@.str.4 = [22 x i8] c"IBV_EVENT_PKEY_CHANGE\00"
@.str.5 = [20 x i8] c"IBV_EVENT_SM_CHANGE\00"
@.str.6 = [28 x i8] c"IBV_EVENT_CLIENT_REREGISTER\00"
@.str.7 = [11 x i8] c"unexpected\00"
@reltable.event_name_str = [15 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str.5 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.7 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.7 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.7 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.7 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.2 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.1 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([22 x i8]* @.str.4 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.7 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.7 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.3 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.7 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.7 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.6 to i64), i64 ptrtoint ([15 x i32]* @reltable.event_name_str to i64)) to i32)]
define i8* @event_name_str(i32 %0) {
%2 = add i32 %0, -131
%3 = icmp ult i32 %2, 15
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([15 x i32]* @reltable.event_name_str to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), %1 ]
ret i8* %9
}