#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 *get_sensor_type_string(int type) {
  static char buf[32];
  if (type == 0x01)
    return "Temperature";
  if (type == 0x04)
    return "Power";
  if (type == 0x0F)
    return "Voltage";
  if (type == 0x10)
    return "Current";
  if (type == 0x03)
    return "Luminance";
  sprintf(buf, "(unknown sensor type %d)", type);
  return buf;
}


x86 assembly (clang, -O0):
<get_sensor_type_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1135 <get_sensor_type_string+0x25>
lea    0xed4(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11be <get_sensor_type_string+0xae>
cmpl   $0x4,-0xc(%rbp)
jne    114f <get_sensor_type_string+0x3f>
lea    0xec6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11be <get_sensor_type_string+0xae>
cmpl   $0xf,-0xc(%rbp)
jne    1169 <get_sensor_type_string+0x59>
lea    0xeb2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11be <get_sensor_type_string+0xae>
cmpl   $0x10,-0xc(%rbp)
jne    1183 <get_sensor_type_string+0x73>
lea    0xea0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11be <get_sensor_type_string+0xae>
cmpl   $0x3,-0xc(%rbp)
jne    119d <get_sensor_type_string+0x8d>
lea    0xe8e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11be <get_sensor_type_string+0xae>
mov    -0xc(%rbp),%edx
lea    0x2e99(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2e86(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_sensor_type_string>:
push   %rbx
mov    %edi,%edx
lea    -0x1(%rdx),%eax
cmp    $0xf,%eax
ja     113b <get_sensor_type_string+0x2b>
lea    0xf1e(%rip),%rbx
lea    0xed7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf29(%rip),%rbx
jmp    116c <get_sensor_type_string+0x5c>
lea    0x2efe(%rip),%rbx
lea    0xf23(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
jmp    116c <get_sensor_type_string+0x5c>
lea    0xef2(%rip),%rbx
jmp    116c <get_sensor_type_string+0x5c>
lea    0xeef(%rip),%rbx
jmp    116c <get_sensor_type_string+0x5c>
lea    0xeee(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@get_sensor_type_string.buf = internal global [32 x i8] zeroinitializer
@.str = [12 x i8] c"Temperature\00"
@.str.1 = [6 x i8] c"Power\00"
@.str.2 = [8 x i8] c"Voltage\00"
@.str.3 = [8 x i8] c"Current\00"
@.str.4 = [10 x i8] c"Luminance\00"
@.str.5 = [25 x i8] c"(unknown sensor type %d)\00"
define i8* @get_sensor_type_string(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %7
6: ; preds = %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %2
br label %26
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 4
br i1 %9, label %10, label %11
10: ; preds = %7
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %26
11: ; preds = %7
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 15
br i1 %13, label %14, label %15
14: ; preds = %11
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %26
15: ; preds = %11
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 16
br i1 %17, label %18, label %19
18: ; preds = %15
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %26
19: ; preds = %15
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, 3
br i1 %21, label %22, label %23
22: ; preds = %19
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %26
23: ; preds = %19
%24 = load i32, i32* %3
%25 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @get_sensor_type_string.buf, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %24)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @get_sensor_type_string.buf, i64 0, i64 0), i8** %2
br label %26
26: ; preds = %23, %22, %18, %14, %10, %6
%27 = load i8*, i8** %2
ret i8* %27
}

LLVM IR (-O2):
@get_sensor_type_string.buf = internal global [32 x i8] zeroinitializer
@.str = [12 x i8] c"Temperature\00"
@.str.1 = [6 x i8] c"Power\00"
@.str.2 = [8 x i8] c"Voltage\00"
@.str.3 = [8 x i8] c"Current\00"
@.str.4 = [10 x i8] c"Luminance\00"
@.str.5 = [25 x i8] c"(unknown sensor type %d)\00"
define i8* @get_sensor_type_string(i32 %0) {
switch i32 %0, label %6 [
i32 1, label %8
i32 4, label %2
i32 15, label %3
i32 16, label %4
i32 3, label %5
]
2: ; preds = %1
br label %8
3: ; preds = %1
br label %8
4: ; preds = %1
br label %8
5: ; preds = %1
br label %8
6: ; preds = %1
%7 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @get_sensor_type_string.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i32 %0)
br label %8
8: ; preds = %1, %6, %5, %4, %3, %2
%9 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %5 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @get_sensor_type_string.buf, i64 0, i64 0), %6 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %9
}