#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;
  scalar_t__ rm_eo;
};
typedef TYPE_1__ regmatch_t;
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
int REG_EXTENDED;
int REG_ICASE;
int /*<<< orphan*/ regcomp(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ regexec(int /*<<< orphan*/ *, char *, int, TYPE_1__ *,
                           int /*<<< orphan*/);
int /*<<< orphan*/ regfree(int /*<<< orphan*/ *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void parse(char *line, char *mac, char *wlan) {
  char *pattern = "hostapd: ([a-z]+[0-9]+[-]*[0-9]*): STA "
                  "(([0-9A-F]{2}[:-]){5}([0-9A-F]{2}))";
  regex_t emma;
  regmatch_t matches[5];
  int numchars;
  regcomp(&emma, pattern, REG_ICASE | REG_EXTENDED);
  regexec(&emma, line, 5, matches, 0);
  numchars = (int)matches[1].rm_eo - (int)matches[1].rm_so;
  strncpy(wlan, line + matches[1].rm_so, numchars);
  wlan[numchars] = '\0';
  numchars = (int)matches[2].rm_eo - (int)matches[2].rm_so;
  strncpy(mac, line + matches[2].rm_so, numchars);
  mac[numchars] = '\0';
  regfree(&emma);
}


x86 assembly (clang, -O0):
<parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xea2(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    0x2e7b(%rip),%rax
mov    (%rax),%edx
mov    0x2e62(%rip),%rax
or     (%rax),%edx
lea    -0x24(%rbp),%rdi
call   1050 <regcomp@plt>
mov    -0x8(%rbp),%rsi
lea    -0x80(%rbp),%rcx
lea    -0x24(%rbp),%rdi
mov    $0x5,%edx
xor    %r8d,%r8d
call   1060 <regexec@plt>
mov    -0x68(%rbp),%rax
sub    -0x70(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x70(%rbp),%rax
add    %rax,%rsi
mov    -0x84(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
movslq -0x84(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x58(%rbp),%rax
sub    -0x60(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x60(%rbp),%rax
add    %rax,%rsi
mov    -0x84(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x10(%rbp),%rax
movslq -0x84(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
lea    -0x24(%rbp),%rdi
call   1040 <regfree@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x60,%rsp
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r13
mov    0x2e8b(%rip),%rax
mov    0x2e74(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0xe91(%rip),%rsi
lea    0xc(%rsp),%r15
mov    %r15,%rdi
call   1050 <regcomp@plt>
lea    0x10(%rsp),%rcx
mov    %r15,%rdi
mov    %r13,%rsi
mov    $0x5,%edx
xor    %r8d,%r8d
call   1060 <regexec@plt>
movslq 0x28(%rsp),%rbx
movslq 0x20(%rsp),%rsi
sub    %rsi,%rbx
add    %r13,%rsi
mov    %r12,%rdi
mov    %ebx,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%r12,%rbx,1)
movslq 0x38(%rsp),%rbx
movslq 0x30(%rsp),%rax
sub    %rax,%rbx
add    %rax,%r13
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1030 <strncpy@plt>
movb   $0x0,(%r14,%rbx,1)
mov    %r15,%rdi
call   1040 <regfree@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i64 }
@.str = [75 x i8] c"hostapd: ([a-z]+[0-9]+[-]*[0-9]*): STA (([0-9A-F]{2}[:-]){5}([0-9A-F]{2}))\00"
@REG_ICASE = global i32 0
@REG_EXTENDED = global i32 0
define void @parse(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [5 x %struct.TYPE_3__]
%10 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), i8** %7
%11 = load i8*, i8** %7
%12 = load i32, i32* @REG_ICASE
%13 = load i32, i32* @REG_EXTENDED
%14 = or i32 %12, %13
%15 = call i32 @regcomp(i32* %8, i8* %11, i32 %14)
%16 = load i8*, i8** %4
%17 = getelementptr inbounds [5 x %struct.TYPE_3__], [5 x %struct.TYPE_3__]* %9, i64 0, i64 0
%18 = call i32 @regexec(i32* %8, i8* %16, i32 5, %struct.TYPE_3__* %17, i32 0)
%19 = getelementptr inbounds [5 x %struct.TYPE_3__], [5 x %struct.TYPE_3__]* %9, i64 0, i64 1
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %19, i32 0, i32 1
%21 = load i64, i64* %20
%22 = trunc i64 %21 to i32
%23 = getelementptr inbounds [5 x %struct.TYPE_3__], [5 x %struct.TYPE_3__]* %9, i64 0, i64 1
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i32 0, i32 0
%25 = load i32, i32* %24
%26 = sub nsw i32 %22, %25
store i32 %26, i32* %10
%27 = load i8*, i8** %6
%28 = load i8*, i8** %4
%29 = getelementptr inbounds [5 x %struct.TYPE_3__], [5 x %struct.TYPE_3__]* %9, i64 0, i64 1
%30 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %29, i32 0, i32 0
%31 = load i32, i32* %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %28, i64 %32
%34 = load i32, i32* %10
%35 = call i32 @strncpy(i8* %27, i8* %33, i32 %34)
%36 = load i8*, i8** %6
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 0, i8* %39
%40 = getelementptr inbounds [5 x %struct.TYPE_3__], [5 x %struct.TYPE_3__]* %9, i64 0, i64 2
%41 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %40, i32 0, i32 1
%42 = load i64, i64* %41
%43 = trunc i64 %42 to i32
%44 = getelementptr inbounds [5 x %struct.TYPE_3__], [5 x %struct.TYPE_3__]* %9, i64 0, i64 2
%45 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %44, i32 0, i32 0
%46 = load i32, i32* %45
%47 = sub nsw i32 %43, %46
store i32 %47, i32* %10
%48 = load i8*, i8** %5
%49 = load i8*, i8** %4
%50 = getelementptr inbounds [5 x %struct.TYPE_3__], [5 x %struct.TYPE_3__]* %9, i64 0, i64 2
%51 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %50, i32 0, i32 0
%52 = load i32, i32* %51
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %49, i64 %53
%55 = load i32, i32* %10
%56 = call i32 @strncpy(i8* %48, i8* %54, i32 %55)
%57 = load i8*, i8** %5
%58 = load i32, i32* %10
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
store i8 0, i8* %60
%61 = call i32 @regfree(i32* %8)
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i64 }
@.str = [75 x i8] c"hostapd: ([a-z]+[0-9]+[-]*[0-9]*): STA (([0-9A-F]{2}[:-]){5}([0-9A-F]{2}))\00"
@REG_ICASE = global i32 0
@REG_EXTENDED = global i32 0
define void @parse(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca [5 x %struct.TYPE_3__]
%6 = bitcast i32* %4 to i8*
%7 = bitcast [5 x %struct.TYPE_3__]* %5 to i8*
%8 = load i32, i32* @REG_ICASE
%9 = load i32, i32* @REG_EXTENDED
%10 = or i32 %9, %8
%11 = call i32 @regcomp(i32* %4, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [5 x %struct.TYPE_3__], [5 x %struct.TYPE_3__]* %5, i64 0, i64 0
%13 = call i32 @regexec(i32* %4, i8* %0, i32 5, %struct.TYPE_3__* %12, i32 0)
%14 = getelementptr inbounds [5 x %struct.TYPE_3__], [5 x %struct.TYPE_3__]* %5, i64 0, i64 1, i32 1
%15 = load i64, i64* %14
%16 = trunc i64 %15 to i32
%17 = getelementptr inbounds [5 x %struct.TYPE_3__], [5 x %struct.TYPE_3__]* %5, i64 0, i64 1, i32 0
%18 = load i32, i32* %17
%19 = sub nsw i32 %16, %18
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8, i8* %0, i64 %20
%22 = call i32 @strncpy(i8* %2, i8* %21, i32 %19)
%23 = sext i32 %19 to i64
%24 = getelementptr inbounds i8, i8* %2, i64 %23
store i8 0, i8* %24
%25 = getelementptr inbounds [5 x %struct.TYPE_3__], [5 x %struct.TYPE_3__]* %5, i64 0, i64 2, i32 1
%26 = load i64, i64* %25
%27 = trunc i64 %26 to i32
%28 = getelementptr inbounds [5 x %struct.TYPE_3__], [5 x %struct.TYPE_3__]* %5, i64 0, i64 2, i32 0
%29 = load i32, i32* %28
%30 = sub nsw i32 %27, %29
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %0, i64 %31
%33 = call i32 @strncpy(i8* %1, i8* %32, i32 %30)
%34 = sext i32 %30 to i64
%35 = getelementptr inbounds i8, i8* %1, i64 %34
store i8 0, i8* %35
%36 = call i32 @regfree(i32* %4)
ret void
}