#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*/ blocked_multiplication(double **, double **, double **);
int /*<<< orphan*/ init_matrix(double **);
int /*<<< orphan*/ memset(double **, int /*<<< orphan*/, int);
int /*<<< orphan*/ naive_multiplication(double **, double **, double **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ srand48(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  srand48(time(NULL));
  double A[6144][6144];
  double B[6144][6144];
  double C[6144][6144];
  init_matrix(A);
  init_matrix(B);
  memset(C, 0, 6144 * 6144 * sizeof(double));
  blocked_multiplication(A, B, C);
  double D[6144][6144];
  memset(D, 0, 6144 * 6144 * sizeof(double));
  naive_multiplication(A, B, D);
  int equal = 1;
  for (int i = 0; i < 6144; ++i) {
    for (int j = 0; j < 6144; ++j) {
      if (C[i][j] != D[i][j])
        equal = 0;
    }
  }
  if (equal) {
    printf("both are equal\n");
  } else {
    printf("they are different\n");
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x48000020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1070 <srand48@plt>
lea    -0x12000010(%rbp),%rdi
call   1080 <init_matrix@plt>
lea    -0x24000010(%rbp),%rdi
call   1080 <init_matrix@plt>
lea    -0x36000010(%rbp),%rdi
xor    %esi,%esi
mov    $0x12000000,%edx
call   1040 <memset@plt>
lea    -0x12000010(%rbp),%rdi
lea    -0x24000010(%rbp),%rsi
lea    -0x36000010(%rbp),%rdx
call   1060 <blocked_multiplication@plt>
lea    -0x48000010(%rbp),%rdi
xor    %esi,%esi
mov    $0x12000000,%edx
call   1040 <memset@plt>
lea    -0x12000010(%rbp),%rdi
lea    -0x24000010(%rbp),%rsi
lea    -0x48000010(%rbp),%rdx
call   1090 <naive_multiplication@plt>
movl   $0x1,-0x48000014(%rbp)
movl   $0x0,-0x48000018(%rbp)
cmpl   $0x1800,-0x48000018(%rbp)
jge    12de <main+0x16e>
movl   $0x0,-0x4800001c(%rbp)
cmpl   $0x1800,-0x4800001c(%rbp)
jge    12c5 <main+0x155>
movslq -0x48000018(%rbp),%rcx
lea    -0x36000010(%rbp),%rax
imul   $0xc000,%rcx,%rcx
add    %rcx,%rax
movslq -0x4800001c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x48000018(%rbp),%rcx
lea    -0x48000010(%rbp),%rax
imul   $0xc000,%rcx,%rcx
add    %rcx,%rax
movslq -0x4800001c(%rbp),%rcx
ucomisd (%rax,%rcx,8),%xmm0
jne    12a2 <main+0x132>
jp     12a2 <main+0x132>
jmp    12ac <main+0x13c>
movl   $0x0,-0x48000014(%rbp)
jmp    12b1 <main+0x141>
mov    -0x4800001c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4800001c(%rbp)
jmp    1239 <main+0xc9>
jmp    12ca <main+0x15a>
mov    -0x48000018(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48000018(%rbp)
jmp    121f <main+0xaf>
cmpl   $0x0,-0x48000014(%rbp)
je     12fc <main+0x18c>
lea    0xd0e(%rip),%rdi
call   1030 <printf@plt>
jmp    1308 <main+0x198>
lea    0xd0d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x48000020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48000000,%rsp
xor    %r13d,%r13d
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1070 <srand48@plt>
lea    0x36000000(%rsp),%r14
36
mov    %r14,%rdi
call   1080 <init_matrix@plt>
lea    0x24000000(%rsp),%r15
24
mov    %r15,%rdi
call   1080 <init_matrix@plt>
lea    0x12000000(%rsp),%r12
12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x12000000,%edx
call   1040 <memset@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <blocked_multiplication@plt>
mov    %rsp,%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x12000000,%edx
call   1040 <memset@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1090 <naive_multiplication@plt>
lea    0x12000030(%rsp),%rax
12
lea    0x30(%rsp),%rdx
mov    $0x1,%ecx
xor    %esi,%esi
nopw   0x0(%rax,%rax,1)
movd   %ecx,%xmm0
pshufd $0x50,%xmm0,%xmm1
xor    %edi,%edi
movdqa %xmm1,%xmm2
nop
movdqa %xmm2,%xmm3
movdqa %xmm1,%xmm2
movapd -0x30(%rdx,%rdi,8),%xmm1
movapd -0x20(%rdx,%rdi,8),%xmm4
movapd -0x10(%rdx,%rdi,8),%xmm5
movapd (%rdx,%rdi,8),%xmm6
cmpneqpd -0x30(%rax,%rdi,8),%xmm1
cmpneqpd -0x20(%rax,%rdi,8),%xmm4
cmpneqpd -0x10(%rax,%rdi,8),%xmm5
cmpneqpd (%rax,%rdi,8),%xmm6
orpd   %xmm1,%xmm5
orpd   %xmm4,%xmm6
pshufd $0xe8,%xmm5,%xmm1
pandn  %xmm2,%xmm1
pshufd $0xe8,%xmm6,%xmm2
pandn  %xmm3,%xmm2
add    $0x8,%rdi
cmp    $0x1800,%rdi
jne    1220 <main+0xb0>
pshufd $0x50,%xmm0,%xmm0
movdqa %xmm1,%xmm3
pcmpeqd %xmm0,%xmm3
pand   %xmm3,%xmm2
pandn  %xmm1,%xmm3
por    %xmm2,%xmm3
movq   %xmm3,%rdi
movq   %xmm0,%rbx
cmp    %rbx,%rdi
cmovne %r13d,%ecx
add    $0x1,%rsi
add    $0xc000,%rax
add    $0xc000,%rdx
cmp    $0x1800,%rsi
jne    1210 <main+0xa0>
test   %ecx,%ecx
lea    0xd2e(%rip),%rax
lea    0xd3a(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x48000000,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"both are equal\0A\00"
@.str.1 = [20 x i8] c"they are different\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [6144 x [6144 x double]]
%7 = alloca [6144 x [6144 x double]]
%8 = alloca [6144 x [6144 x double]]
%9 = alloca [6144 x [6144 x double]]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 @time(i32* null)
%14 = call i32 @srand48(i32 %13)
%15 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %6, i64 0, i64 0
%16 = bitcast [6144 x double]* %15 to double**
%17 = call i32 @init_matrix(double** %16)
%18 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %7, i64 0, i64 0
%19 = bitcast [6144 x double]* %18 to double**
%20 = call i32 @init_matrix(double** %19)
%21 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %8, i64 0, i64 0
%22 = bitcast [6144 x double]* %21 to double**
%23 = call i32 @memset(double** %22, i32 0, i32 301989888)
%24 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %6, i64 0, i64 0
%25 = bitcast [6144 x double]* %24 to double**
%26 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %7, i64 0, i64 0
%27 = bitcast [6144 x double]* %26 to double**
%28 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %8, i64 0, i64 0
%29 = bitcast [6144 x double]* %28 to double**
%30 = call i32 @blocked_multiplication(double** %25, double** %27, double** %29)
%31 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %9, i64 0, i64 0
%32 = bitcast [6144 x double]* %31 to double**
%33 = call i32 @memset(double** %32, i32 0, i32 301989888)
%34 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %6, i64 0, i64 0
%35 = bitcast [6144 x double]* %34 to double**
%36 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %7, i64 0, i64 0
%37 = bitcast [6144 x double]* %36 to double**
%38 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %9, i64 0, i64 0
%39 = bitcast [6144 x double]* %38 to double**
%40 = call i32 @naive_multiplication(double** %35, double** %37, double** %39)
store i32 1, i32* %10
store i32 0, i32* %11
br label %41
41: ; preds = %70, %2
%42 = load i32, i32* %11
%43 = icmp slt i32 %42, 6144
br i1 %43, label %44, label %73
44: ; preds = %41
store i32 0, i32* %12
br label %45
45: ; preds = %66, %44
%46 = load i32, i32* %12
%47 = icmp slt i32 %46, 6144
br i1 %47, label %48, label %69
48: ; preds = %45
%49 = load i32, i32* %11
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %8, i64 0, i64 %50
%52 = load i32, i32* %12
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [6144 x double], [6144 x double]* %51, i64 0, i64 %53
%55 = load double, double* %54
%56 = load i32, i32* %11
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %9, i64 0, i64 %57
%59 = load i32, i32* %12
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [6144 x double], [6144 x double]* %58, i64 0, i64 %60
%62 = load double, double* %61
%63 = fcmp une double %55, %62
br i1 %63, label %64, label %65
64: ; preds = %48
store i32 0, i32* %10
br label %65
65: ; preds = %64, %48
br label %66
66: ; preds = %65
%67 = load i32, i32* %12
%68 = add nsw i32 %67, 1
store i32 %68, i32* %12
br label %45
69: ; preds = %45
br label %70
70: ; preds = %69
%71 = load i32, i32* %11
%72 = add nsw i32 %71, 1
store i32 %72, i32* %11
br label %41
73: ; preds = %41
%74 = load i32, i32* %10
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %78
76: ; preds = %73
%77 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %80
78: ; preds = %73
%79 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %80
80: ; preds = %78, %76
ret i32 0
}

LLVM IR (-O2):
@str = [19 x i8] c"they are different\00"
@str.2 = [15 x i8] c"both are equal\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6144 x [6144 x double]]
%4 = alloca [6144 x [6144 x double]]
%5 = alloca [6144 x [6144 x double]]
%6 = alloca [6144 x [6144 x double]]
%7 = tail call i32 @time(i32* null)
%8 = tail call i32 @srand48(i32 %7)
%9 = bitcast [6144 x [6144 x double]]* %3 to i8*
%10 = bitcast [6144 x [6144 x double]]* %4 to i8*
%11 = bitcast [6144 x [6144 x double]]* %5 to i8*
%12 = bitcast [6144 x [6144 x double]]* %3 to double**
%13 = call i32 @init_matrix(double** %12)
%14 = bitcast [6144 x [6144 x double]]* %4 to double**
%15 = call i32 @init_matrix(double** %14)
%16 = bitcast [6144 x [6144 x double]]* %5 to double**
%17 = call i32 @memset(double** %16, i32 0, i32 301989888)
%18 = call i32 @blocked_multiplication(double** %12, double** %14, double** %16)
%19 = bitcast [6144 x [6144 x double]]* %6 to i8*
%20 = bitcast [6144 x [6144 x double]]* %6 to double**
%21 = call i32 @memset(double** %20, i32 0, i32 301989888)
%22 = call i32 @naive_multiplication(double** %12, double** %14, double** %20)
br label %23
23: ; preds = %67, %2
%24 = phi i64 [ 0, %2 ], [ %78, %67 ]
%25 = phi i32 [ 1, %2 ], [ %77, %67 ]
%26 = insertelement <2 x i32> poison, i32 %25, i64 0
%27 = shufflevector <2 x i32> %26, <2 x i32> poison, <2 x i32> zeroinitializer
br label %28
28: ; preds = %28, %23
%29 = phi i64 [ 0, %23 ], [ %65, %28 ]
%30 = phi <2 x i32> [ %27, %23 ], [ %62, %28 ]
%31 = phi <2 x i32> [ %27, %23 ], [ %64, %28 ]
%32 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %5, i64 0, i64 %24, i64 %29
%33 = bitcast double* %32 to <2 x double>*
%34 = load <2 x double>, <2 x double>* %33
%35 = getelementptr inbounds double, double* %32, i64 2
%36 = bitcast double* %35 to <2 x double>*
%37 = load <2 x double>, <2 x double>* %36
%38 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %6, i64 0, i64 %24, i64 %29
%39 = bitcast double* %38 to <2 x double>*
%40 = load <2 x double>, <2 x double>* %39
%41 = getelementptr inbounds double, double* %38, i64 2
%42 = bitcast double* %41 to <2 x double>*
%43 = load <2 x double>, <2 x double>* %42
%44 = fcmp une <2 x double> %34, %40
%45 = fcmp une <2 x double> %37, %43
%46 = or i64 %29, 4
%47 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %5, i64 0, i64 %24, i64 %46
%48 = bitcast double* %47 to <2 x double>*
%49 = load <2 x double>, <2 x double>* %48
%50 = getelementptr inbounds double, double* %47, i64 2
%51 = bitcast double* %50 to <2 x double>*
%52 = load <2 x double>, <2 x double>* %51
%53 = getelementptr inbounds [6144 x [6144 x double]], [6144 x [6144 x double]]* %6, i64 0, i64 %24, i64 %46
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = getelementptr inbounds double, double* %53, i64 2
%57 = bitcast double* %56 to <2 x double>*
%58 = load <2 x double>, <2 x double>* %57
%59 = fcmp une <2 x double> %49, %55
%60 = fcmp une <2 x double> %52, %58
%61 = select <2 x i1> %59, <2 x i1> <i1 true, i1 true>, <2 x i1> %44
%62 = select <2 x i1> %61, <2 x i32> zeroinitializer, <2 x i32> %30
%63 = select <2 x i1> %60, <2 x i1> <i1 true, i1 true>, <2 x i1> %45
%64 = select <2 x i1> %63, <2 x i32> zeroinitializer, <2 x i32> %31
%65 = add nuw nsw i64 %29, 8
%66 = icmp eq i64 %65, 6144
br i1 %66, label %67, label %28
67: ; preds = %28
%68 = insertelement <2 x i32> poison, i32 %25, i64 0
%69 = shufflevector <2 x i32> %68, <2 x i32> poison, <2 x i32> zeroinitializer
%70 = icmp eq <2 x i32> %62, %69
%71 = select <2 x i1> %70, <2 x i32> %64, <2 x i32> %62
%72 = insertelement <2 x i32> poison, i32 %25, i64 0
%73 = shufflevector <2 x i32> %72, <2 x i32> poison, <2 x i32> zeroinitializer
%74 = bitcast <2 x i32> %71 to i64
%75 = bitcast <2 x i32> %73 to i64
%76 = icmp eq i64 %74, %75
%77 = select i1 %76, i32 %25, i32 0
%78 = add nuw nsw i64 %24, 1
%79 = icmp eq i64 %78, 6144
br i1 %79, label %80, label %23
80: ; preds = %67
%81 = icmp eq i32 %77, 0
%82 = select i1 %81, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @str.2, i64 0, i64 0)
%83 = call i32 @puts(i8* dereferenceable(1) %82)
ret i32 0
}