#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 */
typedef int /*<<< orphan*/ mat4;

/* Variables and functions */
size_t mat4_idx(int, int);
int /*<<< orphan*/ memcpy(float *, float *, int);
void mult_m4m4(float *dest, float *src1, float *src2) {
  int i, j;
  float mat4[16];
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      mat4[mat4_idx(i, j)] = src1[mat4_idx(i, 0)] * src2[mat4_idx(0, j)] +
                             src1[mat4_idx(i, 1)] * src2[mat4_idx(1, j)] +
                             src1[mat4_idx(i, 2)] * src2[mat4_idx(2, j)] +
                             src1[mat4_idx(i, 3)] * src2[mat4_idx(3, j)];
    }
  }
  memcpy(dest, mat4, sizeof(mat4));
}


x86 assembly (clang, -O0):
<mult_m4m4>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    1337 <mult_m4m4+0x217>
movl   $0x0,-0x20(%rbp)
cmpl   $0x4,-0x20(%rbp)
jge    1324 <mult_m4m4+0x204>
mov    -0x10(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x1c(%rbp),%edi
xor    %esi,%esi
call   1030 <mat4_idx@plt>
mov    %rax,%rcx
mov    -0xc8(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0xa8(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x20(%rbp),%esi
xor    %edi,%edi
call   1030 <mat4_idx@plt>
mov    %rax,%rcx
mov    -0xc0(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0xa4(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x1,%esi
call   1030 <mat4_idx@plt>
mov    %rax,%rcx
mov    -0xb8(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0xac(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x20(%rbp),%esi
mov    $0x1,%edi
call   1030 <mat4_idx@plt>
movss  -0xac(%rbp),%xmm1
ff
movss  -0xa8(%rbp),%xmm0
ff
movss  -0xa4(%rbp),%xmm2
ff
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
mulss  (%rax,%rcx,4),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x8c(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x2,%esi
call   1030 <mat4_idx@plt>
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x90(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x20(%rbp),%esi
mov    $0x2,%edi
call   1030 <mat4_idx@plt>
movss  -0x90(%rbp),%xmm0
ff
movss  -0x8c(%rbp),%xmm1
ff
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
movss  (%rax,%rcx,4),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x74(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x3,%esi
call   1030 <mat4_idx@plt>
mov    %rax,%rcx
mov    -0x80(%rbp),%rax
movss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x78(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x20(%rbp),%esi
mov    $0x3,%edi
call   1030 <mat4_idx@plt>
movss  -0x78(%rbp),%xmm0
movss  -0x74(%rbp),%xmm1
mov    %rax,%rcx
mov    -0x70(%rbp),%rax
movss  (%rax,%rcx,4),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x64(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <mat4_idx@plt>
movss  -0x64(%rbp),%xmm0
movss  %xmm0,-0x60(%rbp,%rax,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    114f <mult_m4m4+0x2f>
jmp    1329 <mult_m4m4+0x209>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113e <mult_m4m4+0x1e>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x40,%edx
call   1040 <memcpy@plt>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mult_m4m4>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r14
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
xor    %esi,%esi
call   1030 <mat4_idx@plt>
movss  (%r12,%rax,4),%xmm0
movss  %xmm0,0xc(%rsp)
xor    %edi,%edi
mov    %ebx,%esi
call   1030 <mat4_idx@plt>
movss  0xc(%rsp),%xmm0
mulss  (%r15,%rax,4),%xmm0
movss  %xmm0,0xc(%rsp)
mov    %ebp,%edi
mov    $0x1,%esi
call   1030 <mat4_idx@plt>
movss  (%r12,%rax,4),%xmm0
movss  %xmm0,0x8(%rsp)
mov    $0x1,%edi
mov    %ebx,%esi
call   1030 <mat4_idx@plt>
movss  0x8(%rsp),%xmm0
mulss  (%r15,%rax,4),%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    $0x2,%esi
call   1030 <mat4_idx@plt>
movss  (%r12,%rax,4),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0x2,%edi
mov    %ebx,%esi
call   1030 <mat4_idx@plt>
movss  0xc(%rsp),%xmm0
mulss  (%r15,%rax,4),%xmm0
addss  0x8(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
mov    %ebp,%edi
mov    $0x3,%esi
call   1030 <mat4_idx@plt>
movss  (%r12,%rax,4),%xmm0
movss  %xmm0,0x8(%rsp)
mov    $0x3,%edi
mov    %ebx,%esi
call   1030 <mat4_idx@plt>
movss  0x8(%rsp),%xmm0
mulss  (%r15,%rax,4),%xmm0
addss  0xc(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    %ebx,%esi
call   1030 <mat4_idx@plt>
movss  0x8(%rsp),%xmm0
movss  %xmm0,0x10(%rsp,%rax,4)
add    $0x1,%ebx
cmp    $0x4,%ebx
jne    1150 <mult_m4m4+0x30>
add    $0x1,%ebp
cmp    $0x4,%ebp
jne    1140 <mult_m4m4+0x20>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
mov    $0x40,%edx
call   1040 <memcpy@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mult_m4m4(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [16 x float]
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
store i32 0, i32* %7
br label %10
10: ; preds = %70, %3
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %73
13: ; preds = %10
store i32 0, i32* %8
br label %14
14: ; preds = %66, %13
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 4
br i1 %16, label %17, label %69
17: ; preds = %14
%18 = load float*, float** %5
%19 = load i32, i32* %7
%20 = call i64 @mat4_idx(i32 %19, i32 0)
%21 = getelementptr inbounds float, float* %18, i64 %20
%22 = load float, float* %21
%23 = load float*, float** %6
%24 = load i32, i32* %8
%25 = call i64 @mat4_idx(i32 0, i32 %24)
%26 = getelementptr inbounds float, float* %23, i64 %25
%27 = load float, float* %26
%28 = load float*, float** %5
%29 = load i32, i32* %7
%30 = call i64 @mat4_idx(i32 %29, i32 1)
%31 = getelementptr inbounds float, float* %28, i64 %30
%32 = load float, float* %31
%33 = load float*, float** %6
%34 = load i32, i32* %8
%35 = call i64 @mat4_idx(i32 1, i32 %34)
%36 = getelementptr inbounds float, float* %33, i64 %35
%37 = load float, float* %36
%38 = fmul float %32, %37
%39 = call float @llvm.fmuladd.f32(float %22, float %27, float %38)
%40 = load float*, float** %5
%41 = load i32, i32* %7
%42 = call i64 @mat4_idx(i32 %41, i32 2)
%43 = getelementptr inbounds float, float* %40, i64 %42
%44 = load float, float* %43
%45 = load float*, float** %6
%46 = load i32, i32* %8
%47 = call i64 @mat4_idx(i32 2, i32 %46)
%48 = getelementptr inbounds float, float* %45, i64 %47
%49 = load float, float* %48
%50 = call float @llvm.fmuladd.f32(float %44, float %49, float %39)
%51 = load float*, float** %5
%52 = load i32, i32* %7
%53 = call i64 @mat4_idx(i32 %52, i32 3)
%54 = getelementptr inbounds float, float* %51, i64 %53
%55 = load float, float* %54
%56 = load float*, float** %6
%57 = load i32, i32* %8
%58 = call i64 @mat4_idx(i32 3, i32 %57)
%59 = getelementptr inbounds float, float* %56, i64 %58
%60 = load float, float* %59
%61 = call float @llvm.fmuladd.f32(float %55, float %60, float %50)
%62 = load i32, i32* %7
%63 = load i32, i32* %8
%64 = call i64 @mat4_idx(i32 %62, i32 %63)
%65 = getelementptr inbounds [16 x float], [16 x float]* %9, i64 0, i64 %64
store float %61, float* %65
br label %66
66: ; preds = %17
%67 = load i32, i32* %8
%68 = add nsw i32 %67, 1
store i32 %68, i32* %8
br label %14
69: ; preds = %14
br label %70
70: ; preds = %69
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
store i32 %72, i32* %7
br label %10
73: ; preds = %10
%74 = load float*, float** %4
%75 = getelementptr inbounds [16 x float], [16 x float]* %9, i64 0, i64 0
%76 = call i32 @memcpy(float* %74, float* %75, i32 64)
ret void
}

LLVM IR (-O2):
define void @mult_m4m4(float* %0, float* nocapture %1, float* nocapture %2) {
%4 = alloca [16 x float]
%5 = bitcast [16 x float]* %4 to i8*
br label %6
6: ; preds = %3, %42
%7 = phi i32 [ 0, %3 ], [ %43, %42 ]
br label %8
8: ; preds = %6, %8
%9 = phi i32 [ 0, %6 ], [ %40, %8 ]
%10 = tail call i64 @mat4_idx(i32 %7, i32 0)
%11 = getelementptr inbounds float, float* %1, i64 %10
%12 = load float, float* %11
%13 = tail call i64 @mat4_idx(i32 0, i32 %9)
%14 = getelementptr inbounds float, float* %2, i64 %13
%15 = load float, float* %14
%16 = tail call i64 @mat4_idx(i32 %7, i32 1)
%17 = getelementptr inbounds float, float* %1, i64 %16
%18 = load float, float* %17
%19 = tail call i64 @mat4_idx(i32 1, i32 %9)
%20 = getelementptr inbounds float, float* %2, i64 %19
%21 = load float, float* %20
%22 = fmul float %18, %21
%23 = tail call float @llvm.fmuladd.f32(float %12, float %15, float %22)
%24 = tail call i64 @mat4_idx(i32 %7, i32 2)
%25 = getelementptr inbounds float, float* %1, i64 %24
%26 = load float, float* %25
%27 = tail call i64 @mat4_idx(i32 2, i32 %9)
%28 = getelementptr inbounds float, float* %2, i64 %27
%29 = load float, float* %28
%30 = tail call float @llvm.fmuladd.f32(float %26, float %29, float %23)
%31 = tail call i64 @mat4_idx(i32 %7, i32 3)
%32 = getelementptr inbounds float, float* %1, i64 %31
%33 = load float, float* %32
%34 = tail call i64 @mat4_idx(i32 3, i32 %9)
%35 = getelementptr inbounds float, float* %2, i64 %34
%36 = load float, float* %35
%37 = tail call float @llvm.fmuladd.f32(float %33, float %36, float %30)
%38 = tail call i64 @mat4_idx(i32 %7, i32 %9)
%39 = getelementptr inbounds [16 x float], [16 x float]* %4, i64 0, i64 %38
store float %37, float* %39
%40 = add nuw nsw i32 %9, 1
%41 = icmp eq i32 %40, 4
br i1 %41, label %42, label %8
42: ; preds = %8
%43 = add nuw nsw i32 %7, 1
%44 = icmp eq i32 %43, 4
br i1 %44, label %45, label %6
45: ; preds = %42
%46 = getelementptr inbounds [16 x float], [16 x float]* %4, i64 0, i64 0
%47 = call i32 @memcpy(float* %0, float* %46, i32 64)
ret void
}