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

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int mlfi_regex_mboxtwist(char const *, char const *, char **, char **);
int mlfi_regex_mboxsplit(const char *pMboxDomain, char **ppMbox,
                         char **ppDomain) {
  int match = 0;
  if (pMboxDomain != NULL && ppMbox != NULL && ppDomain != NULL) {
    const char *regstrs[] = {
        ".*<%m@%d>.*",
        ".*[ ]{1,}%m@%d[ ]{1,}.*",
        "%m@%d",
    };
    unsigned int i;
    if (*ppMbox != NULL) {
      free(*ppMbox);
      *ppMbox = NULL;
    }
    if (*ppDomain != NULL) {
      free(*ppDomain);
      *ppDomain = NULL;
    }
    for (i = 0, match = 0; !match && i < sizeof(regstrs) / sizeof(regstrs[0]);
         i++)
      match = mlfi_regex_mboxtwist(pMboxDomain, regstrs[i], ppMbox, ppDomain);
  }
  return match;
}


x86 assembly (clang, -O0):
<mlfi_regex_mboxsplit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1230 <mlfi_regex_mboxsplit+0x110>
cmpq   $0x0,-0x10(%rbp)
je     1230 <mlfi_regex_mboxsplit+0x110>
cmpq   $0x0,-0x18(%rbp)
je     1230 <mlfi_regex_mboxsplit+0x110>
mov    0x2c9d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2c9a(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2c97(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     11a2 <mlfi_regex_mboxsplit+0x82>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11c7 <mlfi_regex_mboxsplit+0xa7>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x1c(%rbp)
mov    %al,-0x45(%rbp)
jne    11f1 <mlfi_regex_mboxsplit+0xd1>
mov    -0x44(%rbp),%eax
cmp    $0x3,%rax
setb   %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
test   $0x1,%al
jne    1201 <mlfi_regex_mboxsplit+0xe1>
jmp    122b <mlfi_regex_mboxsplit+0x10b>
mov    -0x8(%rbp),%rdi
mov    -0x44(%rbp),%eax
mov    -0x40(%rbp,%rax,8),%rsi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1040 <mlfi_regex_mboxtwist@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11d5 <mlfi_regex_mboxsplit+0xb5>
jmp    1230 <mlfi_regex_mboxsplit+0x110>
mov    -0x1c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mlfi_regex_mboxsplit>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
test   %rdi,%rdi
je     11a9 <mlfi_regex_mboxsplit+0x89>
mov    %rsi,%r13
test   %rsi,%rsi
je     11a9 <mlfi_regex_mboxsplit+0x89>
mov    %rdx,%r14
test   %rdx,%rdx
je     11a9 <mlfi_regex_mboxsplit+0x89>
mov    %rdi,%r15
mov    0x0(%r13),%rdi
test   %rdi,%rdi
je     115b <mlfi_regex_mboxsplit+0x3b>
call   1030 <free@plt>
movq   $0x0,0x0(%r13)
mov    (%r14),%rdi
test   %rdi,%rdi
je     116f <mlfi_regex_mboxsplit+0x4f>
call   1030 <free@plt>
movq   $0x0,(%r14)
lea    0xeb6(%rip),%r12
xor    %ebp,%ebp
mov    %r12,%rbx
nopl   0x0(%rax,%rax,1)
movslq (%rbx),%rsi
add    %r12,%rsi
mov    %r15,%rdi
mov    %r13,%rdx
mov    %r14,%rcx
call   1040 <mlfi_regex_mboxtwist@plt>
test   %eax,%eax
jne    11a9 <mlfi_regex_mboxsplit+0x89>
lea    0x1(%rbp),%rcx
add    $0x4,%rbx
cmp    $0x2,%rbp
mov    %rcx,%rbp
jb     1180 <mlfi_regex_mboxsplit+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c".*<%m@%d>.*\00"
@.str.1 = [24 x i8] c".*[ ]{1,}%m@%d[ ]{1,}.*\00"
@.str.2 = [6 x i8] c"%m@%d\00"
@__const.mlfi_regex_mboxsplit.regstrs = [3 x i8*] [i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0)]
define i32 @mlfi_regex_mboxsplit(i8* %0, i8** %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
%8 = alloca [3 x i8*]
%9 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
store i32 0, i32* %7
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %60
12: ; preds = %3
%13 = load i8**, i8*** %5
%14 = icmp ne i8** %13, null
br i1 %14, label %15, label %60
15: ; preds = %12
%16 = load i8**, i8*** %6
%17 = icmp ne i8** %16, null
br i1 %17, label %18, label %60
18: ; preds = %15
%19 = bitcast [3 x i8*]* %8 to i8*
%20 = load i8**, i8*** %5
%21 = load i8*, i8** %20
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i8**, i8*** %5
%25 = load i8*, i8** %24
%26 = call i32 @free(i8* %25)
%27 = load i8**, i8*** %5
store i8* null, i8** %27
br label %28
28: ; preds = %23, %18
%29 = load i8**, i8*** %6
%30 = load i8*, i8** %29
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = load i8**, i8*** %6
%34 = load i8*, i8** %33
%35 = call i32 @free(i8* %34)
%36 = load i8**, i8*** %6
store i8* null, i8** %36
br label %37
37: ; preds = %32, %28
store i32 0, i32* %9
store i32 0, i32* %7
br label %38
38: ; preds = %56, %37
%39 = load i32, i32* %7
%40 = icmp ne i32 %39, 0
br i1 %40, label %45, label %41
41: ; preds = %38
%42 = load i32, i32* %9
%43 = zext i32 %42 to i64
%44 = icmp ult i64 %43, 3
br label %45
45: ; preds = %41, %38
%46 = phi i1 [ false, %38 ], [ %44, %41 ]
br i1 %46, label %47, label %59
47: ; preds = %45
%48 = load i8*, i8** %4
%49 = load i32, i32* %9
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds [3 x i8*], [3 x i8*]* %8, i64 0, i64 %50
%52 = load i8*, i8** %51
%53 = load i8**, i8*** %5
%54 = load i8**, i8*** %6
%55 = call i32 @mlfi_regex_mboxtwist(i8* %48, i8* %52, i8** %53, i8** %54)
store i32 %55, i32* %7
br label %56
56: ; preds = %47
%57 = load i32, i32* %9
%58 = add i32 %57, 1
store i32 %58, i32* %9
br label %38
59: ; preds = %45
br label %60
60: ; preds = %59, %15, %12, %3
%61 = load i32, i32* %7
ret i32 %61
}

LLVM IR (-O2):
@.str = [12 x i8] c".*<%m@%d>.*\00"
@.str.1 = [24 x i8] c".*[ ]{1,}%m@%d[ ]{1,}.*\00"
@.str.2 = [6 x i8] c"%m@%d\00"
@reltable.mlfi_regex_mboxsplit = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.mlfi_regex_mboxsplit to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([24 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.mlfi_regex_mboxsplit to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.mlfi_regex_mboxsplit to i64)) to i32)]
define i32 @mlfi_regex_mboxsplit(i8* %0, i8** %1, i8** %2) {
%4 = icmp ne i8* %0, null
%5 = icmp ne i8** %1, null
%6 = and i1 %4, %5
%7 = icmp ne i8** %2, null
%8 = and i1 %6, %7
br i1 %8, label %9, label %29
9: ; preds = %3
%10 = load i8*, i8** %1
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @free(i8* %10)
store i8* null, i8** %1
br label %14
14: ; preds = %12, %9
%15 = load i8*, i8** %2
%16 = icmp eq i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %14
%18 = tail call i32 @free(i8* %15)
store i8* null, i8** %2
br label %19
19: ; preds = %17, %14
br label %20
20: ; preds = %19, %20
%21 = phi i64 [ %25, %20 ], [ 0, %19 ]
%22 = shl i64 %21, 2
%23 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.mlfi_regex_mboxsplit to i8*), i64 %22)
%24 = tail call i32 @mlfi_regex_mboxtwist(i8* %0, i8* %23, i8** %1, i8** %2)
%25 = add nuw nsw i64 %21, 1
%26 = icmp eq i32 %24, 0
%27 = icmp ult i64 %21, 2
%28 = select i1 %26, i1 %27, i1 false
br i1 %28, label %20, label %29
29: ; preds = %20, %3
%30 = phi i32 [ 0, %3 ], [ %24, %20 ]
ret i32 %30
}