#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;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void dhcp_type_print(uint8_t *msg_type_code) {
  printf("Message-Type");
  switch (*msg_type_code) {
  case 2:
    printf(" OFFER");
    break;
  case 5:
    printf(" ACK");
    break;
  case 6:
    printf(" NACK");
    break;
  default:
    printf(" UNKNOWN");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dhcp_type_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
sub    $0x2,%eax
je     1161 <dhcp_type_print+0x51>
jmp    113f <dhcp_type_print+0x2f>
mov    -0xc(%rbp),%eax
sub    $0x5,%eax
je     1172 <dhcp_type_print+0x62>
jmp    1150 <dhcp_type_print+0x40>
mov    -0xc(%rbp),%eax
sub    $0x6,%eax
je     1183 <dhcp_type_print+0x73>
jmp    1194 <dhcp_type_print+0x84>
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
jmp    11a0 <dhcp_type_print+0x90>
lea    0xe9b(%rip),%rdi
call   1030 <printf@plt>
jmp    11a0 <dhcp_type_print+0x90>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
jmp    11a0 <dhcp_type_print+0x90>
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dhcp_type_print>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rdi
call   1040 <printf@plt>
mov    (%rbx),%eax
add    $0xfffffffe,%eax
cmp    $0x4,%eax
ja     114c <dhcp_type_print+0x2c>
cltq
lea    0xee5(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    1153 <dhcp_type_print+0x33>
lea    0xecc(%rip),%rdi
call   1040 <printf@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"Message-Type\00"
@.str.1 = [7 x i8] c" OFFER\00"
@.str.2 = [5 x i8] c" ACK\00"
@.str.3 = [6 x i8] c" NACK\00"
@.str.4 = [9 x i8] c" UNKNOWN\00"
@.str.5 = [2 x i8] c"\0A\00"
define void @dhcp_type_print(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = load i32*, i32** %2
%5 = load i32, i32* %4
switch i32 %5, label %12 [
i32 2, label %6
i32 5, label %8
i32 6, label %10
]
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %14
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %14
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %14
12: ; preds = %1
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %14
14: ; preds = %12, %10, %8, %6
%15 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"Message-Type\00"
@.str.1 = [7 x i8] c" OFFER\00"
@.str.2 = [5 x i8] c" ACK\00"
@.str.3 = [6 x i8] c" NACK\00"
@.str.4 = [9 x i8] c" UNKNOWN\00"
@reltable.dhcp_type_print = [5 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.1 to i64), i64 ptrtoint ([5 x i32]* @reltable.dhcp_type_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.4 to i64), i64 ptrtoint ([5 x i32]* @reltable.dhcp_type_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.4 to i64), i64 ptrtoint ([5 x i32]* @reltable.dhcp_type_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([5 x i32]* @reltable.dhcp_type_print to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([5 x i32]* @reltable.dhcp_type_print to i64)) to i32)]
define void @dhcp_type_print(i32* nocapture %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* %0
%4 = add i32 %3, -2
%5 = icmp ult i32 %4, 5
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = sext i32 %4 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([5 x i32]* @reltable.dhcp_type_print to i8*), i64 %8)
br label %10
10: ; preds = %1, %6
%11 = phi i8* [ %9, %6 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), %1 ]
%12 = tail call i32 @printf(i8* dereferenceable(1) %11)
%13 = tail call i32 @putchar(i32 10)
ret void
}