#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 */
struct pri {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ pri_message(struct pri *, char *, int);
int typeofnumber_from_q931(struct pri *pri, int ton) {
  switch (ton) {
  case 0x1:
    return 0x01;
  case 0x2:
    return 0x02;
  case 0x3:
    return 0x03;
  case 0x4:
    return 0x04;
  case 0x6:
    return 0x06;
  case 0x7:
  default:
    pri_message(pri, "!! Unsupported Q.931 TypeOfNumber value (%d)\n", ton);
  case 0x0:
    return 0x00;
  }
}


x86 assembly (clang, -O0):
<typeofnumber_from_q931>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x7,%rax
ja     1185 <typeofnumber_from_q931+0x75>
mov    -0x20(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    119f <typeofnumber_from_q931+0x8f>
movl   $0x2,-0x4(%rbp)
jmp    119f <typeofnumber_from_q931+0x8f>
movl   $0x3,-0x4(%rbp)
jmp    119f <typeofnumber_from_q931+0x8f>
movl   $0x4,-0x4(%rbp)
jmp    119f <typeofnumber_from_q931+0x8f>
movl   $0x6,-0x4(%rbp)
jmp    119f <typeofnumber_from_q931+0x8f>
jmp    1185 <typeofnumber_from_q931+0x75>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe8d(%rip),%rsi
call   1030 <pri_message@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<typeofnumber_from_q931>:
push   %rax
mov    %esi,%edx
cmp    $0x7,%esi
jae    1122 <typeofnumber_from_q931+0x12>
mov    $0x5f,%eax
bt     %edx,%eax
jb     1132 <typeofnumber_from_q931+0x22>
lea    0xed7(%rip),%rsi
call   1030 <pri_message@plt>
xor    %eax,%eax
pop    %rcx
ret
movslq %edx,%rax
lea    0xef4(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.pri = type { i32 }
@.str = [46 x i8] c"!! Unsupported Q.931 TypeOfNumber value (%d)\0A\00"
define i32 @typeofnumber_from_q931(%struct.pri* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.pri*
%5 = alloca i32
store %struct.pri* %0, %struct.pri** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
switch i32 %6, label %13 [
i32 1, label %7
i32 2, label %8
i32 3, label %9
i32 4, label %10
i32 6, label %11
i32 7, label %12
i32 0, label %17
]
7: ; preds = %2
store i32 1, i32* %3
br label %18
8: ; preds = %2
store i32 2, i32* %3
br label %18
9: ; preds = %2
store i32 3, i32* %3
br label %18
10: ; preds = %2
store i32 4, i32* %3
br label %18
11: ; preds = %2
store i32 6, i32* %3
br label %18
12: ; preds = %2
br label %13
13: ; preds = %2, %12
%14 = load %struct.pri*, %struct.pri** %4
%15 = load i32, i32* %5
%16 = call i32 @pri_message(%struct.pri* %14, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %2, %13
store i32 0, i32* %3
br label %18
18: ; preds = %17, %11, %10, %9, %8, %7
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
%struct.pri = type { i32 }
@.str = [46 x i8] c"!! Unsupported Q.931 TypeOfNumber value (%d)\0A\00"
@switch.table.typeofnumber_from_q931 = [7 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 1, i32 6]
define i32 @typeofnumber_from_q931(%struct.pri* %0, i32 %1) {
%3 = icmp ult i32 %1, 7
br i1 %3, label %6, label %4
4: ; preds = %6, %2
%5 = tail call i32 @pri_message(%struct.pri* %0, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %15
6: ; preds = %2
%7 = trunc i32 %1 to i8
%8 = lshr i8 95, %7
%9 = and i8 %8, 1
%10 = icmp eq i8 %9, 0
br i1 %10, label %4, label %11
11: ; preds = %6
%12 = sext i32 %1 to i64
%13 = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table.typeofnumber_from_q931, i64 0, i64 %12
%14 = load i32, i32* %13
br label %15
15: ; preds = %11, %4
%16 = phi i32 [ 0, %4 ], [ %14, %11 ]
ret i32 %16
}