#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_scale_string(int type, int scale) {
  static char buf[32];
  if (type == 0x01) {
    if (scale == 0)
      return "C";
    if (scale == 1)
      return "F";
  }
  if (type == 0x04) {
    if (scale == 0)
      return "W";
    if (scale == 1)
      return "Btu/h";
  }
  if (type == 0x0F) {
    if (scale == 0)
      return "V";
    if (scale == 1)
      return "mV";
  }
  if (type == 0x10) {
    if (scale == 0)
      return "A";
    if (scale == 1)
      return "mA";
  }
  if (type == 0x03) {
    if (scale == 1)
      return "Lux";
  }
  sprintf(buf, "(unknown meter scale %d)", scale);
  return buf;
}


x86 assembly (clang, -O0):
<get_sensor_scale_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1161 <get_sensor_scale_string+0x51>
cmpl   $0x0,-0x10(%rbp)
jne    1142 <get_sensor_scale_string+0x32>
lea    0xec7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1274 <get_sensor_scale_string+0x164>
cmpl   $0x1,-0x10(%rbp)
jne    115c <get_sensor_scale_string+0x4c>
lea    0xeaf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1274 <get_sensor_scale_string+0x164>
jmp    1161 <get_sensor_scale_string+0x51>
cmpl   $0x4,-0xc(%rbp)
jne    11a4 <get_sensor_scale_string+0x94>
cmpl   $0x0,-0x10(%rbp)
jne    1185 <get_sensor_scale_string+0x75>
lea    0xe88(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1274 <get_sensor_scale_string+0x164>
cmpl   $0x1,-0x10(%rbp)
jne    119f <get_sensor_scale_string+0x8f>
lea    0xe70(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1274 <get_sensor_scale_string+0x164>
jmp    11a4 <get_sensor_scale_string+0x94>
cmpl   $0xf,-0xc(%rbp)
jne    11e7 <get_sensor_scale_string+0xd7>
cmpl   $0x0,-0x10(%rbp)
jne    11c8 <get_sensor_scale_string+0xb8>
lea    0xe4e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1274 <get_sensor_scale_string+0x164>
cmpl   $0x1,-0x10(%rbp)
jne    11e2 <get_sensor_scale_string+0xd2>
lea    0xe33(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1274 <get_sensor_scale_string+0x164>
jmp    11e7 <get_sensor_scale_string+0xd7>
cmpl   $0x10,-0xc(%rbp)
jne    122a <get_sensor_scale_string+0x11a>
cmpl   $0x0,-0x10(%rbp)
jne    120b <get_sensor_scale_string+0xfb>
lea    0xe0e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1274 <get_sensor_scale_string+0x164>
cmpl   $0x1,-0x10(%rbp)
jne    1225 <get_sensor_scale_string+0x115>
lea    0xdf3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1274 <get_sensor_scale_string+0x164>
jmp    122a <get_sensor_scale_string+0x11a>
cmpl   $0x3,-0xc(%rbp)
jne    1253 <get_sensor_scale_string+0x143>
cmpl   $0x1,-0x10(%rbp)
jne    124e <get_sensor_scale_string+0x13e>
lea    0xdcd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1274 <get_sensor_scale_string+0x164>
jmp    1253 <get_sensor_scale_string+0x143>
mov    -0x10(%rbp),%edx
lea    0x2de3(%rip),%rdi
lea    0xdb2(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2dd0(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_sensor_scale_string>:
push   %rbx
mov    %esi,%edx
lea    -0x1(%rdi),%eax
cmp    $0xf,%eax
ja     1161 <get_sensor_scale_string+0x51>
lea    0xede(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
test   %edx,%edx
je     11a1 <get_sensor_scale_string+0x91>
cmp    $0x1,%edx
jne    1186 <get_sensor_scale_string+0x76>
lea    0xf07(%rip),%rbx
jmp    119c <get_sensor_scale_string+0x8c>
test   %edx,%edx
je     11aa <get_sensor_scale_string+0x9a>
cmp    $0x1,%edx
jne    1186 <get_sensor_scale_string+0x76>
lea    0xef9(%rip),%rbx
jmp    119c <get_sensor_scale_string+0x8c>
test   %edx,%edx
je     11b3 <get_sensor_scale_string+0xa3>
cmp    $0x1,%edx
jne    1186 <get_sensor_scale_string+0x76>
lea    0xeed(%rip),%rbx
jmp    119c <get_sensor_scale_string+0x8c>
cmp    $0x3,%edi
jne    1186 <get_sensor_scale_string+0x76>
cmp    $0x1,%edx
jne    1186 <get_sensor_scale_string+0x76>
lea    0xee0(%rip),%rbx
jmp    119c <get_sensor_scale_string+0x8c>
test   %edx,%edx
je     11bc <get_sensor_scale_string+0xac>
cmp    $0x1,%edx
jne    1186 <get_sensor_scale_string+0x76>
lea    0xecb(%rip),%rbx
jmp    119c <get_sensor_scale_string+0x8c>
lea    0x2eb3(%rip),%rbx
lea    0xec2(%rip),%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret
lea    0xe98(%rip),%rbx
jmp    119c <get_sensor_scale_string+0x8c>
lea    0xe93(%rip),%rbx
jmp    119c <get_sensor_scale_string+0x8c>
lea    0xe93(%rip),%rbx
jmp    119c <get_sensor_scale_string+0x8c>
lea    0xe8d(%rip),%rbx
jmp    119c <get_sensor_scale_string+0x8c>

LLVM IR (-O0):
@get_sensor_scale_string.buf = internal global [32 x i8] zeroinitializer
@.str = [2 x i8] c"C\00"
@.str.1 = [2 x i8] c"F\00"
@.str.2 = [2 x i8] c"W\00"
@.str.3 = [6 x i8] c"Btu/h\00"
@.str.4 = [2 x i8] c"V\00"
@.str.5 = [3 x i8] c"mV\00"
@.str.6 = [2 x i8] c"A\00"
@.str.7 = [3 x i8] c"mA\00"
@.str.8 = [4 x i8] c"Lux\00"
@.str.9 = [25 x i8] c"(unknown meter scale %d)\00"
define i8* @get_sensor_scale_string(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %3
br label %64
12: ; preds = %8
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %16
15: ; preds = %12
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %64
16: ; preds = %12
br label %17
17: ; preds = %16, %2
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 4
br i1 %19, label %20, label %29
20: ; preds = %17
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %64
24: ; preds = %20
%25 = load i32, i32* %5
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %28
27: ; preds = %24
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %64
28: ; preds = %24
br label %29
29: ; preds = %28, %17
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 15
br i1 %31, label %32, label %41
32: ; preds = %29
%33 = load i32, i32* %5
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %64
36: ; preds = %32
%37 = load i32, i32* %5
%38 = icmp eq i32 %37, 1
br i1 %38, label %39, label %40
39: ; preds = %36
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %64
40: ; preds = %36
br label %41
41: ; preds = %40, %29
%42 = load i32, i32* %4
%43 = icmp eq i32 %42, 16
br i1 %43, label %44, label %53
44: ; preds = %41
%45 = load i32, i32* %5
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %44
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %64
48: ; preds = %44
%49 = load i32, i32* %5
%50 = icmp eq i32 %49, 1
br i1 %50, label %51, label %52
51: ; preds = %48
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %64
52: ; preds = %48
br label %53
53: ; preds = %52, %41
%54 = load i32, i32* %4
%55 = icmp eq i32 %54, 3
br i1 %55, label %56, label %61
56: ; preds = %53
%57 = load i32, i32* %5
%58 = icmp eq i32 %57, 1
br i1 %58, label %59, label %60
59: ; preds = %56
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %64
60: ; preds = %56
br label %61
61: ; preds = %60, %53
%62 = load i32, i32* %5
%63 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @get_sensor_scale_string.buf, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i32 %62)
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @get_sensor_scale_string.buf, i64 0, i64 0), i8** %3
br label %64
64: ; preds = %61, %59, %51, %47, %39, %35, %27, %23, %15, %11
%65 = load i8*, i8** %3
ret i8* %65
}

LLVM IR (-O2):
@get_sensor_scale_string.buf = internal global [32 x i8] zeroinitializer
@.str = [2 x i8] c"C\00"
@.str.1 = [2 x i8] c"F\00"
@.str.2 = [2 x i8] c"W\00"
@.str.3 = [6 x i8] c"Btu/h\00"
@.str.4 = [2 x i8] c"V\00"
@.str.5 = [3 x i8] c"mV\00"
@.str.6 = [2 x i8] c"A\00"
@.str.7 = [3 x i8] c"mA\00"
@.str.8 = [4 x i8] c"Lux\00"
@.str.9 = [25 x i8] c"(unknown meter scale %d)\00"
define i8* @get_sensor_scale_string(i32 %0, i32 %1) {
switch i32 %0, label %11 [
i32 1, label %3
i32 4, label %5
i32 15, label %7
i32 16, label %9
]
3: ; preds = %2
switch i32 %1, label %15 [
i32 0, label %17
i32 1, label %4
]
4: ; preds = %3
br label %17
5: ; preds = %2
switch i32 %1, label %15 [
i32 0, label %17
i32 1, label %6
]
6: ; preds = %5
br label %17
7: ; preds = %2
switch i32 %1, label %15 [
i32 0, label %17
i32 1, label %8
]
8: ; preds = %7
br label %17
9: ; preds = %2
switch i32 %1, label %15 [
i32 0, label %17
i32 1, label %10
]
10: ; preds = %9
br label %17
11: ; preds = %2
%12 = icmp eq i32 %0, 3
%13 = icmp eq i32 %1, 1
%14 = and i1 %12, %13
br i1 %14, label %17, label %15
15: ; preds = %9, %3, %5, %7, %11
%16 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @get_sensor_scale_string.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i32 %1)
br label %17
17: ; preds = %11, %9, %7, %5, %3, %15, %10, %8, %6, %4
%18 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), %6 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %8 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), %10 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @get_sensor_scale_string.buf, i64 0, i64 0), %15 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), %5 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), %9 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), %11 ]
ret i8* %18
}