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


x86 assembly (clang, -O0):
<matvec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1175 <matvec+0x65>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x24(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x14(%rbp),%edx
call   1030 <dot@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    112e <matvec+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

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

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

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