#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(double matrix[], int size[2]) {
  for (int i = 0; i < size[0]; i++) {
    for (int j = 0; j < size[1]; j++)
      printf("%8.2f", matrix[i * size[1] + j]);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printmatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%eax
jge    119f <printmatrix+0x8f>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%rcx
cmp    0x4(%rcx),%eax
jge    1183 <printmatrix+0x73>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rdx
imul   0x4(%rdx),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe92(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113d <printmatrix+0x2d>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <printmatrix+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printmatrix>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmpl   $0x0,(%rsi)
jle    1188 <printmatrix+0x68>
mov    %rsi,%r12
mov    %rdi,%r14
xor    %r13d,%r13d
lea    0xec2(%rip),%r15
jmp    1154 <printmatrix+0x34>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13d
cmp    (%r12),%r13d
jge    1188 <printmatrix+0x68>
mov    0x4(%r12),%eax
test   %eax,%eax
jle    1140 <printmatrix+0x20>
xor    %ebx,%ebx
nop
imul   %r13d,%eax
cltq
add    %rbx,%rax
movsd  (%r14,%rax,8),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x4(%r12),%eax
add    $0x1,%rbx
cmp    %eax,%ebx
jl     1160 <printmatrix+0x40>
jmp    1140 <printmatrix+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"%8.2f\00"
define void @printmatrix(double* nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = getelementptr inbounds i32, i32* %1, i64 1
br label %7
7: ; preds = %5, %12
%8 = phi i32 [ 0, %5 ], [ %14, %12 ]
%9 = load i32, i32* %6
%10 = icmp sgt i32 %9, 0
br i1 %10, label %17, label %12
11: ; preds = %12, %2
ret void
12: ; preds = %17, %7
%13 = tail call i32 @putchar(i32 10)
%14 = add nuw nsw i32 %8, 1
%15 = load i32, i32* %1
%16 = icmp slt i32 %14, %15
br i1 %16, label %7, label %11
17: ; preds = %7, %17
%18 = phi i32 [ %27, %17 ], [ %9, %7 ]
%19 = phi i32 [ %26, %17 ], [ 0, %7 ]
%20 = mul nsw i32 %18, %8
%21 = add nsw i32 %20, %19
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %0, i64 %22
%24 = load double, double* %23
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), double %24)
%26 = add nuw nsw i32 %19, 1
%27 = load i32, i32* %6
%28 = icmp slt i32 %26, %27
br i1 %28, label %17, label %12
}