#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 pattern {
  int dummy;
};

/* Variables and functions */
int accurate_approxlib(int, int, int, int /*<<< orphan*/ *);
int countlib(int);
int offset(int, int, int, int);
scalar_t__ play_attack_defend_n(int, int, int, int, int, int, int, int, ...);
int autohelperowl_attackpat40(struct pattern *patt, int transformation,
                              int move, int color, int action) {
  int a, b, c, d, e, f, A;
  (void)patt;
  (void)color;
  (void)action;
  a = offset(-2, -1, move, transformation);
  b = offset(-2, -2, move, transformation);
  c = offset(-1, 0, move, transformation);
  d = offset(0, 1, move, transformation);
  e = offset(0, -2, move, transformation);
  f = offset(1, 0, move, transformation);
  A = offset(-1, -2, move, transformation);
  return (accurate_approxlib(a, (1 + 2 - (color)), 20, NULL) == 1 ||
          countlib(b) > 2) &&
         countlib(A) <= 3 && accurate_approxlib(e, color, 20, NULL) > 1 &&
         play_attack_defend_n(color, 1, 6, move, c, a, d, e, f, A) &&
         play_attack_defend_n(color, 0, 4, move, c, a, e, move);
}


x86 assembly (clang, -O0):
<autohelperowl_attackpat40>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x58,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0xfffffffe,%edi
mov    $0xffffffff,%esi
call   1040 <offset@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0xfffffffe,%esi
mov    %esi,%edi
call   1040 <offset@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0xffffffff,%edi
xor    %esi,%esi
call   1040 <offset@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
xor    %edi,%edi
mov    $0x1,%esi
call   1040 <offset@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
xor    %edi,%edi
mov    $0xfffffffe,%esi
call   1040 <offset@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0x1,%edi
xor    %esi,%esi
call   1040 <offset@plt>
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    $0xffffffff,%edi
mov    $0xfffffffe,%esi
call   1040 <offset@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x24(%rbp),%edi
mov    $0x3,%esi
sub    -0x1c(%rbp),%esi
mov    $0x14,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <accurate_approxlib@plt>
cmp    $0x1,%eax
je     122d <autohelperowl_attackpat40+0xed>
mov    -0x28(%rbp),%edi
call   1060 <countlib@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
mov    %al,-0x3d(%rbp)
jle    12ee <autohelperowl_attackpat40+0x1ae>
mov    -0x3c(%rbp),%edi
call   1060 <countlib@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x3,%ecx
mov    %al,-0x3d(%rbp)
jg     12ee <autohelperowl_attackpat40+0x1ae>
mov    -0x34(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    $0x14,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <accurate_approxlib@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
mov    %al,-0x3d(%rbp)
jle    12ee <autohelperowl_attackpat40+0x1ae>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x24(%rbp),%r9d
mov    -0x30(%rbp),%ebx
mov    -0x34(%rbp),%r11d
mov    -0x38(%rbp),%r10d
mov    -0x3c(%rbp),%eax
mov    $0x1,%esi
mov    $0x6,%edx
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
mov    $0x0,%al
call   1030 <play_attack_defend_n@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x3d(%rbp)
je     12ee <autohelperowl_attackpat40+0x1ae>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x24(%rbp),%r9d
mov    -0x34(%rbp),%r10d
mov    -0x18(%rbp),%eax
xor    %esi,%esi
mov    $0x4,%edx
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1030 <play_attack_defend_n@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x3d(%rbp)
mov    -0x3d(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<autohelperowl_attackpat40>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%r12d
mov    %edx,%ebx
mov    %esi,%ebp
mov    $0xfffffffe,%edi
mov    $0xffffffff,%esi
mov    %ebp,%ecx
call   1040 <offset@plt>
mov    %eax,%r15d
mov    $0xfffffffe,%edi
mov    $0xfffffffe,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1040 <offset@plt>
mov    %eax,%r13d
xor    %r14d,%r14d
mov    $0xffffffff,%edi
xor    %esi,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1040 <offset@plt>
mov    %eax,0xc(%rsp)
xor    %edi,%edi
mov    $0x1,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1040 <offset@plt>
mov    %rax,0x20(%rsp)
xor    %edi,%edi
mov    $0xfffffffe,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1040 <offset@plt>
mov    %rax,0x10(%rsp)
mov    $0x1,%edi
xor    %esi,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1040 <offset@plt>
mov    %rax,0x18(%rsp)
mov    $0xffffffff,%edi
mov    $0xfffffffe,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %r15d,%ebp
call   1040 <offset@plt>
mov    %eax,%r15d
mov    $0x3,%esi
sub    %r12d,%esi
mov    %ebp,%edi
mov    $0x14,%edx
xor    %ecx,%ecx
call   1050 <accurate_approxlib@plt>
cmp    $0x1,%eax
je     121a <autohelperowl_attackpat40+0xda>
mov    %r13d,%edi
call   1060 <countlib@plt>
cmp    $0x3,%eax
jl     12ad <autohelperowl_attackpat40+0x16d>
mov    %r15d,%edi
call   1060 <countlib@plt>
cmp    $0x3,%eax
jg     12ad <autohelperowl_attackpat40+0x16d>
xor    %r14d,%r14d
mov    0x10(%rsp),%rdi
mov    %r12d,%esi
mov    $0x14,%edx
xor    %ecx,%ecx
call   1050 <accurate_approxlib@plt>
cmp    $0x2,%eax
jl     12ad <autohelperowl_attackpat40+0x16d>
xor    %r14d,%r14d
mov    %r12d,%edi
mov    $0x1,%esi
mov    $0x6,%edx
mov    %ebx,%ecx
mov    0xc(%rsp),%r8d
mov    %ebp,%r9d
xor    %eax,%eax
push   %r15
push   0x20(%rsp)
push   0x20(%rsp)
push   0x38(%rsp)
call   1030 <play_attack_defend_n@plt>
add    $0x20,%rsp
test   %rax,%rax
je     12ad <autohelperowl_attackpat40+0x16d>
mov    %r12d,%edi
xor    %esi,%esi
mov    $0x4,%edx
mov    %ebx,%ecx
mov    0xc(%rsp),%r8d
mov    %ebp,%r9d
xor    %eax,%eax
push   %rbx
push   0x18(%rsp)
call   1030 <play_attack_defend_n@plt>
add    $0x10,%rsp
xor    %r14d,%r14d
test   %rax,%rax
setne  %r14b
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.pattern = type { i32 }
define i32 @autohelperowl_attackpat40(%struct.pattern* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca %struct.pattern*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store %struct.pattern* %0, %struct.pattern** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%18 = load %struct.pattern*, %struct.pattern** %6
%19 = load i32, i32* %9
%20 = load i32, i32* %10
%21 = load i32, i32* %8
%22 = load i32, i32* %7
%23 = call i32 @offset(i32 -2, i32 -1, i32 %21, i32 %22)
store i32 %23, i32* %11
%24 = load i32, i32* %8
%25 = load i32, i32* %7
%26 = call i32 @offset(i32 -2, i32 -2, i32 %24, i32 %25)
store i32 %26, i32* %12
%27 = load i32, i32* %8
%28 = load i32, i32* %7
%29 = call i32 @offset(i32 -1, i32 0, i32 %27, i32 %28)
store i32 %29, i32* %13
%30 = load i32, i32* %8
%31 = load i32, i32* %7
%32 = call i32 @offset(i32 0, i32 1, i32 %30, i32 %31)
store i32 %32, i32* %14
%33 = load i32, i32* %8
%34 = load i32, i32* %7
%35 = call i32 @offset(i32 0, i32 -2, i32 %33, i32 %34)
store i32 %35, i32* %15
%36 = load i32, i32* %8
%37 = load i32, i32* %7
%38 = call i32 @offset(i32 1, i32 0, i32 %36, i32 %37)
store i32 %38, i32* %16
%39 = load i32, i32* %8
%40 = load i32, i32* %7
%41 = call i32 @offset(i32 -1, i32 -2, i32 %39, i32 %40)
store i32 %41, i32* %17
%42 = load i32, i32* %11
%43 = load i32, i32* %9
%44 = sub nsw i32 3, %43
%45 = call i32 @accurate_approxlib(i32 %42, i32 %44, i32 20, i32* null)
%46 = icmp eq i32 %45, 1
br i1 %46, label %51, label %47
47: ; preds = %5
%48 = load i32, i32* %12
%49 = call i32 @countlib(i32 %48)
%50 = icmp sgt i32 %49, 2
br i1 %50, label %51, label %80
51: ; preds = %47, %5
%52 = load i32, i32* %17
%53 = call i32 @countlib(i32 %52)
%54 = icmp sle i32 %53, 3
br i1 %54, label %55, label %80
55: ; preds = %51
%56 = load i32, i32* %15
%57 = load i32, i32* %9
%58 = call i32 @accurate_approxlib(i32 %56, i32 %57, i32 20, i32* null)
%59 = icmp sgt i32 %58, 1
br i1 %59, label %60, label %80
60: ; preds = %55
%61 = load i32, i32* %9
%62 = load i32, i32* %8
%63 = load i32, i32* %13
%64 = load i32, i32* %11
%65 = load i32, i32* %14
%66 = load i32, i32* %15
%67 = load i32, i32* %16
%68 = load i32, i32* %17
%69 = call i64 (i32, i32, i32, i32, i32, i32, i32, i32, ...) @play_attack_defend_n(i32 %61, i32 1, i32 6, i32 %62, i32 %63, i32 %64, i32 %65, i32 %66, i32 %67, i32 %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %80
71: ; preds = %60
%72 = load i32, i32* %9
%73 = load i32, i32* %8
%74 = load i32, i32* %13
%75 = load i32, i32* %11
%76 = load i32, i32* %15
%77 = load i32, i32* %8
%78 = call i64 (i32, i32, i32, i32, i32, i32, i32, i32, ...) @play_attack_defend_n(i32 %72, i32 0, i32 4, i32 %73, i32 %74, i32 %75, i32 %76, i32 %77)
%79 = icmp ne i64 %78, 0
br label %80
80: ; preds = %71, %60, %55, %51, %47
%81 = phi i1 [ false, %60 ], [ false, %55 ], [ false, %51 ], [ false, %47 ], [ %79, %71 ]
%82 = zext i1 %81 to i32
ret i32 %82
}

LLVM IR (-O2):
%struct.pattern = type { i32 }
define i32 @autohelperowl_attackpat40(%struct.pattern* nocapture readnone %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 @offset(i32 -2, i32 -1, i32 %2, i32 %1)
%7 = tail call i32 @offset(i32 -2, i32 -2, i32 %2, i32 %1)
%8 = tail call i32 @offset(i32 -1, i32 0, i32 %2, i32 %1)
%9 = tail call i32 @offset(i32 0, i32 1, i32 %2, i32 %1)
%10 = tail call i32 @offset(i32 0, i32 -2, i32 %2, i32 %1)
%11 = tail call i32 @offset(i32 1, i32 0, i32 %2, i32 %1)
%12 = tail call i32 @offset(i32 -1, i32 -2, i32 %2, i32 %1)
%13 = sub nsw i32 3, %3
%14 = tail call i32 @accurate_approxlib(i32 %6, i32 %13, i32 20, i32* null)
%15 = icmp eq i32 %14, 1
br i1 %15, label %19, label %16
16: ; preds = %5
%17 = tail call i32 @countlib(i32 %7)
%18 = icmp sgt i32 %17, 2
br i1 %18, label %19, label %32
19: ; preds = %16, %5
%20 = tail call i32 @countlib(i32 %12)
%21 = icmp slt i32 %20, 4
br i1 %21, label %22, label %32
22: ; preds = %19
%23 = tail call i32 @accurate_approxlib(i32 %10, i32 %3, i32 20, i32* null)
%24 = icmp sgt i32 %23, 1
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = tail call i64 (i32, i32, i32, i32, i32, i32, i32, i32, ...) @play_attack_defend_n(i32 %3, i32 1, i32 6, i32 %2, i32 %8, i32 %6, i32 %9, i32 %10, i32 %11, i32 %12)
%27 = icmp eq i64 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = tail call i64 (i32, i32, i32, i32, i32, i32, i32, i32, ...) @play_attack_defend_n(i32 %3, i32 0, i32 4, i32 %2, i32 %8, i32 %6, i32 %10, i32 %2)
%30 = icmp ne i64 %29, 0
%31 = zext i1 %30 to i32
br label %32
32: ; preds = %28, %25, %22, %19, %16
%33 = phi i32 [ 0, %25 ], [ 0, %22 ], [ 0, %19 ], [ 0, %16 ], [ %31, %28 ]
ret i32 %33
}