#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 my_snprintf(char *, int, char *, ...);
int decode_tpgs_state(int st, char *b, int blen) {
  switch (st) {
  case 0x0:
    return my_snprintf(b, blen, "active/optimized");
  case 0x1:
    return my_snprintf(b, blen, "active/non optimized");
  case 0x2:
    return my_snprintf(b, blen, "standby");
  case 0x3:
    return my_snprintf(b, blen, "unavailable");
  case 0xe:
    return my_snprintf(b, blen, "offline");
  case 0xf:
    return my_snprintf(b, blen, "transitioning between states");
  default:
    return my_snprintf(b, blen, "unknown: 0x%x", st);
  }
}


x86 assembly (clang, -O0):
<decode_tpgs_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0xf,%rax
ja     11f5 <decode_tpgs_state+0xe5>
mov    -0x20(%rbp),%rax
lea    0xec2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xeeb(%rip),%rdx
mov    $0x0,%al
call   1030 <my_snprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    1210 <decode_tpgs_state+0x100>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xedf(%rip),%rdx
mov    $0x0,%al
call   1030 <my_snprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    1210 <decode_tpgs_state+0x100>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xed7(%rip),%rdx
mov    $0x0,%al
call   1030 <my_snprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    1210 <decode_tpgs_state+0x100>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xec2(%rip),%rdx
mov    $0x0,%al
call   1030 <my_snprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    1210 <decode_tpgs_state+0x100>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xeb1(%rip),%rdx
mov    $0x0,%al
call   1030 <my_snprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    1210 <decode_tpgs_state+0x100>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    0xe9c(%rip),%rdx
mov    $0x0,%al
call   1030 <my_snprintf@plt>
mov    %eax,-0x4(%rbp)
jmp    1210 <decode_tpgs_state+0x100>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%ecx
lea    0xe99(%rip),%rdx
mov    $0x0,%al
call   1030 <my_snprintf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_tpgs_state>:
mov    %edi,%ecx
cmp    $0xf,%edi
ja     114d <decode_tpgs_state+0x3d>
mov    %ecx,%eax
lea    0xee0(%rip),%rdi
movslq (%rdi,%rax,4),%rax
add    %rdi,%rax
jmp    *%rax
lea    0xf10(%rip),%rax
jmp    1173 <decode_tpgs_state+0x63>
lea    0xf18(%rip),%rax
jmp    1173 <decode_tpgs_state+0x63>
lea    0xf24(%rip),%rax
jmp    1173 <decode_tpgs_state+0x63>
lea    0xf23(%rip),%rax
jmp    1173 <decode_tpgs_state+0x63>
lea    0xf4b(%rip),%rax
mov    %rsi,%rdi
mov    %edx,%esi
mov    %rax,%rdx
xor    %eax,%eax
jmp    1030 <my_snprintf@plt>
lea    0xf10(%rip),%rax
jmp    1173 <decode_tpgs_state+0x63>
lea    0xf0f(%rip),%rax
mov    %rsi,%rdi
mov    %edx,%esi
mov    %rax,%rdx
xor    %eax,%eax
jmp    1030 <my_snprintf@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"active/optimized\00"
@.str.1 = [21 x i8] c"active/non optimized\00"
@.str.2 = [8 x i8] c"standby\00"
@.str.3 = [12 x i8] c"unavailable\00"
@.str.4 = [8 x i8] c"offline\00"
@.str.5 = [29 x i8] c"transitioning between states\00"
@.str.6 = [14 x i8] c"unknown: 0x%x\00"
define i32 @decode_tpgs_state(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i32, i32* %5
switch i32 %8, label %33 [
i32 0, label %9
i32 1, label %13
i32 2, label %17
i32 3, label %21
i32 14, label %25
i32 15, label %29
]
9: ; preds = %3
%10 = load i8*, i8** %6
%11 = load i32, i32* %7
%12 = call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %10, i32 %11, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 %12, i32* %4
br label %38
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %14, i32 %15, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 %16, i32* %4
br label %38
17: ; preds = %3
%18 = load i8*, i8** %6
%19 = load i32, i32* %7
%20 = call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %18, i32 %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 %20, i32* %4
br label %38
21: ; preds = %3
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %22, i32 %23, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
store i32 %24, i32* %4
br label %38
25: ; preds = %3
%26 = load i8*, i8** %6
%27 = load i32, i32* %7
%28 = call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %26, i32 %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
store i32 %28, i32* %4
br label %38
29: ; preds = %3
%30 = load i8*, i8** %6
%31 = load i32, i32* %7
%32 = call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %30, i32 %31, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
store i32 %32, i32* %4
br label %38
33: ; preds = %3
%34 = load i8*, i8** %6
%35 = load i32, i32* %7
%36 = load i32, i32* %5
%37 = call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %34, i32 %35, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %36)
store i32 %37, i32* %4
br label %38
38: ; preds = %33, %29, %25, %21, %17, %13, %9
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
@.str = [17 x i8] c"active/optimized\00"
@.str.1 = [21 x i8] c"active/non optimized\00"
@.str.2 = [8 x i8] c"standby\00"
@.str.3 = [12 x i8] c"unavailable\00"
@.str.4 = [8 x i8] c"offline\00"
@.str.5 = [29 x i8] c"transitioning between states\00"
@.str.6 = [14 x i8] c"unknown: 0x%x\00"
define i32 @decode_tpgs_state(i32 %0, i8* %1, i32 %2) {
switch i32 %0, label %16 [
i32 0, label %4
i32 1, label %6
i32 2, label %8
i32 3, label %10
i32 14, label %12
i32 15, label %14
]
4: ; preds = %3
%5 = tail call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %18
6: ; preds = %3
%7 = tail call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %18
8: ; preds = %3
%9 = tail call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %18
10: ; preds = %3
%11 = tail call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %18
12: ; preds = %3
%13 = tail call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %18
14: ; preds = %3
%15 = tail call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %18
16: ; preds = %3
%17 = tail call i32 (i8*, i32, i8*, ...) @my_snprintf(i8* %1, i32 %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %0)
br label %18
18: ; preds = %16, %14, %12, %10, %8, %6, %4
%19 = phi i32 [ %17, %16 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ]
ret i32 %19
}