#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 *, float, char *);
int /*<<< orphan*/ strcat(char *, char *);
char *createMotorString(float *speeds, int size) {
  int i;
  char *result = (char *)calloc(size * 6, sizeof(char));
  char *oneSpeed = (char *)calloc(7, sizeof(char));
  char *delim;
  for (i = 0; i < size; i++) {
    if (i == size - 1) {
      delim = "";
    } else {
      delim = ":";
    }
    sprintf(oneSpeed, "%06.2f%s", speeds[i], delim);
    strcat(result, oneSpeed);
  }
  return result;
}


x86 assembly (clang, -O0):
<createMotorString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
imul   $0x6,-0xc(%rbp),%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x7,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11df <createMotorString+0xaf>
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1198 <createMotorString+0x68>
lea    0xe72(%rip),%rax
mov    %rax,-0x28(%rbp)
jmp    11a3 <createMotorString+0x73>
lea    0xe61(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x28(%rbp),%rdx
lea    0xe43(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcat@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116b <createMotorString+0x3b>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createMotorString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r12d
mov    %rdi,%r14
lea    (%r12,%r12,1),%eax
lea    (%rax,%rax,2),%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,%r15
mov    $0x7,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
test   %r12d,%r12d
jle    11be <createMotorString+0x8e>
mov    %rax,%rbx
lea    -0x1(%r12),%r13d
mov    %r12d,%ebp
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
cmp    %r12,%r13
lea    0xe76(%rip),%rdx
lea    0xe70(%rip),%rax
cmove  %rax,%rdx
movss  (%r14,%r12,4),%xmm0
mov    %rbx,%rdi
lea    0xe5d(%rip),%rsi
call   1050 <sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <strcat@plt>
add    $0x1,%r12
cmp    %r12,%rbp
jne    1180 <createMotorString+0x50>
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c":\00"
@.str.2 = [9 x i8] c"%06.2f%s\00"
define i8* @createMotorString(float* nocapture %0, i32 %1) {
%3 = mul nsw i32 %1, 6
%4 = tail call i64 @calloc(i32 %3, i32 1)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i64 @calloc(i32 7, i32 1)
%7 = inttoptr i64 %6 to i8*
%8 = icmp sgt i32 %1, 0
br i1 %8, label %9, label %23
9: ; preds = %2
%10 = add nsw i32 %1, -1
%11 = zext i32 %10 to i64
%12 = zext i32 %1 to i64
br label %13
13: ; preds = %9, %13
%14 = phi i64 [ 0, %9 ], [ %21, %13 ]
%15 = icmp eq i64 %14, %11
%16 = select i1 %15, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%17 = getelementptr inbounds float, float* %0, i64 %14
%18 = load float, float* %17
%19 = tail call i32 @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), float %18, i8* %16)
%20 = tail call i32 @strcat(i8* %5, i8* %7)
%21 = add nuw nsw i64 %14, 1
%22 = icmp eq i64 %21, %12
br i1 %22, label %23, label %13
23: ; preds = %13, %2
ret i8* %5
}