#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fscanf(int /*<<< orphan*/ *, char *, char *);
scalar_t__ malloc(int);
scalar_t__ realloc(char **, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ *tr_get_fp(char const *);
char **tr_get_list(const char *fn, int *n) {
  int i, max;
  char name[256], **list;
  FILE *fp;
  fp = tr_get_fp(fn);
  if (fp == 0)
    return 0;
  i = max = 0;
  list = 0;
  while (!feof(fp) && fscanf(fp, "%s", name) == 1) {
    if (i == max) {
      max += 256;
      list = (char **)realloc(list, sizeof(char *) * max);
    }
    list[i] = (char *)malloc(sizeof(char) * (strlen(name) + 1));
    strcpy(list[i++], name);
  }
  fclose(fp);
  *n = i;
  return list;
}


x86 assembly (clang, -O0):
<tr_get_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   10a0 <tr_get_fp@plt>
mov    %rax,-0x130(%rbp)
cmpq   $0x0,-0x130(%rbp)
jne    11be <tr_get_list+0x3e>
movq   $0x0,-0x8(%rbp)
jmp    12db <tr_get_list+0x15b>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x128(%rbp)
mov    -0x130(%rbp),%rdi
call   1070 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x131(%rbp)
jne    121c <tr_get_list+0x9c>
mov    -0x130(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xdf5(%rip),%rsi
call   1060 <fscanf@plt>
cmp    $0x1,%eax
sete   %al
mov    %al,-0x131(%rbp)
mov    -0x131(%rbp),%al
test   $0x1,%al
jne    122f <tr_get_list+0xaf>
jmp    12bb <tr_get_list+0x13b>
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1263 <tr_get_list+0xe3>
mov    -0x20(%rbp),%eax
add    $0x100,%eax
mov    %eax,-0x20(%rbp)
mov    -0x128(%rbp),%rdi
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   1090 <realloc@plt>
mov    %rax,-0x128(%rbp)
lea    -0x120(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,%rdx
mov    -0x128(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x128(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x120(%rbp),%rsi
call   1030 <strcpy@plt>
jmp    11d7 <tr_get_list+0x57>
mov    -0x130(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x128(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tr_get_list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%r14
call   10a0 <tr_get_fp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11b7 <tr_get_list+0x37>
mov    %rax,%r15
mov    %rax,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11bf <tr_get_list+0x3f>
xor    %r13d,%r13d
jmp    125e <tr_get_list+0xde>
xor    %r13d,%r13d
jmp    1269 <tr_get_list+0xe9>
mov    %r14,0x8(%rsp)
xor    %ebp,%ebp
lea    0xe33(%rip),%rbx
lea    0x10(%rsp),%r12
xor    %r13d,%r13d
xor    %r14d,%r14d
jmp    1210 <tr_get_list+0x90>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1080 <malloc@plt>
mov    %rax,0x0(%r13,%rbp,8)
add    $0x1,%rbp
mov    %rax,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    1259 <tr_get_list+0xd9>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1060 <fscanf@plt>
cmp    $0x1,%eax
jne    1259 <tr_get_list+0xd9>
mov    %r14d,%eax
cmp    %rax,%rbp
jne    11e0 <tr_get_list+0x60>
mov    %r13,%rdi
mov    %r15,%r13
mov    %r12,%r15
mov    %r14d,%r12d
add    $0x100,%r12d
lea    0x800(,%r14,8),%esi
call   1090 <realloc@plt>
mov    %r12d,%r14d
mov    %r15,%r12
mov    %r13,%r15
mov    %rax,%r13
jmp    11e0 <tr_get_list+0x60>
mov    0x8(%rsp),%r14
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    %ebp,(%r14)
mov    %r13,%rax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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