#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*/ multiply(int, int, int, double **, double **, double **);
int /*<<< orphan*/ print_matrix(int, int, double **);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  double matrix1[3][2];
  double matrix2[2][4];
  double result[3][4];
  int i, j;
  for (i = 0; i < 3; i++) {
    for (j = 0; j < 2; j++) {
      matrix1[i][j] = i;
    }
  }
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 4; j++) {
      matrix2[i][j] = j;
    }
  }
  printf("Matrix1:\n");
  print_matrix(3, 2, matrix1);
  printf("Matrix2:\n");
  print_matrix(2, 4, matrix2);
  multiply(3, 2, 4, matrix1, matrix2, result);
  printf("Matrix3:\n");
  print_matrix(3, 4, result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xe4(%rbp)
cmpl   $0x3,-0xe4(%rbp)
jge    11ca <main+0x9a>
movl   $0x0,-0xe8(%rbp)
cmpl   $0x2,-0xe8(%rbp)
jge    11b1 <main+0x81>
cvtsi2sdl -0xe4(%rbp),%xmm0
ff
movslq -0xe4(%rbp),%rcx
lea    -0x40(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0xe8(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    116a <main+0x3a>
jmp    11b6 <main+0x86>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1153 <main+0x23>
movl   $0x0,-0xe4(%rbp)
cmpl   $0x2,-0xe4(%rbp)
jge    124b <main+0x11b>
movl   $0x0,-0xe8(%rbp)
cmpl   $0x4,-0xe8(%rbp)
jge    1232 <main+0x102>
cvtsi2sdl -0xe8(%rbp),%xmm0
ff
movslq -0xe4(%rbp),%rcx
lea    -0x80(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0xe8(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    11eb <main+0xbb>
jmp    1237 <main+0x107>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    11d4 <main+0xa4>
lea    0xdae(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdx
mov    $0x3,%edi
mov    $0x2,%esi
call   1050 <print_matrix@plt>
lea    0xd99(%rip),%rdi
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdx
mov    $0x2,%edi
mov    $0x4,%esi
call   1050 <print_matrix@plt>
lea    -0x40(%rbp),%rcx
lea    -0x80(%rbp),%r8
lea    -0xe0(%rbp),%r9
mov    $0x3,%edi
mov    $0x2,%esi
mov    $0x4,%edx
call   1030 <multiply@plt>
lea    0xd61(%rip),%rdi
call   1040 <printf@plt>
lea    -0xe0(%rbp),%rdx
mov    $0x3,%edi
mov    $0x4,%esi
call   1050 <print_matrix@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xd0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps 0xeb6(%rip),%xmm1
movaps %xmm1,0x10(%rsp)
movaps 0xeba(%rip),%xmm1
movaps %xmm1,0x20(%rsp)
movhps 0xece(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb2(%rip),%xmm1
movaps %xmm1,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm1,0x60(%rsp)
lea    0xeb4(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%r14
mov    $0x3,%edi
mov    $0x2,%esi
mov    %r14,%rdx
call   1050 <print_matrix@plt>
lea    0xe9c(%rip),%rdi
call   1040 <puts@plt>
lea    0x30(%rsp),%rbx
mov    $0x2,%edi
mov    $0x4,%esi
mov    %rbx,%rdx
call   1050 <print_matrix@plt>
lea    0x70(%rsp),%r15
mov    $0x3,%edi
mov    $0x2,%esi
mov    $0x4,%edx
mov    %r14,%rcx
mov    %rbx,%r8
mov    %r15,%r9
call   1030 <multiply@plt>
lea    0xe60(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3,%edi
mov    $0x4,%esi
mov    %r15,%rdx
call   1050 <print_matrix@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@str = [9 x i8] c"Matrix1:\00"
@str.3 = [9 x i8] c"Matrix2:\00"
@str.4 = [9 x i8] c"Matrix3:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x [2 x double]]
%4 = alloca [2 x [4 x double]]
%5 = alloca [3 x [4 x double]]
%6 = bitcast [3 x [2 x double]]* %3 to i8*
%7 = bitcast [2 x [4 x double]]* %4 to i8*
%8 = bitcast [3 x [4 x double]]* %5 to i8*
%9 = getelementptr inbounds [3 x [2 x double]], [3 x [2 x double]]* %3, i64 0, i64 1, i64 0
%10 = bitcast [3 x [2 x double]]* %3 to i8*
%11 = bitcast double* %9 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 1.000000e+00>, <2 x double>* %11
%12 = getelementptr inbounds [3 x [2 x double]], [3 x [2 x double]]* %3, i64 0, i64 2, i64 0
%13 = bitcast double* %12 to <2 x double>*
store <2 x double> <double 2.000000e+00, double 2.000000e+00>, <2 x double>* %13
%14 = bitcast [2 x [4 x double]]* %4 to <2 x double>*
store <2 x double> <double 0.000000e+00, double 1.000000e+00>, <2 x double>* %14
%15 = getelementptr inbounds [2 x [4 x double]], [2 x [4 x double]]* %4, i64 0, i64 0, i64 2
%16 = bitcast double* %15 to <2 x double>*
store <2 x double> <double 2.000000e+00, double 3.000000e+00>, <2 x double>* %16
%17 = getelementptr inbounds [2 x [4 x double]], [2 x [4 x double]]* %4, i64 0, i64 1, i64 0
%18 = bitcast double* %17 to <2 x double>*
store <2 x double> <double 0.000000e+00, double 1.000000e+00>, <2 x double>* %18
%19 = getelementptr inbounds [2 x [4 x double]], [2 x [4 x double]]* %4, i64 0, i64 1, i64 2
%20 = bitcast double* %19 to <2 x double>*
store <2 x double> <double 2.000000e+00, double 3.000000e+00>, <2 x double>* %20
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%22 = bitcast [3 x [2 x double]]* %3 to double**
%23 = call i32 @print_matrix(i32 3, i32 2, double** %22)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.3, i64 0, i64 0))
%25 = bitcast [2 x [4 x double]]* %4 to double**
%26 = call i32 @print_matrix(i32 2, i32 4, double** %25)
%27 = bitcast [3 x [4 x double]]* %5 to double**
%28 = call i32 @multiply(i32 3, i32 2, i32 4, double** %22, double** %25, double** %27)
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.4, i64 0, i64 0))
%30 = call i32 @print_matrix(i32 3, i32 4, double** %27)
ret i32 0
}