#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 */
scalar_t__ is_bad_status(int);
const char *xpb_status_tostring(int status) {
  static const char *strmap[] = {"success",
                                 "bad number of rectangles",
                                 "bad padding number",
                                 "bad rectangle x-size",
                                 "bad rectangle y-size",
                                 "bad x-position",
                                 "bad y-position",
                                 "bad foreground color",
                                 "bad background color",
                                 "out of memory",
                                 "bar too large",
                                 "bad pointer"};
  if (is_bad_status(status)) {
    return NULL;
  }
  return strmap[status];
}


x86 assembly (clang, -O0):
<xpb_status_tostring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <is_bad_status@plt>
cmp    $0x0,%rax
je     113a <xpb_status_tostring+0x2a>
movq   $0x0,-0x8(%rbp)
jmp    114d <xpb_status_tostring+0x3d>
movslq -0xc(%rbp),%rcx
lea    0x2eeb(%rip),%rax
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xpb_status_tostring>:
push   %rbx
mov    %edi,%ebx
call   1030 <is_bad_status@plt>
test   %rax,%rax
je     1121 <xpb_status_tostring+0x11>
xor    %eax,%eax
pop    %rbx
ret
movslq %ebx,%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@xpb_status_tostring.strmap = internal global [12 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i32 0, i32 0)]
@.str = [8 x i8] c"success\00"
@.str.1 = [25 x i8] c"bad number of rectangles\00"
@.str.2 = [19 x i8] c"bad padding number\00"
@.str.3 = [21 x i8] c"bad rectangle x-size\00"
@.str.4 = [21 x i8] c"bad rectangle y-size\00"
@.str.5 = [15 x i8] c"bad x-position\00"
@.str.6 = [15 x i8] c"bad y-position\00"
@.str.7 = [21 x i8] c"bad foreground color\00"
@.str.8 = [21 x i8] c"bad background color\00"
@.str.9 = [14 x i8] c"out of memory\00"
@.str.10 = [14 x i8] c"bar too large\00"
@.str.11 = [12 x i8] c"bad pointer\00"
define i8* @xpb_status_tostring(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i64 @is_bad_status(i32 %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* null, i8** %2
br label %13
8: ; preds = %1
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [12 x i8*], [12 x i8*]* @xpb_status_tostring.strmap, i64 0, i64 %10
%12 = load i8*, i8** %11
store i8* %12, i8** %2
br label %13
13: ; preds = %8, %7
%14 = load i8*, i8** %2
ret i8* %14
}

LLVM IR (-O2):
@reltable.xpb_status_tostring = internal unnamed_addr constant [12 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([12 x i32]* @reltable.xpb_status_tostring to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([25 x i8]* @.str.1 to i64), i64 ptrtoint ([12 x i32]* @reltable.xpb_status_tostring to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.2 to i64), i64 ptrtoint ([12 x i32]* @reltable.xpb_status_tostring to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.3 to i64), i64 ptrtoint ([12 x i32]* @reltable.xpb_status_tostring to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.4 to i64), i64 ptrtoint ([12 x i32]* @reltable.xpb_status_tostring to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.5 to i64), i64 ptrtoint ([12 x i32]* @reltable.xpb_status_tostring to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.6 to i64), i64 ptrtoint ([12 x i32]* @reltable.xpb_status_tostring to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.7 to i64), i64 ptrtoint ([12 x i32]* @reltable.xpb_status_tostring to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([21 x i8]* @.str.8 to i64), i64 ptrtoint ([12 x i32]* @reltable.xpb_status_tostring to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.9 to i64), i64 ptrtoint ([12 x i32]* @reltable.xpb_status_tostring to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.10 to i64), i64 ptrtoint ([12 x i32]* @reltable.xpb_status_tostring to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.11 to i64), i64 ptrtoint ([12 x i32]* @reltable.xpb_status_tostring to i64)) to i32)]
@.str = [8 x i8] c"success\00"
@.str.1 = [25 x i8] c"bad number of rectangles\00"
@.str.2 = [19 x i8] c"bad padding number\00"
@.str.3 = [21 x i8] c"bad rectangle x-size\00"
@.str.4 = [21 x i8] c"bad rectangle y-size\00"
@.str.5 = [15 x i8] c"bad x-position\00"
@.str.6 = [15 x i8] c"bad y-position\00"
@.str.7 = [21 x i8] c"bad foreground color\00"
@.str.8 = [21 x i8] c"bad background color\00"
@.str.9 = [14 x i8] c"out of memory\00"
@.str.10 = [14 x i8] c"bar too large\00"
@.str.11 = [12 x i8] c"bad pointer\00"
define i8* @xpb_status_tostring(i32 %0) {
%2 = tail call i64 @is_bad_status(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %0 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([12 x i32]* @reltable.xpb_status_tostring to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ null, %1 ]
ret i8* %9
}