#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*/ eye(double *, int);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ mmult(double *, double *, double *, int, int, int);
int /*<<< orphan*/ msub(double *, double *, double *, int, int);
int /*<<< orphan*/ scale(double *, int, int, double);
void housemat(double *v, int N, double beta, double *mat) {
  double *temp;
  temp = (double *)malloc(sizeof(double) * N * N);
  eye(mat, N);
  mmult(v, v, temp, N, 1, N);
  scale(temp, N, N, beta);
  msub(mat, temp, mat, N, N);
  free(temp);
}


x86 assembly (clang, -O0):
<housemat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
movslq -0xc(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <eye@plt>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0xc(%rbp),%r9d
mov    $0x1,%r8d
call   1040 <mmult@plt>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
movsd  -0x18(%rbp),%xmm0
call   1080 <scale@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0xc(%rbp),%r8d
call   1050 <msub@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<housemat>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
movsd  %xmm0,(%rsp)
mov    %esi,%ebx
mov    %rdi,%r12
mov    %esi,%edi
imul   %esi,%edi
shl    $0x3,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <eye@plt>
mov    %r12,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %ebx,%ecx
mov    $0x1,%r8d
mov    %ebx,%r9d
call   1040 <mmult@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebx,%edx
movsd  (%rsp),%xmm0
call   1080 <scale@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    %ebx,%ecx
mov    %ebx,%r8d
call   1050 <msub@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @housemat(double* %0, i32 %1, double %2, double* %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca double
%8 = alloca double*
%9 = alloca double*
store double* %0, double** %5
store i32 %1, i32* %6
store double %2, double* %7
store double* %3, double** %8
%10 = load i32, i32* %6
%11 = sext i32 %10 to i64
%12 = mul i64 8, %11
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = mul i64 %12, %14
%16 = trunc i64 %15 to i32
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to double*
store double* %18, double** %9
%19 = load double*, double** %8
%20 = load i32, i32* %6
%21 = call i32 @eye(double* %19, i32 %20)
%22 = load double*, double** %5
%23 = load double*, double** %5
%24 = load double*, double** %9
%25 = load i32, i32* %6
%26 = load i32, i32* %6
%27 = call i32 @mmult(double* %22, double* %23, double* %24, i32 %25, i32 1, i32 %26)
%28 = load double*, double** %9
%29 = load i32, i32* %6
%30 = load i32, i32* %6
%31 = load double, double* %7
%32 = call i32 @scale(double* %28, i32 %29, i32 %30, double %31)
%33 = load double*, double** %8
%34 = load double*, double** %9
%35 = load double*, double** %8
%36 = load i32, i32* %6
%37 = load i32, i32* %6
%38 = call i32 @msub(double* %33, double* %34, double* %35, i32 %36, i32 %37)
%39 = load double*, double** %9
%40 = call i32 @free(double* %39)
ret void
}

LLVM IR (-O2):
define void @housemat(double* %0, i32 %1, double %2, double* %3) {
%5 = shl i32 %1, 3
%6 = mul i32 %5, %1
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to double*
%9 = tail call i32 @eye(double* %3, i32 %1)
%10 = tail call i32 @mmult(double* %0, double* %0, double* %8, i32 %1, i32 1, i32 %1)
%11 = tail call i32 @scale(double* %8, i32 %1, i32 %1, double %2)
%12 = tail call i32 @msub(double* %3, double* %8, double* %3, i32 %1, i32 %1)
%13 = tail call i32 @free(double* %8)
ret void
}