#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*/ printf(char *, ...);
void printMatrix(const char *name, const float mat[16]) {
  int i;
  printf("matrix %s =\n", name);
  for (i = 0; i < 4; i++) {
    printf("  [ %g %g %g %g ]\n", mat[4 * i + 0], mat[4 * i + 1],
           mat[4 * i + 2], mat[4 * i + 3]);
  }
}


x86 assembly (clang, -O0):
<printMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    11c3 <printMatrix+0xb3>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm2
cvtss2sd %xmm2,%xmm2
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm3
cvtss2sd %xmm3,%xmm3
lea    0xe5f(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1139 <printMatrix+0x29>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMatrix>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0xedf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movss  (%rbx),%xmm0
movss  0x4(%rbx),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  0x8(%rbx),%xmm2
cvtss2sd %xmm2,%xmm2
movss  0xc(%rbx),%xmm3
cvtss2sd %xmm3,%xmm3
lea    0xebb(%rip),%r14
mov    %r14,%rdi
mov    $0x4,%al
call   1030 <printf@plt>
movss  0x10(%rbx),%xmm0
movss  0x14(%rbx),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  0x18(%rbx),%xmm2
cvtss2sd %xmm2,%xmm2
movss  0x1c(%rbx),%xmm3
cvtss2sd %xmm3,%xmm3
mov    %r14,%rdi
mov    $0x4,%al
call   1030 <printf@plt>
movss  0x20(%rbx),%xmm0
movss  0x24(%rbx),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  0x28(%rbx),%xmm2
cvtss2sd %xmm2,%xmm2
movss  0x2c(%rbx),%xmm3
cvtss2sd %xmm3,%xmm3
mov    %r14,%rdi
mov    $0x4,%al
call   1030 <printf@plt>
movss  0x30(%rbx),%xmm0
movss  0x34(%rbx),%xmm1
cvtss2sd %xmm0,%xmm0
cvtss2sd %xmm1,%xmm1
movss  0x38(%rbx),%xmm2
cvtss2sd %xmm2,%xmm2
movss  0x3c(%rbx),%xmm3
cvtss2sd %xmm3,%xmm3
mov    %r14,%rdi
mov    $0x4,%al
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"matrix %s =\0A\00"
@.str.1 = [19 x i8] c" [ %g %g %g %g ]\0A\00"
define void @printMatrix(i8* %0, float* %1) {
%3 = alloca i8*
%4 = alloca float*
%5 = alloca i32
store i8* %0, i8** %3
store float* %1, float** %4
%6 = load i8*, i8** %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %6)
store i32 0, i32* %5
br label %8
8: ; preds = %45, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %48
11: ; preds = %8
%12 = load float*, float** %4
%13 = load i32, i32* %5
%14 = mul nsw i32 4, %13
%15 = add nsw i32 %14, 0
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds float, float* %12, i64 %16
%18 = load float, float* %17
%19 = fpext float %18 to double
%20 = load float*, float** %4
%21 = load i32, i32* %5
%22 = mul nsw i32 4, %21
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds float, float* %20, i64 %24
%26 = load float, float* %25
%27 = fpext float %26 to double
%28 = load float*, float** %4
%29 = load i32, i32* %5
%30 = mul nsw i32 4, %29
%31 = add nsw i32 %30, 2
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds float, float* %28, i64 %32
%34 = load float, float* %33
%35 = fpext float %34 to double
%36 = load float*, float** %4
%37 = load i32, i32* %5
%38 = mul nsw i32 4, %37
%39 = add nsw i32 %38, 3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds float, float* %36, i64 %40
%42 = load float, float* %41
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %19, double %27, double %35, double %43)
br label %45
45: ; preds = %11
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %8
48: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"matrix %s =\0A\00"
@.str.1 = [19 x i8] c" [ %g %g %g %g ]\0A\00"
define void @printMatrix(i8* %0, float* nocapture %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = load float, float* %1
%5 = fpext float %4 to double
%6 = getelementptr inbounds float, float* %1, i64 1
%7 = load float, float* %6
%8 = fpext float %7 to double
%9 = getelementptr inbounds float, float* %1, i64 2
%10 = load float, float* %9
%11 = fpext float %10 to double
%12 = getelementptr inbounds float, float* %1, i64 3
%13 = load float, float* %12
%14 = fpext float %13 to double
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %5, double %8, double %11, double %14)
%16 = getelementptr inbounds float, float* %1, i64 4
%17 = load float, float* %16
%18 = fpext float %17 to double
%19 = getelementptr inbounds float, float* %1, i64 5
%20 = load float, float* %19
%21 = fpext float %20 to double
%22 = getelementptr inbounds float, float* %1, i64 6
%23 = load float, float* %22
%24 = fpext float %23 to double
%25 = getelementptr inbounds float, float* %1, i64 7
%26 = load float, float* %25
%27 = fpext float %26 to double
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %18, double %21, double %24, double %27)
%29 = getelementptr inbounds float, float* %1, i64 8
%30 = load float, float* %29
%31 = fpext float %30 to double
%32 = getelementptr inbounds float, float* %1, i64 9
%33 = load float, float* %32
%34 = fpext float %33 to double
%35 = getelementptr inbounds float, float* %1, i64 10
%36 = load float, float* %35
%37 = fpext float %36 to double
%38 = getelementptr inbounds float, float* %1, i64 11
%39 = load float, float* %38
%40 = fpext float %39 to double
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %31, double %34, double %37, double %40)
%42 = getelementptr inbounds float, float* %1, i64 12
%43 = load float, float* %42
%44 = fpext float %43 to double
%45 = getelementptr inbounds float, float* %1, i64 13
%46 = load float, float* %45
%47 = fpext float %46 to double
%48 = getelementptr inbounds float, float* %1, i64 14
%49 = load float, float* %48
%50 = fpext float %49 to double
%51 = getelementptr inbounds float, float* %1, i64 15
%52 = load float, float* %51
%53 = fpext float %52 to double
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %44, double %47, double %50, double %53)
ret void
}