#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ matmul(int, double *, double *, double *);
main() {
  double *A, *B, *C;
  int i, j;
  A = (double *)malloc(200 * 200 * sizeof(double));
  B = (double *)malloc(200 * 200 * sizeof(double));
  C = (double *)malloc(200 * 200 * sizeof(double));
  for (i = 0; i < 200; i++)
    for (j = 0; j < 200; j++) {
      C[i * 200 + j] = 0;
      A[i * 200 + j] = B[i * 200 + j] = i + j;
    }
  matmul(200, A, B, C);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4e200,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x4e200,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x4e200,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0xc8,-0x24(%rbp)
jge    11f1 <main+0xd1>
movl   $0x0,-0x28(%rbp)
cmpl   $0xc8,-0x28(%rbp)
jge    11de <main+0xbe>
mov    -0x20(%rbp),%rax
imul   $0xc8,-0x24(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
imul   $0xc8,-0x24(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
imul   $0xc8,-0x24(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1174 <main+0x54>
jmp    11e3 <main+0xc3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1160 <main+0x40>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0xc8,%edi
call   1040 <matmul@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x4e200,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
mov    $0x4e200,%edi
call   1030 <malloc@plt>
mov    %rax,%rbp
mov    $0x4e200,%edi
call   1030 <malloc@plt>
xor    %ecx,%ecx
movdqa 0xea4(%rip),%xmm0
xorps  %xmm1,%xmm1
movdqa 0xea9(%rip),%xmm2
mov    %rax,%rdx
mov    %rbp,0x8(%rsp)
mov    %rbp,%rsi
mov    %rbx,0x10(%rsp)
mov    %rbx,%rdi
jmp    11a6 <main+0x86>
nopl   0x0(%rax)
add    $0x1,%rcx
add    $0x640,%rdi
add    $0x640,%rsi
add    $0x640,%rdx
cmp    $0xc8,%rcx
je     130e <main+0x1ee>
imul   $0x640,%rcx,%rbx
lea    (%rax,%rbx,1),%r8
lea    (%rax,%rbx,1),%r9
add    $0x640,%r9
mov    0x8(%rsp),%rbp
lea    0x0(%rbp,%rbx,1),%r11
lea    0x640(%rbp,%rbx,1),%r12
mov    0x10(%rsp),%rbp
lea    (%rbx,%rbp,1),%r13
add    %rbx,%rbp
add    $0x640,%rbp
cmp    %r12,%r8
setb   %r14b
cmp    %r9,%r11
setb   %r15b
cmp    %rbp,%r8
setb   %bl
cmp    %r9,%r13
setb   %r10b
cmp    %rbp,%r11
setb   %r8b
cmp    %r12,%r13
setb   %r9b
test   %r15b,%r14b
jne    12b0 <main+0x190>
and    %r10b,%bl
jne    12b0 <main+0x190>
and    %r9b,%r8b
jne    12b0 <main+0x190>
movq   %rcx,%xmm3
pshufd $0x44,%xmm3,%xmm3
lea    0x2(%rcx),%rbp
movq   %rbp,%xmm4
pshufd $0x44,%xmm4,%xmm4
mov    $0x2,%ebx
movdqa %xmm0,%xmm5
cs nopw 0x0(%rax,%rax,1)
movups %xmm1,-0x10(%rdx,%rbx,8)
movdqa %xmm5,%xmm6
paddq  %xmm3,%xmm6
movdqa %xmm4,%xmm7
paddq  %xmm5,%xmm7
pshufd $0xe8,%xmm6,%xmm6
pshufd $0xe8,%xmm7,%xmm7
cvtdq2pd %xmm6,%xmm6
cvtdq2pd %xmm7,%xmm7
movups %xmm1,(%rdx,%rbx,8)
movups %xmm6,-0x10(%rsi,%rbx,8)
movups %xmm7,(%rsi,%rbx,8)
movups %xmm6,-0x10(%rdi,%rbx,8)
movups %xmm7,(%rdi,%rbx,8)
paddq  %xmm2,%xmm5
add    $0x4,%rbx
cmp    $0xca,%rbx
jne    1250 <main+0x130>
jmp    1180 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movq   $0x0,(%rdx,%rbx,8)
lea    (%rcx,%rbx,1),%ebp
xorps  %xmm3,%xmm3
cvtsi2sd %ebp,%xmm3
movsd  %xmm3,(%rsi,%rbx,8)
movsd  %xmm3,(%rdi,%rbx,8)
movq   $0x0,0x8(%rdx,%rbx,8)
lea    0x1(%rcx,%rbx,1),%ebp
xorps  %xmm3,%xmm3
cvtsi2sd %ebp,%xmm3
movsd  %xmm3,0x8(%rsi,%rbx,8)
movsd  %xmm3,0x8(%rdi,%rbx,8)
add    $0x2,%rbx
cmp    $0xc8,%rbx
jne    12c0 <main+0x1a0>
jmp    1180 <main+0x60>
mov    $0xc8,%edi
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    %rax,%rcx
call   1040 <matmul@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() {
%1 = alloca i32
%2 = alloca double*
%3 = alloca double*
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i64 @malloc(i32 320000)
%8 = inttoptr i64 %7 to double*
store double* %8, double** %2
%9 = call i64 @malloc(i32 320000)
%10 = inttoptr i64 %9 to double*
store double* %10, double** %3
%11 = call i64 @malloc(i32 320000)
%12 = inttoptr i64 %11 to double*
store double* %12, double** %4
store i32 0, i32* %5
br label %13
13: ; preds = %50, %0
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 200
br i1 %15, label %16, label %53
16: ; preds = %13
store i32 0, i32* %6
br label %17
17: ; preds = %46, %16
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 200
br i1 %19, label %20, label %49
20: ; preds = %17
%21 = load double*, double** %4
%22 = load i32, i32* %5
%23 = mul nsw i32 %22, 200
%24 = load i32, i32* %6
%25 = add nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds double, double* %21, i64 %26
store double 0.000000e+00, double* %27
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = add nsw i32 %28, %29
%31 = sitofp i32 %30 to double
%32 = load double*, double** %3
%33 = load i32, i32* %5
%34 = mul nsw i32 %33, 200
%35 = load i32, i32* %6
%36 = add nsw i32 %34, %35
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %32, i64 %37
store double %31, double* %38
%39 = load double*, double** %2
%40 = load i32, i32* %5
%41 = mul nsw i32 %40, 200
%42 = load i32, i32* %6
%43 = add nsw i32 %41, %42
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds double, double* %39, i64 %44
store double %31, double* %45
br label %46
46: ; preds = %20
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
br label %17
49: ; preds = %17
br label %50
50: ; preds = %49
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
br label %13
53: ; preds = %13
%54 = load double*, double** %2
%55 = load double*, double** %3
%56 = load double*, double** %4
%57 = call i32 @matmul(i32 200, double* %54, double* %55, double* %56)
%58 = load i32, i32* %1
ret i32 %58
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i64 @malloc(i32 320000)
%2 = inttoptr i64 %1 to double*
%3 = tail call i64 @malloc(i32 320000)
%4 = inttoptr i64 %3 to double*
%5 = tail call i64 @malloc(i32 320000)
%6 = inttoptr i64 %5 to double*
br label %7
7: ; preds = %0, %79
%8 = phi i64 [ 0, %0 ], [ %80, %79 ]
%9 = mul nuw nsw i64 %8, 200
%10 = getelementptr double, double* %6, i64 %9
%11 = add nuw i64 %9, 200
%12 = getelementptr double, double* %6, i64 %11
%13 = getelementptr double, double* %4, i64 %9
%14 = getelementptr double, double* %4, i64 %11
%15 = getelementptr double, double* %2, i64 %9
%16 = getelementptr double, double* %2, i64 %11
%17 = mul nuw nsw i64 %8, 200
%18 = icmp ult double* %10, %14
%19 = icmp ult double* %13, %12
%20 = and i1 %18, %19
%21 = icmp ult double* %10, %16
%22 = icmp ult double* %15, %12
%23 = and i1 %21, %22
%24 = or i1 %20, %23
%25 = icmp ult double* %13, %16
%26 = icmp ult double* %15, %14
%27 = and i1 %25, %26
%28 = or i1 %24, %27
br i1 %28, label %60, label %29
29: ; preds = %7
%30 = insertelement <2 x i64> poison, i64 %8, i64 0
%31 = shufflevector <2 x i64> %30, <2 x i64> poison, <2 x i32> zeroinitializer
%32 = add nuw i64 %8, 2
%33 = insertelement <2 x i64> poison, i64 %32, i64 0
%34 = shufflevector <2 x i64> %33, <2 x i64> poison, <2 x i32> zeroinitializer
br label %35
35: ; preds = %35, %29
%36 = phi i64 [ 0, %29 ], [ %57, %35 ]
%37 = phi <2 x i64> [ <i64 0, i64 1>, %29 ], [ %58, %35 ]
%38 = add nuw nsw i64 %36, %17
%39 = getelementptr inbounds double, double* %6, i64 %38
%40 = bitcast double* %39 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %40
%41 = getelementptr inbounds double, double* %39, i64 2
%42 = bitcast double* %41 to <2 x double>*
store <2 x double> zeroinitializer, <2 x double>* %42
%43 = add nuw nsw <2 x i64> %37, %31
%44 = add <2 x i64> %34, %37
%45 = trunc <2 x i64> %43 to <2 x i32>
%46 = trunc <2 x i64> %44 to <2 x i32>
%47 = sitofp <2 x i32> %45 to <2 x double>
%48 = sitofp <2 x i32> %46 to <2 x double>
%49 = getelementptr inbounds double, double* %4, i64 %38
%50 = bitcast double* %49 to <2 x double>*
store <2 x double> %47, <2 x double>* %50
%51 = getelementptr inbounds double, double* %49, i64 2
%52 = bitcast double* %51 to <2 x double>*
store <2 x double> %48, <2 x double>* %52
%53 = getelementptr inbounds double, double* %2, i64 %38
%54 = bitcast double* %53 to <2 x double>*
store <2 x double> %47, <2 x double>* %54
%55 = getelementptr inbounds double, double* %53, i64 2
%56 = bitcast double* %55 to <2 x double>*
store <2 x double> %48, <2 x double>* %56
%57 = add nuw i64 %36, 4
%58 = add <2 x i64> %37, <i64 4, i64 4>
%59 = icmp eq i64 %57, 200
br i1 %59, label %79, label %35
60: ; preds = %7, %60
%61 = phi i64 [ %77, %60 ], [ 0, %7 ]
%62 = add nuw nsw i64 %61, %17
%63 = getelementptr inbounds double, double* %6, i64 %62
store double 0.000000e+00, double* %63
%64 = add nuw nsw i64 %61, %8
%65 = trunc i64 %64 to i32
%66 = sitofp i32 %65 to double
%67 = getelementptr inbounds double, double* %4, i64 %62
store double %66, double* %67
%68 = getelementptr inbounds double, double* %2, i64 %62
store double %66, double* %68
%69 = or i64 %61, 1
%70 = add nuw nsw i64 %69, %17
%71 = getelementptr inbounds double, double* %6, i64 %70
store double 0.000000e+00, double* %71
%72 = add nuw nsw i64 %69, %8
%73 = trunc i64 %72 to i32
%74 = sitofp i32 %73 to double
%75 = getelementptr inbounds double, double* %4, i64 %70
store double %74, double* %75
%76 = getelementptr inbounds double, double* %2, i64 %70
store double %74, double* %76
%77 = add nuw nsw i64 %61, 2
%78 = icmp eq i64 %77, 200
br i1 %78, label %79, label %60
79: ; preds = %35, %60
%80 = add nuw nsw i64 %8, 1
%81 = icmp eq i64 %80, 200
br i1 %81, label %82, label %7
82: ; preds = %79
%83 = tail call i32 @matmul(i32 200, double* %2, double* %4, double* %6)
ret i32 0
}