#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 *data_getbuilt(int);
int data_hasbuilt(int p, int era, int card) {
  int *built = data_getbuilt(p);
  int i;
  for (i = 0; built[i] != -1; i += 2)
    if (built[i] == era && built[i + 1] == card)
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<data_hasbuilt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <data_getbuilt@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0xffffffff,(%rax,%rcx,4)
je     1192 <data_hasbuilt+0x82>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0xc(%rbp),%eax
jne    117f <data_hasbuilt+0x6f>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x10(%rbp),%eax
jne    117f <data_hasbuilt+0x6f>
movl   $0x1,-0x4(%rbp)
jmp    1199 <data_hasbuilt+0x89>
jmp    1184 <data_hasbuilt+0x74>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    1134 <data_hasbuilt+0x24>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<data_hasbuilt>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%ebp
call   1030 <data_getbuilt@plt>
mov    %rax,%rcx
mov    (%rax),%edx
xor    %eax,%eax
cmp    $0xffffffff,%edx
je     1149 <data_hasbuilt+0x39>
add    $0x8,%rcx
jmp    113b <data_hasbuilt+0x2b>
xchg   %ax,%ax
mov    (%rcx),%edx
add    $0x8,%rcx
cmp    $0xffffffff,%edx
je     1149 <data_hasbuilt+0x39>
cmp    %ebp,%edx
jne    1130 <data_hasbuilt+0x20>
cmp    %ebx,-0x4(%rcx)
jne    1130 <data_hasbuilt+0x20>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @data_hasbuilt(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32* @data_getbuilt(i32 %0)
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, -1
br i1 %6, label %21, label %7
7: ; preds = %3, %16
%8 = phi i64 [ %17, %16 ], [ 0, %3 ]
%9 = phi i32 [ %19, %16 ], [ %5, %3 ]
%10 = icmp eq i32 %9, %1
br i1 %10, label %11, label %16
11: ; preds = %7
%12 = or i64 %8, 1
%13 = getelementptr inbounds i32, i32* %4, i64 %12
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, %2
br i1 %15, label %21, label %16
16: ; preds = %7, %11
%17 = add nuw i64 %8, 2
%18 = getelementptr inbounds i32, i32* %4, i64 %17
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %7
21: ; preds = %11, %16, %3
%22 = phi i32 [ 0, %3 ], [ 0, %16 ], [ 1, %11 ]
ret i32 %22
}