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

/* Variables and functions */
int const REG_BADBR;
int const REG_BADPAT;
int const REG_BADRPT;
int const REG_EBRACE;
int const REG_EBRACK;
int const REG_ECOLLATE;
int const REG_ECTYPE;
int const REG_EESCAPE;
int const REG_EPAREN;
int const REG_ERANGE;
int const REG_ESPACE;
int const REG_ESUBREG;
int const REG_NOMATCH;
int /*<<< orphan*/ printf(char *, char const *, char *, int const, char *,
                          size_t);
size_t regerror(int const, int /*<<< orphan*/ *, char *, int);
void _regex_regerror(char const *progname) {
  const int errors[] = {REG_NOMATCH, REG_BADPAT,  REG_ECOLLATE, REG_ECTYPE,
                        REG_EESCAPE, REG_ESUBREG, REG_EBRACK,   REG_EPAREN,
                        REG_EBRACE,  REG_BADBR,   REG_ERANGE,   REG_ESPACE,
                        REG_BADRPT};
  char buf[80];
  size_t size;
  size_t i;
  for (i = 0; i < sizeof(errors) / sizeof(*errors); i++) {
    size = regerror(errors[i], NULL, buf, sizeof(buf));
    printf("%s: Testing %s: % 2u \"%s\" (%zu)\n", progname, "regerror()",
           errors[i], buf, size);
  }
}


x86 assembly (clang, -O0):
<_regex_regerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2e4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2e8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2e22(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2e02(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e22(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2dee(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e12(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
movq   $0x0,-0xa0(%rbp)
cmpq   $0xd,-0xa0(%rbp)
0d
jae    1252 <_regex_regerror+0x132>
mov    -0xa0(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edi
lea    -0x90(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%esi
mov    $0x50,%ecx
call   1040 <regerror@plt>
mov    %rax,-0x98(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xa0(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%ecx
lea    -0x90(%rbp),%r8
mov    -0x98(%rbp),%r9
lea    0xe05(%rip),%rdi
lea    0xe1f(%rip),%rdx
call   1030 <printf@plt>
mov    -0xa0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xa0(%rbp)
jmp    11d6 <_regex_regerror+0xb6>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_regex_regerror>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rdi,%r14
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movl   $0x0,0x30(%rsp)
lea    0x40(%rsp),%r13
xor    %edi,%edi
xor    %esi,%esi
mov    %r13,%rdx
mov    $0x50,%ecx
call   1040 <regerror@plt>
lea    0xeca(%rip),%r15
lea    0xee4(%rip),%r12
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
xor    %ecx,%ecx
mov    %r13,%r8
mov    %rax,%r9
call   1030 <printf@plt>
mov    $0x1,%ebx
nopl   0x0(%rax)
mov    (%rsp,%rbx,4),%ebp
mov    %ebp,%edi
xor    %esi,%esi
mov    %r13,%rdx
mov    $0x50,%ecx
call   1040 <regerror@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    %ebp,%ecx
mov    %r13,%r8
mov    %rax,%r9
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0xd,%rbx
jne    1190 <_regex_regerror+0x70>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@REG_NOMATCH = constant i32 0
@REG_BADPAT = constant i32 0
@REG_ECOLLATE = constant i32 0
@REG_ECTYPE = constant i32 0
@REG_EESCAPE = constant i32 0
@REG_ESUBREG = constant i32 0
@REG_EBRACK = constant i32 0
@REG_EPAREN = constant i32 0
@REG_EBRACE = constant i32 0
@REG_BADBR = constant i32 0
@REG_ERANGE = constant i32 0
@REG_ESPACE = constant i32 0
@REG_BADRPT = constant i32 0
@.str = [33 x i8] c"%s: Testing %s: % 2u \22%s\22 (%zu)\0A\00"
@.str.1 = [11 x i8] c"regerror()\00"
define void @_regex_regerror(i8* %0) {
%2 = alloca i8*
%3 = alloca [13 x i32]
%4 = alloca [80 x i8]
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %2
%7 = getelementptr inbounds [13 x i32], [13 x i32]* %3, i64 0, i64 0
%8 = load i32, i32* @REG_NOMATCH
store i32 %8, i32* %7
%9 = getelementptr inbounds i32, i32* %7, i64 1
%10 = load i32, i32* @REG_BADPAT
store i32 %10, i32* %9
%11 = getelementptr inbounds i32, i32* %9, i64 1
%12 = load i32, i32* @REG_ECOLLATE
store i32 %12, i32* %11
%13 = getelementptr inbounds i32, i32* %11, i64 1
%14 = load i32, i32* @REG_ECTYPE
store i32 %14, i32* %13
%15 = getelementptr inbounds i32, i32* %13, i64 1
%16 = load i32, i32* @REG_EESCAPE
store i32 %16, i32* %15
%17 = getelementptr inbounds i32, i32* %15, i64 1
%18 = load i32, i32* @REG_ESUBREG
store i32 %18, i32* %17
%19 = getelementptr inbounds i32, i32* %17, i64 1
%20 = load i32, i32* @REG_EBRACK
store i32 %20, i32* %19
%21 = getelementptr inbounds i32, i32* %19, i64 1
%22 = load i32, i32* @REG_EPAREN
store i32 %22, i32* %21
%23 = getelementptr inbounds i32, i32* %21, i64 1
%24 = load i32, i32* @REG_EBRACE
store i32 %24, i32* %23
%25 = getelementptr inbounds i32, i32* %23, i64 1
%26 = load i32, i32* @REG_BADBR
store i32 %26, i32* %25
%27 = getelementptr inbounds i32, i32* %25, i64 1
%28 = load i32, i32* @REG_ERANGE
store i32 %28, i32* %27
%29 = getelementptr inbounds i32, i32* %27, i64 1
%30 = load i32, i32* @REG_ESPACE
store i32 %30, i32* %29
%31 = getelementptr inbounds i32, i32* %29, i64 1
%32 = load i32, i32* @REG_BADRPT
store i32 %32, i32* %31
store i64 0, i64* %6
br label %33
33: ; preds = %49, %1
%34 = load i64, i64* %6
%35 = icmp ult i64 %34, 13
br i1 %35, label %36, label %52
36: ; preds = %33
%37 = load i64, i64* %6
%38 = getelementptr inbounds [13 x i32], [13 x i32]* %3, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%41 = call i64 @regerror(i32 %39, i32* null, i8* %40, i32 80)
store i64 %41, i64* %5
%42 = load i8*, i8** %2
%43 = load i64, i64* %6
%44 = getelementptr inbounds [13 x i32], [13 x i32]* %3, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%47 = load i64, i64* %5
%48 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %42, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %45, i8* %46, i64 %47)
br label %49
49: ; preds = %36
%50 = load i64, i64* %6
%51 = add i64 %50, 1
store i64 %51, i64* %6
br label %33
52: ; preds = %33
ret void
}

LLVM IR (-O2):
@REG_NOMATCH = constant i32 0
@REG_BADPAT = constant i32 0
@REG_ECOLLATE = constant i32 0
@REG_ECTYPE = constant i32 0
@REG_EESCAPE = constant i32 0
@REG_ESUBREG = constant i32 0
@REG_EBRACK = constant i32 0
@REG_EPAREN = constant i32 0
@REG_EBRACE = constant i32 0
@REG_BADBR = constant i32 0
@REG_ERANGE = constant i32 0
@REG_ESPACE = constant i32 0
@REG_BADRPT = constant i32 0
@.str = [33 x i8] c"%s: Testing %s: % 2u \22%s\22 (%zu)\0A\00"
@.str.1 = [11 x i8] c"regerror()\00"
define void @_regex_regerror(i8* %0) {
%2 = alloca [13 x i32]
%3 = alloca [80 x i8]
%4 = bitcast [13 x i32]* %2 to i8*
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%6 = bitcast [13 x i32]* %2 to i8*
%7 = call i64 @regerror(i32 0, i32* null, i8* %5, i32 80)
%8 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* %5, i64 %7)
br label %9
9: ; preds = %1, %9
%10 = phi i64 [ 1, %1 ], [ %15, %9 ]
%11 = getelementptr inbounds [13 x i32], [13 x i32]* %2, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = call i64 @regerror(i32 %12, i32* null, i8* %5, i32 80)
%14 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* %5, i64 %13)
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, 13
br i1 %16, label %17, label %9
17: ; preds = %9
ret void
}