#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*/ abort();
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(float *);
char getopt(int, char **, char *);
int /*<<< orphan*/ init(float *, int);
float *malloc(int);
int optind;
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ rec_matmul(float *, float *, float *, int, int, int, int,
                              int /*<<< orphan*/);
int /*<<< orphan*/ usage(char *);
double wctime();
int /*<<< orphan*/ zero(float *, int);
int main(int argc, char *argv[]) {
  char c;
  while ((c = getopt(argc, argv, "w:q:h")) != -1) {
    switch (c) {
    case 'h':
      usage(argv[0]);
      break;
    default:
      abort();
    }
  }
  if (optind == argc) {
    usage(argv[0]);
    exit(1);
  }
  int n = atoi(argv[optind]);
  float *A = malloc(n * n * sizeof(float));
  float *B = malloc(n * n * sizeof(float));
  float *C1 = malloc(n * n * sizeof(float));
  float *C2 = malloc(n * n * sizeof(float));
  init(A, n);
  init(B, n);
  zero(C1, n);
  zero(C2, n);
  double t1 = wctime();
  rec_matmul(A, B, C2, n, n, n, n, 0);
  double t2 = wctime();
  printf("Time: %f\n", t2 - t1);
  free(C2);
  free(C1);
  free(B);
  free(A);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe1c(%rip),%rdx
call   10a0 <getopt@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     1225 <main+0x65>
mov    -0x11(%rbp),%al
sub    $0x68,%al
jne    1219 <main+0x59>
jmp    1208 <main+0x48>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <usage@plt>
jmp    1220 <main+0x60>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    11d6 <main+0x16>
mov    0x2dbc(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    124d <main+0x8d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <usage@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x2d90(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x18(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1060 <init@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1060 <init@plt>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1080 <zero@plt>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1080 <zero@plt>
mov    $0x0,%al
call   10e0 <wctime@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x18(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    -0x18(%rbp),%eax
xor    %r10d,%r10d
mov    %eax,(%rsp)
movl   $0x0,0x8(%rsp)
call   10c0 <rec_matmul@plt>
mov    $0x0,%al
call   10e0 <wctime@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
lea    0xcb9(%rip),%rdi
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe29(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   10a0 <getopt@plt>
cmp    $0x68,%al
jne    11fb <main+0x3b>
mov    (%rbx),%rdi
call   1090 <usage@plt>
jmp    11e0 <main+0x20>
cmp    $0xff,%al
jne    12ea <main+0x12a>
mov    0x2dde(%rip),%rax
movslq (%rax),%rax
cmp    %ebp,%eax
je     12f1 <main+0x131>
mov    (%rbx,%rax,8),%rdi
call   10b0 <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,%r12
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    %ebp,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <init@plt>
mov    %r12,%rdi
mov    %ebx,%esi
call   1060 <init@plt>
mov    %r15,%rdi
mov    %ebx,%esi
call   1080 <zero@plt>
mov    %r13,%rdi
mov    %ebx,%esi
call   1080 <zero@plt>
xor    %eax,%eax
call   10e0 <wctime@plt>
movsd  %xmm0,(%rsp)
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %ebx,%ecx
mov    %ebx,%r8d
mov    %ebx,%r9d
push   $0x0
push   %rbx
call   10c0 <rec_matmul@plt>
add    $0x10,%rsp
xor    %eax,%eax
call   10e0 <wctime@plt>
subsd  (%rsp),%xmm0
lea    0xd52(%rip),%rdi
call   1050 <printf@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1040 <abort@plt>
mov    (%rbx),%rdi
call   1090 <usage@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"w:q:h\00"
@optind = global i32 0
@.str.1 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
%11 = alloca float*
%12 = alloca double
%13 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %14
14: ; preds = %30, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call signext i8 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8 %17, i8* %6
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %31
20: ; preds = %14
%21 = load i8, i8* %6
%22 = sext i8 %21 to i32
switch i32 %22, label %28 [
i32 104, label %23
]
23: ; preds = %20
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 @usage(i8* %26)
br label %30
28: ; preds = %20
%29 = call i32 (...) @abort()
unreachable
30: ; preds = %23
br label %14
31: ; preds = %14
%32 = load i32, i32* @optind
%33 = load i32, i32* %4
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %41
35: ; preds = %31
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = call i32 @usage(i8* %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %31
%42 = load i8**, i8*** %5
%43 = load i32, i32* @optind
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 @atoi(i8* %46)
store i32 %47, i32* %7
%48 = load i32, i32* %7
%49 = load i32, i32* %7
%50 = mul nsw i32 %48, %49
%51 = sext i32 %50 to i64
%52 = mul i64 %51, 4
%53 = trunc i64 %52 to i32
%54 = call float* @malloc(i32 %53)
store float* %54, float** %8
%55 = load i32, i32* %7
%56 = load i32, i32* %7
%57 = mul nsw i32 %55, %56
%58 = sext i32 %57 to i64
%59 = mul i64 %58, 4
%60 = trunc i64 %59 to i32
%61 = call float* @malloc(i32 %60)
store float* %61, float** %9
%62 = load i32, i32* %7
%63 = load i32, i32* %7
%64 = mul nsw i32 %62, %63
%65 = sext i32 %64 to i64
%66 = mul i64 %65, 4
%67 = trunc i64 %66 to i32
%68 = call float* @malloc(i32 %67)
store float* %68, float** %10
%69 = load i32, i32* %7
%70 = load i32, i32* %7
%71 = mul nsw i32 %69, %70
%72 = sext i32 %71 to i64
%73 = mul i64 %72, 4
%74 = trunc i64 %73 to i32
%75 = call float* @malloc(i32 %74)
store float* %75, float** %11
%76 = load float*, float** %8
%77 = load i32, i32* %7
%78 = call i32 @init(float* %76, i32 %77)
%79 = load float*, float** %9
%80 = load i32, i32* %7
%81 = call i32 @init(float* %79, i32 %80)
%82 = load float*, float** %10
%83 = load i32, i32* %7
%84 = call i32 @zero(float* %82, i32 %83)
%85 = load float*, float** %11
%86 = load i32, i32* %7
%87 = call i32 @zero(float* %85, i32 %86)
%88 = call double (...) @wctime()
store double %88, double* %12
%89 = load float*, float** %8
%90 = load float*, float** %9
%91 = load float*, float** %11
%92 = load i32, i32* %7
%93 = load i32, i32* %7
%94 = load i32, i32* %7
%95 = load i32, i32* %7
%96 = call i32 @rec_matmul(float* %89, float* %90, float* %91, i32 %92, i32 %93, i32 %94, i32 %95, i32 0)
%97 = call double (...) @wctime()
store double %97, double* %13
%98 = load double, double* %13
%99 = load double, double* %12
%100 = fsub double %98, %99
%101 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %100)
%102 = load float*, float** %11
%103 = call i32 @free(float* %102)
%104 = load float*, float** %10
%105 = call i32 @free(float* %104)
%106 = load float*, float** %9
%107 = call i32 @free(float* %106)
%108 = load float*, float** %8
%109 = call i32 @free(float* %108)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"w:q:h\00"
@optind = global i32 0
@.str.1 = [10 x i8] c"Time: %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
switch i8 %4, label %8 [
i8 -1, label %10
i8 104, label %5
]
5: ; preds = %3
%6 = load i8*, i8** %1
%7 = tail call i32 @usage(i8* %6)
br label %3
8: ; preds = %3
%9 = tail call i32 (...) @abort()
unreachable
10: ; preds = %3
%11 = load i32, i32* @optind
%12 = icmp eq i32 %11, %0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i8*, i8** %1
%15 = tail call i32 @usage(i8* %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %10
%18 = sext i32 %11 to i64
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = shl i32 %21, 2
%23 = mul i32 %22, %21
%24 = tail call float* @malloc(i32 %23)
%25 = tail call float* @malloc(i32 %23)
%26 = tail call float* @malloc(i32 %23)
%27 = tail call float* @malloc(i32 %23)
%28 = tail call i32 @init(float* %24, i32 %21)
%29 = tail call i32 @init(float* %25, i32 %21)
%30 = tail call i32 @zero(float* %26, i32 %21)
%31 = tail call i32 @zero(float* %27, i32 %21)
%32 = tail call double (...) @wctime()
%33 = tail call i32 @rec_matmul(float* %24, float* %25, float* %27, i32 %21, i32 %21, i32 %21, i32 %21, i32 0)
%34 = tail call double (...) @wctime()
%35 = fsub double %34, %32
%36 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), double %35)
%37 = tail call i32 @free(float* %27)
%38 = tail call i32 @free(float* %26)
%39 = tail call i32 @free(float* %25)
%40 = tail call i32 @free(float* %24)
ret i32 0
}