#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 */
double scalarp(int, double *, double *);
void matvecdstd(int dim, double mat[dim][dim], double vec_in[dim],
                double vec_out[dim]) {
  int i;
  for (i = 0; i < dim; i++)
    vec_out[i] = scalarp(dim, &mat[i][0], vec_in);
}


x86 assembly (clang, -O0):
<matvecdstd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117f <matvecdstd+0x6f>
mov    -0x30(%rbp),%rcx
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
movslq -0x24(%rbp),%rax
imul   %rcx,%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x18(%rbp),%rdx
call   1030 <scalarp@plt>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1135 <matvecdstd+0x25>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matvecdstd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,0x4(%rsp)
test   %edi,%edi
jle    1161 <matvecdstd+0x51>
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    0x4(%rsp),%r13d
lea    0x0(,%r13,8),%rbp
xor    %r14d,%r14d
nopl   0x0(%rax)
mov    0x4(%rsp),%edi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1030 <scalarp@plt>
movsd  %xmm0,(%r15,%r14,8)
add    $0x1,%r14
add    %rbp,%rbx
cmp    %r14,%r13
jne    1140 <matvecdstd+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @matvecdstd(i32 %0, double* %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%10 = load i32, i32* %5
%11 = zext i32 %10 to i64
%12 = load i32, i32* %5
%13 = zext i32 %12 to i64
%14 = load i32, i32* %5
%15 = zext i32 %14 to i64
%16 = load i32, i32* %5
%17 = zext i32 %16 to i64
store i32 0, i32* %9
br label %18
18: ; preds = %36, %4
%19 = load i32, i32* %9
%20 = load i32, i32* %5
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %39
22: ; preds = %18
%23 = load i32, i32* %5
%24 = load double*, double** %6
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = mul nsw i64 %26, %13
%28 = getelementptr inbounds double, double* %24, i64 %27
%29 = getelementptr inbounds double, double* %28, i64 0
%30 = load double*, double** %7
%31 = call double @scalarp(i32 %23, double* %29, double* %30)
%32 = load double*, double** %8
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds double, double* %32, i64 %34
store double %31, double* %35
br label %36
36: ; preds = %22
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %18
39: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @matvecdstd(i32 %0, double* %1, double* %2, double* nocapture writeonly %3) {
%5 = zext i32 %0 to i64
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %15
7: ; preds = %4, %7
%8 = phi i64 [ %13, %7 ], [ 0, %4 ]
%9 = mul nuw nsw i64 %8, %5
%10 = getelementptr inbounds double, double* %1, i64 %9
%11 = tail call double @scalarp(i32 %0, double* %10, double* %2)
%12 = getelementptr inbounds double, double* %3, i64 %8
store double %11, double* %12
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, %5
br i1 %14, label %15, label %7
15: ; preds = %7, %4
ret void
}