#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*/ daxpy(int, int, double *, int, double *, int);
int /*<<< orphan*/ dgemv(char, int, int, int, double *, int, double *, int,
                         int /*<<< orphan*/, double *, int);
int /*<<< orphan*/ dscal(int, int, double *, int);
int calcResid(double *X, int n, int p, double *y, double *coef, double *resid) {
  dgemv('n', n, p, 1, X, n, coef, 1, 0, resid, 1);
  dscal(n, -1, resid, 1);
  daxpy(n, 1, y, 1, resid, 1);
  return 0;
}


x86 assembly (clang, -O0):
<calcResid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%r8
mov    -0xc(%rbp),%r9d
mov    -0x20(%rbp),%r10
mov    -0x28(%rbp),%rax
mov    $0x6e,%edi
mov    $0x1,%ecx
xor    %r11d,%r11d
mov    %r10,(%rsp)
movl   $0x1,0x8(%rsp)
movl   $0x0,0x10(%rsp)
mov    %rax,0x18(%rsp)
movl   $0x1,0x20(%rsp)
call   1050 <dgemv@plt>
mov    -0xc(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    $0xffffffff,%esi
mov    $0x1,%ecx
call   1040 <dscal@plt>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%r8
mov    $0x1,%r9d
mov    %r9d,%esi
mov    %r9d,%ecx
call   1030 <daxpy@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcResid>:
push   %rbp
push   %r14
push   %rbx
mov    %r9,%rbx
mov    %r8,%rax
mov    %rcx,%r14
mov    %esi,%ebp
mov    %rdi,%r8
sub    $0x8,%rsp
mov    $0x6e,%edi
mov    $0x1,%ecx
mov    %esi,%r9d
push   $0x1
push   %rbx
push   $0x0
push   $0x1
push   %rax
call   1050 <dgemv@plt>
add    $0x30,%rsp
mov    %ebp,%edi
mov    $0xffffffff,%esi
mov    %rbx,%rdx
mov    $0x1,%ecx
call   1040 <dscal@plt>
mov    %ebp,%edi
mov    $0x1,%esi
mov    %r14,%rdx
mov    $0x1,%ecx
mov    %rbx,%r8
mov    $0x1,%r9d
call   1030 <daxpy@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @calcResid(double* %0, i32 %1, i32 %2, double* %3, double* %4, double* %5) {
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
store double* %0, double** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store double* %3, double** %10
store double* %4, double** %11
store double* %5, double** %12
%13 = load i32, i32* %8
%14 = load i32, i32* %9
%15 = load double*, double** %7
%16 = load i32, i32* %8
%17 = load double*, double** %11
%18 = load double*, double** %12
%19 = call i32 @dgemv(i8 signext 110, i32 %13, i32 %14, i32 1, double* %15, i32 %16, double* %17, i32 1, i32 0, double* %18, i32 1)
%20 = load i32, i32* %8
%21 = load double*, double** %12
%22 = call i32 @dscal(i32 %20, i32 -1, double* %21, i32 1)
%23 = load i32, i32* %8
%24 = load double*, double** %10
%25 = load double*, double** %12
%26 = call i32 @daxpy(i32 %23, i32 1, double* %24, i32 1, double* %25, i32 1)
ret i32 0
}

LLVM IR (-O2):
define i32 @calcResid(double* %0, i32 %1, i32 %2, double* %3, double* %4, double* %5) {
%7 = tail call i32 @dgemv(i8 signext 110, i32 %1, i32 %2, i32 1, double* %0, i32 %1, double* %4, i32 1, i32 0, double* %5, i32 1)
%8 = tail call i32 @dscal(i32 %1, i32 -1, double* %5, i32 1)
%9 = tail call i32 @daxpy(i32 %1, i32 1, double* %3, i32 1, double* %5, i32 1)
ret i32 0
}