#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 ss7 {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ss7_message(struct ss7 *, char *, char *, unsigned char);
int((calling_party_cat_dump))(struct ss7 *ss7, int messagetype,
                              unsigned char *parm, int len) {
  char *cattype;
  switch (parm[0]) {
  case 1:
    cattype = "Operator, French";
    break;
  case 2:
    cattype = "Operator, English";
    break;
  case 3:
    cattype = "Operator, German";
    break;
  case 4:
    cattype = "Operator, Russian";
    break;
  case 5:
    cattype = "Operator, Spanish";
    break;
  case 9:
    cattype = "Reserved";
    break;
  case 10:
    cattype = "Ordinary calling sudirriber";
    break;
  case 11:
    cattype = "Calling sudirriber with priority";
    break;
  case 12:
    cattype = "Data Call (voice band data)";
    break;
  case 13:
    cattype = "Test Call";
    break;
  case 15:
    cattype = "Payphone";
    break;
  default:
    cattype = "Unknown";
    break;
  }
  ss7_message(ss7, "\t\t\tCategory: %s (%d)\n", cattype, parm[0]);
  return 1;
}


x86 assembly (clang, -O0):
<calling_party_cat_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0xe,%eax
ja     1203 <calling_party_cat_dump+0xf3>
mov    -0x30(%rbp),%rax
lea    0xeb6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xee2(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    120e <calling_party_cat_dump+0xfe>
lea    0xee3(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    120e <calling_party_cat_dump+0xfe>
lea    0xee5(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    120e <calling_party_cat_dump+0xfe>
lea    0xee6(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    120e <calling_party_cat_dump+0xfe>
lea    0xee8(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    120e <calling_party_cat_dump+0xfe>
lea    0xeea(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    120e <calling_party_cat_dump+0xfe>
lea    0xee3(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    120e <calling_party_cat_dump+0xfe>
lea    0xeef(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    120e <calling_party_cat_dump+0xfe>
lea    0xf00(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    120e <calling_party_cat_dump+0xfe>
lea    0xf0c(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    120e <calling_party_cat_dump+0xfe>
lea    0xf06(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    120e <calling_party_cat_dump+0xfe>
lea    0xeff(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rax
lea    0xef0(%rip),%rsi
movzbl (%rax),%ecx
call   1030 <ss7_message@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calling_party_cat_dump>:
push   %rax
mov    (%rdx),%al
lea    -0x1(%rax),%ecx
cmp    $0xe,%cl
ja     112f <calling_party_cat_dump+0x1f>
movsbq %cl,%rcx
lea    0xfc6(%rip),%rsi
movslq (%rsi,%rcx,4),%rdx
add    %rsi,%rdx
jmp    1136 <calling_party_cat_dump+0x26>
lea    0xf97(%rip),%rdx
movzbl %al,%ecx
lea    0xf95(%rip),%rsi
call   1030 <ss7_message@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.ss7 = type { i32 }
@.str = [17 x i8] c"Operator, French\00"
@.str.1 = [18 x i8] c"Operator, English\00"
@.str.2 = [17 x i8] c"Operator, German\00"
@.str.3 = [18 x i8] c"Operator, Russian\00"
@.str.4 = [18 x i8] c"Operator, Spanish\00"
@.str.5 = [9 x i8] c"Reserved\00"
@.str.6 = [28 x i8] c"Ordinary calling sudirriber\00"
@.str.7 = [33 x i8] c"Calling sudirriber with priority\00"
@.str.8 = [28 x i8] c"Data Call (voice band data)\00"
@.str.9 = [10 x i8] c"Test Call\00"
@.str.10 = [9 x i8] c"Payphone\00"
@.str.11 = [8 x i8] c"Unknown\00"
@.str.12 = [22 x i8] c"\09\09\09Category: %s (%d)\0A\00"
define i32 @calling_party_cat_dump(%struct.ss7* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca %struct.ss7*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
store %struct.ss7* %0, %struct.ss7** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%10 = load i8*, i8** %7
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
switch i32 %13, label %25 [
i32 1, label %14
i32 2, label %15
i32 3, label %16
i32 4, label %17
i32 5, label %18
i32 9, label %19
i32 10, label %20
i32 11, label %21
i32 12, label %22
i32 13, label %23
i32 15, label %24
]
14: ; preds = %4
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %9
br label %26
15: ; preds = %4
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8** %9
br label %26
16: ; preds = %4
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8** %9
br label %26
17: ; preds = %4
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8** %9
br label %26
18: ; preds = %4
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8** %9
br label %26
19: ; preds = %4
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8** %9
br label %26
20: ; preds = %4
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i8** %9
br label %26
21: ; preds = %4
store i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8** %9
br label %26
22: ; preds = %4
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0), i8** %9
br label %26
23: ; preds = %4
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8** %9
br label %26
24: ; preds = %4
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8** %9
br label %26
25: ; preds = %4
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i8** %9
br label %26
26: ; preds = %25, %24, %23, %22, %21, %20, %19, %18, %17, %16, %15, %14
%27 = load %struct.ss7*, %struct.ss7** %5
%28 = load i8*, i8** %9
%29 = load i8*, i8** %7
%30 = getelementptr inbounds i8, i8* %29, i64 0
%31 = load i8, i8* %30
%32 = call i32 @ss7_message(%struct.ss7* %27, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i8* %28, i8 zeroext %31)
ret i32 1
}

LLVM IR (-O2):
%struct.ss7 = type { i32 }
@.str = [17 x i8] c"Operator, French\00"
@.str.1 = [18 x i8] c"Operator, English\00"
@.str.2 = [17 x i8] c"Operator, German\00"
@.str.3 = [18 x i8] c"Operator, Russian\00"
@.str.4 = [18 x i8] c"Operator, Spanish\00"
@.str.5 = [9 x i8] c"Reserved\00"
@.str.6 = [28 x i8] c"Ordinary calling sudirriber\00"
@.str.7 = [33 x i8] c"Calling sudirriber with priority\00"
@.str.8 = [28 x i8] c"Data Call (voice band data)\00"
@.str.9 = [10 x i8] c"Test Call\00"
@.str.10 = [9 x i8] c"Payphone\00"
@.str.11 = [8 x i8] c"Unknown\00"
@.str.12 = [22 x i8] c"\09\09\09Category: %s (%d)\0A\00"
@reltable.calling_party_cat_dump = [15 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.1 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.2 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.3 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.4 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.11 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.11 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.11 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.5 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.6 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([33 x i8]* @.str.7 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([28 x i8]* @.str.8 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.9 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.11 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.10 to i64), i64 ptrtoint ([15 x i32]* @reltable.calling_party_cat_dump to i64)) to i32)]
define i32 @calling_party_cat_dump(%struct.ss7* %0, i32 %1, i8* nocapture %2, i32 %3) {
%5 = load i8, i8* %2
%6 = add i8 %5, -1
%7 = icmp ult i8 %6, 15
br i1 %7, label %8, label %12
8: ; preds = %4
%9 = sext i8 %6 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([15 x i32]* @reltable.calling_party_cat_dump to i8*), i64 %10)
br label %12
12: ; preds = %4, %8
%13 = phi i8* [ %11, %8 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), %4 ]
%14 = tail call i32 @ss7_message(%struct.ss7* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0), i8* %13, i8 zeroext %5)
ret i32 1
}