#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_NOSUB;
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ regcomp(int /*<<< orphan*/ *, char *, int);
int regexec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
            int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int main() {
  regex_t exp;
  regcomp(&exp, " [=f!]{3} ", REG_EXTENDED | REG_NOSUB);
  int r;
  char *s;
  s = "toto === nada";
  r = regexec(&exp, s, 0, NULL, 0);
  printf("\"%s\" match ? %s\n", s, (r == 0 ? "yes" : "no"));
  s = "toto ?== nada";
  r = regexec(&exp, s, 0, NULL, 0);
  printf("\"%s\" match ? %s\n", s, (r == 0 ? "yes" : "no"));
  regfree(&exp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%edx
mov    0x2e88(%rip),%rax
or     (%rax),%edx
lea    -0x4(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1050 <regcomp@plt>
lea    0xe9a(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    -0x4(%rbp),%rdi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   1060 <regexec@plt>
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%ecx
lea    0xe91(%rip),%rdx
lea    0xe86(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rdx
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
lea    0xe73(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    -0x4(%rbp),%rdi
xor    %r8d,%r8d
xor    %eax,%eax
mov    %eax,%ecx
mov    %r8d,%edx
call   1060 <regexec@plt>
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%ecx
lea    0xe44(%rip),%rdx
lea    0xe39(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rdx
lea    0xe1a(%rip),%rdi
call   1040 <printf@plt>
lea    -0x4(%rbp),%rdi
call   1030 <regfree@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x2e84(%rip),%rax
mov    0x2e85(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0xe9a(%rip),%rsi
lea    0xc(%rsp),%r14
mov    %r14,%rdi
call   1050 <regcomp@plt>
lea    0xe91(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <regexec@plt>
test   %eax,%eax
lea    0xe95(%rip),%r13
lea    0xe92(%rip),%rbx
mov    %rbx,%rdx
cmove  %r13,%rdx
lea    0xe6f(%rip),%r12
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
lea    0xe75(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <regexec@plt>
test   %eax,%eax
cmove  %r13,%rbx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <regfree@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c" [=f!]{3} \00"
@REG_EXTENDED = global i32 0
@REG_NOSUB = global i32 0
@.str.1 = [14 x i8] c"toto === nada\00"
@.str.2 = [17 x i8] c"\22%s\22 match ? %s\0A\00"
@.str.3 = [4 x i8] c"yes\00"
@.str.4 = [3 x i8] c"no\00"
@.str.5 = [14 x i8] c"toto ?== nada\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = load i32, i32* @REG_EXTENDED
%5 = load i32, i32* @REG_NOSUB
%6 = or i32 %4, %5
%7 = call i32 @regcomp(i32* %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %6)
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @regexec(i32* %1, i8* %8, i32 0, i32* null, i32 0)
store i32 %9, i32* %2
%10 = load i8*, i8** %3
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%15 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %10, i8* %14)
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %3
%16 = load i8*, i8** %3
%17 = call i32 @regexec(i32* %1, i8* %16, i32 0, i32* null, i32 0)
store i32 %17, i32* %2
%18 = load i8*, i8** %3
%19 = load i32, i32* %2
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%23 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %18, i8* %22)
%24 = call i32 @regfree(i32* %1)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c" [=f!]{3} \00"
@REG_EXTENDED = global i32 0
@REG_NOSUB = global i32 0
@.str.1 = [14 x i8] c"toto === nada\00"
@.str.2 = [17 x i8] c"\22%s\22 match ? %s\0A\00"
@.str.3 = [4 x i8] c"yes\00"
@.str.4 = [3 x i8] c"no\00"
@.str.5 = [14 x i8] c"toto ?== nada\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @REG_EXTENDED
%4 = load i32, i32* @REG_NOSUB
%5 = or i32 %4, %3
%6 = call i32 @regcomp(i32* %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 @regexec(i32* %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 0, i32* null, i32 0)
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%10 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = call i32 @regexec(i32* %1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 0, i32* null, i32 0)
%12 = icmp eq i32 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %13)
%15 = call i32 @regfree(i32* %1)
ret i32 0
}