#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 */
double fabs(double const);
int /*<<< orphan*/ isnan(double const);
int /*<<< orphan*/ printf(char *, ...);
void array_print_d(const unsigned int m, const unsigned int n, const double *A,
                   const char layout) {
  unsigned int i, j;
  bool const AllowZero = 0;
  switch (layout) {
  case 'R':
    for (i = 0; i < m; i++) {
      for (j = 0; j < n; j++) {
        if ((isnan(A[i * n + j]) || fabs(A[i * n + j]) > 1.0e-15) || !AllowZero)
          printf("% .4e ", A[i * n + j]);
        else
          printf(" %d          ", 0);
      }
      printf("\n");
    }
    printf("\n");
    break;
  case 'C':
    for (i = 0; i < m; i++) {
      for (j = 0; j < n; j++) {
        if ((isnan(A[i + j * m]) || fabs(A[i + j * m]) > 1.0e-15) || !AllowZero)
          printf("% .4e ", A[i + j * m]);
        else
          printf(" %d          ", 0);
      }
      printf("\n");
    }
    printf("\n");
    break;
  }
}


x86 assembly (clang, -O0):
<array_print_d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cl,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movl   $0x0,-0x20(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x43,%eax
je     1268 <array_print_d+0x148>
jmp    1153 <array_print_d+0x33>
mov    -0x24(%rbp),%eax
sub    $0x52,%eax
jne    136d <array_print_d+0x24d>
jmp    1164 <array_print_d+0x44>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1255 <array_print_d+0x135>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1239 <array_print_d+0x119>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x1c(%rbp),%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%eax
jne    11ee <array_print_d+0xce>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x1c(%rbp),%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe47(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe2b(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     11ee <array_print_d+0xce>
xor    %eax,%eax
test   $0x1,%al
jne    1216 <array_print_d+0xf6>
jmp    11ee <array_print_d+0xce>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x1c(%rbp),%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe16(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1226 <array_print_d+0x106>
lea    0xe0a(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <array_print_d+0x10b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117e <array_print_d+0x5e>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116b <array_print_d+0x4b>
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    136d <array_print_d+0x24d>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    135f <array_print_d+0x23f>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1343 <array_print_d+0x223>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%edx
imul   -0x4(%rbp),%edx
add    %edx,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%eax
jne    12f6 <array_print_d+0x1d6>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%edx
imul   -0x4(%rbp),%edx
add    %edx,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xd3f(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xd23(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     12f6 <array_print_d+0x1d6>
xor    %eax,%eax
test   $0x1,%al
jne    1320 <array_print_d+0x200>
jmp    12f6 <array_print_d+0x1d6>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%edx
imul   -0x4(%rbp),%edx
add    %edx,%ecx
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
lea    0xd0c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1330 <array_print_d+0x210>
lea    0xd00(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1335 <array_print_d+0x215>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1282 <array_print_d+0x162>
lea    0xceb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    126f <array_print_d+0x14f>
lea    0xccf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_print_d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %edi,%r12d
cmp    $0x52,%ecx
mov    %esi,0x4(%rsp)
je     11d9 <array_print_d+0xa9>
cmp    $0x43,%ecx
jne    1270 <array_print_d+0x140>
test   %r12d,%r12d
je     1258 <array_print_d+0x128>
mov    %esi,%eax
mov    %rax,0x8(%rsp)
movl   $0x0,(%rsp)
lea    0xe88(%rip),%r15
jmp    11a0 <array_print_d+0x70>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%eax
add    $0x1,%eax
mov    %eax,(%rsp)
cmp    %r12d,%eax
mov    0x4(%rsp),%esi
je     1258 <array_print_d+0x128>
test   %esi,%esi
je     1180 <array_print_d+0x50>
mov    0x8(%rsp),%rbp
mov    (%rsp),%r13d
nopl   (%rax)
mov    %r13d,%r14d
movsd  (%rbx,%r14,8),%xmm0
call   1050 <isnan@plt>
movsd  (%rbx,%r14,8),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    %r12d,%r13d
add    $0xffffffffffffffff,%rbp
jne    11b0 <array_print_d+0x80>
jmp    1180 <array_print_d+0x50>
test   %r12d,%r12d
je     1258 <array_print_d+0x128>
mov    %esi,%eax
mov    %rax,0x10(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xe0c(%rip),%r15
xor    %eax,%eax
jmp    121d <array_print_d+0xed>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%eax
add    $0x1,%eax
mov    0x4(%rsp),%esi
add    %esi,0x8(%rsp)
cmp    %r12d,%eax
je     1258 <array_print_d+0x128>
mov    %eax,(%rsp)
test   %esi,%esi
je     1200 <array_print_d+0xd0>
mov    0x10(%rsp),%r14
mov    0x8(%rsp),%r13d
xchg   %ax,%ax
mov    %r13d,%ebp
movsd  (%rbx,%rbp,8),%xmm0
call   1050 <isnan@plt>
movsd  (%rbx,%rbp,8),%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%r13d
add    $0xffffffffffffffff,%r14
jne    1230 <array_print_d+0x100>
jmp    1200 <array_print_d+0xd0>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"% .4e \00"
@.str.1 = [14 x i8] c" %d \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @array_print_d(i32 %0, i32 %1, double* %2, i8 signext %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca double*
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store double* %2, double** %7
store i8 %3, i8* %8
store i32 0, i32* %11
%12 = load i8, i8* %8
%13 = sext i8 %12 to i32
switch i32 %13, label %132 [
i32 82, label %14
i32 67, label %73
]
14: ; preds = %4
store i32 0, i32* %9
br label %15
15: ; preds = %68, %14
%16 = load i32, i32* %9
%17 = load i32, i32* %5
%18 = icmp ult i32 %16, %17
br i1 %18, label %19, label %71
19: ; preds = %15
store i32 0, i32* %10
br label %20
20: ; preds = %63, %19
%21 = load i32, i32* %10
%22 = load i32, i32* %6
%23 = icmp ult i32 %21, %22
br i1 %23, label %24, label %66
24: ; preds = %20
%25 = load double*, double** %7
%26 = load i32, i32* %9
%27 = load i32, i32* %6
%28 = mul i32 %26, %27
%29 = load i32, i32* %10
%30 = add i32 %28, %29
%31 = zext i32 %30 to i64
%32 = getelementptr inbounds double, double* %25, i64 %31
%33 = load double, double* %32
%34 = call i32 @isnan(double %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %49, label %36
36: ; preds = %24
%37 = load double*, double** %7
%38 = load i32, i32* %9
%39 = load i32, i32* %6
%40 = mul i32 %38, %39
%41 = load i32, i32* %10
%42 = add i32 %40, %41
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds double, double* %37, i64 %43
%45 = load double, double* %44
%46 = call double @llvm.fabs.f64(double %45)
%47 = fcmp ogt double %46, 1.000000e-15
br i1 %47, label %49, label %48
48: ; preds = %36
br i1 false, label %60, label %49
49: ; preds = %48, %36, %24
%50 = load double*, double** %7
%51 = load i32, i32* %9
%52 = load i32, i32* %6
%53 = mul i32 %51, %52
%54 = load i32, i32* %10
%55 = add i32 %53, %54
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds double, double* %50, i64 %56
%58 = load double, double* %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %58)
br label %62
60: ; preds = %48
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %62
62: ; preds = %60, %49
br label %63
63: ; preds = %62
%64 = load i32, i32* %10
%65 = add i32 %64, 1
store i32 %65, i32* %10
br label %20
66: ; preds = %20
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %68
68: ; preds = %66
%69 = load i32, i32* %9
%70 = add i32 %69, 1
store i32 %70, i32* %9
br label %15
71: ; preds = %15
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %132
73: ; preds = %4
store i32 0, i32* %9
br label %74
74: ; preds = %127, %73
%75 = load i32, i32* %9
%76 = load i32, i32* %5
%77 = icmp ult i32 %75, %76
br i1 %77, label %78, label %130
78: ; preds = %74
store i32 0, i32* %10
br label %79
79: ; preds = %122, %78
%80 = load i32, i32* %10
%81 = load i32, i32* %6
%82 = icmp ult i32 %80, %81
br i1 %82, label %83, label %125
83: ; preds = %79
%84 = load double*, double** %7
%85 = load i32, i32* %9
%86 = load i32, i32* %10
%87 = load i32, i32* %5
%88 = mul i32 %86, %87
%89 = add i32 %85, %88
%90 = zext i32 %89 to i64
%91 = getelementptr inbounds double, double* %84, i64 %90
%92 = load double, double* %91
%93 = call i32 @isnan(double %92)
%94 = icmp ne i32 %93, 0
br i1 %94, label %108, label %95
95: ; preds = %83
%96 = load double*, double** %7
%97 = load i32, i32* %9
%98 = load i32, i32* %10
%99 = load i32, i32* %5
%100 = mul i32 %98, %99
%101 = add i32 %97, %100
%102 = zext i32 %101 to i64
%103 = getelementptr inbounds double, double* %96, i64 %102
%104 = load double, double* %103
%105 = call double @llvm.fabs.f64(double %104)
%106 = fcmp ogt double %105, 1.000000e-15
br i1 %106, label %108, label %107
107: ; preds = %95
br i1 false, label %119, label %108
108: ; preds = %107, %95, %83
%109 = load double*, double** %7
%110 = load i32, i32* %9
%111 = load i32, i32* %10
%112 = load i32, i32* %5
%113 = mul i32 %111, %112
%114 = add i32 %110, %113
%115 = zext i32 %114 to i64
%116 = getelementptr inbounds double, double* %109, i64 %115
%117 = load double, double* %116
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %117)
br label %121
119: ; preds = %107
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 0)
br label %121
121: ; preds = %119, %108
br label %122
122: ; preds = %121
%123 = load i32, i32* %10
%124 = add i32 %123, 1
store i32 %124, i32* %10
br label %79
125: ; preds = %79
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %127
127: ; preds = %125
%128 = load i32, i32* %9
%129 = add i32 %128, 1
store i32 %129, i32* %9
br label %74
130: ; preds = %74
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %132
132: ; preds = %4, %130, %71
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"% .4e \00"
define void @array_print_d(i32 %0, i32 %1, double* nocapture %2, i8 signext %3) {
%5 = sext i8 %3 to i32
switch i32 %5, label %57 [
i32 82, label %11
i32 67, label %6
]
6: ; preds = %4
%7 = icmp eq i32 %0, 0
br i1 %7, label %55, label %8
8: ; preds = %6
%9 = icmp eq i32 %1, 0
%10 = zext i32 %1 to i64
br label %36
11: ; preds = %4
%12 = icmp eq i32 %0, 0
br i1 %12, label %55, label %13
13: ; preds = %11
%14 = icmp eq i32 %1, 0
%15 = zext i32 %1 to i64
br label %16
16: ; preds = %13, %32
%17 = phi i32 [ 0, %13 ], [ %34, %32 ]
br i1 %14, label %32, label %18
18: ; preds = %16
%19 = mul i32 %17, %1
br label %20
20: ; preds = %18, %20
%21 = phi i64 [ 0, %18 ], [ %30, %20 ]
%22 = trunc i64 %21 to i32
%23 = add i32 %19, %22
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds double, double* %2, i64 %24
%26 = load double, double* %25
%27 = tail call i32 @isnan(double %26)
%28 = load double, double* %25
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %28)
%30 = add nuw nsw i64 %21, 1
%31 = icmp eq i64 %30, %15
br i1 %31, label %32, label %20
32: ; preds = %20, %16
%33 = tail call i32 @putchar(i32 10)
%34 = add nuw i32 %17, 1
%35 = icmp eq i32 %34, %0
br i1 %35, label %55, label %16
36: ; preds = %8, %51
%37 = phi i32 [ 0, %8 ], [ %53, %51 ]
br i1 %9, label %51, label %38
38: ; preds = %36, %38
%39 = phi i64 [ %49, %38 ], [ 0, %36 ]
%40 = trunc i64 %39 to i32
%41 = mul i32 %40, %0
%42 = add i32 %41, %37
%43 = zext i32 %42 to i64
%44 = getelementptr inbounds double, double* %2, i64 %43
%45 = load double, double* %44
%46 = tail call i32 @isnan(double %45)
%47 = load double, double* %44
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %47)
%49 = add nuw nsw i64 %39, 1
%50 = icmp eq i64 %49, %10
br i1 %50, label %51, label %38
51: ; preds = %38, %36
%52 = tail call i32 @putchar(i32 10)
%53 = add nuw i32 %37, 1
%54 = icmp eq i32 %53, %0
br i1 %54, label %55, label %36
55: ; preds = %51, %32, %6, %11
%56 = tail call i32 @putchar(i32 10)
br label %57
57: ; preds = %55, %4
ret void
}