#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 dot(double *, double *, int);
void MatrixVectorMult(double *c, double **A, double *b, int n) {
  int i;
  for (i = 0; i < n; i++) {
    c[i] = dot(A[i], b, n);
  }
}


x86 assembly (clang, -O0):
<MatrixVectorMult>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    116d <MatrixVectorMult+0x5d>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <dot@plt>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112e <MatrixVectorMult+0x1e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MatrixVectorMult>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
jle    114e <MatrixVectorMult+0x3e>
mov    %ecx,%r13d
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %ecx,%ebx
xor    %ebp,%ebp
nop
mov    (%r15,%rbp,8),%rdi
mov    %r14,%rsi
mov    %r13d,%edx
call   1030 <dot@plt>
movsd  %xmm0,(%r12,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1130 <MatrixVectorMult+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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