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

/* Variables and functions */
int netgroup_match(char const *, char const *, char *);
scalar_t__ strcasecmp(char const *, char const *);
scalar_t__ strchr(char const *, char);
scalar_t__ string_match(char const *, char const *);
size_t strlen(char const *);
scalar_t__ strncmp(char const *, char const *, size_t);
int from_match(const char *tok, const char *string) {
  size_t tok_len;
  size_t str_len;
  if (tok[0] == '@') {
    return (netgroup_match(tok + 1, string, (char *)0));
  } else if (string_match(tok, string)) {
    return (1);
  } else if (tok[0] == '.') {
    if ((str_len = strlen(string)) > (tok_len = strlen(tok)) &&
        strcasecmp(tok, string + str_len - tok_len) == 0)
      return (1);
  } else if (strcasecmp(tok, "LOCAL") == 0) {
    if (strchr(string, '.') == 0)
      return (1);
  } else if (tok[(tok_len = strlen(tok)) - 1] == '.' &&
             strncmp(tok, string, tok_len) == 0) {
    return (1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<from_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x40,%eax
jne    119d <from_match+0x3d>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <netgroup_match@plt>
mov    %eax,-0x4(%rbp)
jmp    12e5 <from_match+0x185>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <string_match@plt>
cmp    $0x0,%rax
je     11c0 <from_match+0x60>
movl   $0x1,-0x4(%rbp)
jmp    12e5 <from_match+0x185>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1233 <from_match+0xd3>
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x30(%rbp)
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,-0x20(%rbp)
cmp    %rcx,%rax
jbe    122e <from_match+0xce>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    -0x28(%rbp),%rsi
xor    %eax,%eax
sub    -0x20(%rbp),%rax
add    %rax,%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    122e <from_match+0xce>
movl   $0x1,-0x4(%rbp)
jmp    12e5 <from_match+0x185>
jmp    12d4 <from_match+0x174>
mov    -0x10(%rbp),%rdi
lea    0xdc2(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1276 <from_match+0x116>
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
call   1060 <strchr@plt>
cmp    $0x0,%rax
jne    1271 <from_match+0x111>
movl   $0x1,-0x4(%rbp)
jmp    12e5 <from_match+0x185>
jmp    12cf <from_match+0x16f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,-0x20(%rbp)
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    12ca <from_match+0x16a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    12ca <from_match+0x16a>
movl   $0x1,-0x4(%rbp)
jmp    12e5 <from_match+0x185>
jmp    12cf <from_match+0x16f>
jmp    12d4 <from_match+0x174>
jmp    12d9 <from_match+0x179>
jmp    12de <from_match+0x17e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<from_match>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rbp
cmpb   $0x40,(%rdi)
jne    118d <from_match+0x2d>
add    $0x1,%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <netgroup_match@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1080 <string_match@plt>
mov    $0x1,%r14d
test   %rax,%rax
jne    121c <from_match+0xbc>
cmpb   $0x2e,0x0(%rbp)
jne    11d4 <from_match+0x74>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rax,%r15
mov    %rbp,%rdi
call   1050 <strlen@plt>
cmp    %rax,%r15
jbe    1219 <from_match+0xb9>
add    %r15,%rbx
sub    %rax,%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcasecmp@plt>
jmp    1214 <from_match+0xb4>
lea    0xe25(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1207 <from_match+0xa7>
mov    %rbp,%rdi
call   1050 <strlen@plt>
cmpb   $0x2e,-0x1(%rax,%rbp,1)
jne    1219 <from_match+0xb9>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <strncmp@plt>
jmp    1214 <from_match+0xb4>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     121c <from_match+0xbc>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"LOCAL\00"
define i32 @from_match(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 64
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 1
%16 = load i8*, i8** %5
%17 = call i32 @netgroup_match(i8* %15, i8* %16, i8* null)
store i32 %17, i32* %3
br label %79
18: ; preds = %2
%19 = load i8*, i8** %4
%20 = load i8*, i8** %5
%21 = call i64 @string_match(i8* %19, i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 1, i32* %3
br label %79
24: ; preds = %18
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 46
br i1 %29, label %30, label %48
30: ; preds = %24
%31 = load i8*, i8** %5
%32 = call i64 @strlen(i8* %31)
store i64 %32, i64* %7
%33 = load i8*, i8** %4
%34 = call i64 @strlen(i8* %33)
store i64 %34, i64* %6
%35 = icmp ugt i64 %32, %34
br i1 %35, label %36, label %47
36: ; preds = %30
%37 = load i8*, i8** %4
%38 = load i8*, i8** %5
%39 = load i64, i64* %7
%40 = getelementptr inbounds i8, i8* %38, i64 %39
%41 = load i64, i64* %6
%42 = sub i64 0, %41
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = call i64 @strcasecmp(i8* %37, i8* %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %36
store i32 1, i32* %3
br label %79
47: ; preds = %36, %30
br label %76
48: ; preds = %24
%49 = load i8*, i8** %4
%50 = call i64 @strcasecmp(i8* %49, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %58
52: ; preds = %48
%53 = load i8*, i8** %5
%54 = call i64 @strchr(i8* %53, i8 signext 46)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %52
store i32 1, i32* %3
br label %79
57: ; preds = %52
br label %75
58: ; preds = %48
%59 = load i8*, i8** %4
%60 = load i8*, i8** %4
%61 = call i64 @strlen(i8* %60)
store i64 %61, i64* %6
%62 = sub i64 %61, 1
%63 = getelementptr inbounds i8, i8* %59, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 46
br i1 %66, label %67, label %74
67: ; preds = %58
%68 = load i8*, i8** %4
%69 = load i8*, i8** %5
%70 = load i64, i64* %6
%71 = call i64 @strncmp(i8* %68, i8* %69, i64 %70)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %67
store i32 1, i32* %3
br label %79
74: ; preds = %67, %58
br label %75
75: ; preds = %74, %57
br label %76
76: ; preds = %75, %47
br label %77
77: ; preds = %76
br label %78
78: ; preds = %77
store i32 0, i32* %3
br label %79
79: ; preds = %78, %73, %56, %46, %23, %13
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
@.str = [6 x i8] c"LOCAL\00"
define i32 @from_match(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 64
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = tail call i32 @netgroup_match(i8* %6, i8* %1, i8* null)
br label %40
8: ; preds = %2
%9 = tail call i64 @string_match(i8* %0, i8* %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %40
11: ; preds = %8
%12 = load i8, i8* %0
%13 = icmp eq i8 %12, 46
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%16 = tail call i64 @strlen(i8* %0)
%17 = icmp ugt i64 %15, %16
br i1 %17, label %18, label %39
18: ; preds = %14
%19 = getelementptr inbounds i8, i8* %1, i64 %15
%20 = sub i64 0, %16
%21 = getelementptr inbounds i8, i8* %19, i64 %20
%22 = tail call i64 @strcasecmp(i8* %0, i8* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %40, label %39
24: ; preds = %11
%25 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = tail call i64 @strchr(i8* %1, i8 signext 46)
%29 = icmp eq i64 %28, 0
br i1 %29, label %40, label %39
30: ; preds = %24
%31 = tail call i64 @strlen(i8* %0)
%32 = add i64 %31, -1
%33 = getelementptr inbounds i8, i8* %0, i64 %32
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 46
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = tail call i64 @strncmp(i8* %0, i8* %1, i64 %31)
%38 = icmp eq i64 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %27, %36, %30, %14, %18
br label %40
40: ; preds = %36, %27, %18, %8, %39, %5
%41 = phi i32 [ %7, %5 ], [ 0, %39 ], [ 1, %8 ], [ 1, %18 ], [ 1, %27 ], [ 1, %36 ]
ret i32 %41
}