#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int rm_so;
  int rm_eo;
};
typedef TYPE_1__ regmatch_t;
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
int REG_ICASE;
int REG_NOTBOL;
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int, char *, size_t);
int /*<<< orphan*/ puts(char *);
int regcomp(int /*<<< orphan*/ *, char const *, int);
size_t regerror(int, int /*<<< orphan*/ *, char *, size_t);
int regexec(int /*<<< orphan*/ *, char const *, size_t, TYPE_1__ *, int);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  regex_t preg;
  const char *regex = "<meta\\ name=\"description\".\\+content=\"";
  int cflags = REG_ICASE;
  size_t size = 0;
  int errcode = 0;
  char errbuf[1024] = {0};
  size_t errbuf_size = 1024;
  errcode = regcomp(&preg, regex, cflags);
  if (errcode != 0) {
    size = regerror(errcode, &preg, errbuf, errbuf_size);
    printf("errcode = %d, %s(%u)\n", errcode, errbuf, size);
    return 1;
  }
  const char *string =
      "<a data-href=\"http://news.baidu.com\" (? <meta "
      "name=\"description\"\r\n content=\"yes ok\" /> <title>hello "
      "WORLD</title>   <title>hello <hhhh>world</title> "
      "\r\nhref=\"http://news.baidu.com/"
      "ns?word=word&tn=news&cl=2&rn=20&ct=1&fr=wenku\" class=\"logSend\" "
      "data-lojgsend='{\"send\":[\"general\", ";
  regmatch_t pmatch[1];
  size_t nmatch = 1;
  int eflags = REG_NOTBOL;
  while (errcode == 0) {
    errcode = regexec(&preg, string, nmatch, pmatch, eflags);
    if (errcode == 0) {
      char its[1024];
      memset(its, 0, sizeof its);
      memcpy(its, string + pmatch[0].rm_so, pmatch[0].rm_eo - pmatch[0].rm_so);
      puts(its);
    }
    string += pmatch[0].rm_so + 1;
  }
  regfree(&preg);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x870,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe60(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e3d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
lea    -0x440(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
movq   $0x400,-0x448(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    -0x14(%rbp),%rdi
call   1070 <regcomp@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     123e <main+0xbe>
mov    -0x34(%rbp),%edi
lea    -0x440(%rbp),%rdx
mov    -0x448(%rbp),%rcx
lea    -0x14(%rbp),%rsi
call   1090 <regerror@plt>
mov    %rax,-0x30(%rbp)
mov    -0x34(%rbp),%esi
lea    -0x440(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    0xdf9(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131c <main+0x19c>
lea    0xdf7(%rip),%rax
mov    %rax,-0x450(%rbp)
movq   $0x1,-0x460(%rbp)
mov    0x2d82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x464(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    130c <main+0x18c>
mov    -0x450(%rbp),%rsi
mov    -0x460(%rbp),%rdx
lea    -0x458(%rbp),%rcx
mov    -0x464(%rbp),%r8d
lea    -0x14(%rbp),%rdi
call   10a0 <regexec@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    12ea <main+0x16a>
lea    -0x870(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x870(%rbp),%rdi
mov    -0x450(%rbp),%rsi
movslq -0x458(%rbp),%rax
add    %rax,%rsi
mov    -0x454(%rbp),%edx
sub    -0x458(%rbp),%edx
call   1080 <memcpy@plt>
lea    -0x870(%rbp),%rdi
call   1030 <puts@plt>
mov    -0x458(%rbp),%ecx
add    $0x1,%ecx
mov    -0x450(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x450(%rbp)
jmp    1266 <main+0xe6>
lea    -0x14(%rbp),%rdi
call   1040 <regfree@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x870,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x810,%rsp
mov    0x2e52(%rip),%rax
mov    (%rax),%ebx
lea    0x10(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1060 <memset@plt>
lea    0xe50(%rip),%rsi
lea    0x4(%rsp),%rdi
mov    %ebx,%edx
call   1070 <regcomp@plt>
test   %eax,%eax
je     11f9 <main+0x79>
mov    %eax,%ebx
lea    0x4(%rsp),%rsi
lea    0x10(%rsp),%rbp
mov    $0x400,%ecx
mov    %eax,%edi
mov    %rbp,%rdx
call   1090 <regerror@plt>
lea    0xe44(%rip),%rdi
mov    %ebx,%esi
mov    %rbp,%rdx
mov    %rax,%rcx
call   1050 <printf@plt>
mov    $0x1,%eax
jmp    129f <main+0x11f>
mov    0x2de0(%rip),%rax
mov    (%rax),%r14d
lea    0xe32(%rip),%rbx
lea    0x4(%rsp),%rdi
lea    0x8(%rsp),%rcx
mov    $0x1,%edx
mov    %rbx,%rsi
mov    %r14d,%r8d
call   10a0 <regexec@plt>
test   %eax,%eax
jne    1293 <main+0x113>
lea    0x410(%rsp),%rbp
lea    0x4(%rsp),%r15
lea    0x8(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
movslq 0x8(%rsp),%rsi
mov    0xc(%rsp),%edx
sub    %esi,%edx
add    %rbx,%rsi
mov    %rbp,%rdi
call   1080 <memcpy@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
movslq 0x8(%rsp),%rax
add    %rax,%rbx
add    $0x1,%rbx
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rcx
mov    %r14d,%r8d
call   10a0 <regexec@plt>
test   %eax,%eax
je     1240 <main+0xc0>
lea    0x4(%rsp),%rdi
call   1040 <regfree@plt>
xor    %eax,%eax
add    $0x810,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@.str = [38 x i8] c"<meta\\ name=\22description\22.\\+content=\22\00"
@REG_ICASE = global i32 0
@.str.1 = [22 x i8] c"errcode = %d, %s(%u)\0A\00"
@.str.2 = [278 x i8] c"<a data-href=\22http://news.baidu.com\22 (? <meta name=\22description\22\0D\0A content=\22yes ok\22 /> <title>hello WORLD</title> <title>hello <hhhh>world</title> \0D\0Ahref=\22http://news.baidu.com/ns?word=word&tn=news&cl=2&rn=20&ct=1&fr=wenku\22 class=\22logSend\22 data-lojgsend='{\22send\22:[\22general\22, \00"
@REG_NOTBOL = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
%11 = alloca [1024 x i8]
%12 = alloca i64
%13 = alloca i8*
%14 = alloca [1 x %struct.TYPE_3__]
%15 = alloca i64
%16 = alloca i32
%17 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8** %7
%18 = load i32, i32* @REG_ICASE
store i32 %18, i32* %8
store i64 0, i64* %9
store i32 0, i32* %10
%19 = bitcast [1024 x i8]* %11 to i8*
store i64 1024, i64* %12
%20 = load i8*, i8** %7
%21 = load i32, i32* %8
%22 = call i32 @regcomp(i32* %6, i8* %20, i32 %21)
store i32 %22, i32* %10
%23 = load i32, i32* %10
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %2
%26 = load i32, i32* %10
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%28 = load i64, i64* %12
%29 = call i64 @regerror(i32 %26, i32* %6, i8* %27, i64 %28)
store i64 %29, i64* %9
%30 = load i32, i32* %10
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%32 = load i64, i64* %9
%33 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %30, i8* %31, i64 %32)
store i32 1, i32* %3
br label %77
34: ; preds = %2
store i8* getelementptr inbounds ([278 x i8], [278 x i8]* @.str.2, i64 0, i64 0), i8** %13
store i64 1, i64* %15
%35 = load i32, i32* @REG_NOTBOL
store i32 %35, i32* %16
br label %36
36: ; preds = %67, %34
%37 = load i32, i32* %10
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %75
39: ; preds = %36
%40 = load i8*, i8** %13
%41 = load i64, i64* %15
%42 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %14, i64 0, i64 0
%43 = load i32, i32* %16
%44 = call i32 @regexec(i32* %6, i8* %40, i64 %41, %struct.TYPE_3__* %42, i32 %43)
store i32 %44, i32* %10
%45 = load i32, i32* %10
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %67
47: ; preds = %39
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%49 = call i32 @memset(i8* %48, i32 0, i32 1024)
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%51 = load i8*, i8** %13
%52 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %14, i64 0, i64 0
%53 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %52, i32 0, i32 0
%54 = load i32, i32* %53
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %51, i64 %55
%57 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %14, i64 0, i64 0
%58 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %57, i32 0, i32 1
%59 = load i32, i32* %58
%60 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %14, i64 0, i64 0
%61 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %60, i32 0, i32 0
%62 = load i32, i32* %61
%63 = sub nsw i32 %59, %62
%64 = call i32 @memcpy(i8* %50, i8* %56, i32 %63)
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%66 = call i32 @puts(i8* %65)
br label %67
67: ; preds = %47, %39
%68 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %14, i64 0, i64 0
%69 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %68, i32 0, i32 0
%70 = load i32, i32* %69
%71 = add nsw i32 %70, 1
%72 = load i8*, i8** %13
%73 = sext i32 %71 to i64
%74 = getelementptr inbounds i8, i8* %72, i64 %73
store i8* %74, i8** %13
br label %36
75: ; preds = %36
%76 = call i32 @regfree(i32* %6)
store i32 0, i32* %3
br label %77
77: ; preds = %75, %25
%78 = load i32, i32* %3
ret i32 %78
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@.str = [38 x i8] c"<meta\\ name=\22description\22.\\+content=\22\00"
@REG_ICASE = global i32 0
@.str.1 = [22 x i8] c"errcode = %d, %s(%u)\0A\00"
@.str.2 = [278 x i8] c"<a data-href=\22http://news.baidu.com\22 (? <meta name=\22description\22\0D\0A content=\22yes ok\22 /> <title>hello WORLD</title> <title>hello <hhhh>world</title> \0D\0Ahref=\22http://news.baidu.com/ns?word=word&tn=news&cl=2&rn=20&ct=1&fr=wenku\22 class=\22logSend\22 data-lojgsend='{\22send\22:[\22general\22, \00"
@REG_NOTBOL = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [1024 x i8]
%5 = alloca [1 x %struct.TYPE_3__]
%6 = alloca [1024 x i8]
%7 = bitcast i32* %3 to i8*
%8 = load i32, i32* @REG_ICASE
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%10 = call i32 @regcomp(i32* %3, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %8)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = call i64 @regerror(i32 %10, i32* %3, i8* %9, i64 1024)
%14 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %10, i8* %9, i64 %13)
br label %42
15: ; preds = %2
%16 = bitcast [1 x %struct.TYPE_3__]* %5 to i8*
%17 = load i32, i32* @REG_NOTBOL
%18 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %5, i64 0, i64 0
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%20 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %5, i64 0, i64 0, i32 0
%21 = getelementptr inbounds [1 x %struct.TYPE_3__], [1 x %struct.TYPE_3__]* %5, i64 0, i64 0, i32 1
%22 = call i32 @regexec(i32* %3, i8* getelementptr inbounds ([278 x i8], [278 x i8]* @.str.2, i64 0, i64 0), i64 1, %struct.TYPE_3__* %18, i32 %17)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %40
24: ; preds = %15, %24
%25 = phi i8* [ %37, %24 ], [ getelementptr inbounds ([278 x i8], [278 x i8]* @.str.2, i64 0, i64 0), %15 ]
%26 = call i32 @memset(i8* %19, i32 0, i32 1024)
%27 = load i32, i32* %20
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
%30 = load i32, i32* %21
%31 = sub nsw i32 %30, %27
%32 = call i32 @memcpy(i8* %19, i8* %29, i32 %31)
%33 = call i32 @puts(i8* %19)
%34 = load i32, i32* %20
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %25, i64 %36
%38 = call i32 @regexec(i32* %3, i8* %37, i64 1, %struct.TYPE_3__* %18, i32 %17)
%39 = icmp eq i32 %38, 0
br i1 %39, label %24, label %40
40: ; preds = %24, %15
%41 = call i32 @regfree(i32* %3)
br label %42
42: ; preds = %40, %12
%43 = phi i32 [ 1, %12 ], [ 0, %40 ]
ret i32 %43
}