#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 countlib(int);
int offset(int, int, int, int);
scalar_t__ play_attack_defend_n(int, int, int, int, int);
int autohelperowl_vital_apat12(struct pattern *patt, int transformation,
                               int move, int color, int action) {
  int a, A;
  (void)patt;
  (void)color;
  (void)action;
  a = offset(2, 1, move, transformation);
  A = offset(-1, 0, move, transformation);
  return countlib(A) <= 3 && play_attack_defend_n(color, 1, 1, a, a);
}


x86 assembly (clang, -O0):
<autohelperowl_vital_apat12>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    $0x2,%edi
mov    $0x1,%esi
call   1040 <offset@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    $0xffffffff,%edi
xor    %esi,%esi
call   1040 <offset@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1050 <countlib@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x3,%ecx
mov    %al,-0x21(%rbp)
jg     11ae <autohelperowl_vital_apat12+0x7e>
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <play_attack_defend_n@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<autohelperowl_vital_apat12>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%ebx
mov    $0x2,%edi
mov    $0x1,%esi
mov    %ebx,%ecx
call   1040 <offset@plt>
mov    %eax,%r15d
xor    %r12d,%r12d
mov    $0xffffffff,%edi
xor    %esi,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1040 <offset@plt>
mov    %eax,%edi
call   1050 <countlib@plt>
cmp    $0x3,%eax
jg     1194 <autohelperowl_vital_apat12+0x64>
mov    %r14d,%edi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15d,%ecx
mov    %r15d,%r8d
call   1030 <play_attack_defend_n@plt>
xor    %r12d,%r12d
test   %rax,%rax
setne  %r12b
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.pattern = type { i32 }
define i32 @autohelperowl_vital_apat12(%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
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
%13 = load %struct.pattern*, %struct.pattern** %6
%14 = load i32, i32* %9
%15 = load i32, i32* %10
%16 = load i32, i32* %8
%17 = load i32, i32* %7
%18 = call i32 @offset(i32 2, i32 1, i32 %16, i32 %17)
store i32 %18, i32* %11
%19 = load i32, i32* %8
%20 = load i32, i32* %7
%21 = call i32 @offset(i32 -1, i32 0, i32 %19, i32 %20)
store i32 %21, i32* %12
%22 = load i32, i32* %12
%23 = call i32 @countlib(i32 %22)
%24 = icmp sle i32 %23, 3
br i1 %24, label %25, label %31
25: ; preds = %5
%26 = load i32, i32* %9
%27 = load i32, i32* %11
%28 = load i32, i32* %11
%29 = call i64 @play_attack_defend_n(i32 %26, i32 1, i32 1, i32 %27, i32 %28)
%30 = icmp ne i64 %29, 0
br label %31
31: ; preds = %25, %5
%32 = phi i1 [ false, %5 ], [ %30, %25 ]
%33 = zext i1 %32 to i32
ret i32 %33
}

LLVM IR (-O2):
%struct.pattern = type { i32 }
define i32 @autohelperowl_vital_apat12(%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 -1, i32 0, i32 %2, i32 %1)
%8 = tail call i32 @countlib(i32 %7)
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = tail call i64 @play_attack_defend_n(i32 %3, i32 1, i32 1, i32 %6, i32 %6)
%12 = icmp ne i64 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %10, %5
%15 = phi i32 [ 0, %5 ], [ %13, %10 ]
ret i32 %15
}