#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 *, double);
void printmatrix0(double *x, int n, int p) {
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < p - 1; j++)
      printf("%.0f ", x[i * p + j]);
    printf("%.0f\n", x[i * p + j]);
  }
}


x86 assembly (clang, -O0):
<printmatrix0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ad <printmatrix0+0x9d>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    117d <printmatrix0+0x6d>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113c <printmatrix0+0x2c>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <printmatrix0+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printmatrix0>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %esi,%esi
jle    11d1 <printmatrix0+0xc1>
mov    %edx,%ebx
mov    %rdi,%r13
movslq %edx,%rax
add    $0xffffffff,%ebx
mov    %esi,%ecx
mov    %rcx,0x18(%rsp)
mov    %rax,0x20(%rsp)
lea    0x0(,%rax,8),%rax
mov    %rax,0x10(%rsp)
xor    %r12d,%r12d
lea    0xeac(%rip),%r15
mov    %rdi,%rbp
mov    %rdi,0x8(%rsp)
jmp    1188 <printmatrix0+0x78>
xchg   %ax,%ax
cltq
add    %rax,%r14
movsd  0x0(%r13,%r14,8),%xmm0
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
add    $0x1,%r12
add    0x10(%rsp),%rbp
cmp    0x18(%rsp),%r12
je     11d1 <printmatrix0+0xc1>
mov    %r12,%r14
mov    0x20(%rsp),%rcx
imul   %rcx,%r14
mov    $0x0,%eax
cmp    $0x2,%ecx
jl     1160 <printmatrix0+0x50>
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  0x0(%rbp,%r13,8),%xmm0
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x1,%r13
cmp    %r13,%rbx
jne    11b0 <printmatrix0+0xa0>
mov    %ebx,%eax
mov    0x8(%rsp),%r13
jmp    1160 <printmatrix0+0x50>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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