#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 void *uint32_t;

/* Variables and functions */
void *atoi(char *);
int mergeSuffixArraysIntoSA_LCP(char *, int, void *, void *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int main(int argc, char *argv[]) {
  char inputFileNamePrefix[500];
  int numFiles;
  uint32_t availmemoryInputBuffersBytes;
  uint32_t maxOutputBufferElements;
  if (argc < 5) {
    printf("./mergesa <inputfilenamefullpathprefix> <total_files> "
           "<memory_bytes_for_inputbuffers>  <max_elements_output_buffer>\n");
    return 1;
  }
  sprintf(inputFileNamePrefix, "%s", argv[1]);
  numFiles = atoi(argv[2]);
  availmemoryInputBuffersBytes = atoi(argv[3]);
  maxOutputBufferElements = atoi(argv[4]);
  return mergeSuffixArraysIntoSA_LCP(inputFileNamePrefix, numFiles,
                                     availmemoryInputBuffersBytes,
                                     maxOutputBufferElements);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    117b <main+0x3b>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f4 <main+0xb4>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xee4(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x214(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x220(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1050 <atoi@plt>
mov    %rax,-0x228(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x214(%rbp),%esi
mov    -0x220(%rbp),%rdx
mov    -0x228(%rbp),%rcx
call   1040 <mergeSuffixArraysIntoSA_LCP@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1f8,%rsp
cmp    $0x4,%edi
jg     1166 <main+0x26>
lea    0xea6(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    11aa <main+0x6a>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
mov    %rax,%r15
mov    0x18(%rbx),%rdi
call   1060 <atoi@plt>
mov    %rax,%r12
mov    0x20(%rbx),%rdi
call   1060 <atoi@plt>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %r12,%rdx
mov    %rax,%rcx
call   1050 <mergeSuffixArraysIntoSA_LCP@plt>
add    $0x1f8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [117 x i8] c"./mergesa <inputfilenamefullpathprefix> <total_files> <memory_bytes_for_inputbuffers> <max_elements_output_buffer>\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [500 x i8]
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 5
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([117 x i8], [117 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %38
14: ; preds = %2
%15 = getelementptr inbounds [500 x i8], [500 x i8]* %6, i64 0, i64 0
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i8* @atoi(i8* %22)
%24 = ptrtoint i8* %23 to i32
store i32 %24, i32* %7
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 3
%27 = load i8*, i8** %26
%28 = call i8* @atoi(i8* %27)
store i8* %28, i8** %8
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 4
%31 = load i8*, i8** %30
%32 = call i8* @atoi(i8* %31)
store i8* %32, i8** %9
%33 = getelementptr inbounds [500 x i8], [500 x i8]* %6, i64 0, i64 0
%34 = load i32, i32* %7
%35 = load i8*, i8** %8
%36 = load i8*, i8** %9
%37 = call i32 @mergeSuffixArraysIntoSA_LCP(i8* %33, i32 %34, i8* %35, i8* %36)
store i32 %37, i32* %3
br label %38
38: ; preds = %14, %12
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@str = [116 x i8] c"./mergesa <inputfilenamefullpathprefix> <total_files> <memory_bytes_for_inputbuffers> <max_elements_output_buffer>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [500 x i8]
%4 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 5
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([116 x i8], [116 x i8]* @str, i64 0, i64 0))
br label %24
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i8* @strcpy(i8* %4, i8* dereferenceable(1) %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = call i8* @atoi(i8* %13)
%15 = ptrtoint i8* %14 to i64
%16 = trunc i64 %15 to i32
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = call i8* @atoi(i8* %18)
%20 = getelementptr inbounds i8*, i8** %1, i64 4
%21 = load i8*, i8** %20
%22 = call i8* @atoi(i8* %21)
%23 = call i32 @mergeSuffixArraysIntoSA_LCP(i8* %4, i32 %16, i8* %19, i8* %22)
br label %24
24: ; preds = %8, %6
%25 = phi i32 [ 1, %6 ], [ %23, %8 ]
ret i32 %25
}