#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*/ fprintf(int /*<<< orphan*/, char *, double);
int /*<<< orphan*/ mm_destroy(int, double **);
double **mm_gen(int);
double **mm_mul(int, double **, double **);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  int n = 100;
  double **a, **b, **m;
  if (argc > 1)
    n = atoi(argv[1]);
  n = (n / 2) * 2;
  a = mm_gen(n);
  b = mm_gen(n);
  m = mm_mul(n, a, b);
  fprintf(stderr, "%lf\n", m[n / 2][n / 2]);
  mm_destroy(n, a);
  mm_destroy(n, b);
  mm_destroy(n, m);
  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)
movl   $0x64,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1187 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <mm_gen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <mm_gen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1070 <mm_mul@plt>
mov    %rax,-0x30(%rbp)
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xdef(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <mm_destroy@plt>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1050 <mm_destroy@plt>
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1050 <mm_destroy@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
mov    $0x32,%ebx
cmp    $0x2,%edi
jl     1174 <main+0x24>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
shr    $0x1f,%ebx
add    %eax,%ebx
sar    %ebx
lea    (%rbx,%rbx,1),%ebp
mov    %ebp,%edi
call   1030 <mm_gen@plt>
mov    %rax,%r14
mov    %ebp,%edi
call   1030 <mm_gen@plt>
mov    %rax,%r15
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rax,%rdx
call   1070 <mm_mul@plt>
mov    %rax,%r12
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
movslq %ebx,%rax
mov    (%r12,%rax,8),%rcx
movsd  (%rcx,%rax,8),%xmm0
lea    0xe49(%rip),%rsi
call   1040 <fprintf@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1050 <mm_destroy@plt>
mov    %ebp,%edi
mov    %r15,%rsi
call   1050 <mm_destroy@plt>
mov    %ebp,%edi
mov    %r12,%rsi
call   1050 <mm_destroy@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [5 x i8] c"%lf\0A\00"
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
store i32 100, i32* %6
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
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)
store i32 %16, i32* %6
br label %17
17: ; preds = %12, %2
%18 = load i32, i32* %6
%19 = sdiv i32 %18, 2
%20 = mul nsw i32 %19, 2
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = call double** @mm_gen(i32 %21)
store double** %22, double*** %7
%23 = load i32, i32* %6
%24 = call double** @mm_gen(i32 %23)
store double** %24, double*** %8
%25 = load i32, i32* %6
%26 = load double**, double*** %7
%27 = load double**, double*** %8
%28 = call double** @mm_mul(i32 %25, double** %26, double** %27)
store double** %28, double*** %9
%29 = load i32, i32* @stderr
%30 = load double**, double*** %9
%31 = load i32, i32* %6
%32 = sdiv i32 %31, 2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds double*, double** %30, i64 %33
%35 = load double*, double** %34
%36 = load i32, i32* %6
%37 = sdiv i32 %36, 2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds double, double* %35, i64 %38
%40 = load double, double* %39
%41 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %40)
%42 = load i32, i32* %6
%43 = load double**, double*** %7
%44 = call i32 @mm_destroy(i32 %42, double** %43)
%45 = load i32, i32* %6
%46 = load double**, double*** %8
%47 = call i32 @mm_destroy(i32 %45, double** %46)
%48 = load i32, i32* %6
%49 = load double**, double*** %9
%50 = call i32 @mm_destroy(i32 %48, double** %49)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [5 x i8] c"%lf\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = sdiv i32 %7, 2
br label %9
9: ; preds = %4, %2
%10 = phi i32 [ %8, %4 ], [ 50, %2 ]
%11 = shl nsw i32 %10, 1
%12 = tail call double** @mm_gen(i32 %11)
%13 = tail call double** @mm_gen(i32 %11)
%14 = tail call double** @mm_mul(i32 %11, double** %12, double** %13)
%15 = load i32, i32* @stderr
%16 = sext i32 %10 to i64
%17 = getelementptr inbounds double*, double** %14, i64 %16
%18 = load double*, double** %17
%19 = getelementptr inbounds double, double* %18, i64 %16
%20 = load double, double* %19
%21 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %20)
%22 = tail call i32 @mm_destroy(i32 %11, double** %12)
%23 = tail call i32 @mm_destroy(i32 %11, double** %13)
%24 = tail call i32 @mm_destroy(i32 %11, double** %14)
ret i32 0
}