#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 matrix_print_double(const char *name, const double *a,
                         const unsigned int dimX, const unsigned int dimY) {
  printf("%s=[\n", name);
  for (unsigned int i = 0; i < dimX * dimY; i++) {
    printf("%lf ", a[i]);
  }
  printf("]\n");
}


x86 assembly (clang, -O0):
<matrix_print_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
cmp    %ecx,%eax
jae    1179 <matrix_print_double+0x69>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm0
lea    0xea2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <matrix_print_double+0x2f>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix_print_double>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rsi
lea    0xec7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
imul   %r14d,%ebp
test   %ebp,%ebp
je     1179 <matrix_print_double+0x59>
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0xeb3(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  (%r15,%rbx,8),%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <matrix_print_double+0x40>
lea    0xe8b(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%s=[\0A\00"
@.str.1 = [5 x i8] c"%lf \00"
@.str.2 = [3 x i8] c"]\0A\00"
define void @matrix_print_double(i8* %0, double* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store double* %1, double** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i8*, i8** %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %10)
store i32 0, i32* %9
br label %12
12: ; preds = %25, %4
%13 = load i32, i32* %9
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = mul i32 %14, %15
%17 = icmp ult i32 %13, %16
br i1 %17, label %18, label %28
18: ; preds = %12
%19 = load double*, double** %6
%20 = load i32, i32* %9
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %23)
br label %25
25: ; preds = %18
%26 = load i32, i32* %9
%27 = add i32 %26, 1
store i32 %27, i32* %9
br label %12
28: ; preds = %12
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s=[\0A\00"
@.str.1 = [5 x i8] c"%lf \00"
@str = [2 x i8] c"]\00"
define void @matrix_print_double(i8* %0, double* nocapture %1, i32 %2, i32 %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = mul i32 %3, %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = zext i32 %6 to i64
br label %12
10: ; preds = %12, %4
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
12: ; preds = %8, %12
%13 = phi i64 [ 0, %8 ], [ %17, %12 ]
%14 = getelementptr inbounds double, double* %1, i64 %13
%15 = load double, double* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %15)
%17 = add nuw nsw i64 %13, 1
%18 = icmp eq i64 %17, %9
br i1 %18, label %10, label %12
}