int main() {
  float *matrix1, *matrix2, *result;
  matrix1 = matrix_alloc();
  result = matrix_alloc();
  initialize_matrix(matrix1);
  initialize_matrix(matrix2);
  sum_matrices(result, matrix1, matrix2);
  printf("%f", result);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <matrix_alloc@plt>
cltq
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1050 <matrix_alloc@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1060 <initialize_matrix@plt>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1060 <initialize_matrix@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <sum_matrices@plt>
mov    -0x18(%rbp),%rsi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <matrix_alloc@plt>
movslq %eax,%rbx
xor    %eax,%eax
call   1050 <matrix_alloc@plt>
movslq %eax,%r14
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <initialize_matrix@plt>
xor    %eax,%eax
call   1060 <initialize_matrix@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <sum_matrices@plt>
lea    0xe83(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%f\00"
define i32 @main() {
%1 = alloca float*
%2 = alloca float*
%3 = alloca float*
%4 = call i32 (...) @matrix_alloc()
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to float*
store float* %6, float** %1
%7 = call i32 (...) @matrix_alloc()
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to float*
store float* %9, float** %3
%10 = load float*, float** %1
%11 = call i32 (float*, ...) bitcast (i32 (...)* @initialize_matrix to i32 (float*, ...)*)(float* %10)
%12 = load float*, float** %2
%13 = call i32 (float*, ...) bitcast (i32 (...)* @initialize_matrix to i32 (float*, ...)*)(float* %12)
%14 = load float*, float** %3
%15 = load float*, float** %1
%16 = load float*, float** %2
%17 = call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @sum_matrices to i32 (float*, float*, float*, ...)*)(float* %14, float* %15, float* %16)
%18 = load float*, float** %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%f\00"
define i32 @main() {
%1 = tail call i32 (...) @matrix_alloc()
%2 = sext i32 %1 to i64
%3 = inttoptr i64 %2 to float*
%4 = tail call i32 (...) @matrix_alloc()
%5 = sext i32 %4 to i64
%6 = inttoptr i64 %5 to float*
%7 = tail call i32 (float*, ...) bitcast (i32 (...)* @initialize_matrix to i32 (float*, ...)*)(float* %3)
%8 = tail call i32 (float*, ...) bitcast (i32 (...)* @initialize_matrix to i32 (float*, ...)*)(float* undef)
%9 = tail call i32 (float*, float*, float*, ...) bitcast (i32 (...)* @sum_matrices to i32 (float*, float*, float*, ...)*)(float* %6, float* %3, float* undef)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), float* %6)
ret i32 0
}