#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 *, int, int, double);
void print2(int m, int n, double (*const restrict A)[n]) {
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++)
      printf("(%d,%d)=%lf\n", i, j, A[i][j]);
}


x86 assembly (clang, -O0):
<print2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a2 <print2+0x92>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118f <print2+0x7f>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rdi,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe84(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1143 <print2+0x33>
jmp    1194 <print2+0x84>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1130 <print2+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,0xc(%rsp)
test   %edi,%edi
jle    118d <print2+0x7d>
mov    %rdx,%r12
mov    0xc(%rsp),%r13d
mov    %edi,%eax
mov    %rax,0x10(%rsp)
lea    0x0(,%r13,8),%r14
xor    %ebp,%ebp
lea    0xeba(%rip),%r15
jmp    115e <print2+0x4e>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
add    %r14,%r12
cmp    0x10(%rsp),%rbp
je     118d <print2+0x7d>
cmpl   $0x0,0xc(%rsp)
jle    1150 <print2+0x40>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsd  (%r12,%rbx,8),%xmm0
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1170 <print2+0x60>
jmp    1150 <print2+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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