#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 dmat_vprint(const int n, const double *v) {
  int i;
  printf("\n");
  for (i = 0; i < ((n) < (10) ? (n) : (10)); i++)
    printf("%5.4f    ", v[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<dmat_vprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    114f <dmat_vprint+0x3f>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <dmat_vprint+0x4c>
mov    $0xa,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <dmat_vprint+0x4c>
mov    -0x18(%rbp),%eax
mov    -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jge    1193 <dmat_vprint+0x83>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe84(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1134 <dmat_vprint+0x24>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmat_vprint>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%r14d
mov    $0xa,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jle    1179 <dmat_vprint+0x59>
cmp    $0xa,%r14d
cmovb  %r14d,%ebp
xor    %ebx,%ebx
lea    0xeae(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%r15,%rbx,8),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <dmat_vprint+0x40>
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"\0A\00"
@.str.1 = [10 x i8] c"%5.4f \00"
define void @dmat_vprint(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
%5 = alloca i32
store i32 %0, i32* %3
store double* %1, double** %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %7
7: ; preds = %24, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = load i32, i32* %3
br label %14
13: ; preds = %7
br label %14
14: ; preds = %13, %11
%15 = phi i32 [ %12, %11 ], [ 10, %13 ]
%16 = icmp slt i32 %8, %15
br i1 %16, label %17, label %27
17: ; preds = %14
%18 = load double*, double** %4
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
%22 = load double, double* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %22)
br label %24
24: ; preds = %17
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %7
27: ; preds = %14
%28 = 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 = [10 x i8] c"%5.4f \00"
define void @dmat_vprint(i32 %0, double* nocapture %1) {
%3 = tail call i32 @putchar(i32 10)
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %16
5: ; preds = %2
%6 = icmp ult i32 %0, 10
%7 = select i1 %6, i32 %0, i32 10
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %5, %9
%10 = phi i64 [ 0, %5 ], [ %14, %9 ]
%11 = getelementptr inbounds double, double* %1, i64 %10
%12 = load double, double* %11
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %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 @putchar(i32 10)
ret void
}