#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 REG_EXTENDED;
int REG_ICASE;
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",
                REG_EXTENDED | REG_ICASE) == 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    11ce <main+0x8e>
mov    0x2e63(%rip),%rax
mov    (%rax),%edx
mov    0x2e6a(%rip),%rax
or     (%rax),%edx
lea    -0x8(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1050 <regcomp@plt>
cmp    $0x0,%rax
jne    11b2 <main+0x72>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x10(%rbp)
jmp    11bb <main+0x7b>
lea    -0x8(%rbp),%rdi
call   1040 <regfree@plt>
jmp    11c0 <main+0x80>
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   %r13
push   %r12
push   %rbx
push   %rax
xor    %r14d,%r14d
xor    %eax,%eax
call   1060 <mtrace@plt>
mov    $0x20,%ebx
mov    0x2e77(%rip),%r13
mov    0x2e80(%rip),%r15
lea    0xe91(%rip),%r12
lea    0x4(%rsp),%rbp
jmp    118d <main+0x4d>
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1040 <regfree@plt>
add    $0xffffffff,%ebx
je     11bb <main+0x7b>
mov    (%r15),%edx
or     0x0(%r13),%edx
mov    %rbp,%rdi
mov    %r12,%rsi
call   1050 <regcomp@plt>
test   %rax,%rax
jne    1180 <main+0x40>
lea    0xe76(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r14d
add    $0xffffffff,%ebx
jne    118d <main+0x4d>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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"
@REG_EXTENDED = global i32 0
@REG_ICASE = global i32 0
@.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 = %20, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 32
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i32, i32* @REG_EXTENDED
%11 = load i32, i32* @REG_ICASE
%12 = or i32 %10, %11
%13 = call i64 @regcomp(i32* %2, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = 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 %19
17: ; preds = %9
%18 = call i32 @regfree(i32* %2)
br label %19
19: ; preds = %17, %15
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %6
23: ; preds = %6
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
@.str = [33 x i8] c"X-.+:.+Y=\22.*\\.(A|B|C|D|E|F|G|H|I\00"
@REG_EXTENDED = global i32 0
@REG_ICASE = global i32 0
@.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, %16
%5 = phi i32 [ 0, %0 ], [ %17, %16 ]
%6 = phi i32 [ 0, %0 ], [ %18, %16 ]
%7 = load i32, i32* @REG_EXTENDED
%8 = load i32, i32* @REG_ICASE
%9 = or i32 %8, %7
%10 = call i64 @regcomp(i32* %1, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %16
14: ; preds = %4
%15 = call i32 @regfree(i32* %1)
br label %16
16: ; preds = %12, %14
%17 = phi i32 [ 1, %12 ], [ %5, %14 ]
%18 = add nuw nsw i32 %6, 1
%19 = icmp eq i32 %18, 32
br i1 %19, label %20, label %4
20: ; preds = %16
ret i32 %17
}