#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 REG_NOSUB;
scalar_t__ regcomp(int /*<<< orphan*/ *, char const *, int);
int regexec(int /*<<< orphan*/ *, char const *, size_t, int /*<<< orphan*/ *,
            int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int /*<<< orphan*/ slog(int, char *, char const *);
int regmatchInsensitive(const char *string, const char *pattern) {
  int result;
  regex_t re;
  if (regcomp(&re, pattern, REG_EXTENDED | REG_NOSUB | REG_ICASE) != 0) {
    slog(1,
         "... regmatchInsensitive(): problems compiling the regular expression "
         "%s\n",
         pattern);
    return (0);
  }
  result = regexec(&re, string, (size_t)0, NULL, 0);
  regfree(&re);
  if (result != 0) {
    return (0);
  }
  return (1);
}


x86 assembly (clang, -O0):
<regmatchInsensitive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    0x2e75(%rip),%rax
mov    (%rax),%edx
mov    0x2e74(%rip),%rax
or     (%rax),%edx
mov    0x2e7b(%rip),%rax
or     (%rax),%edx
lea    -0x20(%rbp),%rdi
call   1040 <regcomp@plt>
cmp    $0x0,%rax
je     11a3 <regmatchInsensitive+0x63>
mov    -0x18(%rbp),%rdx
mov    $0x1,%edi
lea    0xe6e(%rip),%rsi
call   1050 <slog@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e3 <regmatchInsensitive+0xa3>
mov    -0x10(%rbp),%rsi
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%ecx
xor    %r8d,%r8d
mov    %rcx,%rdx
call   1060 <regexec@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <regfree@plt>
cmpl   $0x0,-0x1c(%rbp)
je     11dc <regmatchInsensitive+0x9c>
movl   $0x0,-0x4(%rbp)
jmp    11e3 <regmatchInsensitive+0xa3>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<regmatchInsensitive>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e81(%rip),%rax
mov    0x2e82(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2e81(%rip),%rax
or     (%rax),%edx
lea    0xc(%rsp),%rdi
call   1040 <regcomp@plt>
test   %rax,%rax
je     1190 <regmatchInsensitive+0x50>
lea    0xe81(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
call   1050 <slog@plt>
xor    %eax,%eax
jmp    11b8 <regmatchInsensitive+0x78>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1060 <regexec@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <regfree@plt>
xor    %eax,%eax
test   %ebp,%ebp
sete   %al
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@REG_EXTENDED = global i32 0
@REG_NOSUB = global i32 0
@REG_ICASE = global i32 0
@.str = [73 x i8] c"... regmatchInsensitive(): problems compiling the regular expression %s\0A\00"
define i32 @regmatchInsensitive(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = load i32, i32* @REG_EXTENDED
%10 = load i32, i32* @REG_NOSUB
%11 = or i32 %9, %10
%12 = load i32, i32* @REG_ICASE
%13 = or i32 %11, %12
%14 = call i64 @regcomp(i32* %7, i8* %8, i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = load i8*, i8** %5
%18 = call i32 @slog(i32 1, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i8* %17)
store i32 0, i32* %3
br label %27
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = call i32 @regexec(i32* %7, i8* %20, i64 0, i32* null, i32 0)
store i32 %21, i32* %6
%22 = call i32 @regfree(i32* %7)
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 0, i32* %3
br label %27
26: ; preds = %19
store i32 1, i32* %3
br label %27
27: ; preds = %26, %25, %16
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@REG_EXTENDED = global i32 0
@REG_NOSUB = global i32 0
@REG_ICASE = global i32 0
@.str = [73 x i8] c"... regmatchInsensitive(): problems compiling the regular expression %s\0A\00"
define i32 @regmatchInsensitive(i8* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i32, i32* @REG_EXTENDED
%6 = load i32, i32* @REG_NOSUB
%7 = or i32 %6, %5
%8 = load i32, i32* @REG_ICASE
%9 = or i32 %7, %8
%10 = call i64 @regcomp(i32* %3, i8* %1, i32 %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = call i32 @slog(i32 1, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %19
14: ; preds = %2
%15 = call i32 @regexec(i32* %3, i8* %0, i64 0, i32* null, i32 0)
%16 = call i32 @regfree(i32* %3)
%17 = icmp eq i32 %15, 0
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %14, %12
%20 = phi i32 [ 0, %12 ], [ %18, %14 ]
ret i32 %20
}