#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 */
typedef int /*<<< orphan*/ cdiUnits;

/* Variables and functions */
char *cdiUnitNamePtr(int cdi_unit) {
  char *cdiUnits[] = {
      "undefined", "Pa", "hPa", "mm", "cm", "dm", "m",
  };
  char *name;
  int size = (int)(sizeof(cdiUnits) / sizeof(char *));
  if (cdi_unit > 0 && cdi_unit < size)
    name = cdiUnits[cdi_unit];
  else
    name = NULL;
  return (name);
}


x86 assembly (clang, -O0):
<cdiUnitNamePtr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0x2cba(%rip),%rsi
mov    $0x38,%edx
call   1030 <memcpy@plt>
movl   $0x7,-0x4c(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    115f <cdiUnitNamePtr+0x4f>
mov    -0x4(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    115f <cdiUnitNamePtr+0x4f>
movslq -0x4(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rax
mov    %rax,-0x48(%rbp)
jmp    1167 <cdiUnitNamePtr+0x57>
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdiUnitNamePtr>:
lea    -0x1(%rdi),%eax
cmp    $0x5,%eax
ja     1119 <cdiUnitNamePtr+0x19>
mov    %edi,%eax
lea    0xf07(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
@.str = [10 x i8] c"undefined\00"
@.str.1 = [3 x i8] c"Pa\00"
@.str.2 = [4 x i8] c"hPa\00"
@.str.3 = [3 x i8] c"mm\00"
@.str.4 = [3 x i8] c"cm\00"
@.str.5 = [3 x i8] c"dm\00"
@.str.6 = [2 x i8] c"m\00"
@__const.cdiUnitNamePtr.cdiUnits = [7 x i8*] [i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i32 0, i32 0)]
define i8* @cdiUnitNamePtr(i32 %0) {
%2 = alloca i32
%3 = alloca [7 x i8*]
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %2
%6 = bitcast [7 x i8*]* %3 to i8*
store i32 7, i32* %5
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %1
%10 = load i32, i32* %2
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [7 x i8*], [7 x i8*]* %3, i64 0, i64 %15
%17 = load i8*, i8** %16
store i8* %17, i8** %4
br label %19
18: ; preds = %9, %1
store i8* null, i8** %4
br label %19
19: ; preds = %18, %13
%20 = load i8*, i8** %4
ret i8* %20
}

LLVM IR (-O2):
@.str = [10 x i8] c"undefined\00"
@.str.1 = [3 x i8] c"Pa\00"
@.str.2 = [4 x i8] c"hPa\00"
@.str.3 = [3 x i8] c"mm\00"
@.str.4 = [3 x i8] c"cm\00"
@.str.5 = [3 x i8] c"dm\00"
@.str.6 = [2 x i8] c"m\00"
@reltable.cdiUnitNamePtr = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.cdiUnitNamePtr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.cdiUnitNamePtr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.cdiUnitNamePtr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([7 x i32]* @reltable.cdiUnitNamePtr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.4 to i64), i64 ptrtoint ([7 x i32]* @reltable.cdiUnitNamePtr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.cdiUnitNamePtr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.6 to i64), i64 ptrtoint ([7 x i32]* @reltable.cdiUnitNamePtr to i64)) to i32)]
define i8* @cdiUnitNamePtr(i32 %0) {
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 6
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = zext i32 %0 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.cdiUnitNamePtr to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ null, %1 ]
ret i8* %9
}