#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 */
#define REG_BADBR 140
#define REG_BADPAT 139
#define REG_BADRPT 138
#define REG_EBRACE 137
#define REG_EBRACK 136
#define REG_ECOLLATE 135
#define REG_ECTYPE 134
#define REG_EESCAPE 133
#define REG_EPAREN 132
#define REG_ERANGE 131
#define REG_ESPACE 130
#define REG_ESUBREG 129
#define REG_NOMATCH 128
const char *strregerror(int code) {
  static const struct {
    int code;
    const char *descr;
  } tab[] = {{REG_NOMATCH, "regexec() failed to match"},
             {REG_BADPAT, "invalid regular expression"},
             {REG_ECOLLATE, "invalid collating element"},
             {REG_ECTYPE, "invalid character class"},
             {REG_EESCAPE, "\\ applied to unescapable character"},
             {REG_ESUBREG, "invalid backreference number"},
             {REG_EBRACK, "brackets [ ] not balanced"},
             {REG_EPAREN, "parentheses ( ) not balanced"},
             {REG_EBRACE, "braces { } not balanced"},
             {REG_BADBR, "invalid repetition count(s) in { }"},
             {REG_ERANGE, "invalid character range in [ ]"},
             {REG_ESPACE, "ran out of memory"},
             {REG_BADRPT, "?, *, or + operand invalid"},
             {0, NULL}},
    *p;
  for (p = tab; p->descr != NULL; ++p)
    if (code == p->code)
      return p->descr;
  return "unknown error";
}


x86 assembly (clang, -O0):
<strregerror>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
lea    0x2c62(%rip),%rax
mov    %rax,0x2f13(%rip)
mov    0x2f0c(%rip),%rax
cmpq   $0x0,0x8(%rax)
je     1169 <strregerror+0x69>
mov    -0xc(%rbp),%eax
mov    0x2ef7(%rip),%rcx
cmp    (%rcx),%eax
jne    114d <strregerror+0x4d>
mov    0x2ee8(%rip),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1174 <strregerror+0x74>
jmp    1152 <strregerror+0x52>
mov    0x2ecf(%rip),%rax
add    $0x10,%rax
mov    %rax,0x2ec4(%rip)
jmp    1115 <strregerror+0x15>
lea    0xff5(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strregerror>:
add    $0xffffff80,%edi
cmp    $0xc,%edi
ja     111a <strregerror+0x1a>
movslq %edi,%rax
lea    0x1062(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
lea    0x1044(%rip),%rax
ret

LLVM IR (-O0):
%struct.anon = type { i32, i8* }
@strregerror.tab = internal constant [14 x %struct.anon] [%struct.anon { i32 128, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i32 0, i32 0) }, %struct.anon { i32 139, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i32 0, i32 0) }, %struct.anon { i32 135, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i32 0, i32 0) }, %struct.anon { i32 134, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i32 0, i32 0) }, %struct.anon { i32 133, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i32 0, i32 0) }, %struct.anon { i32 129, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i32 0, i32 0) }, %struct.anon { i32 136, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i32 0, i32 0) }, %struct.anon { i32 132, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i32 0, i32 0) }, %struct.anon { i32 137, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i32 0, i32 0) }, %struct.anon { i32 140, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i32 0, i32 0) }, %struct.anon { i32 131, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i32 0, i32 0) }, %struct.anon { i32 130, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i32 0, i32 0) }, %struct.anon { i32 138, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i32 0, i32 0) }, %struct.anon zeroinitializer]
@.str = [26 x i8] c"regexec() failed to match\00"
@.str.1 = [27 x i8] c"invalid regular expression\00"
@.str.2 = [26 x i8] c"invalid collating element\00"
@.str.3 = [24 x i8] c"invalid character class\00"
@.str.4 = [35 x i8] c"\\ applied to unescapable character\00"
@.str.5 = [29 x i8] c"invalid backreference number\00"
@.str.6 = [26 x i8] c"brackets [ ] not balanced\00"
@.str.7 = [29 x i8] c"parentheses ( ) not balanced\00"
@.str.8 = [24 x i8] c"braces { } not balanced\00"
@.str.9 = [35 x i8] c"invalid repetition count(s) in { }\00"
@.str.10 = [31 x i8] c"invalid character range in [ ]\00"
@.str.11 = [18 x i8] c"ran out of memory\00"
@.str.12 = [27 x i8] c"?, *, or + operand invalid\00"
@strregerror.p = internal global %struct.anon* null
@.str.13 = [14 x i8] c"unknown error\00"
define i8* @strregerror(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
store %struct.anon* getelementptr inbounds ([14 x %struct.anon], [14 x %struct.anon]* @strregerror.tab, i64 0, i64 0), %struct.anon** @strregerror.p
br label %4
4: ; preds = %20, %1
%5 = load %struct.anon*, %struct.anon** @strregerror.p
%6 = getelementptr inbounds %struct.anon, %struct.anon* %5, i32 0, i32 1
%7 = load i8*, i8** %6
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %23
9: ; preds = %4
%10 = load i32, i32* %3
%11 = load %struct.anon*, %struct.anon** @strregerror.p
%12 = getelementptr inbounds %struct.anon, %struct.anon* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = icmp eq i32 %10, %13
br i1 %14, label %15, label %19
15: ; preds = %9
%16 = load %struct.anon*, %struct.anon** @strregerror.p
%17 = getelementptr inbounds %struct.anon, %struct.anon* %16, i32 0, i32 1
%18 = load i8*, i8** %17
store i8* %18, i8** %2
br label %24
19: ; preds = %9
br label %20
20: ; preds = %19
%21 = load %struct.anon*, %struct.anon** @strregerror.p
%22 = getelementptr inbounds %struct.anon, %struct.anon* %21, i32 1
store %struct.anon* %22, %struct.anon** @strregerror.p
br label %4
23: ; preds = %4
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), i8** %2
br label %24
24: ; preds = %23, %15
%25 = load i8*, i8** %2
ret i8* %25
}

LLVM IR (-O2):
@.str = [26 x i8] c"regexec() failed to match\00"
@.str.1 = [27 x i8] c"invalid regular expression\00"
@.str.2 = [26 x i8] c"invalid collating element\00"
@.str.3 = [24 x i8] c"invalid character class\00"
@.str.4 = [35 x i8] c"\\ applied to unescapable character\00"
@.str.5 = [29 x i8] c"invalid backreference number\00"
@.str.6 = [26 x i8] c"brackets [ ] not balanced\00"
@.str.7 = [29 x i8] c"parentheses ( ) not balanced\00"
@.str.8 = [24 x i8] c"braces { } not balanced\00"
@.str.9 = [35 x i8] c"invalid repetition count(s) in { }\00"
@.str.10 = [31 x i8] c"invalid character range in [ ]\00"
@.str.11 = [18 x i8] c"ran out of memory\00"
@.str.12 = [27 x i8] c"?, *, or + operand invalid\00"
@.str.13 = [14 x i8] c"unknown error\00"
@reltable.strregerror = [13 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str to i64), i64 ptrtoint ([13 x i32]* @reltable.strregerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @.str.5 to i64), i64 ptrtoint ([13 x i32]* @reltable.strregerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([18 x i8]* @.str.11 to i64), i64 ptrtoint ([13 x i32]* @reltable.strregerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([31 x i8]* @.str.10 to i64), i64 ptrtoint ([13 x i32]* @reltable.strregerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([29 x i8]* @.str.7 to i64), i64 ptrtoint ([13 x i32]* @reltable.strregerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @.str.4 to i64), i64 ptrtoint ([13 x i32]* @reltable.strregerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.3 to i64), i64 ptrtoint ([13 x i32]* @reltable.strregerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.2 to i64), i64 ptrtoint ([13 x i32]* @reltable.strregerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str.6 to i64), i64 ptrtoint ([13 x i32]* @reltable.strregerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.8 to i64), i64 ptrtoint ([13 x i32]* @reltable.strregerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.12 to i64), i64 ptrtoint ([13 x i32]* @reltable.strregerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([27 x i8]* @.str.1 to i64), i64 ptrtoint ([13 x i32]* @reltable.strregerror to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([35 x i8]* @.str.9 to i64), i64 ptrtoint ([13 x i32]* @reltable.strregerror to i64)) to i32)]
define i8* @strregerror(i32 %0) {
%2 = add i32 %0, -128
%3 = icmp ult i32 %2, 13
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([13 x i32]* @reltable.strregerror to i8*), i64 %6)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.13, i64 0, i64 0), %1 ]
ret i8* %9
}