#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 dyString {
  int dummy;
};

/* Variables and functions */
char *dyStringCannibalize(struct dyString **);
int /*<<< orphan*/ dyStringPrintf(struct dyString *, char *, long long);
struct dyString *newDyString(int);
char *sqlLongLongArrayToString(long long *array, int arraySize) {
  int i;
  struct dyString *string = newDyString(256);
  for (i = 0; i < arraySize; i++) {
    dyStringPrintf(string, "%lld,", array[i]);
  }
  return dyStringCannibalize(&string);
}


x86 assembly (clang, -O0):
<sqlLongLongArrayToString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x100,%edi
call   1030 <newDyString@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    118a <sqlLongLongArrayToString+0x5a>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe89(%rip),%rsi
call   1050 <dyStringPrintf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1154 <sqlLongLongArrayToString+0x24>
lea    -0x18(%rbp),%rdi
call   1040 <dyStringCannibalize@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlLongLongArrayToString>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
mov    $0x100,%edi
call   1030 <newDyString@plt>
mov    %rax,0x8(%rsp)
test   %ebp,%ebp
jle    1188 <sqlLongLongArrayToString+0x58>
mov    %rax,%r12
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0xe9e(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rdx
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <dyStringPrintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <sqlLongLongArrayToString+0x40>
lea    0x8(%rsp),%rdi
call   1040 <dyStringCannibalize@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dyString = type { i32 }
@.str = [6 x i8] c"%lld,\00"
define i8* @sqlLongLongArrayToString(i64* %0, i32 %1) {
%3 = alloca i64*
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.dyString*
store i64* %0, i64** %3
store i32 %1, i32* %4
%7 = call %struct.dyString* @newDyString(i32 256)
store %struct.dyString* %7, %struct.dyString** %6
store i32 0, i32* %5
br label %8
8: ; preds = %20, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %23
12: ; preds = %8
%13 = load %struct.dyString*, %struct.dyString** %6
%14 = load i64*, i64** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i64, i64* %14, i64 %16
%18 = load i64, i64* %17
%19 = call i32 @dyStringPrintf(%struct.dyString* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %18)
br label %20
20: ; preds = %12
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %8
23: ; preds = %8
%24 = call i8* @dyStringCannibalize(%struct.dyString** %6)
ret i8* %24
}

LLVM IR (-O2):
%struct.dyString = type { i32 }
@.str = [6 x i8] c"%lld,\00"
define i8* @sqlLongLongArrayToString(i64* nocapture %0, i32 %1) {
%3 = alloca %struct.dyString*
%4 = bitcast %struct.dyString** %3 to i8*
%5 = tail call %struct.dyString* @newDyString(i32 256)
store %struct.dyString* %5, %struct.dyString** %3
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %16
7: ; preds = %2
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %7, %9
%10 = phi i64 [ 0, %7 ], [ %14, %9 ]
%11 = getelementptr inbounds i64, i64* %0, i64 %10
%12 = load i64, i64* %11
%13 = tail call i32 @dyStringPrintf(%struct.dyString* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %12)
%14 = add nuw nsw i64 %10, 1
%15 = icmp eq i64 %14, %8
br i1 %15, label %16, label %9
16: ; preds = %9, %2
%17 = call i8* @dyStringCannibalize(%struct.dyString** %3)
ret i8* %17
}