#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fscanf(int /*<<< orphan*/ *, char *, int *);
void *malloc(int);
int /*<<< orphan*/ stderr;
int strlen(char *);
char **load_indexed_ar(char *filename, int *sz) {
  char **index_ar = malloc(1000000 * sizeof(char *));
  char *vals = malloc(100000000);
  char *p = vals;
  FILE *ifp = fopen(filename, "r");
  if (ifp == NULL) {
    fprintf(stderr, "could not open %s\n", filename);
    exit(1);
  }
  *sz = 0;
  int j;
  while ((fscanf(ifp, "%d\t", &j) == 1) && fgets(p, 1000, ifp)) {
    if (*sz != j) {
      fprintf(stderr,
              "Your index must be dense and in order (see line %ld, should be "
              "%d)\n",
              p - vals, *sz);
      exit(1);
    }
    index_ar[*sz] = p;
    p += strlen(index_ar[*sz]) - 1;
    *(p++) = '\0';
    if ((*sz >= 1000000) || ((p - vals) > (100000000 - 1000))) {
      fprintf(stderr, "Your function or oI index arrays are too small; bump "
                      "MAX_FUNC_OI_INDEX and MAX_FUNC_OI_VALS\n");
      exit(1);
    }
    *sz += 1;
  }
  return index_ar;
}


x86 assembly (clang, -O0):
<load_indexed_ar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x7a1200,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x5f5e100,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11e8 <load_indexed_ar+0x78>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe2b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x30(%rbp),%rdi
lea    0xe18(%rip),%rsi
lea    -0x34(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x1,%ecx
mov    %al,-0x35(%rbp)
jne    1232 <load_indexed_ar+0xc2>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
test   $0x1,%al
jne    1242 <load_indexed_ar+0xd2>
jmp    1327 <load_indexed_ar+0x1b7>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
cmp    -0x34(%rbp),%eax
je     1283 <load_indexed_ar+0x113>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rax
sub    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
lea    0xda7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
sub    $0x1,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0xf4240,(%rax)
jge    12f6 <load_indexed_ar+0x186>
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
cmp    $0x5f5dd18,%rax
jle    1317 <load_indexed_ar+0x1a7>
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
lea    0xd57(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
jmp    11f2 <load_indexed_ar+0x82>
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_indexed_ar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %rdi,%rbx
mov    $0x7a1200,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x5f5e100,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     12a8 <load_indexed_ar+0x138>
mov    %rax,%r12
movl   $0x0,0x0(%r13)
lea    0xe50(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    124e <load_indexed_ar+0xde>
lea    0x4(%rsp),%rbp
mov    %r15,%rbx
nop
mov    %rbx,%rdi
mov    $0x3e8,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     124e <load_indexed_ar+0xde>
movslq 0x0(%r13),%rcx
cmp    0x4(%rsp),%ecx
jne    1260 <load_indexed_ar+0xf0>
mov    %rbx,(%r14,%rcx,8)
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
movb   $0x0,-0x1(%rcx,%rbx,1)
mov    0x0(%r13),%eax
cmp    $0xf423f,%eax
jg     1287 <load_indexed_ar+0x117>
add    %rcx,%rbx
mov    %rbx,%rcx
sub    %r15,%rcx
cmp    $0x5f5dd19,%rcx
jge    1287 <load_indexed_ar+0x117>
add    $0x1,%eax
mov    %eax,0x0(%r13)
mov    %r12,%rdi
lea    0xdd4(%rip),%rsi
mov    %rbp,%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
je     11e0 <load_indexed_ar+0x70>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
sub    %r15,%rbx
lea    0xda6(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
lea    0xdc6(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
lea    0xd4a(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"could not open %s\0A\00"
@.str.2 = [4 x i8] c"%d\09\00"
@.str.3 = [68 x i8] c"Your index must be dense and in order (see line %ld, should be %d)\0A\00"
@.str.4 = [93 x i8] c"Your function or oI index arrays are too small; bump MAX_FUNC_OI_INDEX and MAX_FUNC_OI_VALS\0A\00"
define i8** @load_indexed_ar(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%10 = call i8* @malloc(i32 8000000)
%11 = bitcast i8* %10 to i8**
store i8** %11, i8*** %5
%12 = call i8* @malloc(i32 100000000)
store i8* %12, i8** %6
%13 = load i8*, i8** %6
store i8* %13, i8** %7
%14 = load i8*, i8** %3
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %8
%16 = load i32*, i32** %8
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %3
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load i32*, i32** %4
store i32 0, i32* %24
br label %25
25: ; preds = %86, %23
%26 = load i32*, i32** %8
%27 = call i32 @fscanf(i32* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = load i8*, i8** %7
%31 = load i32*, i32** %8
%32 = call i64 @fgets(i8* %30, i32 1000, i32* %31)
%33 = icmp ne i64 %32, 0
br label %34
34: ; preds = %29, %25
%35 = phi i1 [ false, %25 ], [ %33, %29 ]
br i1 %35, label %36, label %90
36: ; preds = %34
%37 = load i32*, i32** %4
%38 = load i32, i32* %37
%39 = load i32, i32* %9
%40 = icmp ne i32 %38, %39
br i1 %40, label %41, label %52
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = load i8*, i8** %7
%44 = load i8*, i8** %6
%45 = ptrtoint i8* %43 to i64
%46 = ptrtoint i8* %44 to i64
%47 = sub i64 %45, %46
%48 = load i32*, i32** %4
%49 = load i32, i32* %48
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.3, i64 0, i64 0), i64 %47, i32 %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %36
%53 = load i8*, i8** %7
%54 = load i8**, i8*** %5
%55 = load i32*, i32** %4
%56 = load i32, i32* %55
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %54, i64 %57
store i8* %53, i8** %58
%59 = load i8**, i8*** %5
%60 = load i32*, i32** %4
%61 = load i32, i32* %60
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8*, i8** %59, i64 %62
%64 = load i8*, i8** %63
%65 = call i32 @strlen(i8* %64)
%66 = sub nsw i32 %65, 1
%67 = load i8*, i8** %7
%68 = sext i32 %66 to i64
%69 = getelementptr inbounds i8, i8* %67, i64 %68
store i8* %69, i8** %7
%70 = load i8*, i8** %7
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %7
store i8 0, i8* %70
%72 = load i32*, i32** %4
%73 = load i32, i32* %72
%74 = icmp sge i32 %73, 1000000
br i1 %74, label %82, label %75
75: ; preds = %52
%76 = load i8*, i8** %7
%77 = load i8*, i8** %6
%78 = ptrtoint i8* %76 to i64
%79 = ptrtoint i8* %77 to i64
%80 = sub i64 %78, %79
%81 = icmp sgt i64 %80, 99999000
br i1 %81, label %82, label %86
82: ; preds = %75, %52
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.4, i64 0, i64 0))
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %75
%87 = load i32*, i32** %4
%88 = load i32, i32* %87
%89 = add nsw i32 %88, 1
store i32 %89, i32* %87
br label %25
90: ; preds = %34
%91 = load i8**, i8*** %5
ret i8** %91
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [19 x i8] c"could not open %s\0A\00"
@.str.2 = [4 x i8] c"%d\09\00"
@.str.3 = [68 x i8] c"Your index must be dense and in order (see line %ld, should be %d)\0A\00"
@.str.4 = [93 x i8] c"Your function or oI index arrays are too small; bump MAX_FUNC_OI_INDEX and MAX_FUNC_OI_VALS\0A\00"
define noalias i8** @load_indexed_ar(i8* %0, i32* nocapture %1) {
%3 = alloca i32
%4 = tail call dereferenceable_or_null(8000000) i8* @malloc(i32 8000000)
%5 = bitcast i8* %4 to i8**
%6 = tail call dereferenceable_or_null(100000000) i8* @malloc(i32 100000000)
%7 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
store i32 0, i32* %1
%14 = bitcast i32* %3 to i8*
%15 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %55
17: ; preds = %13
%18 = ptrtoint i8* %6 to i64
br label %19
19: ; preds = %17, %51
%20 = phi i8* [ %6, %17 ], [ %40, %51 ]
%21 = call i64 @fgets(i8* %20, i32 1000, i32* %7)
%22 = icmp eq i64 %21, 0
br i1 %22, label %55, label %23
23: ; preds = %19
%24 = load i32, i32* %1
%25 = load i32, i32* %3
%26 = icmp eq i32 %24, %25
br i1 %26, label %33, label %27
27: ; preds = %23
%28 = load i32, i32* @stderr
%29 = ptrtoint i8* %20 to i64
%30 = sub i64 %29, %18
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.3, i64 0, i64 0), i64 %30, i32 %24)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %23
%34 = sext i32 %24 to i64
%35 = getelementptr inbounds i8*, i8** %5, i64 %34
store i8* %20, i8** %35
%36 = call i32 @strlen(i8* %20)
%37 = add nsw i32 %36, -1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %20, i64 %38
%40 = getelementptr inbounds i8, i8* %39, i64 1
store i8 0, i8* %39
%41 = load i32, i32* %1
%42 = icmp sgt i32 %41, 999999
%43 = ptrtoint i8* %40 to i64
%44 = sub i64 %43, %18
%45 = icmp sgt i64 %44, 99999000
%46 = select i1 %42, i1 true, i1 %45
br i1 %46, label %47, label %51
47: ; preds = %33
%48 = load i32, i32* @stderr
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.4, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %33
%52 = add nsw i32 %41, 1
store i32 %52, i32* %1
%53 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%54 = icmp eq i32 %53, 1
br i1 %54, label %19, label %55
55: ; preds = %19, %51, %13
ret i8** %5
}