#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 *, double);
struct dyString *newDyString(int);
char *sqlDoubleArrayToString(double *array, int arraySize) {
  int i;
  struct dyString *string = newDyString(256);
  for (i = 0; i < arraySize; i++) {
    dyStringPrintf(string, "%f,", array[i]);
  }
  return dyStringCannibalize(&string);
}


x86 assembly (clang, -O0):
<sqlDoubleArrayToString>:
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    118b <sqlDoubleArrayToString+0x5b>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe88(%rip),%rsi
call   1050 <dyStringPrintf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1154 <sqlDoubleArrayToString+0x24>
lea    -0x18(%rbp),%rdi
call   1040 <dyStringCannibalize@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqlDoubleArrayToString>:
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    118a <sqlDoubleArrayToString+0x5a>
mov    %rax,%r12
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0xe9e(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%r14,%rbx,8),%xmm0
mov    %r12,%rdi
mov    %r15,%rsi
call   1050 <dyStringPrintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1170 <sqlDoubleArrayToString+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 = [4 x i8] c"%f,\00"
define i8* @sqlDoubleArrayToString(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.dyString*
store double* %0, double** %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 double*, double** %3
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %14, i64 %16
%18 = load double, double* %17
%19 = call i32 @dyStringPrintf(%struct.dyString* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %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 = [4 x i8] c"%f,\00"
define i8* @sqlDoubleArrayToString(double* 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 double, double* %0, i64 %10
%12 = load double, double* %11
%13 = tail call i32 @dyStringPrintf(%struct.dyString* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %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
}