#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 *);
double *calloc(int, int);
double *init(int);
int /*<<< orphan*/ mm(double *, double *, double *, int);
int main(int argc, char *argv[]) {
  int size = (argc == 2) ? atoi(argv[1]) : 512;
  double *a = init(size);
  double *b = init(size);
  double *c = calloc(size * size, sizeof(double));
  mm(a, b, c, size);
  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)
jne    1175 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x34(%rbp)
jmp    1182 <main+0x42>
mov    $0x200,%eax
mov    %eax,-0x34(%rbp)
jmp    1182 <main+0x42>
mov    -0x34(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <init@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <init@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
imul   -0x14(%rbp),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1060 <mm@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x200,%ebx
cmp    $0x2,%edi
jne    115a <main+0x1a>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    %ebx,%edi
call   1040 <init@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1040 <init@plt>
mov    %rax,%r15
mov    %ebx,%edi
imul   %ebx,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
mov    %ebx,%ecx
call   1060 <mm@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
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 double*
%8 = alloca double*
%9 = alloca double*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
br label %18
17: ; preds = %2
br label %18
18: ; preds = %17, %12
%19 = phi i32 [ %16, %12 ], [ 512, %17 ]
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = call double* @init(i32 %20)
store double* %21, double** %7
%22 = load i32, i32* %6
%23 = call double* @init(i32 %22)
store double* %23, double** %8
%24 = load i32, i32* %6
%25 = load i32, i32* %6
%26 = mul nsw i32 %24, %25
%27 = call double* @calloc(i32 %26, i32 8)
store double* %27, double** %9
%28 = load double*, double** %7
%29 = load double*, double** %8
%30 = load double*, double** %9
%31 = load i32, i32* %6
%32 = call i32 @mm(double* %28, double* %29, double* %30, i32 %31)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %8
8: ; preds = %2, %4
%9 = phi i32 [ %7, %4 ], [ 512, %2 ]
%10 = tail call double* @init(i32 %9)
%11 = tail call double* @init(i32 %9)
%12 = mul nsw i32 %9, %9
%13 = tail call double* @calloc(i32 %12, i32 8)
%14 = tail call i32 @mm(double* %10, double* %11, double* %13, i32 %9)
ret i32 0
}