#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 */
struct C_MatrixXd {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ MatrixXd_delete(struct C_MatrixXd *);
int /*<<< orphan*/ MatrixXd_multiply(struct C_MatrixXd *, struct C_MatrixXd *,
                                     struct C_MatrixXd *);
struct C_MatrixXd *MatrixXd_new(int, int);
int /*<<< orphan*/ MatrixXd_print(struct C_MatrixXd *);
int /*<<< orphan*/ MatrixXd_set_coeff(struct C_MatrixXd *, int, int, double);
int /*<<< orphan*/ MatrixXd_set_zero(struct C_MatrixXd *);
int /*<<< orphan*/ printf(char *);
void demo_MatrixXd() {
  struct C_MatrixXd *matrix1, *matrix2, *result;
  printf("*** demo_MatrixXd ***\n");
  matrix1 = MatrixXd_new(3, 3);
  MatrixXd_set_zero(matrix1);
  MatrixXd_set_coeff(matrix1, 0, 1, 2.5);
  MatrixXd_set_coeff(matrix1, 1, 0, 1.4);
  printf("Here is matrix1:\n");
  MatrixXd_print(matrix1);
  matrix2 = MatrixXd_new(3, 3);
  MatrixXd_multiply(matrix1, matrix1, matrix2);
  printf("Here is matrix1*matrix1:\n");
  MatrixXd_print(matrix2);
  MatrixXd_delete(matrix1);
  MatrixXd_delete(matrix2);
}


x86 assembly (clang, -O0):
<demo_MatrixXd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
mov    $0x3,%esi
mov    %esi,%edi
call   1030 <MatrixXd_new@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <MatrixXd_set_zero@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
movsd  0xe58(%rip),%xmm0
call   1090 <MatrixXd_set_coeff@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
xor    %edx,%edx
movsd  0xe38(%rip),%xmm0
call   1090 <MatrixXd_set_coeff@plt>
lea    0xe53(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1060 <MatrixXd_print@plt>
mov    $0x3,%esi
mov    %esi,%edi
call   1030 <MatrixXd_new@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1070 <MatrixXd_multiply@plt>
lea    0xe2f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <MatrixXd_print@plt>
mov    -0x8(%rbp),%rdi
call   1040 <MatrixXd_delete@plt>
mov    -0x10(%rbp),%rdi
call   1040 <MatrixXd_delete@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<demo_MatrixXd>:
push   %r14
push   %rbx
push   %rax
lea    0xe95(%rip),%rdi
call   1040 <puts@plt>
mov    $0x3,%edi
mov    $0x3,%esi
call   1030 <MatrixXd_new@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <MatrixXd_set_zero@plt>
movsd  0xe5e(%rip),%xmm0
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1090 <MatrixXd_set_coeff@plt>
movsd  0xe4f(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1090 <MatrixXd_set_coeff@plt>
lea    0xe57(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1060 <MatrixXd_print@plt>
mov    $0x3,%edi
mov    $0x3,%esi
call   1030 <MatrixXd_new@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1070 <MatrixXd_multiply@plt>
lea    0xe34(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1060 <MatrixXd_print@plt>
mov    %rbx,%rdi
call   1050 <MatrixXd_delete@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <MatrixXd_delete@plt>

LLVM IR (-O0):
%struct.C_MatrixXd = type { i32 }
@.str = [23 x i8] c"*** demo_MatrixXd ***\0A\00"
@.str.1 = [18 x i8] c"Here is matrix1:\0A\00"
@.str.2 = [26 x i8] c"Here is matrix1*matrix1:\0A\00"
define void @demo_MatrixXd() {
%1 = alloca %struct.C_MatrixXd*
%2 = alloca %struct.C_MatrixXd*
%3 = alloca %struct.C_MatrixXd*
%4 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%5 = call %struct.C_MatrixXd* @MatrixXd_new(i32 3, i32 3)
store %struct.C_MatrixXd* %5, %struct.C_MatrixXd** %1
%6 = load %struct.C_MatrixXd*, %struct.C_MatrixXd** %1
%7 = call i32 @MatrixXd_set_zero(%struct.C_MatrixXd* %6)
%8 = load %struct.C_MatrixXd*, %struct.C_MatrixXd** %1
%9 = call i32 @MatrixXd_set_coeff(%struct.C_MatrixXd* %8, i32 0, i32 1, double 2.500000e+00)
%10 = load %struct.C_MatrixXd*, %struct.C_MatrixXd** %1
%11 = call i32 @MatrixXd_set_coeff(%struct.C_MatrixXd* %10, i32 1, i32 0, double 1.400000e+00)
%12 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%13 = load %struct.C_MatrixXd*, %struct.C_MatrixXd** %1
%14 = call i32 @MatrixXd_print(%struct.C_MatrixXd* %13)
%15 = call %struct.C_MatrixXd* @MatrixXd_new(i32 3, i32 3)
store %struct.C_MatrixXd* %15, %struct.C_MatrixXd** %2
%16 = load %struct.C_MatrixXd*, %struct.C_MatrixXd** %1
%17 = load %struct.C_MatrixXd*, %struct.C_MatrixXd** %1
%18 = load %struct.C_MatrixXd*, %struct.C_MatrixXd** %2
%19 = call i32 @MatrixXd_multiply(%struct.C_MatrixXd* %16, %struct.C_MatrixXd* %17, %struct.C_MatrixXd* %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%21 = load %struct.C_MatrixXd*, %struct.C_MatrixXd** %2
%22 = call i32 @MatrixXd_print(%struct.C_MatrixXd* %21)
%23 = load %struct.C_MatrixXd*, %struct.C_MatrixXd** %1
%24 = call i32 @MatrixXd_delete(%struct.C_MatrixXd* %23)
%25 = load %struct.C_MatrixXd*, %struct.C_MatrixXd** %2
%26 = call i32 @MatrixXd_delete(%struct.C_MatrixXd* %25)
ret void
}

LLVM IR (-O2):
%struct.C_MatrixXd = type { i32 }
@str = [22 x i8] c"*** demo_MatrixXd ***\00"
@str.3 = [17 x i8] c"Here is matrix1:\00"
@str.4 = [25 x i8] c"Here is matrix1*matrix1:\00"
define void @demo_MatrixXd() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%2 = tail call %struct.C_MatrixXd* @MatrixXd_new(i32 3, i32 3)
%3 = tail call i32 @MatrixXd_set_zero(%struct.C_MatrixXd* %2)
%4 = tail call i32 @MatrixXd_set_coeff(%struct.C_MatrixXd* %2, i32 0, i32 1, double 2.500000e+00)
%5 = tail call i32 @MatrixXd_set_coeff(%struct.C_MatrixXd* %2, i32 1, i32 0, double 1.400000e+00)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.3, i64 0, i64 0))
%7 = tail call i32 @MatrixXd_print(%struct.C_MatrixXd* %2)
%8 = tail call %struct.C_MatrixXd* @MatrixXd_new(i32 3, i32 3)
%9 = tail call i32 @MatrixXd_multiply(%struct.C_MatrixXd* %2, %struct.C_MatrixXd* %2, %struct.C_MatrixXd* %8)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.4, i64 0, i64 0))
%11 = tail call i32 @MatrixXd_print(%struct.C_MatrixXd* %8)
%12 = tail call i32 @MatrixXd_delete(%struct.C_MatrixXd* %2)
%13 = tail call i32 @MatrixXd_delete(%struct.C_MatrixXd* %8)
ret void
}