#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 */
char *decode_cc(unsigned char, unsigned char);
char *hpm_decode_cc(unsigned char cmd, unsigned char cc) {
  char *pstr;
  switch (cc) {
  case 0x80:
    pstr = "Command in progress";
    break;
  case 0x81:
    pstr = "HPM not supported";
    break;
  case 0x82:
    pstr = "Checksum error";
    break;
  case 0x83:
    pstr = "Firmware mismatch";
    break;
  default:
    pstr = decode_cc(cmd, cc);
  }
  return (pstr);
}


x86 assembly (clang, -O0):
<hpm_decode_cc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     118e <hpm_decode_cc+0x7e>
mov    -0x18(%rbp),%rax
lea    0xebb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebb(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11a1 <hpm_decode_cc+0x91>
lea    0xebf(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11a1 <hpm_decode_cc+0x91>
lea    0xec1(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11a1 <hpm_decode_cc+0x91>
lea    0xec0(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    11a1 <hpm_decode_cc+0x91>
mov    -0x1(%rbp),%al
movzbl %al,%edi
movzbl -0x2(%rbp),%esi
call   1030 <decode_cc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hpm_decode_cc>:
mov    %esi,%eax
xor    $0x80,%al
cmp    $0x4,%al
jae    112b <hpm_decode_cc+0x1b>
movsbq %al,%rax
lea    0xf25(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
movzbl %dil,%edi
movzbl %sil,%esi
jmp    1030 <decode_cc@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Command in progress\00"
@.str.1 = [18 x i8] c"HPM not supported\00"
@.str.2 = [15 x i8] c"Checksum error\00"
@.str.3 = [18 x i8] c"Firmware mismatch\00"
define i8* @hpm_decode_cc(i8 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8*
store i8 %0, i8* %3
store i8 %1, i8* %4
%6 = load i8, i8* %4
%7 = zext i8 %6 to i32
switch i32 %7, label %12 [
i32 128, label %8
i32 129, label %9
i32 130, label %10
i32 131, label %11
]
8: ; preds = %2
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8** %5
br label %16
9: ; preds = %2
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8** %5
br label %16
10: ; preds = %2
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %5
br label %16
11: ; preds = %2
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8** %5
br label %16
12: ; preds = %2
%13 = load i8, i8* %3
%14 = load i8, i8* %4
%15 = call i8* @decode_cc(i8 zeroext %13, i8 zeroext %14)
store i8* %15, i8** %5
br label %16
16: ; preds = %12, %11, %10, %9, %8
%17 = load i8*, i8** %5
ret i8* %17
}

LLVM IR (-O2):
@.str = [20 x i8] c"Command in progress\00"
@.str.1 = [18 x i8] c"HPM not supported\00"
@.str.2 = [15 x i8] c"Checksum error\00"
@.str.3 = [18 x i8] c"Firmware mismatch\00"
@reltable.hpm_decode_cc = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([20 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.hpm_decode_cc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.hpm_decode_cc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.hpm_decode_cc to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.hpm_decode_cc to i64)) to i32)]
define i8* @hpm_decode_cc(i8 zeroext %0, i8 zeroext %1) {
%3 = xor i8 %1, -128
%4 = icmp ult i8 %3, 4
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i8* @decode_cc(i8 zeroext %0, i8 zeroext %1)
br label %11
7: ; preds = %2
%8 = sext i8 %3 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.hpm_decode_cc to i8*), i64 %9)
br label %11
11: ; preds = %7, %5
%12 = phi i8* [ %6, %5 ], [ %10, %7 ]
ret i8* %12
}