#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
void DisplayDMatrix(char *name, double **matrix, int num_rows, int num_cols) {
  int nrow, ncol;
  fprintf(stdout, "\n%s Matrix: %d rows X %d columns\n", name, num_rows,
          num_cols);
  for (nrow = 0; nrow < num_rows; nrow++) {
    for (ncol = 0; ncol < num_cols; ncol++) {
      if (ncol == nrow)
        fprintf(stdout, "\\ ");
      fprintf(stdout, "%.1e ", matrix[nrow][ncol]);
      if (ncol == nrow)
        fprintf(stdout, "\\ ");
    }
    fprintf(stdout, "\n");
  }
  fprintf(stdout, "\n");
}


x86 assembly (clang, -O0):
<DisplayDMatrix>:
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    0x2eb3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
lea    0xebf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1218 <DisplayDMatrix+0x108>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11f3 <DisplayDMatrix+0xe3>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1191 <DisplayDMatrix+0x81>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe6f(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    11e0 <DisplayDMatrix+0xd0>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11e5 <DisplayDMatrix+0xd5>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1162 <DisplayDMatrix+0x52>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114f <DisplayDMatrix+0x3f>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
lea    0xdf8(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DisplayDMatrix>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r8d
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%rdx
mov    0x2eaf(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xec5(%rip),%rsi
mov    %r15d,%ecx
mov    %r8d,0xc(%rsp)
xor    %eax,%eax
call   1030 <fprintf@plt>
test   %r15d,%r15d
jle    1204 <DisplayDMatrix+0xf4>
mov    %r15d,%eax
mov    %rax,0x10(%rsp)
mov    0xc(%rsp),%r14d
xor    %r12d,%r12d
jmp    118c <DisplayDMatrix+0x7c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%rbp),%edi
lea    0xea6(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%r12
cmp    0x10(%rsp),%r12
je     1204 <DisplayDMatrix+0xf4>
cmpl   $0x0,0xc(%rsp)
jle    1170 <DisplayDMatrix+0x60>
xor    %r15d,%r15d
jmp    11c1 <DisplayDMatrix+0xb1>
nopl   0x0(%rax,%rax,1)
mov    (%rbx,%r12,8),%rax
movsd  (%rax,%r15,8),%xmm0
lea    0xe74(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
add    $0x1,%r15
cmp    %r15,%r14
je     1170 <DisplayDMatrix+0x60>
mov    0x0(%rbp),%edi
cmp    %r15,%r12
jne    11a0 <DisplayDMatrix+0x90>
lea    0xe52(%rip),%r13
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    (%rbx,%r12,8),%rax
movsd  (%rax,%r12,8),%xmm0
lea    0xe37(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    11b8 <DisplayDMatrix+0xa8>
mov    0x0(%rbp),%edi
lea    0xe12(%rip),%rsi
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [34 x i8] c"\0A%s Matrix: %d rows X %d columns\0A\00"
@.str.1 = [3 x i8] c"\\ \00"
@.str.2 = [6 x i8] c"%.1e \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @DisplayDMatrix(i8* %0, double** %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca double**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store double** %1, double*** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%11 = load i32, i32* @stdout
%12 = load i8*, i8** %5
%13 = load i32, i32* %7
%14 = load i32, i32* %8
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %13, i32 %14)
store i32 0, i32* %9
br label %16
16: ; preds = %57, %4
%17 = load i32, i32* %9
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %60
20: ; preds = %16
store i32 0, i32* %10
br label %21
21: ; preds = %51, %20
%22 = load i32, i32* %10
%23 = load i32, i32* %8
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %54
25: ; preds = %21
%26 = load i32, i32* %10
%27 = load i32, i32* %9
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = load i32, i32* @stdout
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %29, %25
%33 = load i32, i32* @stdout
%34 = load double**, double*** %6
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double*, double** %34, i64 %36
%38 = load double*, double** %37
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %42)
%44 = load i32, i32* %10
%45 = load i32, i32* %9
%46 = icmp eq i32 %44, %45
br i1 %46, label %47, label %50
47: ; preds = %32
%48 = load i32, i32* @stdout
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %50
50: ; preds = %47, %32
br label %51
51: ; preds = %50
%52 = load i32, i32* %10
%53 = add nsw i32 %52, 1
store i32 %53, i32* %10
br label %21
54: ; preds = %21
%55 = load i32, i32* @stdout
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %57
57: ; preds = %54
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
store i32 %59, i32* %9
br label %16
60: ; preds = %16
%61 = load i32, i32* @stdout
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [34 x i8] c"\0A%s Matrix: %d rows X %d columns\0A\00"
@.str.1 = [3 x i8] c"\\ \00"
@.str.2 = [6 x i8] c"%.1e \00"
@.str.3 = [2 x i8] c"\0A\00"
define void @DisplayDMatrix(i8* %0, double** nocapture %1, i32 %2, i32 %3) {
%5 = load i32, i32* @stdout
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %2, i32 %3)
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %42
8: ; preds = %4
%9 = icmp sgt i32 %3, 0
%10 = zext i32 %2 to i64
%11 = zext i32 %3 to i64
br label %12
12: ; preds = %8, %37
%13 = phi i64 [ 0, %8 ], [ %40, %37 ]
br i1 %9, label %14, label %37
14: ; preds = %12
%15 = getelementptr inbounds double*, double** %1, i64 %13
br label %16
16: ; preds = %14, %34
%17 = phi i64 [ 0, %14 ], [ %35, %34 ]
%18 = icmp eq i64 %17, %13
%19 = load i32, i32* @stdout
br i1 %18, label %20, label %29
20: ; preds = %16
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @stdout
%23 = load double*, double** %15
%24 = getelementptr inbounds double, double* %23, i64 %13
%25 = load double, double* %24
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %25)
%27 = load i32, i32* @stdout
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %34
29: ; preds = %16
%30 = load double*, double** %15
%31 = getelementptr inbounds double, double* %30, i64 %17
%32 = load double, double* %31
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %32)
br label %34
34: ; preds = %29, %20
%35 = add nuw nsw i64 %17, 1
%36 = icmp eq i64 %35, %11
br i1 %36, label %37, label %16
37: ; preds = %34, %12
%38 = load i32, i32* @stdout
%39 = tail call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%40 = add nuw nsw i64 %13, 1
%41 = icmp eq i64 %40, %10
br i1 %41, label %42, label %12
42: ; preds = %37, %4
%43 = load i32, i32* @stdout
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}