#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*/ regex_t;

/* Variables and functions */
int /*<<< orphan*/ REG_EXTENDED;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ printf(char *, char const *, int, char *);
int regcomp(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/);
size_t regerror(int, int /*<<< orphan*/ *, char *, size_t);
void create_reg_exp(regex_t *cre, const char *re) {
  int errcode;
  if ((errcode = regcomp(cre, re, REG_EXTENDED))) {
    size_t length = regerror(errcode, cre, NULL, 0);
    char *buffer = (char *)malloc(length + 1);
    regerror(errcode, cre, buffer, length);
    printf("Error in regular expression: %s\nError # %d: %s\n", re, errcode,
           buffer);
    free(buffer);
    exit(0);
  }
}


x86 assembly (clang, -O0):
<create_reg_exp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e61(%rip),%rax
mov    (%rax),%edx
call   1050 <regcomp@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11f5 <create_reg_exp+0x95>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1060 <regerror@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x1,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1060 <regerror@plt>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x28(%rbp),%rcx
lea    0xe20(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1080 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_reg_exp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e6b(%rip),%rax
mov    (%rax),%edx
call   1050 <regcomp@plt>
test   %eax,%eax
jne    1189 <create_reg_exp+0x29>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1060 <regerror@plt>
mov    %rax,%r15
lea    0x1(%rax),%rdi
call   1070 <malloc@plt>
mov    %rax,%r12
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
mov    %r15,%rcx
call   1060 <regerror@plt>
lea    0xe41(%rip),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %r12,%rcx
call   1040 <printf@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@REG_EXTENDED = global i32 0
@.str = [48 x i8] c"Error in regular expression: %s\0AError # %d: %s\0A\00"
define void @create_reg_exp(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%8 = load i32*, i32** %3
%9 = load i8*, i8** %4
%10 = load i32, i32* @REG_EXTENDED
%11 = call i32 @regcomp(i32* %8, i8* %9, i32 %10)
store i32 %11, i32* %5
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %33
13: ; preds = %2
%14 = load i32, i32* %5
%15 = load i32*, i32** %3
%16 = call i64 @regerror(i32 %14, i32* %15, i8* null, i64 0)
store i64 %16, i64* %6
%17 = load i64, i64* %6
%18 = add i64 %17, 1
%19 = call i64 @malloc(i64 %18)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %7
%21 = load i32, i32* %5
%22 = load i32*, i32** %3
%23 = load i8*, i8** %7
%24 = load i64, i64* %6
%25 = call i64 @regerror(i32 %21, i32* %22, i8* %23, i64 %24)
%26 = load i8*, i8** %4
%27 = load i32, i32* %5
%28 = load i8*, i8** %7
%29 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %26, i32 %27, i8* %28)
%30 = load i8*, i8** %7
%31 = call i32 @free(i8* %30)
%32 = call i32 @exit(i32 0)
unreachable
33: ; preds = %2
ret void
}

LLVM IR (-O2):
@REG_EXTENDED = global i32 0
@.str = [48 x i8] c"Error in regular expression: %s\0AError # %d: %s\0A\00"
define void @create_reg_exp(i32* %0, i8* %1) {
%3 = load i32, i32* @REG_EXTENDED
%4 = tail call i32 @regcomp(i32* %0, i8* %1, i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %15, label %6
6: ; preds = %2
%7 = tail call i64 @regerror(i32 %4, i32* %0, i8* null, i64 0)
%8 = add i64 %7, 1
%9 = tail call i64 @malloc(i64 %8)
%10 = inttoptr i64 %9 to i8*
%11 = tail call i64 @regerror(i32 %4, i32* %0, i8* %10, i64 %7)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i8* %1, i32 %4, i8* %10)
%13 = tail call i32 @free(i8* %10)
%14 = tail call i32 @exit(i32 0)
unreachable
15: ; preds = %2
ret void
}