#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 *, ...);
void printvec(char str[], float *a, int row) {
  int i;
  printf("\n");
  for (i = 1; i <= row; i++)
    printf("%s[%d] = %14.10f\n", str, i, a[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<printvec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1178 <printvec+0x68>
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1138 <printvec+0x28>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printvec>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r12d,%r12d
jle    1182 <printvec+0x62>
add    $0x1,%r12d
mov    $0x1,%ebx
lea    0xeaf(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  (%r14,%rbx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r13,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <printvec+0x40>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str.1 = [18 x i8] c"%s[%d] = %14.10f\0A\00"
define void @printvec(i8* %0, float* nocapture %1, i32 %2) {
%4 = tail call i32 @putchar(i32 10)
%5 = icmp slt i32 %2, 1
br i1 %5, label %18, label %6
6: ; preds = %3
%7 = add nuw i32 %2, 1
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ 1, %6 ], [ %16, %9 ]
%11 = getelementptr inbounds float, float* %1, i64 %10
%12 = load float, float* %11
%13 = fpext float %12 to double
%14 = trunc i64 %10 to i32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %14, double %13)
%16 = add nuw nsw i64 %10, 1
%17 = icmp eq i64 %16, %8
br i1 %17, label %18, label %9
18: ; preds = %9, %3
%19 = tail call i32 @putchar(i32 10)
ret void
}