#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 */
struct session {
  int dummy;
};

/* Variables and functions */
int action_regexp(char *, char *, int);
scalar_t__ isdigit(char);
int /*<<< orphan*/ substitute(struct session *, char *, char *, int);
int check_one_action(char *line, char *original, char *action,
                     struct session *ses) {
  char result[10000], *ptr;
  char *ptl;
  substitute(ses, action, result, (1 << 1) | (1 << 2) | (1 << 4));
  ptr = result;
  if (*ptr == '~') {
    ptr++;
    ptl = original;
  } else {
    ptl = line;
  }
  if (*ptr == '^') {
    ptr++;
    return action_regexp(ptr, ptl, 255);
  }
  if (ptr[0] == '%' && isdigit(ptr[1])) {
    return action_regexp(ptr, ptl, 255);
  }
  while (*ptl) {
    if ((*ptr == '[' || *ptr == *ptl) && action_regexp(ptr, ptl, 255)) {
      return 1;
    }
    ptl++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_one_action>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2750,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x2740(%rbp),%rdx
mov    $0x16,%ecx
call   1050 <substitute@plt>
lea    -0x2740(%rbp),%rax
mov    %rax,-0x2748(%rbp)
mov    -0x2748(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7e,%eax
jne    11a7 <check_one_action+0x77>
mov    -0x2748(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2748(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x2750(%rbp)
jmp    11b2 <check_one_action+0x82>
mov    -0x10(%rbp),%rax
mov    %rax,-0x2750(%rbp)
mov    -0x2748(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5e,%eax
jne    11f7 <check_one_action+0xc7>
mov    -0x2748(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2748(%rbp)
mov    -0x2748(%rbp),%rdi
mov    -0x2750(%rbp),%rsi
mov    $0xff,%edx
call   1040 <action_regexp@plt>
mov    %eax,-0x4(%rbp)
jmp    12d3 <check_one_action+0x1a3>
mov    -0x2748(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
jne    1244 <check_one_action+0x114>
mov    -0x2748(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1244 <check_one_action+0x114>
mov    -0x2748(%rbp),%rdi
mov    -0x2750(%rbp),%rsi
mov    $0xff,%edx
call   1040 <action_regexp@plt>
mov    %eax,-0x4(%rbp)
jmp    12d3 <check_one_action+0x1a3>
jmp    1249 <check_one_action+0x119>
mov    -0x2750(%rbp),%rax
cmpb   $0x0,(%rax)
je     12cc <check_one_action+0x19c>
mov    -0x2748(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
je     1288 <check_one_action+0x158>
mov    -0x2748(%rbp),%rax
movsbl (%rax),%eax
mov    -0x2750(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    12b5 <check_one_action+0x185>
mov    -0x2748(%rbp),%rdi
mov    -0x2750(%rbp),%rsi
mov    $0xff,%edx
call   1040 <action_regexp@plt>
cmp    $0x0,%eax
je     12b5 <check_one_action+0x185>
movl   $0x1,-0x4(%rbp)
jmp    12d3 <check_one_action+0x1a3>
mov    -0x2750(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x2750(%rbp)
jmp    1249 <check_one_action+0x119>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2750,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_one_action>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2710,%rsp
mov    %rsi,%r12
mov    %rdi,%rbx
mov    %rsp,%r15
mov    %rcx,%rdi
mov    %rdx,%rsi
mov    %r15,%rdx
mov    $0x16,%ecx
call   1050 <substitute@plt>
mov    (%rsp),%al
xor    %ebp,%ebp
cmp    $0x7e,%al
sete   %bpl
lea    0x1(%rsp),%rcx
mov    %r15,%r14
cmove  %rcx,%r14
cmove  %r12,%rbx
mov    (%rsp,%rbp,1),%dl
cmp    $0x25,%dl
je     1193 <check_one_action+0x63>
cmp    $0x5e,%dl
jne    11d0 <check_one_action+0xa0>
cmp    $0x7e,%al
lea    0x2(%rsp),%rax
cmove  %rax,%rcx
mov    %rcx,%r14
jmp    11aa <check_one_action+0x7a>
xor    %ecx,%ecx
cmp    $0x7e,%al
sete   %cl
movsbl 0x1(%rcx,%r15,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11d0 <check_one_action+0xa0>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0xff,%edx
call   1040 <action_regexp@plt>
mov    %eax,%r15d
mov    %r15d,%eax
add    $0x2710,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%al
xor    %r15d,%r15d
jmp    11fc <check_one_action+0xcc>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0xff,%edx
call   1040 <action_regexp@plt>
test   %eax,%eax
jne    120f <check_one_action+0xdf>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     11bd <check_one_action+0x8d>
movzbl (%rsp,%rbp,1),%ecx
cmp    $0x5b,%cl
je     11e0 <check_one_action+0xb0>
cmp    %al,%cl
jne    11f4 <check_one_action+0xc4>
jmp    11e0 <check_one_action+0xb0>
mov    $0x1,%r15d
jmp    11bd <check_one_action+0x8d>

LLVM IR (-O0):
%struct.session = type { i32 }
define i32 @check_one_action(i8* %0, i8* %1, i8* %2, %struct.session* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.session*
%10 = alloca [10000 x i8]
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store %struct.session* %3, %struct.session** %9
%13 = load %struct.session*, %struct.session** %9
%14 = load i8*, i8** %8
%15 = getelementptr inbounds [10000 x i8], [10000 x i8]* %10, i64 0, i64 0
%16 = call i32 @substitute(%struct.session* %13, i8* %14, i8* %15, i32 22)
%17 = getelementptr inbounds [10000 x i8], [10000 x i8]* %10, i64 0, i64 0
store i8* %17, i8** %11
%18 = load i8*, i8** %11
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 126
br i1 %21, label %22, label %26
22: ; preds = %4
%23 = load i8*, i8** %11
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %11
%25 = load i8*, i8** %7
store i8* %25, i8** %12
br label %28
26: ; preds = %4
%27 = load i8*, i8** %6
store i8* %27, i8** %12
br label %28
28: ; preds = %26, %22
%29 = load i8*, i8** %11
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 94
br i1 %32, label %33, label %39
33: ; preds = %28
%34 = load i8*, i8** %11
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %11
%36 = load i8*, i8** %11
%37 = load i8*, i8** %12
%38 = call i32 @action_regexp(i8* %36, i8* %37, i32 255)
store i32 %38, i32* %5
br label %83
39: ; preds = %28
%40 = load i8*, i8** %11
%41 = getelementptr inbounds i8, i8* %40, i64 0
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 37
br i1 %44, label %45, label %55
45: ; preds = %39
%46 = load i8*, i8** %11
%47 = getelementptr inbounds i8, i8* %46, i64 1
%48 = load i8, i8* %47
%49 = call i64 @isdigit(i8 signext %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %45
%52 = load i8*, i8** %11
%53 = load i8*, i8** %12
%54 = call i32 @action_regexp(i8* %52, i8* %53, i32 255)
store i32 %54, i32* %5
br label %83
55: ; preds = %45, %39
br label %56
56: ; preds = %79, %55
%57 = load i8*, i8** %12
%58 = load i8, i8* %57
%59 = icmp ne i8 %58, 0
br i1 %59, label %60, label %82
60: ; preds = %56
%61 = load i8*, i8** %11
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 91
br i1 %64, label %73, label %65
65: ; preds = %60
%66 = load i8*, i8** %11
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = load i8*, i8** %12
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %68, %71
br i1 %72, label %73, label %79
73: ; preds = %65, %60
%74 = load i8*, i8** %11
%75 = load i8*, i8** %12
%76 = call i32 @action_regexp(i8* %74, i8* %75, i32 255)
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %79
78: ; preds = %73
store i32 1, i32* %5
br label %83
79: ; preds = %73, %65
%80 = load i8*, i8** %12
%81 = getelementptr inbounds i8, i8* %80, i32 1
store i8* %81, i8** %12
br label %56
82: ; preds = %56
store i32 0, i32* %5
br label %83
83: ; preds = %82, %78, %51, %33
%84 = load i32, i32* %5
ret i32 %84
}

LLVM IR (-O2):
%struct.session = type { i32 }
define i32 @check_one_action(i8* %0, i8* %1, i8* %2, %struct.session* %3) {
%5 = alloca [10000 x i8]
%6 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%7 = call i32 @substitute(%struct.session* %3, i8* %2, i8* %6, i32 22)
%8 = load i8, i8* %6
%9 = icmp eq i8 %8, 126
%10 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 1
%11 = select i1 %9, i8* %10, i8* %6
%12 = select i1 %9, i8* %1, i8* %0
%13 = load i8, i8* %11
switch i8 %13, label %24 [
i8 94, label %14
i8 37, label %17
]
14: ; preds = %4
%15 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 2
%16 = select i1 %9, i8* %15, i8* %10
br label %41
17: ; preds = %4
%18 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 2
%19 = load i8, i8* %18
%20 = load i8, i8* %10
%21 = select i1 %9, i8 %19, i8 %20
%22 = call i64 @isdigit(i8 signext %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %41
24: ; preds = %4, %17
%25 = load i8, i8* %12
%26 = icmp eq i8 %25, 0
br i1 %26, label %44, label %27
27: ; preds = %24, %37
%28 = phi i8 [ %39, %37 ], [ %25, %24 ]
%29 = phi i8* [ %38, %37 ], [ %12, %24 ]
%30 = load i8, i8* %11
%31 = icmp eq i8 %30, 91
%32 = icmp eq i8 %30, %28
%33 = select i1 %31, i1 true, i1 %32
br i1 %33, label %34, label %37
34: ; preds = %27
%35 = call i32 @action_regexp(i8* %11, i8* %29, i32 255)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %44
37: ; preds = %27, %34
%38 = getelementptr inbounds i8, i8* %29, i64 1
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 0
br i1 %40, label %44, label %27
41: ; preds = %17, %14
%42 = phi i8* [ %16, %14 ], [ %11, %17 ]
%43 = call i32 @action_regexp(i8* %42, i8* %12, i32 255)
br label %44
44: ; preds = %34, %37, %41, %24
%45 = phi i32 [ 0, %24 ], [ %43, %41 ], [ 1, %34 ], [ 0, %37 ]
ret i32 %45
}