#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_Map_MatrixXd {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ Map_MatrixXd_add(struct C_Map_MatrixXd *,
                                    struct C_Map_MatrixXd *,
                                    struct C_Map_MatrixXd *);
int /*<<< orphan*/ Map_MatrixXd_delete(struct C_Map_MatrixXd *);
struct C_Map_MatrixXd *Map_MatrixXd_new(double *, int, int);
int /*<<< orphan*/ print_array(double *, int);
int /*<<< orphan*/ printf(char *);
void demo_Map_MatrixXd() {
  struct C_Map_MatrixXd *map;
  double array[5];
  int i;
  printf("*** demo_Map_MatrixXd ***\n");
  for (i = 0; i < 5; ++i)
    array[i] = i;
  printf("Initially, the array is:\n");
  print_array(array, 5);
  map = Map_MatrixXd_new(array, 5, 1);
  Map_MatrixXd_add(map, map, map);
  Map_MatrixXd_delete(map);
  printf("Now the array is:\n");
  print_array(array, 5);
}


x86 assembly (clang, -O0):
<demo_Map_MatrixXd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x5,-0x34(%rbp)
jge    1192 <demo_Map_MatrixXd+0x42>
cvtsi2sdl -0x34(%rbp),%xmm0
movslq -0x34(%rbp),%rax
movsd  %xmm0,-0x30(%rbp,%rax,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    116b <demo_Map_MatrixXd+0x1b>
lea    0xe82(%rip),%rdi
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1040 <print_array@plt>
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
call   1030 <Map_MatrixXd_new@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1060 <Map_MatrixXd_add@plt>
mov    -0x8(%rbp),%rdi
call   1070 <Map_MatrixXd_delete@plt>
lea    0xe51(%rip),%rdi
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1040 <print_array@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<demo_Map_MatrixXd>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
xorps  %xmm0,%xmm0
movhps 0xe93(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xe98(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x4010000000000000,%rax
mov    %rax,0x20(%rsp)
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x5,%esi
call   1050 <print_array@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    $0x1,%edx
call   1040 <Map_MatrixXd_new@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rax,%rsi
mov    %rax,%rdx
call   1060 <Map_MatrixXd_add@plt>
mov    %rbx,%rdi
call   1070 <Map_MatrixXd_delete@plt>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x5,%esi
call   1050 <print_array@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.C_Map_MatrixXd = type { i32 }
@.str = [27 x i8] c"*** demo_Map_MatrixXd ***\0A\00"
@.str.1 = [26 x i8] c"Initially, the array is:\0A\00"
@.str.2 = [19 x i8] c"Now the array is:\0A\00"
define void @demo_Map_MatrixXd() {
%1 = alloca %struct.C_Map_MatrixXd*
%2 = alloca [5 x double]
%3 = alloca i32
%4 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %5
5: ; preds = %14, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 5
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = load i32, i32* %3
%10 = sitofp i32 %9 to double
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 %12
store double %10, double* %13
br label %14
14: ; preds = %8
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %5
17: ; preds = %5
%18 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%19 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%20 = call i32 @print_array(double* %19, i32 5)
%21 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%22 = call %struct.C_Map_MatrixXd* @Map_MatrixXd_new(double* %21, i32 5, i32 1)
store %struct.C_Map_MatrixXd* %22, %struct.C_Map_MatrixXd** %1
%23 = load %struct.C_Map_MatrixXd*, %struct.C_Map_MatrixXd** %1
%24 = load %struct.C_Map_MatrixXd*, %struct.C_Map_MatrixXd** %1
%25 = load %struct.C_Map_MatrixXd*, %struct.C_Map_MatrixXd** %1
%26 = call i32 @Map_MatrixXd_add(%struct.C_Map_MatrixXd* %23, %struct.C_Map_MatrixXd* %24, %struct.C_Map_MatrixXd* %25)
%27 = load %struct.C_Map_MatrixXd*, %struct.C_Map_MatrixXd** %1
%28 = call i32 @Map_MatrixXd_delete(%struct.C_Map_MatrixXd* %27)
%29 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%30 = getelementptr inbounds [5 x double], [5 x double]* %2, i64 0, i64 0
%31 = call i32 @print_array(double* %30, i32 5)
ret void
}

LLVM IR (-O2):
%struct.C_Map_MatrixXd = type { i32 }
@str = [26 x i8] c"*** demo_Map_MatrixXd ***\00"
@str.3 = [25 x i8] c"Initially, the array is:\00"
@str.4 = [18 x i8] c"Now the array is:\00"
define void @demo_Map_MatrixXd() {
%1 = alloca [5 x double]
%2 = bitcast [5 x double]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 0, i64 0
%5 = bitcast [5 x double]* %1 to <2 x double>*
store <2 x double> <double 0.000000e+00, double 1.000000e+00>, <2 x double>* %5
%6 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 0, i64 2
%7 = bitcast double* %6 to <2 x double>*
store <2 x double> <double 2.000000e+00, double 3.000000e+00>, <2 x double>* %7
%8 = getelementptr inbounds [5 x double], [5 x double]* %1, i64 0, i64 4
store double 4.000000e+00, double* %8
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.3, i64 0, i64 0))
%10 = call i32 @print_array(double* %4, i32 5)
%11 = call %struct.C_Map_MatrixXd* @Map_MatrixXd_new(double* %4, i32 5, i32 1)
%12 = call i32 @Map_MatrixXd_add(%struct.C_Map_MatrixXd* %11, %struct.C_Map_MatrixXd* %11, %struct.C_Map_MatrixXd* %11)
%13 = call i32 @Map_MatrixXd_delete(%struct.C_Map_MatrixXd* %11)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
%15 = call i32 @print_array(double* %4, i32 5)
ret void
}