#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*/ regmatch_t;
typedef int /*<<< orphan*/ regex_t;
typedef int /*<<< orphan*/ errbuf;

/* Variables and functions */
int REG_EXTENDED;
int REG_NOSUB;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ printf(char *, int);
int regcomp(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ regerror(int, int /*<<< orphan*/ *, char *, int);
int regexec(int /*<<< orphan*/ *, char *, int, int /*<<< orphan*/ *,
            int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  regex_t preg;
  char errbuf[128];
  int errcode;
  regmatch_t pmatch[3];
  char *s1 = ""
             "[12;34f";
  char *s2 = ""
             "[1;3f";
  char *s3 = ""
             "12;34f";
  char *s4 = ""
             "[;34f";
  char *s5 = "[12;34f";
  char *p = ""
            "[[][0-9]+;[0-9]+f";
  if ((errcode = regcomp(&preg, p, REG_EXTENDED | REG_NOSUB)) != 0) {
    regerror(errcode, &preg, errbuf, sizeof(errbuf));
    fprintf(stderr, "%s: regcomp failed ( %s)\n", argv[0], errbuf);
    exit(1);
  }
  printf("regexec of s1 = %d\n", regexec(&preg, s1, 1, pmatch, 0));
  printf("regexec of s2 = %d\n", regexec(&preg, s2, 1, pmatch, 0));
  printf("regexec of s3 = %d\n", regexec(&preg, s3, 1, pmatch, 0));
  printf("regexec of s4 = %d\n", regexec(&preg, s4, 1, pmatch, 0));
  printf("regexec of s5 = %d\n", regexec(&preg, s5, 1, pmatch, 0));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe87(%rip),%rax
mov    %rax,-0xb8(%rbp)
lea    0xe82(%rip),%rax
mov    %rax,-0xc0(%rbp)
lea    0xe7b(%rip),%rax
mov    %rax,-0xc8(%rbp)
lea    0xe75(%rip),%rax
mov    %rax,-0xd0(%rbp)
lea    0xe50(%rip),%rax
mov    %rax,-0xd8(%rbp)
lea    0xe60(%rip),%rax
mov    %rax,-0xe0(%rbp)
mov    -0xe0(%rbp),%rsi
mov    0x2dfc(%rip),%rax
mov    (%rax),%edx
mov    0x2e03(%rip),%rax
or     (%rax),%edx
lea    -0x14(%rbp),%rdi
call   1040 <regcomp@plt>
mov    %eax,-0xa4(%rbp)
cmp    $0x0,%eax
je     123f <main+0xdf>
mov    -0xa4(%rbp),%edi
lea    -0xa0(%rbp),%rdx
lea    -0x14(%rbp),%rsi
mov    $0x80,%ecx
call   1060 <regerror@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    -0xa0(%rbp),%rcx
lea    0xe02(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0xb8(%rbp),%rsi
lea    -0xb0(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1070 <regexec@plt>
mov    %eax,%esi
lea    0xde5(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc0(%rbp),%rsi
lea    -0xb0(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1070 <regexec@plt>
mov    %eax,%esi
lea    0xdcc(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc8(%rbp),%rsi
lea    -0xb0(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1070 <regexec@plt>
mov    %eax,%esi
lea    0xdb3(%rip),%rdi
call   1030 <printf@plt>
mov    -0xd0(%rbp),%rsi
lea    -0xb0(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1070 <regexec@plt>
mov    %eax,%esi
lea    0xd9a(%rip),%rdi
call   1030 <printf@plt>
mov    -0xd8(%rbp),%rsi
lea    -0xb0(%rbp),%rcx
lea    -0x14(%rbp),%rdi
mov    $0x1,%edx
xor    %r8d,%r8d
call   1070 <regexec@plt>
mov    %eax,%esi
lea    0xd81(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    %rsi,%rbx
mov    0x2e5c(%rip),%rax
mov    0x2e65(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0xe99(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1040 <regcomp@plt>
test   %eax,%eax
jne    1277 <main+0x117>
lea    0xe61(%rip),%rsi
lea    0xc(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rdi
mov    $0x1,%edx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1070 <regexec@plt>
lea    0xe89(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe38(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1070 <regexec@plt>
lea    0xe75(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xe17(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1070 <regexec@plt>
lea    0xe61(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xdf7(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1070 <regexec@plt>
lea    0xe4d(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
lea    0xdb8(%rip),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1070 <regexec@plt>
lea    0xe39(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r14
ret
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%r14
mov    %eax,%edi
mov    %r14,%rdx
mov    $0x80,%ecx
call   1060 <regerror@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd8f(%rip),%rsi
mov    %r14,%rcx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"\1B[12;34f\00"
@.str.1 = [7 x i8] c"\1B[1;3f\00"
@.str.2 = [8 x i8] c"\1B12;34f\00"
@.str.3 = [7 x i8] c"\1B[;34f\00"
@.str.4 = [8 x i8] c"[12;34f\00"
@.str.5 = [19 x i8] c"\1B[[][0-9]+;[0-9]+f\00"
@REG_EXTENDED = global i32 0
@REG_NOSUB = global i32 0
@stderr = global i32 0
@.str.6 = [26 x i8] c"%s: regcomp failed ( %s)\0A\00"
@.str.7 = [20 x i8] c"regexec of s1 = %d\0A\00"
@.str.8 = [20 x i8] c"regexec of s2 = %d\0A\00"
@.str.9 = [20 x i8] c"regexec of s3 = %d\0A\00"
@.str.10 = [20 x i8] c"regexec of s4 = %d\0A\00"
@.str.11 = [20 x i8] c"regexec of s5 = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca [128 x i8]
%7 = alloca i32
%8 = alloca [3 x i32]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8** %9
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %10
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %11
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8** %12
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8** %13
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8** %14
%15 = load i8*, i8** %14
%16 = load i32, i32* @REG_EXTENDED
%17 = load i32, i32* @REG_NOSUB
%18 = or i32 %16, %17
%19 = call i32 @regcomp(i32* %5, i8* %15, i32 %18)
store i32 %19, i32* %7
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %32
21: ; preds = %2
%22 = load i32, i32* %7
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%24 = call i32 @regerror(i32 %22, i32* %5, i8* %23, i32 128)
%25 = load i32, i32* @stderr
%26 = load i8**, i8*** %4
%27 = getelementptr inbounds i8*, i8** %26, i64 0
%28 = load i8*, i8** %27
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%30 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %28, i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %2
%33 = load i8*, i8** %9
%34 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%35 = call i32 @regexec(i32* %5, i8* %33, i32 1, i32* %34, i32 0)
%36 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %35)
%37 = load i8*, i8** %10
%38 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%39 = call i32 @regexec(i32* %5, i8* %37, i32 1, i32* %38, i32 0)
%40 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %39)
%41 = load i8*, i8** %11
%42 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%43 = call i32 @regexec(i32* %5, i8* %41, i32 1, i32* %42, i32 0)
%44 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %43)
%45 = load i8*, i8** %12
%46 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%47 = call i32 @regexec(i32* %5, i8* %45, i32 1, i32* %46, i32 0)
%48 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %47)
%49 = load i8*, i8** %13
%50 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
%51 = call i32 @regexec(i32* %5, i8* %49, i32 1, i32* %50, i32 0)
%52 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i32 %51)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"\1B[12;34f\00"
@.str.1 = [7 x i8] c"\1B[1;3f\00"
@.str.2 = [8 x i8] c"\1B12;34f\00"
@.str.3 = [7 x i8] c"\1B[;34f\00"
@.str.4 = [8 x i8] c"[12;34f\00"
@.str.5 = [19 x i8] c"\1B[[][0-9]+;[0-9]+f\00"
@REG_EXTENDED = global i32 0
@REG_NOSUB = global i32 0
@stderr = global i32 0
@.str.6 = [26 x i8] c"%s: regcomp failed ( %s)\0A\00"
@.str.7 = [20 x i8] c"regexec of s1 = %d\0A\00"
@.str.8 = [20 x i8] c"regexec of s2 = %d\0A\00"
@.str.9 = [20 x i8] c"regexec of s3 = %d\0A\00"
@.str.10 = [20 x i8] c"regexec of s4 = %d\0A\00"
@.str.11 = [20 x i8] c"regexec of s5 = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [128 x i8]
%5 = alloca [3 x i32]
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%8 = bitcast [3 x i32]* %5 to i8*
%9 = load i32, i32* @REG_EXTENDED
%10 = load i32, i32* @REG_NOSUB
%11 = or i32 %10, %9
%12 = call i32 @regcomp(i32* %3, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %2
%15 = call i32 @regerror(i32 %12, i32* %3, i8* %7, i32 128)
%16 = load i32, i32* @stderr
%17 = load i8*, i8** %1
%18 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %17, i8* %7)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%22 = call i32 @regexec(i32* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1, i32* %21, i32 0)
%23 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %22)
%24 = call i32 @regexec(i32* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 1, i32* %21, i32 0)
%25 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %24)
%26 = call i32 @regexec(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 1, i32* %21, i32 0)
%27 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %26)
%28 = call i32 @regexec(i32* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 1, i32* %21, i32 0)
%29 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %28)
%30 = call i32 @regexec(i32* %3, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 1, i32* %21, i32 0)
%31 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i32 %30)
ret i32 0
}