#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 /*<<< orphan*/ free(char **);
char **readNexusTrees(char const *, int *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int const, int const);
char *readNexusTreeAt(const char *infile, const int index) {
  int count = 0;
  char str[1000];
  sprintf(str, "%d-%d", index, index);
  char **trees = readNexusTrees(infile, &count, str, 1);
  if (count == 1) {
    char *tree = trees[0];
    free(trees);
    trees = NULL;
    return tree;
  } else {
    return NULL;
  }
}


x86 assembly (clang, -O0):
<readNexusTreeAt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x400(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xea3(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x400(%rbp),%rdx
lea    -0x18(%rbp),%rsi
mov    $0x1,%ecx
call   1040 <readNexusTrees@plt>
mov    %rax,-0x408(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    11c4 <readNexusTreeAt+0x94>
mov    -0x408(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x410(%rbp)
mov    -0x408(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x408(%rbp)
mov    -0x410(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11cc <readNexusTreeAt+0x9c>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readNexusTreeAt>:
push   %r14
push   %rbx
sub    $0x3f8,%rsp
mov    %esi,%ecx
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
lea    0xeb2(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    %ecx,%edx
call   1050 <sprintf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    $0x1,%ecx
call   1040 <readNexusTrees@plt>
cmpl   $0x1,0xc(%rsp)
jne    1186 <readNexusTreeAt+0x56>
mov    (%rax),%rbx
mov    %rax,%rdi
call   1030 <free@plt>
jmp    1188 <readNexusTreeAt+0x58>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x3f8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d-%d\00"
define i8* @readNexusTreeAt(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1000 x i8]
%8 = alloca i8**
%9 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %6
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%11 = load i32, i32* %5
%12 = load i32, i32* %5
%13 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
%14 = load i8*, i8** %4
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%16 = call i8** @readNexusTrees(i8* %14, i32* %6, i8* %15, i32 1)
store i8** %16, i8*** %8
%17 = load i32, i32* %6
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %26
19: ; preds = %2
%20 = load i8**, i8*** %8
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
store i8* %22, i8** %9
%23 = load i8**, i8*** %8
%24 = call i32 @free(i8** %23)
store i8** null, i8*** %8
%25 = load i8*, i8** %9
store i8* %25, i8** %3
br label %27
26: ; preds = %2
store i8* null, i8** %3
br label %27
27: ; preds = %26, %19
%28 = load i8*, i8** %3
ret i8* %28
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d-%d\00"
define i8* @readNexusTreeAt(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca [1000 x i8]
%5 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %1)
%8 = call i8** @readNexusTrees(i8* %0, i32* %3, i8* %6, i32 1)
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %8
%13 = call i32 @free(i8** %8)
br label %14
14: ; preds = %2, %11
%15 = phi i8* [ %12, %11 ], [ null, %2 ]
ret i8* %15
}