#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 */
scalar_t__ REG_NOMATCH;
scalar_t__ regexec(int /*<<< orphan*/ *, char *, int, TYPE_1__ *,
                   int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ zero_str(char *, int, int);
char do_keep_re(regex_t *pre, int *match_count, char *in, char *strip_what) {
  char changed = 0;
  regmatch_t matches[(80)];
  int last_offset = 0;
  if (regexec(pre, in, (80), matches, 0) != REG_NOMATCH) {
    int match_i;
    for (match_i = 1; match_i < (80); match_i++) {
      if (matches[match_i].rm_so == -1 || matches[match_i].rm_eo == -1)
        break;
      zero_str(strip_what, last_offset, matches[match_i].rm_so);
      last_offset = matches[match_i].rm_eo;
    }
    if (last_offset != 0) {
      zero_str(strip_what, last_offset, strlen(in));
    }
    changed = 1;
  }
  return changed;
}


x86 assembly (clang, -O0):
<do_keep_re>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2d0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
movl   $0x0,-0x2b4(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x2b0(%rbp),%rcx
mov    $0x50,%edx
xor    %r8d,%r8d
call   1050 <regexec@plt>
mov    0x2e6c(%rip),%rcx
cmp    (%rcx),%rax
je     1255 <do_keep_re+0x125>
movl   $0x1,-0x2b8(%rbp)
cmpl   $0x50,-0x2b8(%rbp)
jge    1210 <do_keep_re+0xe0>
movslq -0x2b8(%rbp),%rax
cmpl   $0xffffffff,-0x2b0(%rbp,%rax,8)
ff
je     11c6 <do_keep_re+0x96>
movslq -0x2b8(%rbp),%rax
cmpl   $0xffffffff,-0x2ac(%rbp,%rax,8)
ff
jne    11cb <do_keep_re+0x9b>
jmp    1210 <do_keep_re+0xe0>
mov    -0x20(%rbp),%rdi
mov    -0x2b4(%rbp),%esi
movslq -0x2b8(%rbp),%rax
mov    -0x2b0(%rbp,%rax,8),%edx
call   1040 <zero_str@plt>
movslq -0x2b8(%rbp),%rax
mov    -0x2ac(%rbp,%rax,8),%eax
mov    %eax,-0x2b4(%rbp)
mov    -0x2b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2b8(%rbp)
jmp    118f <do_keep_re+0x5f>
cmpl   $0x0,-0x2b4(%rbp)
je     1251 <do_keep_re+0x121>
mov    -0x20(%rbp),%rax
mov    %rax,-0x2c8(%rbp)
mov    -0x2b4(%rbp),%eax
mov    %eax,-0x2bc(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x2c8(%rbp),%rdi
mov    -0x2bc(%rbp),%esi
mov    %eax,%edx
call   1040 <zero_str@plt>
movb   $0x1,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
add    $0x2d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_keep_re>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x280,%rsp
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsp,%rcx
xor    %r13d,%r13d
mov    %rdx,%rsi
mov    $0x50,%edx
xor    %r8d,%r8d
call   1050 <regexec@plt>
mov    0x2e85(%rip),%rcx
mov    $0x0,%r12d
cmp    (%rcx),%rax
je     11bb <do_keep_re+0x8b>
xor    %ebx,%ebx
mov    0x8(%rsp,%rbx,8),%edx
cmp    $0xffffffff,%edx
je     119e <do_keep_re+0x6e>
cmpl   $0xffffffff,0xc(%rsp,%rbx,8)
je     119e <do_keep_re+0x6e>
lea    (%rbx,%rbx,1),%r12
mov    %r15,%rdi
mov    %r13d,%esi
call   1040 <zero_str@plt>
mov    0xc(%rsp,%r12,4),%r13d
add    $0x1,%rbx
cmp    $0x4f,%rbx
jne    1170 <do_keep_re+0x40>
mov    $0x1,%r12b
test   %r13d,%r13d
je     11bb <do_keep_re+0x8b>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %r15,%rdi
mov    %r13d,%esi
mov    %eax,%edx
call   1040 <zero_str@plt>
mov    %r12d,%eax
add    $0x280,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@REG_NOMATCH = global i64 0
define signext i8 @do_keep_re(i32* %0, i32* %1, i8* %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8
%10 = alloca [80 x %struct.TYPE_3__]
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
store i8 0, i8* %9
store i32 0, i32* %11
%13 = load i32*, i32** %5
%14 = load i8*, i8** %7
%15 = getelementptr inbounds [80 x %struct.TYPE_3__], [80 x %struct.TYPE_3__]* %10, i64 0, i64 0
%16 = call i64 @regexec(i32* %13, i8* %14, i32 80, %struct.TYPE_3__* %15, i32 0)
%17 = load i64, i64* @REG_NOMATCH
%18 = icmp ne i64 %16, %17
br i1 %18, label %19, label %65
19: ; preds = %4
store i32 1, i32* %12
br label %20
20: ; preds = %52, %19
%21 = load i32, i32* %12
%22 = icmp slt i32 %21, 80
br i1 %22, label %23, label %55
23: ; preds = %20
%24 = load i32, i32* %12
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [80 x %struct.TYPE_3__], [80 x %struct.TYPE_3__]* %10, i64 0, i64 %25
%27 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %26, i32 0, i32 0
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, -1
br i1 %29, label %37, label %30
30: ; preds = %23
%31 = load i32, i32* %12
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [80 x %struct.TYPE_3__], [80 x %struct.TYPE_3__]* %10, i64 0, i64 %32
%34 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %33, i32 0, i32 1
%35 = load i32, i32* %34
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %38
37: ; preds = %30, %23
br label %55
38: ; preds = %30
%39 = load i8*, i8** %8
%40 = load i32, i32* %11
%41 = load i32, i32* %12
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [80 x %struct.TYPE_3__], [80 x %struct.TYPE_3__]* %10, i64 0, i64 %42
%44 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %43, i32 0, i32 0
%45 = load i32, i32* %44
%46 = call i32 @zero_str(i8* %39, i32 %40, i32 %45)
%47 = load i32, i32* %12
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [80 x %struct.TYPE_3__], [80 x %struct.TYPE_3__]* %10, i64 0, i64 %48
%50 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %49, i32 0, i32 1
%51 = load i32, i32* %50
store i32 %51, i32* %11
br label %52
52: ; preds = %38
%53 = load i32, i32* %12
%54 = add nsw i32 %53, 1
store i32 %54, i32* %12
br label %20
55: ; preds = %37, %20
%56 = load i32, i32* %11
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %64
58: ; preds = %55
%59 = load i8*, i8** %8
%60 = load i32, i32* %11
%61 = load i8*, i8** %7
%62 = call i32 @strlen(i8* %61)
%63 = call i32 @zero_str(i8* %59, i32 %60, i32 %62)
br label %64
64: ; preds = %58, %55
store i8 1, i8* %9
br label %65
65: ; preds = %64, %4
%66 = load i8, i8* %9
ret i8 %66
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@REG_NOMATCH = global i64 0
define signext i8 @do_keep_re(i32* %0, i32* nocapture readnone %1, i8* %2, i8* %3) {
%5 = alloca [80 x %struct.TYPE_3__]
%6 = bitcast [80 x %struct.TYPE_3__]* %5 to i8*
%7 = getelementptr inbounds [80 x %struct.TYPE_3__], [80 x %struct.TYPE_3__]* %5, i64 0, i64 0
%8 = call i64 @regexec(i32* %0, i8* %2, i32 80, %struct.TYPE_3__* %7, i32 0)
%9 = load i64, i64* @REG_NOMATCH
%10 = icmp eq i64 %8, %9
br i1 %10, label %32, label %11
11: ; preds = %4, %21
%12 = phi i64 [ %24, %21 ], [ 1, %4 ]
%13 = phi i32 [ %23, %21 ], [ 0, %4 ]
%14 = getelementptr inbounds [80 x %struct.TYPE_3__], [80 x %struct.TYPE_3__]* %5, i64 0, i64 %12, i32 0
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, -1
br i1 %16, label %26, label %17
17: ; preds = %11
%18 = getelementptr inbounds [80 x %struct.TYPE_3__], [80 x %struct.TYPE_3__]* %5, i64 0, i64 %12, i32 1
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, -1
br i1 %20, label %26, label %21
21: ; preds = %17
%22 = call i32 @zero_str(i8* %3, i32 %13, i32 %15)
%23 = load i32, i32* %18
%24 = add nuw nsw i64 %12, 1
%25 = icmp eq i64 %24, 80
br i1 %25, label %26, label %11
26: ; preds = %11, %17, %21
%27 = phi i32 [ %13, %11 ], [ %13, %17 ], [ %23, %21 ]
%28 = icmp eq i32 %27, 0
br i1 %28, label %32, label %29
29: ; preds = %26
%30 = call i32 @strlen(i8* %2)
%31 = call i32 @zero_str(i8* %3, i32 %27, i32 %30)
br label %32
32: ; preds = %26, %29, %4
%33 = phi i8 [ 0, %4 ], [ 1, %29 ], [ 1, %26 ]
ret i8 %33
}