#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 */
int /*<<< orphan*/ printf(char const *, ...);
void floats_print(const float *a, int len, const char *fmt) {
  for (int i = 0; i < len; i++)
    printf(fmt, a[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<floats_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1160 <floats_print+0x50>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112a <floats_print+0x1a>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floats_print>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    115d <floats_print+0x3d>
mov    %rdx,%r14
mov    %rdi,%r15
mov    %esi,%r12d
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movss  (%r15,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <floats_print+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
define void @floats_print(float* nocapture %0, i32 %1, i8* nocapture %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = zext i32 %1 to i64
br label %9
7: ; preds = %9, %3
%8 = tail call i32 @putchar(i32 10)
ret void
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %15, %9 ]
%11 = getelementptr inbounds float, float* %0, i64 %10
%12 = load float, float* %11
%13 = fpext float %12 to double
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %2, double %13)
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, %6
br i1 %16, label %7, label %9
}