#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 pmat(int m, int n, double y[]) {
  int i;
  int j;
  int k;
  k = 0;
  for (i = 0; i < m; i++) {
    printf("row %d: ", i);
    for (j = 0; j < n; j++) {
      printf("%.6f  ", y[k]);
      k += 1;
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<pmat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11ae <pmat+0x9e>
mov    -0x14(%rbp),%esi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1192 <pmat+0x82>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe95(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1154 <pmat+0x44>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1130 <pmat+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pmat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %esi,0x8(%rsp)
mov    %edi,0xc(%rsp)
test   %edi,%edi
jle    11bf <pmat+0x9f>
mov    0x8(%rsp),%r15d
lea    0xeba(%rip),%rbp
xor    %r14d,%r14d
xor    %ebx,%ebx
jmp    1173 <pmat+0x53>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    0xc(%rsp),%ebx
je     11bf <pmat+0x9f>
lea    0xe86(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x8(%rsp)
jle    1160 <pmat+0x40>
movslq %r14d,%rax
mov    0x10(%rsp),%rcx
lea    (%rcx,%rax,8),%r13
xor    %r12d,%r12d
nopl   0x0(%rax)
movsd  0x0(%r13,%r12,8),%xmm0
mov    %rbp,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%r12
cmp    %r12d,%r15d
jne    11a0 <pmat+0x80>
add    %r12d,%r14d
jmp    1160 <pmat+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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