#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 *, int);
int strlen(char *);
char *llspeech_int_array_to_string(int *array, int length) {
  char *ret_string = (char *)calloc(16 * length, 1);
  int i;
  for (i = 0; i < length; i++) {
    sprintf(ret_string, "%s%d,", ret_string, array[i]);
  }
  ret_string[strlen(ret_string) - 1] = '\0';
  return ret_string;
}


x86 assembly (clang, -O0):
<llspeech_int_array_to_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
shl    $0x4,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1193 <llspeech_int_array_to_string+0x63>
mov    -0x18(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xe80(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115a <llspeech_int_array_to_string+0x2a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<llspeech_int_array_to_string>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    %esi,%edi
shl    $0x4,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
test   %ebp,%ebp
jle    117b <llspeech_int_array_to_string+0x4b>
mov    %ebp,%r12d
xor    %ebp,%ebp
lea    0xea1(%rip),%r15
nop
mov    (%r14,%rbp,4),%ecx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <sprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1160 <llspeech_int_array_to_string+0x30>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s%d,\00"
define i8* @llspeech_int_array_to_string(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = mul nsw i32 16, %7
%9 = call i64 @calloc(i32 %8, i32 1)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %5
store i32 0, i32* %6
br label %11
11: ; preds = %24, %2
%12 = load i32, i32* %6
%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** %5
%17 = load i8*, i8** %5
%18 = load i32*, i32** %3
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = load i32, i32* %21
%23 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %22)
br label %24
24: ; preds = %15
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %11
27: ; preds = %11
%28 = load i8*, i8** %5
%29 = load i8*, i8** %5
%30 = call i32 @strlen(i8* %29)
%31 = sub nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %28, i64 %32
store i8 0, i8* %33
%34 = load i8*, i8** %5
ret i8* %34
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s%d,\00"
define i8* @llspeech_int_array_to_string(i32* nocapture %0, i32 %1) {
%3 = shl nsw i32 %1, 4
%4 = tail call i64 @calloc(i32 %3, i32 1)
%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 i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = tail call i32 @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5, i32 %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 = tail call i32 @strlen(i8* %5)
%18 = add nsw i32 %17, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %5, i64 %19
store i8 0, i8* %20
ret i8* %5
}