#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 */
char *athena_find_tech(char const *, char const **, unsigned int);
unsigned athena_meets_bonus_reqs(const char **has_tech, unsigned num_has_tech,
                                 const char **needs_tech,
                                 unsigned num_needs_tech) {
  if (num_needs_tech == 0)
    return 1;
  else {
    const char *const found =
        athena_find_tech(*needs_tech, has_tech, num_needs_tech);
    if (!found)
      return 0;
    else if (found == *has_tech) {
      has_tech++;
      num_has_tech--;
    } else if (0 && found == has_tech[num_has_tech - 1]) {
      num_has_tech--;
    }
    return athena_meets_bonus_reqs(has_tech, num_has_tech, needs_tech + 1,
                                   num_needs_tech - 1);
  }
}


x86 assembly (clang, -O0):
<athena_meets_bonus_reqs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    114c <athena_meets_bonus_reqs+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    11cc <athena_meets_bonus_reqs+0xac>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <athena_find_tech@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    117a <athena_meets_bonus_reqs+0x5a>
movl   $0x0,-0x4(%rbp)
jmp    11cc <athena_meets_bonus_reqs+0xac>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jne    11a5 <athena_meets_bonus_reqs+0x85>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11aa <athena_meets_bonus_reqs+0x8a>
jmp    11aa <athena_meets_bonus_reqs+0x8a>
jmp    11af <athena_meets_bonus_reqs+0x8f>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
add    $0x8,%rdx
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
call   1040 <athena_meets_bonus_reqs@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<athena_meets_bonus_reqs>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%r14d
test   %ecx,%ecx
je     1160 <athena_meets_bonus_reqs+0x50>
mov    %ecx,%r15d
mov    %rdx,%rbx
mov    %rdi,%rbp
nopw   0x0(%rax,%rax,1)
mov    (%rbx),%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
call   1030 <athena_find_tech@plt>
test   %rax,%rax
je     115d <athena_meets_bonus_reqs+0x4d>
xor    %ecx,%ecx
cmp    0x0(%rbp),%rax
sete   %cl
lea    0x0(%rbp,%rcx,8),%rbp
add    $0x8,%rbx
add    $0xffffffff,%r15d
jne    1130 <athena_meets_bonus_reqs+0x20>
jmp    1160 <athena_meets_bonus_reqs+0x50>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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