#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*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ malloc(int);
int regcomp(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ stderr;
void c_regcomp_(regex_t **preg, char *regex, int *cflags, int *errc,
                int lregex) {
  if ((*preg = (regex_t *)malloc(sizeof(regex_t))) == NULL) {
    fprintf(stderr, "Memory allocation failed in posix90::c_regcomp_\n");
  }
  *errc = regcomp(*preg, regex, *cflags);
}


x86 assembly (clang, -O0):
<c_regcomp_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    -0x8(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    117c <c_regcomp_+0x4c>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
call   1030 <regcomp@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_regcomp_>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x4,%edi
call   1050 <malloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
jne    116e <c_regcomp_+0x3e>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%rax
mov    (%r12),%edx
mov    %rax,%rdi
mov    %r15,%rsi
call   1030 <regcomp@plt>
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [49 x i8] c"Memory allocation failed in posix90::c_regcomp_\0A\00"
define void @c_regcomp_(i32** %0, i8* %1, i32* %2, i32* %3, i32 %4) {
%6 = alloca i32**
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
store i32** %0, i32*** %6
store i8* %1, i8** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32 %4, i32* %10
%11 = call i64 @malloc(i32 4)
%12 = inttoptr i64 %11 to i32*
%13 = load i32**, i32*** %6
store i32* %12, i32** %13
%14 = icmp eq i32* %12, null
br i1 %14, label %15, label %18
15: ; preds = %5
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %15, %5
%19 = load i32**, i32*** %6
%20 = load i32*, i32** %19
%21 = load i8*, i8** %7
%22 = load i32*, i32** %8
%23 = load i32, i32* %22
%24 = call i32 @regcomp(i32* %20, i8* %21, i32 %23)
%25 = load i32*, i32** %9
store i32 %24, i32* %25
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [49 x i8] c"Memory allocation failed in posix90::c_regcomp_\0A\00"
define void @c_regcomp_(i32** nocapture %0, i8* %1, i32* nocapture %2, i32* nocapture writeonly %3, i32 %4) {
%6 = tail call i64 @malloc(i32 4)
%7 = inttoptr i64 %6 to i32*
store i32* %7, i32** %0
%8 = icmp eq i64 %6, 0
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%12 = load i32*, i32** %0
br label %13
13: ; preds = %9, %5
%14 = phi i32* [ %12, %9 ], [ %7, %5 ]
%15 = load i32, i32* %2
%16 = tail call i32 @regcomp(i32* %14, i8* %1, i32 %15)
store i32 %16, i32* %3
ret void
}