#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*/ Gen_matrix(double *, int, int);
int /*<<< orphan*/ Gen_vector(double *, int);
int /*<<< orphan*/ Get_args(int, char **, int *, int *, int *);
int /*<<< orphan*/ Omp_mat_vect(double *, double *, double *, int, int, int);
int /*<<< orphan*/ free(double *);
double *malloc(int);
int main(int argc, char *argv[]) {
  int thread_count;
  int m, n;
  double *A;
  double *x;
  double *y;
  Get_args(argc, argv, &thread_count, &m, &n);
  A = malloc(m * n * sizeof(double));
  x = malloc(n * sizeof(double));
  y = malloc(m * sizeof(double));
  Gen_matrix(A, m, n);
  Gen_vector(x, n);
  Omp_mat_vect(A, x, y, m, n, thread_count);
  free(A);
  free(x);
  free(y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
call   1050 <Get_args@plt>
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <Gen_matrix@plt>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1060 <Gen_vector@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    -0x14(%rbp),%r9d
call   1080 <Omp_mat_vect@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
call   1050 <Get_args@plt>
mov    0x10(%rsp),%r12d
mov    0xc(%rsp),%ebx
lea    0x0(,%r12,8),%ebp
mov    %ebp,%edi
imul   %ebx,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0x0(,%rbx,8),%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
call   1040 <Gen_matrix@plt>
mov    0xc(%rsp),%esi
mov    %r13,%rdi
call   1060 <Gen_vector@plt>
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x14(%rsp),%r9d
mov    %r14,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1080 <Omp_mat_vect@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call i32 @Get_args(i32 %12, i8** %13, i32* %6, i32* %7, i32* %8)
%15 = load i32, i32* %7
%16 = load i32, i32* %8
%17 = mul nsw i32 %15, %16
%18 = sext i32 %17 to i64
%19 = mul i64 %18, 8
%20 = trunc i64 %19 to i32
%21 = call double* @malloc(i32 %20)
store double* %21, double** %9
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 8
%25 = trunc i64 %24 to i32
%26 = call double* @malloc(i32 %25)
store double* %26, double** %10
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 8
%30 = trunc i64 %29 to i32
%31 = call double* @malloc(i32 %30)
store double* %31, double** %11
%32 = load double*, double** %9
%33 = load i32, i32* %7
%34 = load i32, i32* %8
%35 = call i32 @Gen_matrix(double* %32, i32 %33, i32 %34)
%36 = load double*, double** %10
%37 = load i32, i32* %8
%38 = call i32 @Gen_vector(double* %36, i32 %37)
%39 = load double*, double** %9
%40 = load double*, double** %10
%41 = load double*, double** %11
%42 = load i32, i32* %7
%43 = load i32, i32* %8
%44 = load i32, i32* %6
%45 = call i32 @Omp_mat_vect(double* %39, double* %40, double* %41, i32 %42, i32 %43, i32 %44)
%46 = load double*, double** %9
%47 = call i32 @free(double* %46)
%48 = load double*, double** %10
%49 = call i32 @free(double* %48)
%50 = load double*, double** %11
%51 = call i32 @free(double* %50)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i32 @Get_args(i32 %0, i8** %1, i32* %3, i32* %4, i32* %5)
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = shl i32 %10, 3
%13 = mul i32 %12, %11
%14 = call double* @malloc(i32 %13)
%15 = shl i32 %11, 3
%16 = call double* @malloc(i32 %15)
%17 = call double* @malloc(i32 %12)
%18 = call i32 @Gen_matrix(double* %14, i32 %10, i32 %11)
%19 = load i32, i32* %5
%20 = call i32 @Gen_vector(double* %16, i32 %19)
%21 = load i32, i32* %4
%22 = load i32, i32* %5
%23 = load i32, i32* %3
%24 = call i32 @Omp_mat_vect(double* %14, double* %16, double* %17, i32 %21, i32 %22, i32 %23)
%25 = call i32 @free(double* %14)
%26 = call i32 @free(double* %16)
%27 = call i32 @free(double* %17)
ret i32 0
}