#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void printProtocol(int protocol) {
  printf("Protocol: ");
  switch (protocol) {
  case 1:
    printf("IPv4\n");
    break;
  case 2:
    printf("ARP\n");
    break;
  case 3:
    printf("IPv6");
    break;
  default:
    printf("unknown");
    break;
  }
}


x86 assembly (clang, -O0):
<printProtocol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x1,%eax
je     115d <printProtocol+0x4d>
jmp    113b <printProtocol+0x2b>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     116e <printProtocol+0x5e>
jmp    114c <printProtocol+0x3c>
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
je     117f <printProtocol+0x6f>
jmp    1190 <printProtocol+0x80>
lea    0xea7(%rip),%rdi
call   1030 <printf@plt>
jmp    119c <printProtocol+0x8c>
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
jmp    119c <printProtocol+0x8c>
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
jmp    119c <printProtocol+0x8c>
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printProtocol>:
push   %rbx
mov    %edi,%ebx
lea    0xed6(%rip),%rdi
call   1040 <printf@plt>
cmp    $0x3,%ebx
je     114b <printProtocol+0x2b>
cmp    $0x2,%ebx
je     1158 <printProtocol+0x38>
cmp    $0x1,%ebx
jne    1165 <printProtocol+0x45>
lea    0xed7(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xeb9(%rip),%rdi
pop    %rbx
jmp    1040 <printf@plt>
lea    0xeb9(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>
lea    0xea4(%rip),%rdi
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"Protocol: \00"
@.str.1 = [6 x i8] c"IPv4\0A\00"
@.str.2 = [5 x i8] c"ARP\0A\00"
@.str.3 = [5 x i8] c"IPv6\00"
@.str.4 = [8 x i8] c"unknown\00"
define void @printProtocol(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
switch i32 %4, label %11 [
i32 1, label %5
i32 2, label %7
i32 3, label %9
]
5: ; preds = %1
%6 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %13
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %13
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %13
11: ; preds = %1
%12 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %13
13: ; preds = %11, %9, %7, %5
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"Protocol: \00"
@.str.3 = [5 x i8] c"IPv6\00"
@.str.4 = [8 x i8] c"unknown\00"
@str = [4 x i8] c"ARP\00"
@str.5 = [5 x i8] c"IPv4\00"
define void @printProtocol(i32 %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
switch i32 %0, label %9 [
i32 1, label %3
i32 2, label %5
i32 3, label %7
]
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str.5, i64 0, i64 0))
br label %11
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %11
7: ; preds = %1
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %11
9: ; preds = %1
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %11
11: ; preds = %9, %7, %5, %3
ret void
}