#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 *, char);
char *get_state(char n) {
  static char duff[64];
  switch (n) {
  case 'R':
    return "Running  ";
  case 'S':
    return "Sleeping ";
  case 'D':
    return "DiskSleep";
  case 'Z':
    return "Zombie   ";
  case 'T':
    return "Traced   ";
  case 'W':
    return "Paging   ";
  default:
    sprintf(duff, "%d", n);
    return duff;
  }
}


x86 assembly (clang, -O0):
<get_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffbc,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x16,%eax
ja     11a8 <get_state+0x98>
mov    -0x18(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf0d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ca <get_state+0xba>
lea    0xf07(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ca <get_state+0xba>
lea    0xf01(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ca <get_state+0xba>
lea    0xefb(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ca <get_state+0xba>
lea    0xef5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ca <get_state+0xba>
lea    0xeef(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11ca <get_state+0xba>
lea    0x2e91(%rip),%rdi
lea    0xee2(%rip),%rsi
movsbl -0x9(%rbp),%edx
call   1030 <sprintf@plt>
lea    0x2e7a(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_state>:
push   %rbx
lea    -0x44(%rdi),%eax
cmp    $0x16,%eax
ja     1139 <get_state+0x29>
lea    0xf3c(%rip),%rbx
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf39(%rip),%rbx
jmp    1177 <get_state+0x67>
movsbl %dil,%edx
lea    0x2efc(%rip),%rbx
lea    0xf4d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
jmp    1177 <get_state+0x67>
lea    0xf0a(%rip),%rbx
jmp    1177 <get_state+0x67>
lea    0xf1f(%rip),%rbx
jmp    1177 <get_state+0x67>
lea    0xf20(%rip),%rbx
jmp    1177 <get_state+0x67>
lea    0xf03(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@get_state.duff = internal global [64 x i8] zeroinitializer
@.str = [10 x i8] c"Running \00"
@.str.1 = [10 x i8] c"Sleeping \00"
@.str.2 = [10 x i8] c"DiskSleep\00"
@.str.3 = [10 x i8] c"Zombie \00"
@.str.4 = [10 x i8] c"Traced \00"
@.str.5 = [10 x i8] c"Paging \00"
@.str.6 = [3 x i8] c"%d\00"
define i8* @get_state(i8 signext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %12 [
i32 82, label %6
i32 83, label %7
i32 68, label %8
i32 90, label %9
i32 84, label %10
i32 87, label %11
]
6: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %2
br label %15
7: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %15
8: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %15
9: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %15
10: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %15
11: ; preds = %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %15
12: ; preds = %1
%13 = load i8, i8* %3
%14 = call i32 @sprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_state.duff, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8 signext %13)
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_state.duff, i64 0, i64 0), i8** %2
br label %15
15: ; preds = %12, %11, %10, %9, %8, %7, %6
%16 = load i8*, i8** %2
ret i8* %16
}

LLVM IR (-O2):
@get_state.duff = internal global [64 x i8] zeroinitializer
@.str = [10 x i8] c"Running \00"
@.str.1 = [10 x i8] c"Sleeping \00"
@.str.2 = [10 x i8] c"DiskSleep\00"
@.str.3 = [10 x i8] c"Zombie \00"
@.str.4 = [10 x i8] c"Traced \00"
@.str.5 = [10 x i8] c"Paging \00"
@.str.6 = [3 x i8] c"%d\00"
define i8* @get_state(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %8 [
i32 82, label %10
i32 83, label %3
i32 68, label %4
i32 90, label %5
i32 84, label %6
i32 87, label %7
]
3: ; preds = %1
br label %10
4: ; preds = %1
br label %10
5: ; preds = %1
br label %10
6: ; preds = %1
br label %10
7: ; preds = %1
br label %10
8: ; preds = %1
%9 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @get_state.duff, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8 signext %0)
br label %10
10: ; preds = %1, %8, %7, %6, %5, %4, %3
%11 = phi i8* [ getelementptr inbounds ([64 x i8], [64 x i8]* @get_state.duff, i64 0, i64 0), %8 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %6 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %5 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %11
}