#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*/ snprintf(char *, int, char *, int);
const char *ex_desc(int ex) {
  static char num[12];
  static const char *const desc[] = {"normal",  "start",  "sock",     "modem",
                                     "dial",    "dead",   "done",     "reboot",
                                     "errdead", "hangup", "term",     "nodial",
                                     "nologin", "redial", "reconnect"};
  if (ex >= 0 && ex < (int)(sizeof desc / sizeof *desc))
    return desc[ex];
  snprintf(num, sizeof num, "%d", ex);
  return num;
}


x86 assembly (clang, -O0):
<ex_desc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     1147 <ex_desc+0x37>
cmpl   $0xf,-0xc(%rbp)
jge    1147 <ex_desc+0x37>
movslq -0xc(%rbp),%rcx
lea    0x2c66(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
jmp    116d <ex_desc+0x5d>
mov    -0xc(%rbp),%ecx
lea    0x2ed8(%rip),%rdi
mov    $0xc,%esi
lea    0xefb(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2ec0(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex_desc>:
push   %rbx
mov    %edi,%ecx
cmp    $0xe,%edi
ja     112a <ex_desc+0x1a>
mov    %ecx,%eax
lea    0xedf(%rip),%rcx
movslq (%rcx,%rax,4),%rbx
add    %rcx,%rbx
jmp    1145 <ex_desc+0x35>
lea    0x2ef8(%rip),%rbx
lea    0xf5c(%rip),%rdx
mov    %rbx,%rdi
mov    $0xc,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@ex_desc.num = internal global [12 x i8] zeroinitializer
@ex_desc.desc = internal constant [15 x i8*] [i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i32 0, i32 0)]
@.str = [7 x i8] c"normal\00"
@.str.1 = [6 x i8] c"start\00"
@.str.2 = [5 x i8] c"sock\00"
@.str.3 = [6 x i8] c"modem\00"
@.str.4 = [5 x i8] c"dial\00"
@.str.5 = [5 x i8] c"dead\00"
@.str.6 = [5 x i8] c"done\00"
@.str.7 = [7 x i8] c"reboot\00"
@.str.8 = [8 x i8] c"errdead\00"
@.str.9 = [7 x i8] c"hangup\00"
@.str.10 = [5 x i8] c"term\00"
@.str.11 = [7 x i8] c"nodial\00"
@.str.12 = [8 x i8] c"nologin\00"
@.str.13 = [7 x i8] c"redial\00"
@.str.14 = [10 x i8] c"reconnect\00"
@.str.15 = [3 x i8] c"%d\00"
define i8* @ex_desc(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 slt i32 %7, 15
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [15 x i8*], [15 x i8*]* @ex_desc.desc, 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 @snprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @ex_desc.num, i64 0, i64 0), i32 12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i32 %15)
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @ex_desc.num, i64 0, i64 0), i8** %2
br label %17
17: ; preds = %14, %9
%18 = load i8*, i8** %2
ret i8* %18
}

LLVM IR (-O2):
@ex_desc.num = internal global [12 x i8] zeroinitializer
@reltable.ex_desc = internal unnamed_addr constant [15 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.3 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.4 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.5 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.6 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.7 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.8 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.9 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.10 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.11 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.12 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.13 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.14 to i64), i64 ptrtoint ([15 x i32]* @reltable.ex_desc to i64)) to i32)]
@.str = [7 x i8] c"normal\00"
@.str.1 = [6 x i8] c"start\00"
@.str.2 = [5 x i8] c"sock\00"
@.str.3 = [6 x i8] c"modem\00"
@.str.4 = [5 x i8] c"dial\00"
@.str.5 = [5 x i8] c"dead\00"
@.str.6 = [5 x i8] c"done\00"
@.str.7 = [7 x i8] c"reboot\00"
@.str.8 = [8 x i8] c"errdead\00"
@.str.9 = [7 x i8] c"hangup\00"
@.str.10 = [5 x i8] c"term\00"
@.str.11 = [7 x i8] c"nodial\00"
@.str.12 = [8 x i8] c"nologin\00"
@.str.13 = [7 x i8] c"redial\00"
@.str.14 = [10 x i8] c"reconnect\00"
@.str.15 = [3 x i8] c"%d\00"
define i8* @ex_desc(i32 %0) {
%2 = icmp ult i32 %0, 15
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 ([15 x i32]* @reltable.ex_desc to i8*), i64 %5)
br label %9
7: ; preds = %1
%8 = tail call i32 @snprintf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @ex_desc.num, i64 0, i64 0), i32 12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i32 %0)
br label %9
9: ; preds = %7, %3
%10 = phi i8* [ %6, %3 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @ex_desc.num, i64 0, i64 0), %7 ]
ret i8* %10
}