#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 doliteral(unsigned char const *, unsigned char const *,
              unsigned char const *const *);
unsigned char *trailing_N_elements(unsigned char const *const **, int);
int litmatch_array(const char *string, const char *const *texts, int where) {
  const unsigned char *s = (const unsigned char *)string;
  const unsigned char *const *a = (const unsigned char *const *)texts;
  const unsigned char *text;
  if (where > 0)
    text = trailing_N_elements(&a, where);
  else
    text = *a++;
  if (!text)
    return 0;
  return doliteral(s, text, a) == 1;
}


x86 assembly (clang, -O0):
<litmatch_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jle    1162 <litmatch_array+0x42>
mov    -0x1c(%rbp),%esi
lea    -0x30(%rbp),%rdi
call   1040 <trailing_N_elements@plt>
mov    %rax,-0x38(%rbp)
jmp    1178 <litmatch_array+0x58>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    118f <litmatch_array+0x6f>
movl   $0x0,-0x4(%rbp)
jmp    11ae <litmatch_array+0x8e>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1030 <doliteral@plt>
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<litmatch_array>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %rsi,0x8(%rsp)
test   %edx,%edx
jle    115e <litmatch_array+0x3e>
lea    0x8(%rsp),%rdi
mov    %edx,%esi
call   1040 <trailing_N_elements@plt>
test   %rax,%rax
je     116f <litmatch_array+0x4f>
mov    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <doliteral@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
sete   %al
jmp    1171 <litmatch_array+0x51>
lea    0x8(%rsi),%rax
mov    %rax,0x8(%rsp)
mov    (%rsi),%rax
test   %rax,%rax
jne    1142 <litmatch_array+0x22>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @litmatch_array(i8* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8**
%10 = alloca i8*
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%11 = load i8*, i8** %5
store i8* %11, i8** %8
%12 = load i8**, i8*** %6
store i8** %12, i8*** %9
%13 = load i32, i32* %7
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = load i32, i32* %7
%17 = call i8* @trailing_N_elements(i8*** %9, i32 %16)
store i8* %17, i8** %10
br label %22
18: ; preds = %3
%19 = load i8**, i8*** %9
%20 = getelementptr inbounds i8*, i8** %19, i32 1
store i8** %20, i8*** %9
%21 = load i8*, i8** %19
store i8* %21, i8** %10
br label %22
22: ; preds = %18, %15
%23 = load i8*, i8** %10
%24 = icmp ne i8* %23, null
br i1 %24, label %26, label %25
25: ; preds = %22
store i32 0, i32* %4
br label %33
26: ; preds = %22
%27 = load i8*, i8** %8
%28 = load i8*, i8** %10
%29 = load i8**, i8*** %9
%30 = call i32 @doliteral(i8* %27, i8* %28, i8** %29)
%31 = icmp eq i32 %30, 1
%32 = zext i1 %31 to i32
store i32 %32, i32* %4
br label %33
33: ; preds = %26, %25
%34 = load i32, i32* %4
ret i32 %34
}

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