#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 BUFSIZ;
int regcomp(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ regerror(int, int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ warnx(char *, char *);
int bee_regcomp(regex_t *preg, char *regex, int cflags) {
  int regerr;
  char errbuf[BUFSIZ];
  regerr = regcomp(preg, regex, cflags);
  if (!regerr)
    return 1;
  regerror(regerr, preg, errbuf, BUFSIZ);
  warnx("bee_regcomp: %s\n", errbuf);
  return 0;
}


x86 assembly (clang, -O0):
<bee_regcomp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <regcomp@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    119f <bee_regcomp+0x6f>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    11d6 <bee_regcomp+0xa6>
mov    -0x40(%rbp),%rdx
mov    -0x20(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2e2f(%rip),%rax
mov    (%rax),%ecx
call   1050 <regerror@plt>
mov    -0x40(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1030 <warnx@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bee_regcomp>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e9c(%rip),%r15
mov    (%r15),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
call   1040 <regcomp@plt>
test   %eax,%eax
je     1184 <bee_regcomp+0x54>
mov    (%r15),%ecx
mov    %eax,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <regerror@plt>
lea    0xe88(%rip),%rdi
mov    %rbx,%rsi
call   1030 <warnx@plt>
xor    %eax,%eax
jmp    1189 <bee_regcomp+0x59>
mov    $0x1,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [17 x i8] c"bee_regcomp: %s\0A\00"
define i32 @bee_regcomp(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%12 = load i32, i32* @BUFSIZ
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %9
%15 = alloca i8, i64 %13
store i64 %13, i64* %10
%16 = load i32*, i32** %5
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = call i32 @regcomp(i32* %16, i8* %17, i32 %18)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %3
store i32 1, i32* %4
store i32 1, i32* %11
br label %29
23: ; preds = %3
%24 = load i32, i32* %8
%25 = load i32*, i32** %5
%26 = load i32, i32* @BUFSIZ
%27 = call i32 @regerror(i32 %24, i32* %25, i8* %15, i32 %26)
%28 = call i32 @warnx(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 0, i32* %4
store i32 1, i32* %11
br label %29
29: ; preds = %23, %22
%30 = load i8*, i8** %9
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [17 x i8] c"bee_regcomp: %s\0A\00"
define i32 @bee_regcomp(i32* %0, i8* %1, i32 %2) {
%4 = load i32, i32* @BUFSIZ
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = tail call i32 @regcomp(i32* %0, i8* %1, i32 %2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = load i32, i32* @BUFSIZ
%11 = call i32 @regerror(i32 %7, i32* %0, i8* %6, i32 %10)
%12 = call i32 @warnx(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %13
13: ; preds = %3, %9
%14 = phi i32 [ 0, %9 ], [ 1, %3 ]
ret i32 %14
}