#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*/ sprintf(char *, char *, int);
char *frag_protocol(int e) {
  static char *names[] = {"none", "sequenced2012", "ccnx2013"};
  static char buf[100];
  if (e >= 0 && e <= 2)
    return names[e];
  sprintf(buf, "%d", e);
  return buf;
}


x86 assembly (clang, -O0):
<frag_protocol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1147 <frag_protocol+0x37>
cmpl   $0x2,-0xc(%rbp)
jg     1147 <frag_protocol+0x37>
movslq -0xc(%rbp),%rcx
lea    0x2ef6(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    1168 <frag_protocol+0x58>
mov    -0xc(%rbp),%edx
lea    0x2f0f(%rip),%rdi
lea    0xec4(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2efc(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<frag_protocol>:
push   %rbx
mov    %edi,%edx
cmp    $0x2,%edi
ja     112a <frag_protocol+0x1a>
mov    %edx,%eax
lea    0xedf(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    1140 <frag_protocol+0x30>
lea    0x2f0f(%rip),%rbx
lea    0xef0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@frag_protocol.names = internal global [3 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i32 0, i32 0)]
@.str = [5 x i8] c"none\00"
@.str.1 = [14 x i8] c"sequenced2012\00"
@.str.2 = [9 x i8] c"ccnx2013\00"
@frag_protocol.buf = internal global [100 x i8] zeroinitializer
@.str.3 = [3 x i8] c"%d\00"
define i8* @frag_protocol(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sge i32 %4, 0
br i1 %5, label %6, label %14
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp sle i32 %7, 2
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [3 x i8*], [3 x i8*]* @frag_protocol.names, i64 0, i64 %11
%13 = load i8*, i8** %12
store i8* %13, i8** %2
br label %17
14: ; preds = %6, %1
%15 = load i32, i32* %3
%16 = call i32 @sprintf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @frag_protocol.buf, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %15)
store i8* getelementptr inbounds ([100 x i8], [100 x i8]* @frag_protocol.buf, i64 0, i64 0), i8** %2
br label %17
17: ; preds = %14, %9
%18 = load i8*, i8** %2
ret i8* %18
}

LLVM IR (-O2):
@reltable.frag_protocol = internal unnamed_addr constant [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.frag_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.frag_protocol to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.frag_protocol to i64)) to i32)]
@.str = [5 x i8] c"none\00"
@.str.1 = [14 x i8] c"sequenced2012\00"
@.str.2 = [9 x i8] c"ccnx2013\00"
@frag_protocol.buf = internal global [100 x i8] zeroinitializer
@.str.3 = [3 x i8] c"%d\00"
define i8* @frag_protocol(i32 %0) {
%2 = icmp ult i32 %0, 3
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = zext i32 %0 to i64
%5 = shl i64 %4, 2
%6 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.frag_protocol to i8*), i64 %5)
br label %9
7: ; preds = %1
%8 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([100 x i8], [100 x i8]* @frag_protocol.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %0)
br label %9
9: ; preds = %7, %3
%10 = phi i8* [ %6, %3 ], [ getelementptr inbounds ([100 x i8], [100 x i8]* @frag_protocol.buf, i64 0, i64 0), %7 ]
ret i8* %10
}