#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 */
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, long long);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *array2StringLongLong(long long *arr, int size) {
  char *result = malloc(size * 7);
  strcpy(result, "");
  char temp[50];
  strcpy(temp, "");
  for (int i = 0; i < size; ++i) {
    sprintf(temp, "%lld", arr[i]);
    strcat(result, temp);
    strcat(result, ", ");
    strcpy(temp, "");
  }
  result[strlen(result) - 2] = '\0';
  return result;
}


x86 assembly (clang, -O0):
<array2StringLongLong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
imul   $0x7,-0xc(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x50(%rbp),%rdi
lea    0xe80(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f6 <array2StringLongLong+0xa6>
lea    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe4a(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x18(%rbp),%rdi
lea    -0x50(%rbp),%rsi
call   1060 <strcat@plt>
mov    -0x18(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x50(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1193 <array2StringLongLong+0x43>
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%rax
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array2StringLongLong>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
lea    0x0(,%rbx,8),%edi
sub    %esi,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
lea    0xe8c(%rip),%rbp
mov    %rax,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    %rsp,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
test   %ebx,%ebx
jle    11f1 <array2StringLongLong+0xa1>
mov    %ebx,%r15d
xor    %r13d,%r13d
mov    %rsp,%rbx
lea    0xe62(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14,%r13,8),%rdx
mov    %rbx,%rdi
lea    0xe42(%rip),%rsi
call   1070 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <strcat@plt>
mov    %r12,%rdi
lea    0xe2d(%rip),%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
add    $0x1,%r13
cmp    %r13,%r15
jne    11b0 <array2StringLongLong+0x60>
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x2(%rax,%r12,1)
mov    %r12,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [3 x i8] c", \00"
define i8* @array2StringLongLong(i64* %0, i32 %1) {
%3 = alloca i64*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [50 x i8]
%7 = alloca i32
store i64* %0, i64** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = mul nsw i32 %8, 7
%10 = call i8* @malloc(i32 %9)
store i8* %10, i8** %5
%11 = load i8*, i8** %5
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %15
15: ; preds = %34, %2
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %37
19: ; preds = %15
%20 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%21 = load i64*, i64** %3
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i64, i64* %21, i64 %23
%25 = load i64, i64* %24
%26 = call i32 @sprintf(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %25)
%27 = load i8*, i8** %5
%28 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%29 = call i32 @strcat(i8* %27, i8* %28)
%30 = load i8*, i8** %5
%31 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%32 = getelementptr inbounds [50 x i8], [50 x i8]* %6, i64 0, i64 0
%33 = call i32 @strcpy(i8* %32, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %34
34: ; preds = %19
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %15
37: ; preds = %15
%38 = load i8*, i8** %5
%39 = load i8*, i8** %5
%40 = call i32 @strlen(i8* %39)
%41 = sub nsw i32 %40, 2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %38, i64 %42
store i8 0, i8* %43
%44 = load i8*, i8** %5
ret i8* %44
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"%lld\00"
@.str.2 = [3 x i8] c", \00"
define i8* @array2StringLongLong(i64* nocapture %0, i32 %1) {
%3 = alloca [50 x i8]
%4 = mul nsw i32 %1, 7
%5 = tail call i8* @malloc(i32 %4)
%6 = tail call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %3, i64 0, i64 0
%8 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = zext i32 %1 to i64
br label %17
12: ; preds = %17, %2
%13 = call i32 @strlen(i8* %5)
%14 = add nsw i32 %13, -2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %5, i64 %15
store i8 0, i8* %16
ret i8* %5
17: ; preds = %10, %17
%18 = phi i64 [ 0, %10 ], [ %25, %17 ]
%19 = getelementptr inbounds i64, i64* %0, i64 %18
%20 = load i64, i64* %19
%21 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %20)
%22 = call i32 @strcat(i8* %5, i8* %7)
%23 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%25 = add nuw nsw i64 %18, 1
%26 = icmp eq i64 %25, %11
br i1 %26, label %12, label %17
}