#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 vector_row_printf(double *v, int length, char *format) {
  int i;
  for (i = 0; i < length; i++) {
    if (i > 0)
      printf(" ");
    printf(format, v[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<vector_row_printf>:
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    1174 <vector_row_printf+0x64>
cmpl   $0x0,-0x1c(%rbp)
jle    114e <vector_row_printf+0x3e>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112a <vector_row_printf+0x1a>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vector_row_printf>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    1173 <vector_row_printf+0x53>
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%r15
movsd  (%rdi),%xmm0
mov    %rdx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
cmp    $0x1,%ebp
je     1173 <vector_row_printf+0x53>
mov    %ebp,%ebp
mov    $0x1,%ebx
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
movsd  (%r15,%rbx,8),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <vector_row_printf+0x30>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

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