#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_for_q931(struct pri *pri, int ton) {
  switch (ton) {
  case 0x00:
    return 0x0;
  case 0x01:
    return 0x1;
  case 0x02:
    return 0x2;
  case 0x03:
    return 0x3;
  case 0x04:
    return 0x4;
  case 0x06:
    return 0x6;
  default:
    pri_message(pri, "!! Invalid Q.932 TypeOfNumber %d\n", ton);
    return 0x0;
  }
}


x86 assembly (clang, -O0):
<typeofnumber_for_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    $0x6,%rax
ja     118c <typeofnumber_for_q931+0x7c>
mov    -0x20(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x4(%rbp)
jmp    11a6 <typeofnumber_for_q931+0x96>
movl   $0x1,-0x4(%rbp)
jmp    11a6 <typeofnumber_for_q931+0x96>
movl   $0x2,-0x4(%rbp)
jmp    11a6 <typeofnumber_for_q931+0x96>
movl   $0x3,-0x4(%rbp)
jmp    11a6 <typeofnumber_for_q931+0x96>
movl   $0x4,-0x4(%rbp)
jmp    11a6 <typeofnumber_for_q931+0x96>
movl   $0x6,-0x4(%rbp)
jmp    11a6 <typeofnumber_for_q931+0x96>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe82(%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_for_q931>:
push   %rax
mov    %esi,%edx
cmp    $0x7,%esi
jae    1122 <typeofnumber_for_q931+0x12>
mov    $0x5f,%eax
bt     %edx,%eax
jb     1132 <typeofnumber_for_q931+0x22>
lea    0xed7(%rip),%rsi
call   1030 <pri_message@plt>
xor    %eax,%eax
pop    %rcx
ret
movslq %edx,%rax
lea    0xee8(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.pri = type { i32 }
@.str = [34 x i8] c"!! Invalid Q.932 TypeOfNumber %d\0A\00"
define i32 @typeofnumber_for_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 0, label %7
i32 1, label %8
i32 2, label %9
i32 3, label %10
i32 4, label %11
i32 6, label %12
]
7: ; preds = %2
store i32 0, i32* %3
br label %17
8: ; preds = %2
store i32 1, i32* %3
br label %17
9: ; preds = %2
store i32 2, i32* %3
br label %17
10: ; preds = %2
store i32 3, i32* %3
br label %17
11: ; preds = %2
store i32 4, i32* %3
br label %17
12: ; preds = %2
store i32 6, i32* %3
br label %17
13: ; preds = %2
%14 = load %struct.pri*, %struct.pri** %4
%15 = load i32, i32* %5
%16 = call i32 @pri_message(%struct.pri* %14, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %15)
store i32 0, i32* %3
br label %17
17: ; preds = %13, %12, %11, %10, %9, %8, %7
%18 = load i32, i32* %3
ret i32 %18
}

LLVM IR (-O2):
%struct.pri = type { i32 }
@.str = [34 x i8] c"!! Invalid Q.932 TypeOfNumber %d\0A\00"
@switch.table.typeofnumber_for_q931 = [7 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 0, i32 6]
define i32 @typeofnumber_for_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 ([34 x i8], [34 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_for_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
}