#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*/ mtrace();
int /*<<< orphan*/ puts(char *);
scalar_t__ regcomp(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int main(void) {
  regex_t re;
  int i;
  int ret = 0;
  mtrace();
  for (i = 0; i < 32; ++i) {
    if (regcomp(&re, "X-.+:.+Y=\".*\\.(A|B|C|D|E|F|G|H|I", 1 | (1 << 1)) == 0) {
      puts("regcomp unexpectedly succeeded");
      ret = 1;
    } else
      regfree(&re);
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1060 <mtrace@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x20,-0xc(%rbp)
jge    11c1 <main+0x81>
lea    -0x8(%rbp),%rdi
lea    0xe87(%rip),%rsi
mov    $0x3,%edx
call   1050 <regcomp@plt>
cmp    $0x0,%rax
jne    11a5 <main+0x65>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x10(%rbp)
jmp    11ae <main+0x6e>
lea    -0x8(%rbp),%rdi
call   1040 <regfree@plt>
jmp    11b3 <main+0x73>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <main+0x24>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %r14d,%r14d
xor    %eax,%eax
call   1060 <mtrace@plt>
mov    $0x20,%ebx
lea    0xe9e(%rip),%r12
lea    0xc(%rsp),%rbp
lea    0xeb3(%rip),%r15
jmp    117d <main+0x3d>
mov    %rbp,%rdi
call   1040 <regfree@plt>
add    $0xffffffff,%ebx
je     11a5 <main+0x65>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   1050 <regcomp@plt>
test   %rax,%rax
jne    1170 <main+0x30>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
add    $0xffffffff,%ebx
jne    117d <main+0x3d>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"X-.+:.+Y=\22.*\\.(A|B|C|D|E|F|G|H|I\00"
@.str.1 = [31 x i8] c"regcomp unexpectedly succeeded\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
%5 = call i32 (...) @mtrace()
store i32 0, i32* %3
br label %6
6: ; preds = %17, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 32
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = call i64 @regcomp(i32* %2, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %4
br label %16
14: ; preds = %9
%15 = call i32 @regfree(i32* %2)
br label %16
16: ; preds = %14, %12
br label %17
17: ; preds = %16
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %6
20: ; preds = %6
%21 = load i32, i32* %4
ret i32 %21
}

LLVM IR (-O2):
@.str = [33 x i8] c"X-.+:.+Y=\22.*\\.(A|B|C|D|E|F|G|H|I\00"
@.str.1 = [31 x i8] c"regcomp unexpectedly succeeded\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @mtrace()
br label %4
4: ; preds = %0, %13
%5 = phi i32 [ 0, %0 ], [ %14, %13 ]
%6 = phi i32 [ 0, %0 ], [ %15, %13 ]
%7 = call i64 @regcomp(i32* %1, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %13
11: ; preds = %4
%12 = call i32 @regfree(i32* %1)
br label %13
13: ; preds = %9, %11
%14 = phi i32 [ 1, %9 ], [ %5, %11 ]
%15 = add nuw nsw i32 %6, 1
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %4
17: ; preds = %13
ret i32 %14
}