#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 */
struct ResultArguments {
  int dummy;
};

/* Variables and functions */
char **ResultArguments_getFlagsFromSuffix(struct ResultArguments const *,
                                          char const *);
int /*<<< orphan*/ ResultArguments_getProgram(char const *);
int StringArray_getLength(char const **);
char *Tool_toString(int /*<<< orphan*/);
char **malloc(int);
int /*<<< orphan*/ memcpy(char const **, char const **, int);
const char **ResultArguments_toProgramCall(const struct ResultArguments *this,
                                           const char *file) {
  const char **flags = ResultArguments_getFlagsFromSuffix(this, file);
  const int numberOfFlags = StringArray_getLength(flags);
  const int length = 2 + numberOfFlags + 1;
  const char **programCall = malloc(sizeof(*flags) * length);
  programCall[0] = Tool_toString(ResultArguments_getProgram(file));
  programCall[1] = file;
  memcpy(&programCall[2], flags,
         StringArray_getLength(flags) * sizeof(*programCall));
  return programCall;
}


x86 assembly (clang, -O0):
<ResultArguments_toProgramCall>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <ResultArguments_getFlagsFromSuffix@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <StringArray_getLength@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <ResultArguments_getProgram@plt>
mov    %eax,%edi
call   1070 <Tool_toString@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x28(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <StringArray_getLength@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
cltq
shl    $0x3,%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x28(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ResultArguments_toProgramCall>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
call   1040 <ResultArguments_getFlagsFromSuffix@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <StringArray_getLength@plt>
lea    0x18(,%rax,8),%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1080 <ResultArguments_getProgram@plt>
mov    %eax,%edi
call   1070 <Tool_toString@plt>
mov    %rax,(%rbx)
mov    %r15,0x8(%rbx)
lea    0x10(%rbx),%r15
mov    %r14,%rdi
call   1030 <StringArray_getLength@plt>
lea    0x0(,%rax,8),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <memcpy@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.ResultArguments = type { i32 }
define i8** @ResultArguments_toProgramCall(%struct.ResultArguments* %0, i8* %1) {
%3 = alloca %struct.ResultArguments*
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
store %struct.ResultArguments* %0, %struct.ResultArguments** %3
store i8* %1, i8** %4
%9 = load %struct.ResultArguments*, %struct.ResultArguments** %3
%10 = load i8*, i8** %4
%11 = call i8** @ResultArguments_getFlagsFromSuffix(%struct.ResultArguments* %9, i8* %10)
store i8** %11, i8*** %5
%12 = load i8**, i8*** %5
%13 = call i32 @StringArray_getLength(i8** %12)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = add nsw i32 2, %14
%16 = add nsw i32 %15, 1
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = mul i64 8, %18
%20 = trunc i64 %19 to i32
%21 = call i8** @malloc(i32 %20)
store i8** %21, i8*** %8
%22 = load i8*, i8** %4
%23 = call i32 @ResultArguments_getProgram(i8* %22)
%24 = call i8* @Tool_toString(i32 %23)
%25 = load i8**, i8*** %8
%26 = getelementptr inbounds i8*, i8** %25, i64 0
store i8* %24, i8** %26
%27 = load i8*, i8** %4
%28 = load i8**, i8*** %8
%29 = getelementptr inbounds i8*, i8** %28, i64 1
store i8* %27, i8** %29
%30 = load i8**, i8*** %8
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8**, i8*** %5
%33 = load i8**, i8*** %5
%34 = call i32 @StringArray_getLength(i8** %33)
%35 = sext i32 %34 to i64
%36 = mul i64 %35, 8
%37 = trunc i64 %36 to i32
%38 = call i32 @memcpy(i8** %31, i8** %32, i32 %37)
%39 = load i8**, i8*** %8
ret i8** %39
}

LLVM IR (-O2):
%struct.ResultArguments = type { i32 }
define i8** @ResultArguments_toProgramCall(%struct.ResultArguments* %0, i8* %1) {
%3 = tail call i8** @ResultArguments_getFlagsFromSuffix(%struct.ResultArguments* %0, i8* %1)
%4 = tail call i32 @StringArray_getLength(i8** %3)
%5 = shl i32 %4, 3
%6 = add i32 %5, 24
%7 = tail call i8** @malloc(i32 %6)
%8 = tail call i32 @ResultArguments_getProgram(i8* %1)
%9 = tail call i8* @Tool_toString(i32 %8)
store i8* %9, i8** %7
%10 = getelementptr inbounds i8*, i8** %7, i64 1
store i8* %1, i8** %10
%11 = getelementptr inbounds i8*, i8** %7, i64 2
%12 = tail call i32 @StringArray_getLength(i8** %3)
%13 = shl i32 %12, 3
%14 = tail call i32 @memcpy(i8** %11, i8** %3, i32 %13)
ret i8** %7
}