#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 atoi(char *);
int /*<<< orphan*/ dados(float *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(float *);
scalar_t__ malloc(int);
int /*<<< orphan*/ matrixMulOnHost(float *, float *, float *, int);
int /*<<< orphan*/ printf(char *, ...);
double wtime();
int main(int argc, char *argv[]) {
  float *M;
  float *N;
  float *P;
  int size;
  double start_time, end_time;
  if (argc != 2) {
    printf("Informe size\n");
    exit(1);
  }
  size = atoi(argv[1]);
  M = (float *)malloc(sizeof(float) * size * size);
  N = (float *)malloc(sizeof(float) * size * size);
  P = (float *)malloc(sizeof(float) * size * size);
  dados(M, size);
  dados(N, size);
  start_time = wtime();
  matrixMulOnHost(M, N, P, size);
  end_time = wtime();
  free(M);
  free(N);
  free(P);
  printf("%d %f\n", size, end_time - start_time);
  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)
cmpl   $0x2,-0x8(%rbp)
je     11b8 <main+0x38>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
movslq -0x2c(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
movslq -0x2c(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
movslq -0x2c(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1090 <dados@plt>
mov    -0x20(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1090 <dados@plt>
mov    $0x0,%al
call   1050 <wtime@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
call   1070 <matrixMulOnHost@plt>
mov    $0x0,%al
call   1050 <wtime@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%esi
movsd  -0x40(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
lea    0xd82(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    1255 <main+0xc5>
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebx
mov    %eax,%ebp
imul   %eax,%ebp
shl    $0x2,%ebp
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r12
mov    %r14,%rdi
mov    %ebx,%esi
call   10a0 <dados@plt>
mov    %r15,%rdi
mov    %ebx,%esi
call   10a0 <dados@plt>
xor    %eax,%eax
call   1060 <wtime@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %ebx,%ecx
call   1080 <matrixMulOnHost@plt>
xor    %eax,%eax
call   1060 <wtime@plt>
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
lea    0xdc3(%rip),%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdab(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"Informe size\0A\00"
@.str.1 = [7 x i8] c"%d %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca i32
%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 = icmp ne i32 %12, 2
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %9
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = mul i64 4, %23
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = mul i64 %24, %26
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to float*
store float* %30, float** %6
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = mul i64 4, %32
%34 = load i32, i32* %9
%35 = sext i32 %34 to i64
%36 = mul i64 %33, %35
%37 = trunc i64 %36 to i32
%38 = call i64 @malloc(i32 %37)
%39 = inttoptr i64 %38 to float*
store float* %39, float** %7
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = mul i64 4, %41
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = mul i64 %42, %44
%46 = trunc i64 %45 to i32
%47 = call i64 @malloc(i32 %46)
%48 = inttoptr i64 %47 to float*
store float* %48, float** %8
%49 = load float*, float** %6
%50 = load i32, i32* %9
%51 = call i32 @dados(float* %49, i32 %50)
%52 = load float*, float** %7
%53 = load i32, i32* %9
%54 = call i32 @dados(float* %52, i32 %53)
%55 = call double (...) @wtime()
store double %55, double* %10
%56 = load float*, float** %6
%57 = load float*, float** %7
%58 = load float*, float** %8
%59 = load i32, i32* %9
%60 = call i32 @matrixMulOnHost(float* %56, float* %57, float* %58, i32 %59)
%61 = call double (...) @wtime()
store double %61, double* %11
%62 = load float*, float** %6
%63 = call i32 @free(float* %62)
%64 = load float*, float** %7
%65 = call i32 @free(float* %64)
%66 = load float*, float** %8
%67 = call i32 @free(float* %66)
%68 = load i32, i32* %9
%69 = load double, double* %11
%70 = load double, double* %10
%71 = fsub double %69, %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %68, double %71)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d %f\0A\00"
@str = [13 x i8] c"Informe size\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = shl i32 %10, 2
%12 = mul i32 %11, %10
%13 = tail call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to float*
%15 = tail call i64 @malloc(i32 %12)
%16 = inttoptr i64 %15 to float*
%17 = tail call i64 @malloc(i32 %12)
%18 = inttoptr i64 %17 to float*
%19 = tail call i32 @dados(float* %14, i32 %10)
%20 = tail call i32 @dados(float* %16, i32 %10)
%21 = tail call double (...) @wtime()
%22 = tail call i32 @matrixMulOnHost(float* %14, float* %16, float* %18, i32 %10)
%23 = tail call double (...) @wtime()
%24 = tail call i32 @free(float* %14)
%25 = tail call i32 @free(float* %16)
%26 = tail call i32 @free(float* %18)
%27 = fsub double %23, %21
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %10, double %27)
ret i32 0
}