#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, double);
char *strVec(double a[], int n) {
  int i;
  char *string;
  string = (char *)calloc(sizeof(char), 100 * n);
  for (i = 0; i < n; i++)
    sprintf(string, "%s %.17e", string, a[i]);
  return string;
}


x86 assembly (clang, -O0):
<strVec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
imul   $0x64,-0xc(%rbp),%esi
mov    $0x1,%edi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1183 <strVec+0x63>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe90(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1148 <strVec+0x28>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strVec>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
imul   $0x64,%esi,%esi
mov    $0x1,%edi
call   1030 <calloc@plt>
mov    %rax,%rbx
test   %ebp,%ebp
jle    116d <strVec+0x4d>
mov    %ebp,%r12d
xor    %ebp,%ebp
lea    0xeb3(%rip),%r15
nopl   (%rax)
movsd  (%r14,%rbp,8),%xmm0
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <sprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1150 <strVec+0x30>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%s %.17e\00"
define i8* @strVec(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store double* %0, double** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = mul nsw i32 100, %7
%9 = call i64 @calloc(i32 1, i32 %8)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %6
store i32 0, i32* %5
br label %11
11: ; preds = %24, %2
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %27
15: ; preds = %11
%16 = load i8*, i8** %6
%17 = load i8*, i8** %6
%18 = load double*, double** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %17, double %22)
br label %24
24: ; preds = %15
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %11
27: ; preds = %11
%28 = load i8*, i8** %6
ret i8* %28
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s %.17e\00"
define i8* @strVec(double* nocapture %0, i32 %1) {
%3 = mul nsw i32 %1, 100
%4 = tail call i64 @calloc(i32 1, i32 %3)
%5 = inttoptr i64 %4 to i8*
%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 @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %5, 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
ret i8* %5
}