#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*/ vecadds(int, double *, double *, double);
int /*<<< orphan*/ vecset(int, double *, double);
void lincomb(int n, int m, double *p, double **v, double *c) {
  vecset(n, p, 0.0);
  for (int i = 0; i < m; i++) {
    vecadds(n, p, v[i], c[i]);
  }
  return;
}


x86 assembly (clang, -O0):
<lincomb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
xorps  %xmm0,%xmm0
call   1030 <vecset@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118f <lincomb+0x6f>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <vecadds@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1150 <lincomb+0x30>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lincomb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r13
mov    %esi,%ebx
mov    %edi,%r12d
xorps  %xmm0,%xmm0
mov    %rdx,%rsi
call   1030 <vecset@plt>
test   %ebx,%ebx
jle    116e <lincomb+0x4e>
mov    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r15,%rbp,8),%rdx
movsd  (%r14,%rbp,8),%xmm0
mov    %r12d,%edi
mov    %r13,%rsi
call   1040 <vecadds@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1150 <lincomb+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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