#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 /*<<< orphan*/ cards_getcouponed(int, int, int *);
scalar_t__ data_hasbuilt(int, int, int);
int data_iscouponed(int p, int era, int card) {
  int coupons[4];
  cards_getcouponed(era, card, coupons);
  int i;
  for (i = 0; i < 3; i += 2) {
    if (coupons[i + 1])
      if (data_hasbuilt(p, coupons[i], coupons[i + 1]))
        return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<data_iscouponed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
lea    -0x20(%rbp),%rdx
call   1040 <cards_getcouponed@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x24(%rbp)
jge    11ae <data_iscouponed+0x8e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
cmpl   $0x0,-0x20(%rbp,%rax,4)
je     119b <data_iscouponed+0x7b>
mov    -0x8(%rbp),%edi
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%esi
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
mov    -0x20(%rbp,%rax,4),%edx
call   1030 <data_hasbuilt@plt>
cmp    $0x0,%rax
je     1196 <data_iscouponed+0x76>
movl   $0x1,-0x4(%rbp)
jmp    11b5 <data_iscouponed+0x95>
jmp    119b <data_iscouponed+0x7b>
jmp    11a0 <data_iscouponed+0x80>
mov    -0x24(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x24(%rbp)
jmp    1147 <data_iscouponed+0x27>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<data_iscouponed>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
mov    %rsp,%rax
mov    %esi,%edi
mov    %edx,%esi
mov    %rax,%rdx
call   1040 <cards_getcouponed@plt>
mov    0x4(%rsp),%edx
test   %edx,%edx
je     1155 <data_iscouponed+0x35>
mov    (%rsp),%esi
mov    %ebx,%edi
call   1030 <data_hasbuilt@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1177 <data_iscouponed+0x57>
mov    0xc(%rsp),%edx
test   %edx,%edx
je     1175 <data_iscouponed+0x55>
mov    0x8(%rsp),%esi
mov    %ebx,%edi
call   1030 <data_hasbuilt@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1177 <data_iscouponed+0x57>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @data_iscouponed(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [4 x i32]
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 0
%13 = call i32 @cards_getcouponed(i32 %10, i32 %11, i32* %12)
store i32 0, i32* %9
br label %14
14: ; preds = %40, %3
%15 = load i32, i32* %9
%16 = icmp slt i32 %15, 3
br i1 %16, label %17, label %43
17: ; preds = %14
%18 = load i32, i32* %9
%19 = add nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %39
24: ; preds = %17
%25 = load i32, i32* %5
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [4 x i32], [4 x i32]* %8, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = call i64 @data_hasbuilt(i32 %25, i32 %29, i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %24
store i32 1, i32* %4
br label %44
38: ; preds = %24
br label %39
39: ; preds = %38, %17
br label %40
40: ; preds = %39
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 2
store i32 %42, i32* %9
br label %14
43: ; preds = %14
store i32 0, i32* %4
br label %44
44: ; preds = %43, %37
%45 = load i32, i32* %4
ret i32 %45
}

LLVM IR (-O2):
define i32 @data_iscouponed(i32 %0, i32 %1, i32 %2) {
%4 = alloca [4 x i32]
%5 = bitcast [4 x i32]* %4 to i8*
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%7 = call i32 @cards_getcouponed(i32 %1, i32 %2, i32* %6)
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 1
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %3
%12 = load i32, i32* %6
%13 = call i64 @data_hasbuilt(i32 %0, i32 %12, i32 %9)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %25
15: ; preds = %3, %11
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 3
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %15
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 2
%21 = load i32, i32* %20
%22 = call i64 @data_hasbuilt(i32 %0, i32 %21, i32 %17)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19, %15
br label %25
25: ; preds = %24, %19, %11
%26 = phi i32 [ 1, %11 ], [ 1, %19 ], [ 0, %24 ]
ret i32 %26
}