#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*/ checkPTRALLOC(void **);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
void *malloc(int);
char *realloc(char *, int);
char **database_extract(int *len) {
  int i, alloc_size = 200;
  FILE *file = fopen("ord.txt", "r");
  char **out = malloc(alloc_size * sizeof(char *));
  checkPTRALLOC((void **)&out);
  for (i = 0; !feof(file); i++) {
    out[i] = malloc(30 * sizeof(char));
    fscanf(file, " %s", out[i]);
    if (i >= alloc_size) {
      out[i] = realloc(out[i], sizeof(char *) * (alloc_size += 200));
      checkPTRALLOC((void **)&out[i]);
    }
  }
  fclose(file);
  *len = i;
  return out;
}


x86 assembly (clang, -O0):
<database_extract>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0xc8,-0x10(%rbp)
lea    0xe76(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
lea    -0x20(%rbp),%rdi
call   1060 <checkPTRALLOC@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11db <database_extract+0x6b>
jmp    1276 <database_extract+0x106>
mov    $0x1e,%edi
call   1070 <malloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xdff(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     1263 <database_extract+0xf3>
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%eax
add    $0xc8,%eax
mov    %eax,-0x10(%rbp)
cltq
shl    $0x3,%rax
mov    %eax,%esi
call   1080 <realloc@plt>
mov    %rax,%rdx
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x20(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1060 <checkPTRALLOC@plt>
jmp    1268 <database_extract+0xf8>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11bd <database_extract+0x4d>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<database_extract>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbp
lea    0xe78(%rip),%rdi
lea    0xe79(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r12
mov    $0x640,%edi
call   1070 <malloc@plt>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1060 <checkPTRALLOC@plt>
mov    %r12,%rdi
call   1050 <feof@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    1269 <database_extract+0xf9>
mov    %rbp,0x10(%rsp)
mov    $0xc8,%ebp
xor    %ebx,%ebx
lea    0xe35(%rip),%r15
jmp    11f0 <database_extract+0x80>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r12,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    1264 <database_extract+0xf4>
mov    $0x1e,%edi
call   1070 <malloc@plt>
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx,%rbx,8)
mov    0x8(%rsp),%rax
mov    (%rax,%rbx,8),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
call   1040 <fscanf@plt>
movslq %ebp,%rax
cmp    %rax,%rbx
jl     11e0 <database_extract+0x70>
mov    0x8(%rsp),%rax
lea    0x0(,%rbx,8),%r13
mov    (%rax,%rbx,8),%rdi
mov    %ebp,%r14d
add    $0xc8,%r14d
lea    0x640(,%rbp,8),%esi
call   1080 <realloc@plt>
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx,%rbx,8)
add    0x8(%rsp),%r13
mov    %r13,%rdi
call   1060 <checkPTRALLOC@plt>
mov    %r14d,%ebp
jmp    11e0 <database_extract+0x70>
mov    0x10(%rsp),%rbp
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    %ebx,0x0(%rbp)
mov    0x8(%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"ord.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c" %s\00"
define i8** @database_extract(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8**
store i32* %0, i32** %2
store i32 200, i32* %4
%7 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %5
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 8
%11 = trunc i64 %10 to i32
%12 = call i8* @malloc(i32 %11)
%13 = bitcast i8* %12 to i8**
store i8** %13, i8*** %6
%14 = bitcast i8*** %6 to i8**
%15 = call i32 @checkPTRALLOC(i8** %14)
store i32 0, i32* %3
br label %16
16: ; preds = %59, %1
%17 = load i32*, i32** %5
%18 = call i32 @feof(i32* %17)
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
br i1 %20, label %21, label %62
21: ; preds = %16
%22 = call i8* @malloc(i32 30)
%23 = load i8**, i8*** %6
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
store i8* %22, i8** %26
%27 = load i32*, i32** %5
%28 = load i8**, i8*** %6
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @fscanf(i32* %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %32)
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = icmp sge i32 %34, %35
br i1 %36, label %37, label %58
37: ; preds = %21
%38 = load i8**, i8*** %6
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = load i32, i32* %4
%44 = add nsw i32 %43, 200
store i32 %44, i32* %4
%45 = sext i32 %44 to i64
%46 = mul i64 8, %45
%47 = trunc i64 %46 to i32
%48 = call i8* @realloc(i8* %42, i32 %47)
%49 = load i8**, i8*** %6
%50 = load i32, i32* %3
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
store i8* %48, i8** %52
%53 = load i8**, i8*** %6
%54 = load i32, i32* %3
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = call i32 @checkPTRALLOC(i8** %56)
br label %58
58: ; preds = %37, %21
br label %59
59: ; preds = %58
%60 = load i32, i32* %3
%61 = add nsw i32 %60, 1
store i32 %61, i32* %3
br label %16
62: ; preds = %16
%63 = load i32*, i32** %5
%64 = call i32 @fclose(i32* %63)
%65 = load i32, i32* %3
%66 = load i32*, i32** %2
store i32 %65, i32* %66
%67 = load i8**, i8*** %6
ret i8** %67
}

LLVM IR (-O2):
@.str = [8 x i8] c"ord.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c" %s\00"
define i8** @database_extract(i32* nocapture writeonly %0) {
%2 = alloca i8**
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = bitcast i8*** %2 to i8*
%5 = tail call dereferenceable_or_null(1600) i8* @malloc(i32 1600)
%6 = bitcast i8*** %2 to i8**
store i8* %5, i8** %6
%7 = call i32 @checkPTRALLOC(i8** %6)
%8 = call i32 @feof(i32* %3)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %41
10: ; preds = %1, %34
%11 = phi i64 [ %36, %34 ], [ 0, %1 ]
%12 = phi i32 [ %35, %34 ], [ 200, %1 ]
%13 = call dereferenceable_or_null(30) i8* @malloc(i32 30)
%14 = load i8**, i8*** %2
%15 = getelementptr inbounds i8*, i8** %14, i64 %11
store i8* %13, i8** %15
%16 = load i8**, i8*** %2
%17 = getelementptr inbounds i8*, i8** %16, i64 %11
%18 = load i8*, i8** %17
%19 = call i32 @fscanf(i32* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = sext i32 %12 to i64
%21 = icmp slt i64 %11, %20
br i1 %21, label %34, label %22
22: ; preds = %10
%23 = load i8**, i8*** %2
%24 = getelementptr inbounds i8*, i8** %23, i64 %11
%25 = load i8*, i8** %24
%26 = add nsw i32 %12, 200
%27 = shl i32 %26, 3
%28 = call i8* @realloc(i8* %25, i32 %27)
%29 = load i8**, i8*** %2
%30 = getelementptr inbounds i8*, i8** %29, i64 %11
store i8* %28, i8** %30
%31 = load i8**, i8*** %2
%32 = getelementptr inbounds i8*, i8** %31, i64 %11
%33 = call i32 @checkPTRALLOC(i8** %32)
br label %34
34: ; preds = %10, %22
%35 = phi i32 [ %26, %22 ], [ %12, %10 ]
%36 = add nuw i64 %11, 1
%37 = call i32 @feof(i32* %3)
%38 = icmp eq i32 %37, 0
br i1 %38, label %10, label %39
39: ; preds = %34
%40 = trunc i64 %36 to i32
br label %41
41: ; preds = %39, %1
%42 = phi i32 [ 0, %1 ], [ %40, %39 ]
%43 = call i32 @fclose(i32* %3)
store i32 %42, i32* %0
%44 = load i8**, i8*** %2
ret i8** %44
}