#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*/ __error(int /*<<< orphan*/, int /*<<< orphan*/ *, char *,
                           char *);
int regexec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
            int /*<<< orphan*/ *, int /*<<< orphan*/);
int reginit(int /*<<< orphan*/ *, char *, char *, size_t);
int regmatch(regex_t *regex, char *call, char *pattern, char *buf,
             size_t buflen) {
  int ret = reginit(regex, pattern, buf, buflen);
  if (ret) {
    __error(0, NULL, "GCC plugin: failed to compile regexp: %s", buf);
    return ret;
  }
  return regexec(regex, call, 0, NULL, 0);
}


x86 assembly (clang, -O0):
<regmatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1040 <reginit@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     118f <regmatch+0x5f>
mov    -0x28(%rbp),%rcx
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%esi
lea    0xe81(%rip),%rdx
call   1050 <__error@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a9 <regmatch+0x79>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   1030 <regexec@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<regmatch>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %r8,%rcx
call   1040 <reginit@plt>
test   %eax,%eax
je     1174 <regmatch+0x44>
mov    %eax,%ebp
lea    0xea5(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
mov    %r15,%rcx
call   1050 <__error@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <regexec@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"GCC plugin: failed to compile regexp: %s\00"
define i32 @regmatch(i32* %0, i8* %1, i8* %2, i8* %3, i64 %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
store i32* %0, i32** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i64 %4, i64* %11
%13 = load i32*, i32** %7
%14 = load i8*, i8** %9
%15 = load i8*, i8** %10
%16 = load i64, i64* %11
%17 = call i32 @reginit(i32* %13, i8* %14, i8* %15, i64 %16)
store i32 %17, i32* %12
%18 = load i32, i32* %12
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %5
%21 = load i8*, i8** %10
%22 = call i32 @__error(i32 0, i32* null, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = load i32, i32* %12
store i32 %23, i32* %6
br label %28
24: ; preds = %5
%25 = load i32*, i32** %7
%26 = load i8*, i8** %8
%27 = call i32 @regexec(i32* %25, i8* %26, i32 0, i32* null, i32 0)
store i32 %27, i32* %6
br label %28
28: ; preds = %24, %20
%29 = load i32, i32* %6
ret i32 %29
}

LLVM IR (-O2):
@.str = [41 x i8] c"GCC plugin: failed to compile regexp: %s\00"
define i32 @regmatch(i32* %0, i8* %1, i8* %2, i8* %3, i64 %4) {
%6 = tail call i32 @reginit(i32* %0, i8* %2, i8* %3, i64 %4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 @__error(i32 0, i32* null, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %12
10: ; preds = %5
%11 = tail call i32 @regexec(i32* %0, i8* %1, i32 0, i32* null, i32 0)
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ %6, %8 ], [ %11, %10 ]
ret i32 %13
}