#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 int uint8_t;
struct pkt_buff {
  int dummy;
};
typedef int /*<<< orphan*/ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ dissect_mobilityhdr_type_0(struct pkt_buff *,
                                              int /*<<< orphan*/ *);
int /*<<< orphan*/ dissect_mobilityhdr_type_1_2(struct pkt_buff *,
                                                int /*<<< orphan*/ *);
int /*<<< orphan*/ dissect_mobilityhdr_type_3_4(struct pkt_buff *,
                                                int /*<<< orphan*/ *);
int /*<<< orphan*/ dissect_mobilityhdr_type_5(struct pkt_buff *,
                                              int /*<<< orphan*/ *);
int /*<<< orphan*/ dissect_mobilityhdr_type_6(struct pkt_buff *,
                                              int /*<<< orphan*/ *);
int /*<<< orphan*/ dissect_mobilityhdr_type_7(struct pkt_buff *,
                                              int /*<<< orphan*/ *);
int /*<<< orphan*/ tprintf(char *, ...);
void get_mh_type(struct pkt_buff *pkt, ssize_t *message_data_len,
                 uint8_t *mh_type) {
  switch (*mh_type) {
  case 0x00:
    tprintf("Binding Refresh Request Message ");
    dissect_mobilityhdr_type_0(pkt, message_data_len);
    break;
  case 0x01:
    tprintf("Home Test Init Message ");
    dissect_mobilityhdr_type_1_2(pkt, message_data_len);
    break;
  case 0x02:
    tprintf("Care-of Test Init Message ");
    dissect_mobilityhdr_type_1_2(pkt, message_data_len);
    break;
  case 0x03:
    tprintf("Binding Refresh Request Message ");
    dissect_mobilityhdr_type_3_4(pkt, message_data_len);
    break;
  case 0x04:
    tprintf("Binding Refresh Request Message ");
    dissect_mobilityhdr_type_3_4(pkt, message_data_len);
    break;
  case 0x05:
    tprintf("Binding Refresh Request Message ");
    dissect_mobilityhdr_type_5(pkt, message_data_len);
    break;
  case 0x06:
    tprintf("Binding Refresh Request Message ");
    dissect_mobilityhdr_type_6(pkt, message_data_len);
    break;
  case 0x07:
    tprintf("Binding Refresh Request Message ");
    dissect_mobilityhdr_type_7(pkt, message_data_len);
    break;
  default:
    tprintf("Type %u is unknown. Error", *mh_type);
  }
}


x86 assembly (clang, -O0):
<get_mh_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %rax,-0x20(%rbp)
sub    $0x7,%rax
ja     12ac <get_mh_type+0x13c>
mov    -0x20(%rbp),%rax
lea    0xe5d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1050 <tprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <dissect_mobilityhdr_type_0@plt>
jmp    12c0 <get_mh_type+0x150>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1050 <tprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <dissect_mobilityhdr_type_1_2@plt>
jmp    12c0 <get_mh_type+0x150>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1050 <tprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <dissect_mobilityhdr_type_1_2@plt>
jmp    12c0 <get_mh_type+0x150>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1050 <tprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <dissect_mobilityhdr_type_3_4@plt>
jmp    12c0 <get_mh_type+0x150>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1050 <tprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <dissect_mobilityhdr_type_3_4@plt>
jmp    12c0 <get_mh_type+0x150>
lea    0xdcd(%rip),%rdi
mov    $0x0,%al
call   1050 <tprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <dissect_mobilityhdr_type_5@plt>
jmp    12c0 <get_mh_type+0x150>
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1050 <tprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <dissect_mobilityhdr_type_6@plt>
jmp    12c0 <get_mh_type+0x150>
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1050 <tprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <dissect_mobilityhdr_type_7@plt>
jmp    12c0 <get_mh_type+0x150>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1050 <tprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mh_type>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    (%rdx),%esi
cmp    $0x7,%rsi
ja     11b2 <get_mh_type+0x42>
mov    %rdi,%rbx
lea    0xe77(%rip),%rax
movslq (%rax,%rsi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xe87(%rip),%rdi
xor    %eax,%eax
call   1050 <tprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <dissect_mobilityhdr_type_3_4@plt>
lea    0xebb(%rip),%rdi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <tprintf@plt>
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1050 <tprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <dissect_mobilityhdr_type_0@plt>
lea    0xe53(%rip),%rdi
jmp    11f7 <get_mh_type+0x87>
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1050 <tprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <dissect_mobilityhdr_type_1_2@plt>
lea    0xe09(%rip),%rdi
xor    %eax,%eax
call   1050 <tprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1080 <dissect_mobilityhdr_type_5@plt>
lea    0xde9(%rip),%rdi
xor    %eax,%eax
call   1050 <tprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <dissect_mobilityhdr_type_6@plt>
lea    0xdc9(%rip),%rdi
xor    %eax,%eax
call   1050 <tprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1090 <dissect_mobilityhdr_type_7@plt>

LLVM IR (-O0):
%struct.pkt_buff = type { i32 }
@.str = [33 x i8] c"Binding Refresh Request Message \00"
@.str.1 = [24 x i8] c"Home Test Init Message \00"
@.str.2 = [27 x i8] c"Care-of Test Init Message \00"
@.str.3 = [26 x i8] c"Type %u is unknown. Error\00"
define void @get_mh_type(%struct.pkt_buff* %0, i32* %1, i32* %2) {
%4 = alloca %struct.pkt_buff*
%5 = alloca i32*
%6 = alloca i32*
store %struct.pkt_buff* %0, %struct.pkt_buff** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%7 = load i32*, i32** %6
%8 = load i32, i32* %7
switch i32 %8, label %49 [
i32 0, label %9
i32 1, label %14
i32 2, label %19
i32 3, label %24
i32 4, label %29
i32 5, label %34
i32 6, label %39
i32 7, label %44
]
9: ; preds = %3
%10 = call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%11 = load %struct.pkt_buff*, %struct.pkt_buff** %4
%12 = load i32*, i32** %5
%13 = call i32 @dissect_mobilityhdr_type_0(%struct.pkt_buff* %11, i32* %12)
br label %53
14: ; preds = %3
%15 = call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%16 = load %struct.pkt_buff*, %struct.pkt_buff** %4
%17 = load i32*, i32** %5
%18 = call i32 @dissect_mobilityhdr_type_1_2(%struct.pkt_buff* %16, i32* %17)
br label %53
19: ; preds = %3
%20 = call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%21 = load %struct.pkt_buff*, %struct.pkt_buff** %4
%22 = load i32*, i32** %5
%23 = call i32 @dissect_mobilityhdr_type_1_2(%struct.pkt_buff* %21, i32* %22)
br label %53
24: ; preds = %3
%25 = call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%26 = load %struct.pkt_buff*, %struct.pkt_buff** %4
%27 = load i32*, i32** %5
%28 = call i32 @dissect_mobilityhdr_type_3_4(%struct.pkt_buff* %26, i32* %27)
br label %53
29: ; preds = %3
%30 = call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%31 = load %struct.pkt_buff*, %struct.pkt_buff** %4
%32 = load i32*, i32** %5
%33 = call i32 @dissect_mobilityhdr_type_3_4(%struct.pkt_buff* %31, i32* %32)
br label %53
34: ; preds = %3
%35 = call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%36 = load %struct.pkt_buff*, %struct.pkt_buff** %4
%37 = load i32*, i32** %5
%38 = call i32 @dissect_mobilityhdr_type_5(%struct.pkt_buff* %36, i32* %37)
br label %53
39: ; preds = %3
%40 = call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%41 = load %struct.pkt_buff*, %struct.pkt_buff** %4
%42 = load i32*, i32** %5
%43 = call i32 @dissect_mobilityhdr_type_6(%struct.pkt_buff* %41, i32* %42)
br label %53
44: ; preds = %3
%45 = call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%46 = load %struct.pkt_buff*, %struct.pkt_buff** %4
%47 = load i32*, i32** %5
%48 = call i32 @dissect_mobilityhdr_type_7(%struct.pkt_buff* %46, i32* %47)
br label %53
49: ; preds = %3
%50 = load i32*, i32** %6
%51 = load i32, i32* %50
%52 = call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %49, %44, %39, %34, %29, %24, %19, %14, %9
ret void
}

LLVM IR (-O2):
%struct.pkt_buff = type { i32 }
@.str = [33 x i8] c"Binding Refresh Request Message \00"
@.str.1 = [24 x i8] c"Home Test Init Message \00"
@.str.2 = [27 x i8] c"Care-of Test Init Message \00"
@.str.3 = [26 x i8] c"Type %u is unknown. Error\00"
define void @get_mh_type(%struct.pkt_buff* %0, i32* %1, i32* nocapture %2) {
%4 = load i32, i32* %2
switch i32 %4, label %29 [
i32 0, label %5
i32 1, label %8
i32 2, label %11
i32 3, label %14
i32 4, label %17
i32 5, label %20
i32 6, label %23
i32 7, label %26
]
5: ; preds = %3
%6 = tail call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @dissect_mobilityhdr_type_0(%struct.pkt_buff* %0, i32* %1)
br label %31
8: ; preds = %3
%9 = tail call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @dissect_mobilityhdr_type_1_2(%struct.pkt_buff* %0, i32* %1)
br label %31
11: ; preds = %3
%12 = tail call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @dissect_mobilityhdr_type_1_2(%struct.pkt_buff* %0, i32* %1)
br label %31
14: ; preds = %3
%15 = tail call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @dissect_mobilityhdr_type_3_4(%struct.pkt_buff* %0, i32* %1)
br label %31
17: ; preds = %3
%18 = tail call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 @dissect_mobilityhdr_type_3_4(%struct.pkt_buff* %0, i32* %1)
br label %31
20: ; preds = %3
%21 = tail call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%22 = tail call i32 @dissect_mobilityhdr_type_5(%struct.pkt_buff* %0, i32* %1)
br label %31
23: ; preds = %3
%24 = tail call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%25 = tail call i32 @dissect_mobilityhdr_type_6(%struct.pkt_buff* %0, i32* %1)
br label %31
26: ; preds = %3
%27 = tail call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%28 = tail call i32 @dissect_mobilityhdr_type_7(%struct.pkt_buff* %0, i32* %1)
br label %31
29: ; preds = %3
%30 = tail call i32 (i8*, ...) @tprintf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %4)
br label %31
31: ; preds = %29, %26, %23, %20, %17, %14, %11, %8, %5
ret void
}