#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 */

/* Variables and functions */
int /*<<< orphan*/ REG_ICASE;
int /*<<< orphan*/ _regex_regerror(char const *);
int _regex_regexec(char const *, char *, char *, int /*<<< orphan*/);
int _regex(char const *progname) {
  int ret;
  ret = _regex_regexec(progname, "^test$", "test", 0);
  ret |= _regex_regexec(progname, "^test$", "TEST", REG_ICASE);
  _regex_regerror(progname);
  return ret;
}


x86 assembly (clang, -O0):
<_regex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
lea    0xec9(%rip),%rdx
xor    %ecx,%ecx
call   1040 <_regex_regexec@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e95(%rip),%rax
mov    (%rax),%ecx
lea    0xea4(%rip),%rsi
lea    0xea9(%rip),%rdx
call   1040 <_regex_regexec@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <_regex_regerror@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_regex>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xecf(%rip),%r14
lea    0xecf(%rip),%rdx
mov    %r14,%rsi
xor    %ecx,%ecx
call   1040 <_regex_regexec@plt>
mov    %eax,%r15d
mov    0x2e9c(%rip),%rax
mov    (%rax),%ecx
lea    0xeb7(%rip),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <_regex_regexec@plt>
mov    %eax,%ebp
or     %r15d,%ebp
mov    %rbx,%rdi
call   1030 <_regex_regerror@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"^test$\00"
@.str.1 = [5 x i8] c"test\00"
@.str.2 = [5 x i8] c"TEST\00"
@REG_ICASE = global i32 0
define i32 @_regex(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @_regex_regexec(i8* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 0)
store i32 %5, i32* %3
%6 = load i8*, i8** %2
%7 = load i32, i32* @REG_ICASE
%8 = call i32 @_regex_regexec(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %3
%10 = or i32 %9, %8
store i32 %10, i32* %3
%11 = load i8*, i8** %2
%12 = call i32 @_regex_regerror(i8* %11)
%13 = load i32, i32* %3
ret i32 %13
}

LLVM IR (-O2):
@.str = [7 x i8] c"^test$\00"
@.str.1 = [5 x i8] c"test\00"
@.str.2 = [5 x i8] c"TEST\00"
@REG_ICASE = global i32 0
define i32 @_regex(i8* %0) {
%2 = tail call i32 @_regex_regexec(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 0)
%3 = load i32, i32* @REG_ICASE
%4 = tail call i32 @_regex_regexec(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %3)
%5 = or i32 %4, %2
%6 = tail call i32 @_regex_regerror(i8* %0)
ret i32 %5
}