#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 printArray(double *array, int m, int n) {
  printf("Array output:\n(");
  for (int j = 0; j < n; ++j) {
    for (int i = 0; i < m; ++i) {
      printf("%g", *(array + n * i + j));
      if (i < m - 1)
        printf(",");
    }
    if (j < n - 1)
      printf(";\n");
  }
  printf(")\n\n");
}


x86 assembly (clang, -O0):
<printArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11e6 <printArray+0xd6>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b4 <printArray+0xa4>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
imul   -0x18(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe95(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11a1 <printArray+0x91>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a6 <printArray+0x96>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114a <printArray+0x3a>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11d3 <printArray+0xc3>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d8 <printArray+0xc8>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <printArray+0x27>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%ebx
mov    %rsi,(%rsp)
mov    %rdi,0x8(%rsp)
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
jle    121a <printArray+0xea>
mov    %rbx,%rcx
mov    (%rsp),%rdx
lea    -0x1(%rdx),%eax
mov    %ecx,%esi
add    $0xffffffff,%ecx
mov    %rcx,0x18(%rsp)
movslq %eax,%r13
mov    %edx,%r14d
mov    %rsi,0x10(%rsp)
lea    0x0(,%rsi,8),%r15
xor    %ebp,%ebp
lea    0xe81(%rip),%rbx
jmp    11b1 <printArray+0x81>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
addq   $0x8,0x8(%rsp)
cmp    0x10(%rsp),%rbp
je     121a <printArray+0xea>
mov    %rbp,0x20(%rsp)
cmpl   $0x0,(%rsp)
jle    1200 <printArray+0xd0>
mov    0x8(%rsp),%r12
xor    %ebp,%ebp
jmp    11dc <printArray+0xac>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbp
add    %r15,%r12
cmp    %rbp,%r14
je     1200 <printArray+0xd0>
movsd  (%r12),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
cmp    %r13,%rbp
jge    11d0 <printArray+0xa0>
mov    $0x2c,%edi
call   1030 <putchar@plt>
jmp    11d0 <printArray+0xa0>
nopl   (%rax)
mov    0x20(%rsp),%rbp
cmp    0x18(%rsp),%rbp
jae    11a0 <printArray+0x70>
lea    0xe03(%rip),%rdi
call   1040 <puts@plt>
jmp    11a0 <printArray+0x70>
lea    0xdf2(%rip),%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

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

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