#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 get_wan_connection_status(char const *);
const char *get_wan_connection_status_str(const char *ifname) {
  int status;
  const char *str = NULL;
  status = get_wan_connection_status(ifname);
  switch (status) {
  case 0:
    str = "Unconfigured";
    break;
  case 1:
    str = "Connecting";
    break;
  case 2:
    str = "Connected";
    break;
  case 3:
    str = "PendingDisconnect";
    break;
  case 4:
    str = "Disconnecting";
    break;
  case 5:
    str = "Disconnected";
    break;
  }
  return str;
}


x86 assembly (clang, -O0):
<get_wan_connection_status_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <get_wan_connection_status@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x5,%rax
ja     11b0 <get_wan_connection_status_str+0xa0>
mov    -0x20(%rbp),%rax
lea    0xeb4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebc(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11b0 <get_wan_connection_status_str+0xa0>
lea    0xeb9(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11b0 <get_wan_connection_status_str+0xa0>
lea    0xeb4(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11b0 <get_wan_connection_status_str+0xa0>
lea    0xeae(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11b0 <get_wan_connection_status_str+0xa0>
lea    0xeb0(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    11b0 <get_wan_connection_status_str+0xa0>
lea    0xeae(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_wan_connection_status_str>:
push   %rax
call   1030 <get_wan_connection_status@plt>
cmp    $0x5,%eax
ja     112d <get_wan_connection_status_str+0x1d>
cltq
lea    0xf2c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Unconfigured\00"
@.str.1 = [11 x i8] c"Connecting\00"
@.str.2 = [10 x i8] c"Connected\00"
@.str.3 = [18 x i8] c"PendingDisconnect\00"
@.str.4 = [14 x i8] c"Disconnecting\00"
@.str.5 = [13 x i8] c"Disconnected\00"
define i8* @get_wan_connection_status_str(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i8* null, i8** %4
%5 = load i8*, i8** %2
%6 = call i32 @get_wan_connection_status(i8* %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
switch i32 %7, label %14 [
i32 0, label %8
i32 1, label %9
i32 2, label %10
i32 3, label %11
i32 4, label %12
i32 5, label %13
]
8: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %4
br label %14
9: ; preds = %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %14
10: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %4
br label %14
11: ; preds = %1
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8** %4
br label %14
12: ; preds = %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8** %4
br label %14
13: ; preds = %1
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8** %4
br label %14
14: ; preds = %1, %13, %12, %11, %10, %9, %8
%15 = load i8*, i8** %4
ret i8* %15
}

LLVM IR (-O2):
@.str = [13 x i8] c"Unconfigured\00"
@.str.1 = [11 x i8] c"Connecting\00"
@.str.2 = [10 x i8] c"Connected\00"
@.str.3 = [18 x i8] c"PendingDisconnect\00"
@.str.4 = [14 x i8] c"Disconnecting\00"
@.str.5 = [13 x i8] c"Disconnected\00"
@reltable.get_wan_connection_status_str = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str to i64), i64 ptrtoint ([6 x i32]* @reltable.get_wan_connection_status_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.1 to i64), i64 ptrtoint ([6 x i32]* @reltable.get_wan_connection_status_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.2 to i64), i64 ptrtoint ([6 x i32]* @reltable.get_wan_connection_status_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.3 to i64), i64 ptrtoint ([6 x i32]* @reltable.get_wan_connection_status_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.4 to i64), i64 ptrtoint ([6 x i32]* @reltable.get_wan_connection_status_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.5 to i64), i64 ptrtoint ([6 x i32]* @reltable.get_wan_connection_status_str to i64)) to i32)]
define i8* @get_wan_connection_status_str(i8* %0) {
%2 = tail call i32 @get_wan_connection_status(i8* %0)
%3 = icmp ult i32 %2, 6
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.get_wan_connection_status_str to i8*), i64 %6)
br label %8
8: ; preds = %4, %1
%9 = phi i8* [ null, %1 ], [ %7, %4 ]
ret i8* %9
}