#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 regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ regerror(int, int /*<<< orphan*/ *, char *, size_t);
int reginit(regex_t *regex, char *pattern, char *buf, size_t buflen) {
  int ret = 0;
  if (*((char *)regex))
    return ret;
  ret = regcomp(regex, pattern, REG_EXTENDED);
  if (ret)
    regerror(ret, regex, buf, buflen);
  return ret;
}


x86 assembly (clang, -O0):
<reginit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1157 <reginit+0x37>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1194 <reginit+0x74>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e7a(%rip),%rax
mov    (%rax),%edx
call   1030 <regcomp@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     118e <reginit+0x6e>
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1040 <regerror@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reginit>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %ebp,%ebp
cmpb   $0x0,(%rdi)
jne    1160 <reginit+0x40>
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%rbx
mov    0x2ea1(%rip),%rax
mov    (%rax),%edx
call   1030 <regcomp@plt>
test   %eax,%eax
je     1160 <reginit+0x40>
mov    %eax,%r12d
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <regerror@plt>
mov    %r12d,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@REG_EXTENDED = global i32 0
define i32 @reginit(i32* %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
store i32* %0, i32** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i32 0, i32* %10
%11 = load i32*, i32** %6
%12 = bitcast i32* %11 to i8*
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %4
%16 = load i32, i32* %10
store i32 %16, i32* %5
br label %32
17: ; preds = %4
%18 = load i32*, i32** %6
%19 = load i8*, i8** %7
%20 = load i32, i32* @REG_EXTENDED
%21 = call i32 @regcomp(i32* %18, i8* %19, i32 %20)
store i32 %21, i32* %10
%22 = load i32, i32* %10
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %17
%25 = load i32, i32* %10
%26 = load i32*, i32** %6
%27 = load i8*, i8** %8
%28 = load i64, i64* %9
%29 = call i32 @regerror(i32 %25, i32* %26, i8* %27, i64 %28)
br label %30
30: ; preds = %24, %17
%31 = load i32, i32* %10
store i32 %31, i32* %5
br label %32
32: ; preds = %30, %15
%33 = load i32, i32* %5
ret i32 %33
}

LLVM IR (-O2):
@REG_EXTENDED = global i32 0
define i32 @reginit(i32* %0, i8* %1, i8* %2, i64 %3) {
%5 = bitcast i32* %0 to i8*
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %4
%9 = load i32, i32* @REG_EXTENDED
%10 = tail call i32 @regcomp(i32* %0, i8* %1, i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = tail call i32 @regerror(i32 %10, i32* %0, i8* %2, i64 %3)
br label %14
14: ; preds = %8, %12, %4
%15 = phi i32 [ 0, %4 ], [ %10, %12 ], [ 0, %8 ]
ret i32 %15
}